Skip to content

Commit

Permalink
chore: address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-Torrent committed Aug 17, 2021
1 parent d6e8b3f commit b0a6609
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 39 deletions.
2 changes: 1 addition & 1 deletion cypress/integration/item/copy/gridCopyItem.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('Copy Item in Grid', () => {
});

describe('Error handling', () => {
it('error while moving item does not create in interface', () => {
it('error while copying item does not create in interface', () => {
cy.setUpApi({ ...SAMPLE_ITEMS, copyItemError: true });
const { id } = SAMPLE_ITEMS.items[0];

Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/item/copy/listCopyItem.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('Copy Item in List', () => {
});

describe('Error handling', () => {
it('error while moving item does not create in interface', () => {
it('error while copying item does not create in interface', () => {
cy.setUpApi({ ...SAMPLE_ITEMS, copyItemError: true });
const { id } = SAMPLE_ITEMS.items[0];

Expand Down
12 changes: 6 additions & 6 deletions cypress/integration/item/copy/listCopyMultiple.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { SAMPLE_ITEMS } from '../../../fixtures/items';
import { TABLE_ITEM_RENDER_TIME } from '../../../support/constants';


const copyItem = ({ itemIds, toItemPath }) => {
const copyItems = ({ itemIds, toItemPath }) => {
// check selected ids
itemIds.forEach((id) => {
cy.wait(TABLE_ITEM_RENDER_TIME);
Expand All @@ -39,7 +39,7 @@ describe('Copy items in List', () => {

const itemIds = [SAMPLE_ITEMS.items[0].id, SAMPLE_ITEMS.items[5].id];
const { id: toItem, path: toItemPath } = SAMPLE_ITEMS.items[1];
copyItem({ itemIds, toItemPath });
copyItems({ itemIds, toItemPath });

cy.wait('@copyItems').then(({ response: { body } }) => {
itemIds.forEach(id =>{
Expand Down Expand Up @@ -67,7 +67,7 @@ describe('Copy items in List', () => {
// copy
const itemIds = [SAMPLE_ITEMS.items[2].id, SAMPLE_ITEMS.items[4].id];
const { id: toItem, path: toItemPath } = SAMPLE_ITEMS.items[3];
copyItem({ itemIds, toItemPath });
copyItems({ itemIds, toItemPath });

cy.wait('@copyItems').then(({ response: { body } }) => {
itemIds.forEach(id => {
Expand All @@ -94,7 +94,7 @@ describe('Copy items in List', () => {

// copy
const itemIds = [SAMPLE_ITEMS.items[2].id, SAMPLE_ITEMS.items[4].id];
copyItem({itemIds, toItemPath: ROOT_ID });
copyItems({itemIds, toItemPath: ROOT_ID });

cy.wait('@copyItems').then(({ response: { body } }) => {
itemIds.forEach(id => {
Expand All @@ -110,7 +110,7 @@ describe('Copy items in List', () => {
});

describe('Error handling', () => {
it('error while moving item does not create in interface', () => {
it('error while copying item does not create in interface', () => {
cy.setUpApi({ ...SAMPLE_ITEMS, copyItemError: true });
const { id :start } = SAMPLE_ITEMS.items[0];

Expand All @@ -123,7 +123,7 @@ describe('Copy items in List', () => {
// copy
const itemIds = [SAMPLE_ITEMS.items[2].id, SAMPLE_ITEMS.items[4].id];
const { path: toItemPath } = SAMPLE_ITEMS.items[0];
copyItem({ itemIds, toItemPath });
copyItems({ itemIds, toItemPath });

cy.wait('@copyItems').then(({ response: { body } }) => {
// check item is still existing in parent
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/item/move/listMoveMultiple.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const moveItem = ({ itemIds, toItemPath }) => {
cy.fillTreeModal(toItemPath);
};

describe('Move Item in List', () => {
describe('Move Items in List', () => {
it('Move items on Home', () => {
cy.setUpApi(SAMPLE_ITEMS);
cy.visit(HOME_PATH);
Expand Down
4 changes: 2 additions & 2 deletions src/components/context/CopyItemModalContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const CopyItemModalContext = React.createContext();

const CopyItemModalProvider = ({ children }) => {
const { t } = useTranslation();
const { mutate: copyItem } = useMutation(MUTATION_KEYS.COPY_ITEMS);
const { mutate: copyItems } = useMutation(MUTATION_KEYS.COPY_ITEMS);
const [open, setOpen] = useState(false);
const [itemId, setItemId] = useState(false);

Expand All @@ -30,7 +30,7 @@ const CopyItemModalProvider = ({ children }) => {
...payload,
to: payload.to === ROOT_ID ? null : payload.to,
};
copyItem(newPayload);
copyItems(newPayload);
onClose();
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/context/CreateShortcutModalContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const CreateShortcutModalProvider = ({ children }) => {
const onConfirm = ({ id: target, to }) => {
const shortcut = {
name: t('Shortcut to name', { name: item.name }),
extra: buildShortcutExtra(target),
extra: buildShortcutExtra(target[0]),
type: ITEM_TYPES.SHORTCUT,
};
// set parent id if not root
Expand All @@ -50,7 +50,7 @@ const CreateShortcutModalProvider = ({ children }) => {
<TreeModal
onClose={onClose}
open={open}
itemId={item.id}
itemId={[item.id]}
onConfirm={onConfirm}
title={t('Where do you want to create the shortcut?')}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/components/context/MoveItemModalContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const MoveItemModalContext = React.createContext();

const MoveItemModalProvider = ({ children }) => {
const { t } = useTranslation();
const { mutate: moveItem } = useMutation(MUTATION_KEYS.MOVE_ITEMS);
const { mutate: moveItems } = useMutation(MUTATION_KEYS.MOVE_ITEMS);

const [open, setOpen] = useState(false);
const [itemId, setItemId] = useState(false);
Expand All @@ -32,7 +32,7 @@ const MoveItemModalProvider = ({ children }) => {
...payload,
to: payload.to === ROOT_ID ? null : payload.to,
};
moveItem(newPayload);
moveItems(newPayload);
onClose();
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/main/TreeModal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import PropTypes, { arrayOf } from 'prop-types';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -130,7 +130,7 @@ TreeModal.propTypes = {
onClose: PropTypes.func.isRequired,
title: PropTypes.string.isRequired,
prevent: PropTypes.oneOf(Object.values(TREE_PREVENT_SELECTION)),
itemId: PropTypes.oneOfType([ PropTypes.string, PropTypes.array ]),
itemId: arrayOf(PropTypes.string),
open: PropTypes.bool,
};

Expand Down
22 changes: 0 additions & 22 deletions src/middlewares/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { toastr } from 'react-redux-toastr';
import { routines } from '@graasp/query-client';
import i18n from '../config/i18n';
import {
COPY_ITEM_ERROR_MESSAGE,
COPY_ITEM_SUCCESS_MESSAGE,
COPY_ITEMS_ERROR_MESSAGE,
COPY_ITEMS_SUCCESS_MESSAGE,
CREATE_ITEM_ERROR_MESSAGE,
Expand All @@ -12,8 +10,6 @@ import {
DELETE_ITEMS_SUCCESS_MESSAGE,
EDIT_ITEM_ERROR_MESSAGE,
EDIT_ITEM_SUCCESS_MESSAGE,
MOVE_ITEM_ERROR_MESSAGE,
MOVE_ITEM_SUCCESS_MESSAGE,
MOVE_ITEMS_ERROR_MESSAGE,
MOVE_ITEMS_SUCCESS_MESSAGE,
SHARE_ITEM_ERROR_MESSAGE,
Expand Down Expand Up @@ -51,9 +47,7 @@ const {
createItemRoutine,
deleteItemsRoutine,
deleteItemRoutine,
moveItemRoutine,
moveItemsRoutine,
copyItemRoutine,
copyItemsRoutine,
editItemRoutine,
shareItemRoutine,
Expand Down Expand Up @@ -97,18 +91,10 @@ export default ({ type, payload }) => {
message = DELETE_ITEMS_ERROR_MESSAGE;
break;
}
case moveItemRoutine.FAILURE: {
message = MOVE_ITEM_ERROR_MESSAGE;
break;
}
case moveItemsRoutine.FAILURE:{
message = MOVE_ITEMS_ERROR_MESSAGE;
break;
}
case copyItemRoutine.FAILURE: {
message = COPY_ITEM_ERROR_MESSAGE;
break;
}
case copyItemsRoutine.FAILURE: {
message = COPY_ITEMS_ERROR_MESSAGE;
break;
Expand Down Expand Up @@ -163,18 +149,10 @@ export default ({ type, payload }) => {
message = DELETE_ITEMS_SUCCESS_MESSAGE;
break;
}
case moveItemRoutine.SUCCESS: {
message = MOVE_ITEM_SUCCESS_MESSAGE;
break;
}
case moveItemsRoutine.SUCCESS: {
message = MOVE_ITEMS_SUCCESS_MESSAGE;
break;
}
case copyItemRoutine.SUCCESS: {
message = COPY_ITEM_SUCCESS_MESSAGE;
break;
}
case copyItemsRoutine.SUCCESS: {
message = COPY_ITEMS_SUCCESS_MESSAGE;
break;
Expand Down

0 comments on commit b0a6609

Please sign in to comment.