-
Notifications
You must be signed in to change notification settings - Fork 2k
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
MetaEditor + ImageEditor - new state machine logic #4939
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Diff output filesdiff --git a/packages/@uppy/dashboard/lib/Dashboard.js b/packages/@uppy/dashboard/lib/Dashboard.js
index d5a44dd..fc6a331 100644
--- a/packages/@uppy/dashboard/lib/Dashboard.js
+++ b/packages/@uppy/dashboard/lib/Dashboard.js
@@ -139,6 +139,24 @@ export default class Dashboard extends UIPlugin {
this.uppy.getPlugin(editor.id).selectFile(file);
});
};
+ this.closeFileEditor = () => {
+ const {
+ metaFields,
+ } = this.getPluginState();
+ const isMetaEditorEnabled = metaFields && metaFields.length > 0;
+ if (isMetaEditorEnabled) {
+ this.setPluginState({
+ showFileEditor: false,
+ activeOverlayType: "FileCard",
+ });
+ } else {
+ this.setPluginState({
+ showFileEditor: false,
+ fileCardFor: null,
+ activeOverlayType: "AddFiles",
+ });
+ }
+ };
this.saveFileEditor = () => {
const {
targets,
@@ -147,7 +165,7 @@ export default class Dashboard extends UIPlugin {
editors.forEach(editor => {
this.uppy.getPlugin(editor.id).save();
});
- this.hideAllPanels();
+ this.closeFileEditor();
};
this.openModal = () => {
const {
@@ -552,7 +570,14 @@ export default class Dashboard extends UIPlugin {
writable: true,
value: files => {
const firstFile = files[0];
- if (this.canEditFile(firstFile)) {
+ const {
+ metaFields,
+ } = this.getPluginState();
+ const isMetaEditorEnabled = metaFields && metaFields.length > 0;
+ const isFileEditorEnabled = this.canEditFile(firstFile);
+ if (isMetaEditorEnabled) {
+ this.toggleFileCard(true, firstFile.id);
+ } else if (isFileEditorEnabled) {
this.openFileEditor(firstFile);
}
},
@@ -578,7 +603,6 @@ export default class Dashboard extends UIPlugin {
this.uppy.on("plugin-remove", this.removeTarget);
this.uppy.on("file-added", this.hideAllPanels);
this.uppy.on("dashboard:modal-closed", this.hideAllPanels);
- this.uppy.on("file-editor:complete", this.hideAllPanels);
this.uppy.on("complete", this.handleComplete);
this.uppy.on(
"files-added",
@@ -615,7 +639,6 @@ export default class Dashboard extends UIPlugin {
this.uppy.off("plugin-remove", this.removeTarget);
this.uppy.off("file-added", this.hideAllPanels);
this.uppy.off("dashboard:modal-closed", this.hideAllPanels);
- this.uppy.off("file-editor:complete", this.hideAllPanels);
this.uppy.off("complete", this.handleComplete);
this.uppy.off(
"files-added",
@@ -771,6 +794,7 @@ export default class Dashboard extends UIPlugin {
activePickerPanel: pluginState.activePickerPanel,
showFileEditor: pluginState.showFileEditor,
saveFileEditor: this.saveFileEditor,
+ closeFileEditor: this.closeFileEditor,
disableInteractiveElements: this.disableInteractiveElements,
animateOpenClose: this.opts.animateOpenClose,
isClosing: pluginState.isClosing,
diff --git a/packages/@uppy/dashboard/lib/components/EditorPanel.js b/packages/@uppy/dashboard/lib/components/EditorPanel.js
index 279bdc5..3008be5 100644
--- a/packages/@uppy/dashboard/lib/components/EditorPanel.js
+++ b/packages/@uppy/dashboard/lib/components/EditorPanel.js
@@ -4,7 +4,7 @@ function EditorPanel(props) {
const file = props.files[props.fileCardFor];
const handleCancel = () => {
props.uppy.emit("file-editor:cancel", file);
- props.hideAllPanels();
+ props.closeFileEditor();
};
return h(
"div", |
Murderlon
approved these changes
Feb 21, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Murderlon
added a commit
that referenced
this pull request
Feb 22, 2024
* main: MetaEditor + ImageEditor - new state machine logic (#4939)
Murderlon
added a commit
that referenced
this pull request
Feb 22, 2024
* main: MetaEditor + ImageEditor - new state machine logic (#4939) meta: disable `@typescript-eslint/no-non-null-assertion` lint rule (#4945) remove unnecessary `'use strict'` directives (#4943) @uppy/companion-client: type changes for provider-views (#4938) meta: bump ip from 1.1.8 to 1.1.9 (#4941) @uppy/companion-client: update types (#4927) Release: uppy@3.22.1 (#4935) update vi_VN translation (#4930) bump `@transloadit/prettier-bytes` (#4933) Release: uppy@3.22.0 (#4929) update `UppyFile` objects before emitting events (#4928) @uppy/transloadit: add `clientName` option (#4920) Fix broken previews after cropping (#4926) @uppy/compressor: upgrade compressorjs (#4924) Fix companion dns and allow redirects from http->https again (#4895) autoOpenFileEditor - rename "Edit file" to "Edit image" (#4925)
Merged
github-actions bot
added a commit
that referenced
this pull request
Feb 22, 2024
| Package | Version | Package | Version | | ---------------------- | ------- | ---------------------- | ------- | | @uppy/audio | 1.1.7 | @uppy/react | 3.2.2 | | @uppy/companion | 4.12.3 | @uppy/status-bar | 3.2.8 | | @uppy/companion-client | 3.7.3 | @uppy/tus | 3.5.3 | | @uppy/core | 3.9.2 | @uppy/utils | 5.7.3 | | @uppy/dashboard | 3.7.4 | @uppy/xhr-upload | 3.6.3 | | @uppy/image-editor | 2.4.3 | uppy | 3.22.2 | - @uppy/core: fix plugin detection (Antoine du Hamel / #4951) - @uppy/core,@uppy/utils: Introduce `ValidateableFile` & move `MinimalRequiredUppyFile` into utils (Antoine du Hamel / #4944) - meta: uppy: fix bundle builder (Antoine du Hamel / #4950) - @uppy/core: improve `UIPluginOptions` types (Merlijn Vos / #4946) - @uppy/companion-client: fix body/url on upload-success (Merlijn Vos / #4922) - @uppy/utils: remove EventManager circular reference (Merlijn Vos / #4949) - @uppy/dashboard: MetaEditor + ImageEditor - new state machine logic (Evgenia Karunus / #4939) - meta: disable `@typescript-eslint/no-non-null-assertion` lint rule (Antoine du Hamel / #4945) - @uppy/companion-client: remove unnecessary `'use strict'` directives (Antoine du Hamel / #4943) - @uppy/companion-client: type changes for provider-views (Antoine du Hamel / #4938) - meta: bump ip from 1.1.8 to 1.1.9 (dependabot[bot] / #4941) - @uppy/companion-client: update types (Antoine du Hamel / #4927)
Murderlon
added a commit
that referenced
this pull request
Feb 26, 2024
* main: @uppy/file-input: refactor to TypeScript (#4954) Release: uppy@3.22.2 (#4952) @uppy/core: fix plugin detection (#4951) Introduce `ValidateableFile` & move `MinimalRequiredUppyFile` into utils (#4944) uppy: fix bundle builder (#4950) @uppy/core: improve `UIPluginOptions` types (#4946) @uppy/companion-client: fix body/url on upload-success (#4922) @uppy/utils: remove EventManager circular reference (#4949) MetaEditor + ImageEditor - new state machine logic (#4939) meta: disable `@typescript-eslint/no-non-null-assertion` lint rule (#4945) remove unnecessary `'use strict'` directives (#4943) @uppy/companion-client: type changes for provider-views (#4938) meta: bump ip from 1.1.8 to 1.1.9 (#4941)
Closed
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4878, implicitly fixes #4442.
Implements "file list ⟷ metaEditor ⟷ imageEditor" state machine we discussed in Slack.
Tested with all combinations of:
.use(ImageEditor, { target: Dashboard })
present/absentautoOpenFileEditor
true/falsemetaFields
present/absent