Commit ae3135bf authored by Eric Rosenbaum's avatar Eric Rosenbaum

Use "host" instead of "owner"

parent f964d6a1
......@@ -54,7 +54,7 @@ const selectCanRemoveManager = (state, managerId) =>
!selectIsMuted(state) && (selectIsAdmin(state) || isManager(state)) && managerId !== state.studio.owner;
const selectCanPromoteCurators = state => !selectIsMuted(state) && isManager(state);
const selectCanTransferOwnership = (state, managerId) =>
const selectCanTransfer = (state, managerId) =>
state.managers && state.managers.items && state.managers.items.length > 1 && // there is more than one manager
managerId === state.studio.owner && // and the selected manager is the owner
isCreator(state); // and the current user is the owner
......@@ -104,7 +104,7 @@ export {
selectCanRemoveCurator,
selectCanRemoveManager,
selectCanPromoteCurators,
selectCanTransferOwnership,
selectCanTransfer,
selectCanRemoveProject,
selectShowCommentsList,
selectShowCommentsGloballyOffError,
......
......@@ -187,14 +187,14 @@ const acceptInvitation = () => ((dispatch, getState) => new Promise((resolve, re
});
}));
const transferOwnership = (password, newOwnerName, newOwnerId) =>
const transferHost = (password, newHostName, newHostId) =>
((dispatch, getState) => new Promise((resolve, reject) => {
const state = getState();
const studioId = selectStudioId(state);
const token = selectToken(state);
newOwnerName = newOwnerName.trim();
newHostName = newHostName.trim();
api({
uri: `/studios/${studioId}/transfer/${newOwnerName}?password=${password}`,
uri: `/studios/${studioId}/transfer/${newHostName}?password=${password}`,
method: 'PUT',
authentication: token,
withCredentials: true,
......@@ -202,7 +202,7 @@ const transferOwnership = (password, newOwnerName, newOwnerId) =>
}, (err, body, res) => {
const error = normalizeError(err, body, res);
if (error) return reject(error);
dispatch(setInfo({owner: newOwnerId}));
dispatch(setInfo({owner: newHostId}));
return resolve();
});
}));
......@@ -216,5 +216,5 @@ export {
promoteCurator,
removeCurator,
removeManager,
transferOwnership
transferHost
};
......@@ -5,29 +5,29 @@ import {FormattedMessage} from 'react-intl';
import ModalInnerContent from '../../../components/modal/base/modal-inner-content.jsx';
import TransferOwnershipTile from './transfer-ownership-tile.jsx';
import TransferHostTile from './transfer-host-tile.jsx';
import Form from '../../../components/forms/form.jsx';
import {selectUserId} from '../../../redux/session';
import {managers} from '../lib/redux-modules';
import {loadManagers} from '../lib/studio-member-actions';
import './transfer-ownership-modal.scss';
import './transfer-host-modal.scss';
const TransferOwnershipConfirmation = ({
const TransferHostConfirmation = ({
handleBack,
handleTransfer,
items,
userId,
selectedId
}) => {
const currentOwnerUsername = items.find(item => item.id === userId).username;
const currentOwnerImage = items.find(item => item.id === userId).profile.images['90x90'];
const newOwnerUsername = items.find(item => item.id === selectedId).username;
const newOwnerImage = items.find(item => item.id === selectedId).profile.images['90x90'];
const currentHostUsername = items.find(item => item.id === userId).username;
const currentHostImage = items.find(item => item.id === userId).profile.images['90x90'];
const newHostUsername = items.find(item => item.id === selectedId).username;
const newHostImage = items.find(item => item.id === selectedId).profile.images['90x90'];
const [passwordInputValue, setPasswordInputValue] = useState('');
const handleSubmit = () => {
handleTransfer(passwordInputValue, newOwnerUsername, selectedId);
handleTransfer(passwordInputValue, newHostUsername, selectedId);
};
const handleChangePasswordInput = e => {
setPasswordInputValue(e.target.value);
......@@ -39,12 +39,12 @@ const TransferOwnershipConfirmation = ({
<div className="transfer-outcome-label">
<FormattedMessage id="studio.transfer.currentHost" />
</div>
<TransferOwnershipTile
<TransferHostTile
className="transfer-outcome-tile"
key={userId}
id={userId}
image={currentOwnerImage}
username={currentOwnerUsername}
image={currentHostImage}
username={currentHostUsername}
isCreator={false}
/>
</div>
......@@ -56,12 +56,12 @@ const TransferOwnershipConfirmation = ({
<div className="transfer-outcome-label">
<FormattedMessage id="studio.transfer.newHost" />
</div>
<TransferOwnershipTile
<TransferHostTile
className="transfer-outcome-tile"
key={selectedId}
id={selectedId}
image={newOwnerImage}
username={newOwnerUsername}
image={newHostImage}
username={newHostUsername}
isCreator={false}
/>
</div>
......@@ -92,7 +92,7 @@ const TransferOwnershipConfirmation = ({
</a>
</div>
<div
className="transfer-ownership-button-row transfer-ownership-button-row-split"
className="transfer-host-button-row transfer-host-button-row-split"
>
<button
className="button"
......@@ -114,7 +114,7 @@ const TransferOwnershipConfirmation = ({
);
};
TransferOwnershipConfirmation.propTypes = {
TransferHostConfirmation.propTypes = {
handleBack: PropTypes.func,
handleTransfer: PropTypes.func,
items: PropTypes.arrayOf(PropTypes.shape({
......@@ -138,4 +138,4 @@ export default connect(
{
onLoadMore: loadManagers
}
)(TransferOwnershipConfirmation);
)(TransferHostConfirmation);
......@@ -7,16 +7,16 @@ import ModalInnerContent from '../../../components/modal/base/modal-inner-conten
import AlertComponent from '../../../components/alert/alert-component.jsx';
import errorIcon from '../../../components/alert/icon-alert-error.svg';
import './transfer-ownership-modal.scss';
import './transfer-host-modal.scss';
const TransferOwnershipInfo = ({
const TransferHostInfo = ({
handleClose,
handleNext
}) =>
(<div className="content">
<img
src="/svgs/studio/transfer-ownership.svg"
className="transfer-ownership-image"
src="/svgs/studio/transfer-host.svg"
className="transfer-host-image"
/>
<ModalInnerContent
className="inner"
......@@ -26,9 +26,9 @@ const TransferOwnershipInfo = ({
<FormattedMessage id="studio.transfer.youAreAboutTo" />
</h2>
</div>
<div className="transfer-ownership-alert-wrapper">
<div className="transfer-host-alert-wrapper">
<AlertComponent
className="alert-error transfer-ownership-alert"
className="alert-error transfer-host-alert"
icon={errorIcon}
id="studio.transfer.cannotUndo"
/>
......@@ -43,7 +43,7 @@ const TransferOwnershipInfo = ({
<li><FormattedMessage id="studio.transfer.noLongerDelete" /></li>
</ul>
<div
className="transfer-ownership-button-row"
className="transfer-host-button-row"
>
<button
className="button cancel-button"
......@@ -61,9 +61,9 @@ const TransferOwnershipInfo = ({
</ModalInnerContent>
</div>);
TransferOwnershipInfo.propTypes = {
TransferHostInfo.propTypes = {
handleClose: PropTypes.func,
handleNext: PropTypes.func
};
export default TransferOwnershipInfo;
export default TransferHostInfo;
......@@ -6,11 +6,11 @@ import keyMirror from 'keymirror';
import Modal from '../../../components/modal/base/modal.jsx';
import ModalTitle from '../../../components/modal/base/modal-title.jsx';
import TransferOwnershipInfo from './transfer-ownership-info.jsx';
import TransferOwnershipSelection from './transfer-ownership-selection.jsx';
import TransferOwnershipConfirmation from './transfer-ownership-confirmation.jsx';
import TransferHostInfo from './transfer-host-info.jsx';
import TransferHostSelection from './transfer-host-selection.jsx';
import TransferHostConfirmation from './transfer-host-confirmation.jsx';
import './transfer-ownership-modal.scss';
import './transfer-host-modal.scss';
const STEPS = keyMirror({
info: null,
......@@ -18,7 +18,7 @@ const STEPS = keyMirror({
confirmation: null
});
const TransferOwnershipModal = ({
const TransferHostModal = ({
handleClose,
handleTransfer
}) => {
......@@ -26,25 +26,25 @@ const TransferOwnershipModal = ({
const [selectedId, setSelectedId] = useState(null);
return (<Modal
isOpen
className="transfer-ownership-modal"
className="transfer-host-modal"
onRequestClose={handleClose}
>
<ModalTitle
className="transfer-ownership-title"
className="transfer-host-title"
title={<FormattedMessage id="studio.transfer" />}
/>
{step === STEPS.info && <TransferOwnershipInfo
{step === STEPS.info && <TransferHostInfo
handleClose={handleClose}
handleNext={() => setStep(STEPS.selection)} // eslint-disable-line react/jsx-no-bind
/>}
{step === STEPS.selection && <TransferOwnershipSelection
{step === STEPS.selection && <TransferHostSelection
handleClose={handleClose}
handleNext={() => setStep(STEPS.confirmation)} // eslint-disable-line react/jsx-no-bind
handleBack={() => setStep(STEPS.info)} // eslint-disable-line react/jsx-no-bind
handleSelected={setSelectedId}
selectedId={selectedId}
/>}
{step === STEPS.confirmation && <TransferOwnershipConfirmation
{step === STEPS.confirmation && <TransferHostConfirmation
handleClose={handleClose}
handleBack={() => setStep(STEPS.selection)} // eslint-disable-line react/jsx-no-bind
handleTransfer={handleTransfer}
......@@ -53,9 +53,9 @@ const TransferOwnershipModal = ({
</Modal>);
};
TransferOwnershipModal.propTypes = {
TransferHostModal.propTypes = {
handleClose: PropTypes.func,
handleTransfer: PropTypes.func
};
export default TransferOwnershipModal;
export default TransferHostModal;
@import "../../../colors";
@import "../../../frameless";
.transfer-ownership-modal {
.transfer-ownership-title {
.transfer-host-modal {
.transfer-host-title {
background: $ui-blue;
border-top-left-radius: 12px;
border-top-right-radius: 12px;
......@@ -35,7 +35,7 @@
align-items: flex-start;
}
.transfer-ownership-image {
.transfer-host-image {
margin-top: 2rem;
}
......@@ -43,27 +43,27 @@
padding: 1rem;
}
.transfer-ownership-alert-wrapper {
.transfer-host-alert-wrapper {
margin-right: 2rem;
}
.transfer-ownership-alert-wrapper .alert-wrapper {
.transfer-host-alert-wrapper .alert-wrapper {
position: relative;
display: block;
margin-bottom: 2rem;
}
.transfer-ownership-alert .alert-msg {
.transfer-host-alert .alert-msg {
font-size: 16px;
}
.transfer-ownership-button-row {
.transfer-host-button-row {
display: flex;
justify-content: flex-end;
padding-top: 1.5rem;
}
.transfer-ownership-button-row-split {
.transfer-host-button-row-split {
justify-content: space-between;
}
......@@ -103,7 +103,7 @@
overflow: auto;
}
.transfer-ownership-grid {
.transfer-host-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0,1fr));
@media #{$intermediate-and-smaller} {
......@@ -114,7 +114,7 @@
margin-bottom: 1rem;
}
.transfer-ownership-name-selected {
.transfer-host-name-selected {
color: white !important;
}
......@@ -122,7 +122,7 @@
margin: auto 8px;
}
.transfer-ownership-tile-selected {
.transfer-host-tile-selected {
background: #0EBD8C;
}
......
......@@ -5,15 +5,15 @@ import {FormattedMessage} from 'react-intl';
import ModalInnerContent from '../../../components/modal/base/modal-inner-content.jsx';
import TransferOwnershipTile from './transfer-ownership-tile.jsx';
import TransferHostTile from './transfer-host-tile.jsx';
import {selectUserId} from '../../../redux/session';
import {managers} from '../lib/redux-modules';
import {loadManagers} from '../lib/studio-member-actions';
import './transfer-ownership-modal.scss';
import './transfer-host-modal.scss';
const TransferOwnershipSelection = ({
const TransferHostSelection = ({
handleSelected,
handleNext,
handleBack,
......@@ -34,10 +34,10 @@ const TransferOwnershipSelection = ({
</h3>
</div>
<div className="transfer-selection-scroll-pane">
<div className="transfer-ownership-grid">
<div className="transfer-host-grid">
{items.map(item =>
userId !== item.id &&
(<TransferOwnershipTile
(<TransferHostTile
key={item.username}
// eslint-disable-next-line react/jsx-no-bind
handleSelected={() => handleSelected(item.id)}
......@@ -63,7 +63,7 @@ const TransferOwnershipSelection = ({
</div>
</div>
<div
className="transfer-ownership-button-row transfer-ownership-button-row-split transfer-selection-buttons"
className="transfer-host-button-row transfer-host-button-row-split transfer-selection-buttons"
>
<button
className="button"
......@@ -83,7 +83,7 @@ const TransferOwnershipSelection = ({
);
};
TransferOwnershipSelection.propTypes = {
TransferHostSelection.propTypes = {
handleBack: PropTypes.func,
handleNext: PropTypes.func,
handleSelected: PropTypes.func,
......@@ -110,4 +110,4 @@ export default connect(
{
onLoadMore: loadManagers
}
)(TransferOwnershipSelection);
)(TransferHostSelection);
......@@ -3,12 +3,12 @@ import PropTypes from 'prop-types';
import {FormattedMessage} from 'react-intl';
import classNames from 'classnames';
const TransferOwnershipTile = ({
const TransferHostTile = ({
className, username, image, isCreator, selected, handleSelected
}) => (
<div
className={classNames('studio-member-tile', className, {
'transfer-ownership-tile-selected': selected
'transfer-host-tile-selected': selected
})}
onClick={handleSelected}
>
......@@ -19,7 +19,7 @@ const TransferOwnershipTile = ({
<div className="studio-member-info">
<div
className={classNames('studio-member-name',
{'transfer-ownership-name-selected': selected}
{'transfer-host-name-selected': selected}
)}
>
......@@ -34,7 +34,7 @@ const TransferOwnershipTile = ({
</div>
);
TransferOwnershipTile.propTypes = {
TransferHostTile.propTypes = {
className: PropTypes.string,
username: PropTypes.string,
handleSelected: PropTypes.func,
......@@ -43,4 +43,4 @@ TransferOwnershipTile.propTypes = {
selected: PropTypes.bool
};
export default TransferOwnershipTile;
export default TransferHostTile;
......@@ -7,11 +7,11 @@ import {FormattedMessage} from 'react-intl';
import PromoteModal from './modals/promote-modal.jsx';
import ManagerLimitModal from './modals/manager-limit-modal.jsx';
import TransferOwnershipModal from './modals/transfer-ownership-modal.jsx';
import TransferHostModal from './modals/transfer-host-modal.jsx';
import {
selectCanRemoveCurator, selectCanRemoveManager, selectCanPromoteCurators,
selectCanTransferOwnership
selectCanTransfer
} from '../../redux/studio-permissions';
import {selectStudioTransferLaunched} from '../../redux/session.js';
import {
......@@ -19,7 +19,7 @@ import {
promoteCurator,
removeCurator,
removeManager,
transferOwnership
transferHost
} from './lib/studio-member-actions';
import {selectStudioHasReachedManagerLimit} from '../../redux/studio';
......@@ -30,13 +30,13 @@ import removeIcon from './icons/remove-icon.svg';
import promoteIcon from './icons/curator-icon.svg';
const StudioMemberTile = ({
canRemove, canPromote, onRemove, canTransferOwnership, onPromote, onTransferOwnership,
canRemove, canPromote, onRemove, canTransferHost, onPromote, onTransferHost,
isCreator, hasReachedManagerLimit, // mapState props
username, image // own props
}) => {
const [submitting, setSubmitting] = useState(false);
const [promoteModalOpen, setPromoteModalOpen] = useState(false);
const [transferOwnershipModalOpen, setTransferOwnershipModalOpen] = useState(false);
const [transferHostModalOpen, setTransferHostModalOpen] = useState(false);
const [managerLimitReached, setManagerLimitReached] = useState(false);
const {errorAlert, successAlert} = useAlertContext();
const userUrl = `/users/${username}`;
......@@ -55,7 +55,7 @@ const StudioMemberTile = ({
>{username}</a>
{isCreator && <div className="studio-member-role"><FormattedMessage id="studio.creatorRole" /></div>}
</div>
{(canRemove || canPromote || canTransferOwnership) &&
{(canRemove || canPromote || canTransferHost) &&
<OverflowMenu>
{canPromote && <li>
<button
......@@ -88,11 +88,11 @@ const StudioMemberTile = ({
<FormattedMessage id="studio.remove" />
</button>
</li>}
{canTransferOwnership && <li>
{canTransferHost && <li>
<button
className="studio-member-tile-menu-wide"
onClick={() => {
setTransferOwnershipModalOpen(true);
setTransferHostModalOpen(true);
}}
>
<img src={promoteIcon} />
......@@ -132,23 +132,23 @@ const StudioMemberTile = ({
/>
)
}
{transferOwnershipModalOpen &&
<TransferOwnershipModal
handleClose={() => setTransferOwnershipModalOpen(false)}
handleTransfer={(password, newOwnerUsername, newOwnerUsernameId) => {
onTransferOwnership(password, newOwnerUsername, newOwnerUsernameId)
{transferHostModalOpen &&
<TransferHostModal
handleClose={() => setTransferHostModalOpen(false)}
handleTransfer={(password, newHostUsername, newHostUsernameId) => {
onTransferHost(password, newHostUsername, newHostUsernameId)
.then(() => {
setTransferOwnershipModalOpen(false);
setTransferHostModalOpen(false);
successAlert({
id: 'studio.alertTransfer',
values: {name: newOwnerUsername}
values: {name: newHostUsername}
});
})
.catch(() => {
setTransferOwnershipModalOpen(false);
setTransferHostModalOpen(false);
errorAlert({
id: 'studio.transfer.alert.somethingWentWrong',
values: {name: newOwnerUsername}
values: {name: newHostUsername}
});
});
}}
......@@ -161,10 +161,10 @@ const StudioMemberTile = ({
StudioMemberTile.propTypes = {
canRemove: PropTypes.bool,
canPromote: PropTypes.bool,
canTransferOwnership: PropTypes.bool,
canTransferHost: PropTypes.bool,
onRemove: PropTypes.func,
onPromote: PropTypes.func,
onTransferOwnership: PropTypes.func,
onTransferHost: PropTypes.func,
username: PropTypes.string,
image: PropTypes.string,
isCreator: PropTypes.bool,
......@@ -175,13 +175,13 @@ const ManagerTile = connect(
(state, ownProps) => ({
canRemove: selectCanRemoveManager(state, ownProps.id),
canPromote: false,
canTransferOwnership: selectCanTransferOwnership(state, ownProps.id) &&
canTransferHost: selectCanTransfer(state, ownProps.id) &&
selectStudioTransferLaunched(state),
isCreator: state.studio.owner === ownProps.id
}),
{
onRemove: removeManager,
onTransferOwnership: transferOwnership
onTransferHost: transferHost
}
)(StudioMemberTile);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment