Skip to content

Commit

Permalink
fix: Changed collaborator to editor
Browse files Browse the repository at this point in the history
  • Loading branch information
josebui committed Sep 8, 2023
1 parent ce49554 commit a459472
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/localization/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -987,9 +987,9 @@
"share_dialog_confirm_label": "Invite",
"share_dialog_cancel_label": "Cancel",
"delete_membership": "Remove",
"role_collaborator": "Editor",
"role_editor": "Editor",
"role_owner": "Owner",
"share_dialog_collaborators_title": "People with access",
"share_dialog_editors_title": "People with access",
"share_dialog_autocomplete_label": "Editors",
"share_dialog_autocomplete_helper_text": "They will receive an email invitation to join this story map.",
"delete_membership_confirm_title": "Remove {{name}} from this story map?",
Expand Down
4 changes: 2 additions & 2 deletions src/localization/locales/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -994,9 +994,9 @@
"share_dialog_confirm_label": "Invitar",
"share_dialog_cancel_label": "Cancelar",
"delete_membership": "Eliminar",
"role_collaborator": "Editor",
"role_editor": "Editor",
"role_owner": "Dueña(o)",
"share_dialog_collaborators_title": "Personas con acceso",
"share_dialog_editors_title": "Personas con acceso",
"share_dialog_autocomplete_label": "Editores",
"share_dialog_autocomplete_helper_text": "Ella(o)s recibirán una invitación por correo electrónico para unirse a este story map.",
"delete_membership_confirm_title": "¿Eliminar {{name}} de este story map?",
Expand Down
4 changes: 2 additions & 2 deletions src/permissions/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
MEMBERSHIP_STATUS_APPROVED,
ROLE_MANAGER,
} from 'group/membership/components/groupMembershipConstants';
import { MEMBERSHIP_ROLE_CONTRIBUTOR } from 'storyMap/storyMapConstants';
import { MEMBERSHIP_ROLE_EDITOR } from 'storyMap/storyMapConstants';

const getAccountMembership = group =>
_.getOr(
Expand Down Expand Up @@ -127,7 +127,7 @@ const isAllowedToChangeStoryMap = ({ resource: storyMap, user }) => {
const accountMembership = storyMap.accountMembership;
return Promise.resolve(
accountMembership &&
accountMembership.userRole === MEMBERSHIP_ROLE_CONTRIBUTOR &&
accountMembership.userRole === MEMBERSHIP_ROLE_EDITOR &&
accountMembership.membershipStatus === MEMBERSHIP_STATUS_APPROVED
);
};
Expand Down
24 changes: 12 additions & 12 deletions src/storyMap/components/StoryMapForm/ShareDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import ExternalLink from 'common/components/ExternalLink';
import UserEmailAutocomplete from 'common/components/UserEmailAutocomplete';
import Restricted from 'permissions/components/Restricted';
import {
MEMBERSHIP_ROLE_CONTRIBUTOR,
MEMBERSHIP_ROLE_EDITOR,
MEMBERSHIP_ROLE_OWNER,
} from 'storyMap/storyMapConstants';
import { addMemberships, deleteMembership } from 'storyMap/storyMapSlice';
Expand Down Expand Up @@ -167,7 +167,7 @@ const ShareDialog = props => {
);
const { open, onClose } = props;
const { storyMap } = useStoryMapConfigContext();
const [newCollaborators, setNewCollaborators] = useState([]);
const [newEditors, setNewEditors] = useState([]);
const [expanded, setExpanded] = React.useState(false);

useEffect(() => {
Expand All @@ -176,26 +176,26 @@ const ShareDialog = props => {

const onChange = useCallback(
value => {
setNewCollaborators(value);
setNewEditors(value);
},
[setNewCollaborators]
[setNewEditors]
);

const onConfirm = useCallback(() => {
dispatch(
addMemberships({
storyMap,
emails: newCollaborators,
userRole: MEMBERSHIP_ROLE_CONTRIBUTOR,
emails: newEditors,
userRole: MEMBERSHIP_ROLE_EDITOR,
})
).then(data => {
const success = data?.meta?.requestStatus === 'fulfilled';
if (success) {
setNewCollaborators([]);
setNewEditors([]);
onClose();
}
});
}, [dispatch, onClose, storyMap, newCollaborators]);
}, [dispatch, onClose, storyMap, newEditors]);

const memberships = useMemo(
() => [
Expand Down Expand Up @@ -229,7 +229,7 @@ const ShareDialog = props => {
<UserEmailAutocomplete
label={t('storyMap.share_dialog_autocomplete_label')}
helperText={t('storyMap.share_dialog_autocomplete_helper_text')}
value={newCollaborators}
value={newEditors}
onChange={onChange}
/>
<Accordion
Expand Down Expand Up @@ -265,13 +265,13 @@ const ShareDialog = props => {
}}
>
<Typography variant="h2" sx={{ p: 0, textTransform: 'none' }}>
{t('storyMap.share_dialog_collaborators_title')}
{t('storyMap.share_dialog_editors_title')}
</Typography>
</AccordionSummary>
<AccordionDetails sx={{ p: 0 }}>
<MembershipsList
showCards
label={t('storyMap.share_dialog_collaborators_title')}
label={t('storyMap.share_dialog_editors_title')}
memberships={memberships}
RemoveComponent={RemoveButton}
RoleComponent={RoleComponent}
Expand All @@ -293,7 +293,7 @@ const ShareDialog = props => {
variant="contained"
onClick={onConfirm}
loading={processing}
disabled={_.isEmpty(newCollaborators)}
disabled={_.isEmpty(newEditors)}
>
{t('storyMap.share_dialog_confirm_label')}
</LoadingButton>
Expand Down
15 changes: 8 additions & 7 deletions src/storyMap/components/StoryMapUpdate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { changeCombobox } from 'tests/uiUtils';
import i18n from 'localization/i18n';

import StoryMapUpdate from './StoryMapUpdate';
import { MEMBERSHIP_ROLE_EDITOR } from 'storyMap/storyMapConstants';

jest.mock('terraso-client-shared/terrasoApi/api');

Expand Down Expand Up @@ -66,7 +67,7 @@ const API_STORY_MAP = {
{
node: {
id: '08a06380-911e-49ea-b44b-24c7ddafce1f',
userRole: 'collaborator',
userRole: MEMBERSHIP_ROLE_EDITOR,
membershipStatus: 'PENDING',
pendingEmail: '[email protected]',
user: null,
Expand All @@ -75,7 +76,7 @@ const API_STORY_MAP = {
{
node: {
id: '75bdc04e-9bdc-4c46-b8cb-916a93e8f4b8',
userRole: 'collaborator',
userRole: MEMBERSHIP_ROLE_EDITOR
membershipStatus: 'APPROVED',

Check failure on line 80 in src/storyMap/components/StoryMapUpdate.test.js

View workflow job for this annotation

GitHub Actions / lint

',' expected.
pendingEmail: null,
user: {
Expand Down Expand Up @@ -187,13 +188,13 @@ test('StoryMapUpdate: Share Dialog invite members', async () => {
memberships: [
{
id: 'new-id-1',
userRole: 'collaborator',
userRole: MEMBERSHIP_ROLE_EDITOR,
membershipStatus: 'PENDING',
pendingEmail: '[email protected]',
},
{
id: 'new-id-2',
userRole: 'collaborator',
userRole: MEMBERSHIP_ROLE_EDITOR,
membershipStatus: 'PENDING',
user: {
firstName: 'Manuel',
Expand Down Expand Up @@ -229,7 +230,7 @@ test('StoryMapUpdate: Share Dialog invite members', async () => {
expect(inviteCall).toMatchObject({
input: {
userEmails: ['[email protected]', '[email protected]'],
userRole: 'collaborator',
userRole: MEMBERSHIP_ROLE_EDITOR,
storyMapId: API_STORY_MAP.storyMapId,
storyMapSlug: API_STORY_MAP.slug,
},
Expand Down Expand Up @@ -291,7 +292,7 @@ test('StoryMapUpdate: Share Dialog remove members', async () => {
});
});

test('StoryMapUpdate: See story map as collaborator', async () => {
test('StoryMapUpdate: See story map as editor', async () => {
mockTerrasoAPIrequestGraphQL({
'query fetchStoryMap': Promise.resolve({
storyMaps: {
Expand All @@ -303,7 +304,7 @@ test('StoryMapUpdate: See story map as collaborator', async () => {
...API_STORY_MAP.membershipList,
accountMembership: {
id: API_STORY_MAP.membershipList.memberships.edges[1].node.id,
userRole: 'collaborator',
userRole: MEMBERSHIP_ROLE_EDITOR,
membershipStatus: 'APPROVED',
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/storyMap/storyMapConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ export const ALIGNMENTS = {
full: 'fully',
};

export const MEMBERSHIP_ROLE_CONTRIBUTOR = 'collaborator';
export const MEMBERSHIP_ROLE_EDITOR = 'editor';
export const MEMBERSHIP_ROLE_OWNER = 'owner';

0 comments on commit a459472

Please sign in to comment.