Skip to content

Commit

Permalink
fix: make requested changes and update query-client dep
Browse files Browse the repository at this point in the history
  • Loading branch information
spaenleh committed May 6, 2024
1 parent b716756 commit e1090fb
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions src/components/item/sharing/ItemSharingTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -90,7 +89,6 @@ const ItemSharingTab = (): JSX.Element => {
<Typography variant="h6" m={0} p={0}>
{translateBuilder(BUILDER.SHARING_AUTHORIZED_MEMBERS_TITLE)}
</Typography>
{/* {canAdmin && <CsvInputParser item={item} />} */}
{canAdmin && <ImportUsersWithCSVButton item={item} />}
</Grid>
{canAdmin && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -70,7 +68,9 @@ const DisplayInvitationSummary = ({
if (Array.isArray(userCsvData)) {
return (
<Alert severity="info" id={SHARE_CSV_TEMPLATE_SUMMARY_CONTAINER_ID}>
<AlertTitle>{t('Summary of the structure created')}</AlertTitle>
<AlertTitle>
{t(BUILDER.SHARE_ITEM_CSV_SUMMARY_GROUP_TITLE)}
</AlertTitle>
<Stack direction="column" gap={2}>
{userCsvData.map(({ groupName, memberships, invitations }) => (
<Stack>
Expand Down Expand Up @@ -104,6 +104,8 @@ const DisplayInvitationSummary = ({
</Alert>
);
}

// no error and no data, display nothing
return false;
};
export default DisplayInvitationSummary;
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLInputElement>;
};
Expand Down Expand Up @@ -89,7 +89,6 @@ const ImportUsersDialogContent = ({
isFolder,
handleClose,
}: ImportUsersDialogContentProps): JSX.Element => {
// const { t } = useBuilderTranslation();
const { t: translateCommon } = useCommonTranslation();
const [csvFile, setCsvFile] = useState<File>();
const [csvFileErrors, setCsvFileErrors] = useState<string>();
Expand Down Expand Up @@ -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())) {
Expand Down
3 changes: 3 additions & 0 deletions src/langs/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions src/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit e1090fb

Please sign in to comment.