diff --git a/package.json b/package.json index db4d284a5..a705a8e41 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "@emotion/styled": "11.11.5", "@graasp/chatbox": "3.1.0", "@graasp/map": "1.11.1", - "@graasp/query-client": "github:graasp/graasp-query-client#714-csv-mutations", + "@graasp/query-client": "3.7.0", "@graasp/sdk": "4.7.6", "@graasp/translations": "1.28.0", "@graasp/ui": "4.17.0", diff --git a/src/components/item/sharing/ItemSharingTab.tsx b/src/components/item/sharing/ItemSharingTab.tsx index b501ecf19..18011d87e 100644 --- a/src/components/item/sharing/ItemSharingTab.tsx +++ b/src/components/item/sharing/ItemSharingTab.tsx @@ -22,7 +22,6 @@ import CreateItemMembershipForm from './CreateItemMembershipForm'; import InvitationsTable from './InvitationsTable'; import ItemMembershipsTable from './ItemMembershipsTable'; import VisibilitySelect from './VisibilitySelect'; -// import CsvInputParser from './csvImport/CSVParser'; import ImportUsersWithCSVButton from './csvImport/ImportUsersWithCSVButton'; import ShortLinksRenderer from './shortLink/ShortLinksRenderer'; @@ -90,7 +89,6 @@ const ItemSharingTab = (): JSX.Element => { {translateBuilder(BUILDER.SHARING_AUTHORIZED_MEMBERS_TITLE)} - {/* {canAdmin && } */} {canAdmin && } {canAdmin && ( diff --git a/src/components/item/sharing/csvImport/DisplayInvitationSummary.tsx b/src/components/item/sharing/csvImport/DisplayInvitationSummary.tsx index 73ad6c740..b0dda37aa 100644 --- a/src/components/item/sharing/csvImport/DisplayInvitationSummary.tsx +++ b/src/components/item/sharing/csvImport/DisplayInvitationSummary.tsx @@ -15,9 +15,7 @@ const ErrorDisplay = ({ errorMessage }: { errorMessage: string }): string => { const { t: translateMessages } = useMessagesTranslation(); switch (errorMessage) { case 'MODIFY_EXISTING': { - return t( - 'You are trying to import a user that already has a permission on this item. We currently do not support this. Please remove users that already have permissions on this item from your csv file and try again.', - ); + return t(BUILDER.SHARE_ITEM_CSV_SUMMARY_MODIFYING_EXISTING); } default: { return translateMessages(FAILURE_MESSAGES.UNEXPECTED_ERROR); @@ -70,7 +68,9 @@ const DisplayInvitationSummary = ({ if (Array.isArray(userCsvData)) { return ( - {t('Summary of the structure created')} + + {t(BUILDER.SHARE_ITEM_CSV_SUMMARY_GROUP_TITLE)} + {userCsvData.map(({ groupName, memberships, invitations }) => ( @@ -104,6 +104,8 @@ const DisplayInvitationSummary = ({ ); } + + // no error and no data, display nothing return false; }; export default DisplayInvitationSummary; diff --git a/src/components/item/sharing/csvImport/ImportUsersDialogContent.tsx b/src/components/item/sharing/csvImport/ImportUsersDialogContent.tsx index 9888e9765..86c483070 100644 --- a/src/components/item/sharing/csvImport/ImportUsersDialogContent.tsx +++ b/src/components/item/sharing/csvImport/ImportUsersDialogContent.tsx @@ -40,7 +40,7 @@ export const DIALOG_ID_LABEL = 'shareItemFromCsvLabel'; const allowedExtensions = ['.csv'].join(','); type CSVFileSelectionButtonProps = { - csvFile: File | undefined; + csvFile?: File; removeFile: () => void; handleFileChange: ChangeEventHandler; }; @@ -89,7 +89,6 @@ const ImportUsersDialogContent = ({ isFolder, handleClose, }: ImportUsersDialogContentProps): JSX.Element => { - // const { t } = useBuilderTranslation(); const { t: translateCommon } = useCommonTranslation(); const [csvFile, setCsvFile] = useState(); const [csvFileErrors, setCsvFileErrors] = useState(); @@ -119,8 +118,8 @@ const ImportUsersDialogContent = ({ transformHeader(header) { return header.trim().toLowerCase(); }, - complete(_results) { - const headers = _results.meta.fields; + complete(results) { + const headers = results.meta.fields; // check for errors in the column names if (!headers?.includes(CSV_EMAIL_COLUMN_NAME.toLowerCase())) { diff --git a/src/langs/constants.ts b/src/langs/constants.ts index 1a11104d1..2cdbc77a7 100644 --- a/src/langs/constants.ts +++ b/src/langs/constants.ts @@ -146,6 +146,9 @@ export const BUILDER = { SHARE_ITEM_FORM_EMAIL_LABEL: 'SHARE_ITEM_FORM_EMAIL_LABEL', SHARE_ITEM_FORM_CONFIRM_BUTTON: 'SHARE_ITEM_FORM_CONFIRM_BUTTON', SHARE_ITEM_FORM_INVITATION_TOOLTIP: 'SHARE_ITEM_FORM_INVITATION_TOOLTIP', + SHARE_ITEM_CSV_SUMMARY_GROUP_TITLE: 'SHARE_ITEM_CSV_SUMMARY_GROUP_TITLE', + SHARE_ITEM_CSV_SUMMARY_MODIFYING_EXISTING: + 'SHARE_ITEM_CSV_SUMMARY_MODIFYING_EXISTING', SHARE_ITEM_FORM_INVITATION_EMAIL_EXISTS_MESSAGE: 'SHARE_ITEM_FORM_INVITATION_EMAIL_EXISTS_MESSAGE', diff --git a/src/langs/en.json b/src/langs/en.json index 10f809314..bcba1b6b4 100644 --- a/src/langs/en.json +++ b/src/langs/en.json @@ -247,6 +247,8 @@ "IMPORT_CSV_SUCCESS_TITLE": "Operation successful", "IMPORT_CSV_SUCCESS_TEXT": "You can close this dialog.", "IMPORT_CSV_ERROR_TITLE": "Operation returned errors, please try again after fixing the issues", + "SHARE_ITEM_CSV_SUMMARY_GROUP_TITLE": "Summary of the structure created", + "SHARE_ITEM_CSV_SUMMARY_MODIFYING_EXISTING": "You are trying to import a user that already has a permission on this item. We currently do not support this. Please remove users that already have permissions on this item from your csv file and try again.", "SHARE_ITEM_CSV_IMPORT_MODAL_CONTENT": "Your CSV should have at least the column 'email'. The columns 'name', 'permission' and 'group_name' are optional.\n A CSV entry cannot override the data already saved. If a user already has permission, update the value in the table manually. Once a CSV file is selected, please click on the confirm button to start the importation of users", "SHARE_ITEM_CSV_IMPORT_MODAL_CONTENT_GROUP_COLUMN_DETECTED": "'group_name' column has been detected. Importing the CSV will create group folders in the current directory and invite the corresponding users to them.", "SHARE_ITEM_CSV_IMPORT_MODAL_TITLE": "Import users from a CSV file", diff --git a/yarn.lock b/yarn.lock index acb052c40..15664a990 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1494,9 +1494,9 @@ __metadata: languageName: node linkType: hard -"@graasp/query-client@github:graasp/graasp-query-client#714-csv-mutations": - version: 3.6.0 - resolution: "@graasp/query-client@https://github.com/graasp/graasp-query-client.git#commit=63ec21451b8c7bd97518adbfc8fea284ac917d9c" +"@graasp/query-client@npm:3.7.0": + version: 3.7.0 + resolution: "@graasp/query-client@npm:3.7.0" dependencies: "@tanstack/react-query": "npm:4.36.1" "@tanstack/react-query-devtools": "npm:4.36.1" @@ -1507,7 +1507,7 @@ __metadata: "@graasp/sdk": ^4.0.0 "@graasp/translations": ^1.23.0 react: ^18.0.0 - checksum: 10/9216f8175bc65c9043411db86fd94c4c63da5e23be8a8c63660b5c8ed92c69926d3b46ffedc8eaa1bd8fd9d158fc4250fd9ee1ef2bac212f6cd379941be7e2b8 + checksum: 10/649e0f1f1db5355f50ec5af4ce5ed1c77aae5eeb330d56d50309e3a0317b2f96727ef9caea21de13cb88c8621a3c5d2fed787f9de2409005d8bf8ade8e6fab3d languageName: node linkType: hard @@ -7360,7 +7360,7 @@ __metadata: "@emotion/styled": "npm:11.11.5" "@graasp/chatbox": "npm:3.1.0" "@graasp/map": "npm:1.11.1" - "@graasp/query-client": "github:graasp/graasp-query-client#714-csv-mutations" + "@graasp/query-client": "npm:3.7.0" "@graasp/sdk": "npm:4.7.6" "@graasp/translations": "npm:1.28.0" "@graasp/ui": "npm:4.17.0"