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

fix(editor): Fix shortcut issue on save buttons #9309

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ function goToUpgrade() {
type="primary"
:saved="!uiStore.stateIsDirty && !isNewWorkflow"
:disabled="isWorkflowSaving || readOnly"
with-shortcut
:shortcut-tooltip="$locale.baseText('saveWorkflowButton.hint')"
data-test-id="workflow-save-button"
@click="onSaveButtonClick"
/>
Expand Down
34 changes: 27 additions & 7 deletions packages/editor-ui/src/components/SaveButton.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
<template>
<span :class="$style.container" data-test-id="save-button">
<span v-if="saved" :class="$style.saved">{{ $locale.baseText('saveButton.saved') }}</span>
<KeyboardShortcutTooltip
v-else
:label="$locale.baseText('saveButton.hint')"
:shortcut="{ keys: ['s'], metaKey: true }"
placement="bottom"
>
<template v-else>
<KeyboardShortcutTooltip
v-if="withShortcut"
:label="shortcutTooltipLabel"
:shortcut="{ keys: ['s'], metaKey: true }"
placement="bottom"
>
<n8n-button
:label="saveButtonLabel"
:loading="isSaving"
:disabled="disabled"
:class="$style.button"
:type="type"
/>
</KeyboardShortcutTooltip>
<n8n-button
v-else
:label="saveButtonLabel"
:loading="isSaving"
:disabled="disabled"
:class="$style.button"
:type="type"
/>
</KeyboardShortcutTooltip>
</template>
</span>
</template>

Expand Down Expand Up @@ -50,13 +60,23 @@ export default defineComponent({
type: String,
default: 'primary',
},
withShortcut: {
type: Boolean,
default: false,
},
shortcutTooltip: {
type: String,
},
},
computed: {
saveButtonLabel() {
return this.isSaving
? this.$locale.baseText('saveButton.saving')
: this.$locale.baseText('saveButton.save');
},
shortcutTooltipLabel() {
return this.shortcutTooltip ?? this.$locale.baseText('saveButton.save');
},
},
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@
"runData.aiContentBlock.tokens.completion": "Completion:",
"saveButton.save": "@:_reusableBaseText.save",
"saveButton.saved": "Saved",
"saveButton.hint": "Save workflow",
"saveWorkflowButton.hint": "Save workflow",
"saveButton.saving": "Saving",
"settings": "Settings",
"settings.communityNodes": "Community nodes",
Expand Down
Loading