Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add bulk edit to File Manager #3715

Merged
merged 14 commits into from Nov 23, 2023
Merged

feat: add bulk edit to File Manager #3715

merged 14 commits into from Nov 23, 2023

Conversation

leopuleo
Copy link
Contributor

Changes

With this PR, we can bulk edit file custom registered fields.

To work, the field should be registered as bulkEdit: true as follows:

modifier.addField({
  id: "customLabel",
  fieldId: "customLabel",
  label: "Custom Label",
  type: "text",
  renderer: {
    name: "text-input"
  },
  bulkEdit: true <-- Available for bulk edit actions
});

By clicking on the action, the user will have the possibility to select the fields to edit and:

  • Override existing data
  • Remove existing data
  • Append new data (available for fields that accept multipleValues)

The file data is updated using the default bulk actions worker.
CleanShot 2023-11-21 at 14 32 57

How Has This Been Tested?

Jest + Manually

@leopuleo leopuleo added this to the 5.38.2 milestone Nov 21, 2023
@leopuleo leopuleo self-assigned this Nov 21, 2023
Comment on lines +48 to +98
const openWorkerDialog = (batch: BatchDTO) => {
showConfirmationDialog({
title: "Edit files",
message: `You are about to edit ${filesLabel}. Are you sure you want to continue?`,
loadingLabel: `Processing ${filesLabel}`,
execute: async () => {
await worker.processInSeries(async ({ item, report }) => {
try {
const extensions = defaultFields.find(
field => field.fieldId === "extensions"
);

const extensionsData = GraphQLInputMapper.toGraphQLExtensions(
item.extensions,
batch
);

const output = omit(item, ["id", "createdBy", "createdOn", "src"]);

const fileData = {
...output,
extensions: prepareFormData(
extensionsData,
extensions?.settings?.fields || []
)
};

await updateFile(item.id, fileData);

report.success({
title: `${item.name}`,
message: "File successfully edited."
});
} catch (e) {
report.error({
title: `${item.name}`,
message: e.message
});
}
});

worker.resetItems();

showResultsDialog({
results: worker.results,
title: "Edit files",
message: "Finished editing files! See full report below:"
});
}
});
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment on this: I think it would be great to create a generic DialogPresenter class which can be reused across other presenter implementations, to manage thee dialog interactions. That way we'll be able to remove this huge bloat of coad from the components. Something to try.

Copy link
Collaborator

@Pavel910 Pavel910 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Let's merge this! 🚀 🎸

@Pavel910 Pavel910 merged commit 619ae2f into dev Nov 23, 2023
62 checks passed
@Pavel910 Pavel910 modified the milestones: 5.38.2, 5.38.1 Nov 23, 2023
@leopuleo leopuleo deleted the leo/feat/fm-bulk-edit branch December 5, 2023 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants