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): disable settings link in executions view for unsaved workflows #4493

Merged
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 @@ -19,6 +19,7 @@
<n8n-text color="text-base" size="small" align="left">
<span v-html="description"></span>
</n8n-text>
<slot name="customContent"></slot>
</div>
</div>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,41 @@
:class="[$style.accordion, 'mt-2xl']"
:title="$locale.baseText('executionsLandingPage.emptyState.accordion.title')"
:items="accordionItems"
:description="accordionDescription"
:initiallyExpanded="shouldExpandAccordion"
:headerIcon="accordionIcon"
@click="onAccordionClick"
@tooltipClick="onItemTooltipClick"
></n8n-info-accordion>
>
<template #customContent>
<footer class="mt-2xs">
{{ $locale.baseText('executionsLandingPage.emptyState.accordion.footer') }}
<n8n-tooltip :disabled="!isNewWorkflow">
<div slot="content">
<n8n-link @click.prevent="onSaveWorkflowClick">{{ $locale.baseText('executionsLandingPage.emptyState.accordion.footer.tooltipLink') }}</n8n-link>
{{ $locale.baseText('executionsLandingPage.emptyState.accordion.footer.tooltipText') }}
</div>
<n8n-link @click.prevent="openWorkflowSettings" :class="{[$style.disabled]: isNewWorkflow}">
{{ $locale.baseText('executionsLandingPage.emptyState.accordion.footer.settingsLink') }}
</n8n-link>
</n8n-tooltip>
</footer>
</template>
</n8n-info-accordion>
</template>

<script lang="ts">
import { WORKFLOW_SETTINGS_MODAL_KEY } from '@/constants';
import { PLACEHOLDER_EMPTY_WORKFLOW_ID, WORKFLOW_SETTINGS_MODAL_KEY } from '@/constants';
import { deepCopy, IWorkflowSettings } from 'n8n-workflow';
import Vue from 'vue';
import mixins from 'vue-typed-mixins';
import { workflowHelpers } from '../mixins/workflowHelpers';

interface IWorkflowSaveSettings {
saveFailedExecutions: boolean,
saveSuccessfulExecutions: boolean,
saveManualExecutions: boolean,
};

export default Vue.extend({
export default mixins(workflowHelpers).extend({
name: 'executions-info-accordion',
props: {
initiallyExpanded: {
Expand Down Expand Up @@ -103,19 +118,24 @@ export default Vue.extend({
const workflowSettings = deepCopy(this.$store.getters.workflowSettings);
return workflowSettings;
},
accordionDescription(): string {
return `
<footer class="mt-2xs">
${this.$locale.baseText('executionsLandingPage.emptyState.accordion.footer')}
</footer>
`;
},
accordionIcon(): { icon: string, color: string }|null {
if (this.workflowSaveSettings.saveManualExecutions !== true || this.productionExecutionsStatus !== 'saving') {
return { icon: 'exclamation-triangle', color: 'warning' };
}
return null;
},
currentWorkflowId(): string {
return this.$store.getters.workflowId;
},
isNewWorkflow(): boolean {
return !this.currentWorkflowId || (this.currentWorkflowId === PLACEHOLDER_EMPTY_WORKFLOW_ID || this.currentWorkflowId === 'new');
},
workflowName(): string {
return this.$store.getters.workflowName;
},
currentWorkflowTagIds(): string[] {
return this.$store.getters.workflowTags;
},
},
methods: {
updateSettings(settingsInStore: IWorkflowSettings): void {
Expand All @@ -135,6 +155,19 @@ export default Vue.extend({
this.$store.dispatch('ui/openModal', WORKFLOW_SETTINGS_MODAL_KEY);
}
},
openWorkflowSettings(event: MouseEvent): void {
this.$store.dispatch('ui/openModal', WORKFLOW_SETTINGS_MODAL_KEY);
},
async onSaveWorkflowClick(event: MouseEvent): void {
let currentId = undefined;
if (this.currentWorkflowId !== PLACEHOLDER_EMPTY_WORKFLOW_ID) {
currentId = this.currentWorkflowId;
} else if (this.$route.params.name && this.$route.params.name !== 'new') {
currentId = this.$route.params.name;
}
const saved = await this.saveCurrentWorkflow({ id: currentId, name: this.workflowName, tags: this.currentWorkflowTagIds });
if (saved) this.$store.dispatch('settings/fetchPromptsData');
},
},
});
</script>
Expand Down Expand Up @@ -168,6 +201,14 @@ export default Vue.extend({
footer {
text-align: left;
width: 100%;
font-size: var(--font-size-2xs);
}

.disabled a {
color: currentColor;
cursor: not-allowed;
opacity: 0.5;
text-decoration: none;
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@
"executionsLandingPage.emptyState.accordion.productionExecutions": "Production executions",
"executionsLandingPage.emptyState.accordion.manualExecutions": "Manual executions",
"executionsLandingPage.emptyState.accordion.productionExecutionsWarningTooltip": "Not all production executions are being saved. Change this in the workflow's <a href=\"#\">settings</a>",
"executionsLandingPage.emptyState.accordion.footer": "You can change this in <a href=\"#\">Workflow Settings</a>",
"executionsLandingPage.emptyState.accordion.footer": "You can change this in",
"executionsLandingPage.emptyState.accordion.footer.settingsLink": "Workflow settings",
"executionsLandingPage.emptyState.accordion.footer.tooltipLink": "Save your workflow",
"executionsLandingPage.emptyState.accordion.footer.tooltipText": "in order to access workflow settings",
"executionsLandingPage.noResults": "No executions found",
"executionsList.allWorkflows": "All Workflows",
"executionsList.anyStatus": "Any Status",
Expand Down