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

This commit is contained in:
Iván Ovejero 2024-05-07 09:09:09 +02:00 committed by GitHub
parent cf441e0294
commit e74c14ffbe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 8 deletions

View file

@ -623,6 +623,8 @@ function goToUpgrade() {
type="primary" type="primary"
:saved="!uiStore.stateIsDirty && !isNewWorkflow" :saved="!uiStore.stateIsDirty && !isNewWorkflow"
:disabled="isWorkflowSaving || readOnly" :disabled="isWorkflowSaving || readOnly"
with-shortcut
:shortcut-tooltip="$locale.baseText('saveWorkflowButton.hint')"
data-test-id="workflow-save-button" data-test-id="workflow-save-button"
@click="onSaveButtonClick" @click="onSaveButtonClick"
/> />

View file

@ -1,20 +1,30 @@
<template> <template>
<span :class="$style.container" data-test-id="save-button"> <span :class="$style.container" data-test-id="save-button">
<span v-if="saved" :class="$style.saved">{{ $locale.baseText('saveButton.saved') }}</span> <span v-if="saved" :class="$style.saved">{{ $locale.baseText('saveButton.saved') }}</span>
<KeyboardShortcutTooltip <template v-else>
v-else <KeyboardShortcutTooltip
:label="$locale.baseText('saveButton.hint')" v-if="withShortcut"
:shortcut="{ keys: ['s'], metaKey: true }" :label="shortcutTooltipLabel"
placement="bottom" :shortcut="{ keys: ['s'], metaKey: true }"
> placement="bottom"
>
<n8n-button
:label="saveButtonLabel"
:loading="isSaving"
:disabled="disabled"
:class="$style.button"
:type="type"
/>
</KeyboardShortcutTooltip>
<n8n-button <n8n-button
v-else
:label="saveButtonLabel" :label="saveButtonLabel"
:loading="isSaving" :loading="isSaving"
:disabled="disabled" :disabled="disabled"
:class="$style.button" :class="$style.button"
:type="type" :type="type"
/> />
</KeyboardShortcutTooltip> </template>
</span> </span>
</template> </template>
@ -50,6 +60,13 @@ export default defineComponent({
type: String, type: String,
default: 'primary', default: 'primary',
}, },
withShortcut: {
type: Boolean,
default: false,
},
shortcutTooltip: {
type: String,
},
}, },
computed: { computed: {
saveButtonLabel() { saveButtonLabel() {
@ -57,6 +74,9 @@ export default defineComponent({
? this.$locale.baseText('saveButton.saving') ? this.$locale.baseText('saveButton.saving')
: this.$locale.baseText('saveButton.save'); : this.$locale.baseText('saveButton.save');
}, },
shortcutTooltipLabel() {
return this.shortcutTooltip ?? this.$locale.baseText('saveButton.save');
},
}, },
}); });
</script> </script>

View file

@ -1455,7 +1455,7 @@
"runData.aiContentBlock.tokens.completion": "Completion:", "runData.aiContentBlock.tokens.completion": "Completion:",
"saveButton.save": "@:_reusableBaseText.save", "saveButton.save": "@:_reusableBaseText.save",
"saveButton.saved": "Saved", "saveButton.saved": "Saved",
"saveButton.hint": "Save workflow", "saveWorkflowButton.hint": "Save workflow",
"saveButton.saving": "Saving", "saveButton.saving": "Saving",
"settings": "Settings", "settings": "Settings",
"settings.communityNodes": "Community nodes", "settings.communityNodes": "Community nodes",