feat(editor): create new workflows page (#4267)

* feat(editor): extract credentials view into reusable layout components for workflows view

* feat(editor): add workflow card and start work on empty state

* feat: add hoverable card and finish workflows empty state

* fix: undo workflows response interface changes

* chore: fix linting issues.

* fix: remove enterprise sharing env schema

* fix(editor): fix workflows resource view when sharing is enabled

* fix: change owner tag design and order

* feat: add personalization survey on workflows page

* fix: update component snapshots

* feat: refactored workflow card to use workflow-activator properly

* fix: fix workflow activator and proptypes

* fix: hide owner tag for workflow card until sharing is available

* fix: fixed ownedBy and sharedWith appearing for workflows list

* feat: update tags component design

* refactor: change resource filter select to n8n-user-select

* fix: made telemetry messages reusable

* chore: remove unused import

* refactor: fix component name casing

* refactor: use Vue.set to make workflow property reactive

* feat: add support for clicking on tags for filtering

* chore: fix tags linting issues

* fix: fix resources list layout when title words are very long

* refactor: add active and inactive status text to workflow activator

* fix: fix credentials and workflows sorting when name contains leading whitespace

* fix: remove wrongfully added style tag

* feat: add translations and storybook examples for truncated tags

* fix: remove enterprise sharing env from schema

* refactor: fix workflows module and workflows field store naming conflict

* fix: fix workflow activator wrapping

* feat: updated empty workflows list cards design

* feat: update workflow activator margins and workflow card

* feat: add duplicate workflow functionality and update tags

* feat: fix duplicate workflow flow

* fix: fix status color for workflow activator with could not be started status

* fix: remove createdAt and updatedAt from workflow duplication
This commit is contained in:
Alex Grozav
2022-10-18 16:28:21 +03:00
committed by GitHub
parent bb4e08c076
commit be7aac3279
44 changed files with 1612 additions and 970 deletions

View File

@@ -16,7 +16,7 @@
<script lang="ts">
import { genericHelpers } from '@/components/mixins/genericHelpers';
import Card from '@/components/WorkflowCard.vue';
import Card from '@/components/CollectionWorkflowCard.vue';
import mixins from 'vue-typed-mixins';
import NodeList from '@/components/NodeList.vue';

View File

@@ -0,0 +1,66 @@
<template>
<n8n-card
:class="$style.card"
v-on="$listeners"
>
<template #header v-if="!loading">
<span
v-text="title"
:class="$style.title"
/>
</template>
<n8n-loading :loading="loading" :rows="3" variant="p" />
<template #footer v-if="!loading">
<slot name="footer" />
</template>
</n8n-card>
</template>
<script lang="ts">
import { genericHelpers } from '@/components/mixins/genericHelpers';
import mixins from 'vue-typed-mixins';
export default mixins(genericHelpers).extend({
name: 'Card',
props: {
loading: {
type: Boolean,
},
title: {
type: String,
},
},
});
</script>
<style lang="scss" module>
.card {
width: 240px !important;
height: 140px;
margin-right: var(--spacing-2xs);
cursor: pointer;
&:last-child {
margin-right: var(--spacing-5xs);
}
&:hover {
box-shadow: 0 2px 4px rgba(68,28,23,0.07);
}
> div {
height: 100%;
}
}
.title {
display: -webkit-box;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
font-size: var(--font-size-s);
line-height: var(--font-line-height-regular);
font-weight: var(--font-weight-bold);
overflow: hidden;
white-space: normal;
}
</style>

View File

@@ -21,7 +21,7 @@
<script lang="ts">
import { PropType } from "vue";
import { ITemplatesCollection } from "@/Interface";
import Card from '@/components/WorkflowCard.vue';
import Card from '@/components/CollectionWorkflowCard.vue';
import CollectionCard from '@/components/CollectionCard.vue';
import VueAgile from 'vue-agile';

View File

@@ -86,7 +86,9 @@ export default mixins(
},
},
computed: {
...mapGetters('users', ['currentUser']),
currentUser (): IUser {
return this.$store.getters['users/currentUser'];
},
credentialType(): ICredentialType {
return this.$store.getters['credentials/getCredentialTypeByName'](this.data.type);
},

View File

@@ -47,15 +47,15 @@ import { showMessage } from "@/components/mixins/showMessage";
import TagsDropdown from "@/components/TagsDropdown.vue";
import Modal from "./Modal.vue";
import { mapGetters } from "vuex";
import {restApi} from "@/components/mixins/restApi";
import {IWorkflowDb} from "@/Interface";
export default mixins(showMessage, workflowHelpers).extend({
export default mixins(showMessage, workflowHelpers, restApi).extend({
components: { TagsDropdown, Modal },
name: "DuplicateWorkflow",
props: ["modalName", "isActive"],
props: ["modalName", "isActive", "data"],
data() {
const currentTagIds = this.$store.getters[
"workflowTags"
] as string[];
const currentTagIds = this.data.tags;
return {
name: '',
@@ -68,7 +68,7 @@ export default mixins(showMessage, workflowHelpers).extend({
};
},
async mounted() {
this.$data.name = await this.$store.dispatch('workflows/getDuplicateCurrentWorkflowName');
this.name = await this.$store.dispatch('workflows/getDuplicateCurrentWorkflowName', this.data.name);
this.$nextTick(() => this.focusOnNameInput());
},
computed: {
@@ -113,21 +113,29 @@ export default mixins(showMessage, workflowHelpers).extend({
return;
}
const currentWorkflowId = this.$store.getters.workflowId;
const currentWorkflowId = this.data.id;
this.$data.isSaving = true;
this.isSaving = true;
const saved = await this.saveAsNewWorkflow({name, tags: this.currentTagIds, resetWebhookUrls: true, openInNewWindow: true, resetNodeIds: true});
const { createdAt, updatedAt, ...workflow } = await this.restApi().getWorkflow(this.data.id);
const saved = await this.saveAsNewWorkflow({
name,
data: workflow,
tags: this.currentTagIds,
resetWebhookUrls: true,
openInNewWindow: true,
resetNodeIds: true,
});
if (saved) {
this.closeDialog();
this.$telemetry.track('User duplicated workflow', {
old_workflow_id: currentWorkflowId,
workflow_id: this.$store.getters.workflowId,
workflow_id: this.data.id,
});
}
this.$data.isSaving = false;
this.isSaving = false;
},
closeDialog(): void {
this.modalBus.$emit("close");

View File

@@ -62,8 +62,7 @@
<PushConnectionTracker class="actions">
<template>
<span class="activator">
<span>{{ $locale.baseText('workflowDetails.active') + ':' }}</span>
<WorkflowActivator :workflow-active="isWorkflowActive" :workflow-id="currentWorkflowId"/>
<WorkflowActivator :workflow-active="isWorkflowActive" :workflow-id="currentWorkflowId" />
</span>
<SaveButton
type="secondary"
@@ -308,7 +307,14 @@ export default mixins(workflowHelpers, titleChange).extend({
async onWorkflowMenuSelect(action: string): Promise<void> {
switch (action) {
case WORKFLOW_MENU_ACTIONS.DUPLICATE: {
this.$store.dispatch('ui/openModal', DUPLICATE_MODAL_KEY);
await this.$store.dispatch('ui/openModalWithData', {
name: DUPLICATE_MODAL_KEY,
data: {
id: this.$store.getters.workflowId,
name: this.$store.getters.workflowName,
tags: this.$store.getters.workflowTags,
},
});
break;
}
case WORKFLOW_MENU_ACTIONS.DOWNLOAD: {
@@ -347,15 +353,15 @@ export default mixins(workflowHelpers, titleChange).extend({
this.$locale.baseText('mainSidebar.prompt.workflowUrl') + ':',
this.$locale.baseText('mainSidebar.prompt.importWorkflowFromUrl') + ':',
{
confirmButtonText: this.$locale.baseText('mainSidebar.prompt.import'),
cancelButtonText: this.$locale.baseText('mainSidebar.prompt.cancel'),
inputErrorMessage: this.$locale.baseText('mainSidebar.prompt.invalidUrl'),
inputPattern: /^http[s]?:\/\/.*\.json$/i,
},
) as MessageBoxInputData;
confirmButtonText: this.$locale.baseText('mainSidebar.prompt.import'),
cancelButtonText: this.$locale.baseText('mainSidebar.prompt.cancel'),
inputErrorMessage: this.$locale.baseText('mainSidebar.prompt.invalidUrl'),
inputPattern: /^http[s]?:\/\/.*\.json$/i,
},
) as MessageBoxInputData;
this.$root.$emit('importWorkflowUrl', { url: promptResponse.value });
} catch (e) {}
this.$root.$emit('importWorkflowUrl', { url: promptResponse.value });
} catch (e) {}
break;
}
case WORKFLOW_MENU_ACTIONS.IMPORT_FROM_FILE: {
@@ -465,7 +471,6 @@ $--header-spacing: 20px;
.tags {
flex: 1;
padding-right: 20px;
margin-right: $--header-spacing;
}

View File

@@ -78,7 +78,6 @@ import {
VERSIONS_MODAL_KEY,
EXECUTIONS_MODAL_KEY,
VIEWS,
WORKFLOW_OPEN_MODAL_KEY,
} from '@/constants';
import { userHelpers } from './mixins/userHelpers';
import { debounceHelper } from './mixins/debounce';
@@ -174,20 +173,7 @@ export default mixins(
icon: 'network-wired',
label: this.$locale.baseText('mainSidebar.workflows'),
position: 'top',
activateOnRouteNames: [ VIEWS.NEW_WORKFLOW, VIEWS.WORKFLOWS, VIEWS.WORKFLOW ],
children: [
{
id: 'workflow',
label: this.$locale.baseText('mainSidebar.new'),
icon: 'file',
activateOnRouteNames: [ VIEWS.NEW_WORKFLOW ],
},
{
id: 'workflow-open',
label: this.$locale.baseText('mainSidebar.open'),
icon: 'folder-open',
},
],
activateOnRouteNames: [ VIEWS.WORKFLOWS ],
},
{
id: 'templates',
@@ -333,12 +319,10 @@ export default mixins(
},
async handleSelect (key: string) {
switch (key) {
case 'workflow': {
await this.createNewWorkflow();
break;
}
case 'workflow-open': {
this.$store.dispatch('ui/openModal', WORKFLOW_OPEN_MODAL_KEY);
case 'workflows': {
if (this.$router.currentRoute.name !== VIEWS.WORKFLOWS) {
this.$router.push({name: VIEWS.WORKFLOWS});
}
break;
}
case 'templates': {

View File

@@ -8,6 +8,7 @@
:open="isOpen(name)"
:activeId="getActiveId(name)"
:mode="getMode(name)"
:data="getData(name)"
></slot>
</div>
</template>
@@ -25,6 +26,9 @@ export default Vue.extend({
isOpen(name: string) {
return this.$store.getters['ui/isModalOpen'](name);
},
getData(name: string) {
return this.$store.getters['ui/getModalData'](name);
},
getMode(name: string) {
return this.$store.getters['ui/getModalMode'](name);
},

View File

@@ -26,8 +26,9 @@
</ModalRoot>
<ModalRoot :name="DUPLICATE_MODAL_KEY">
<template v-slot:default="{ modalName, active }">
<template v-slot:default="{ modalName, active, data }">
<DuplicateWorkflowDialog
:data="data"
:isActive="active"
:modalName="modalName"
/>
@@ -52,10 +53,6 @@
</template>
</ModalRoot>
<ModalRoot :name="WORKFLOW_OPEN_MODAL_KEY">
<WorkflowOpen />
</ModalRoot>
<ModalRoot :name="WORKFLOW_SETTINGS_MODAL_KEY">
<WorkflowSettings />
</ModalRoot>
@@ -130,7 +127,6 @@ import {
VALUE_SURVEY_MODAL_KEY,
VERSIONS_MODAL_KEY,
WORKFLOW_ACTIVE_MODAL_KEY,
WORKFLOW_OPEN_MODAL_KEY,
WORKFLOW_SETTINGS_MODAL_KEY,
IMPORT_CURL_MODAL_KEY,
} from '@/constants';
@@ -151,7 +147,6 @@ import TagsManager from "./TagsManager/TagsManager.vue";
import UpdatesPanel from "./UpdatesPanel.vue";
import ValueSurvey from "./ValueSurvey.vue";
import WorkflowSettings from "./WorkflowSettings.vue";
import WorkflowOpen from "./WorkflowOpen.vue";
import DeleteUserModal from "./DeleteUserModal.vue";
import ExecutionsList from "./ExecutionsList.vue";
import ActivationModal from "./ActivationModal.vue";
@@ -179,7 +174,6 @@ export default Vue.extend({
UpdatesPanel,
ValueSurvey,
WorkflowSettings,
WorkflowOpen,
ImportCurlModal,
},
data: () => ({
@@ -197,7 +191,6 @@ export default Vue.extend({
INVITE_USER_MODAL_KEY,
TAGS_MANAGER_MODAL_KEY,
VERSIONS_MODAL_KEY,
WORKFLOW_OPEN_MODAL_KEY,
WORKFLOW_SETTINGS_MODAL_KEY,
VALUE_SURVEY_MODAL_KEY,
EXECUTIONS_MODAL_KEY,

View File

@@ -245,6 +245,23 @@ $--max-input-height: 60px;
</style>
<style lang="scss">
.tags-container {
.el-tag {
padding: 1px var(--spacing-4xs);
color: var(--color-text-dark);
background-color: var(--color-background-base);
border-radius: var(--border-radius-base);
font-size: var(--font-size-2xs);
border: 0;
.el-tag__close {
max-height: 14px;
max-width: 14px;
line-height: 14px;
}
}
}
.tags-dropdown {
$--item-font-size: 14px;
$--item-line-height: 18px;

View File

@@ -1,5 +1,13 @@
<template>
<div class="workflow-activator">
<div :class="$style.activeStatusText">
<n8n-text v-if="workflowActive" :color="couldNotBeStarted ? 'danger' : 'success'" size="small" bold>
{{ $locale.baseText('workflowActivator.active') }}
</n8n-text>
<n8n-text v-else color="text-base" size="small" bold>
{{ $locale.baseText('workflowActivator.inactive') }}
</n8n-text>
</div>
<n8n-tooltip :disabled="!disabled" placement="bottom">
<div slot="content">{{ $locale.baseText('workflowActivator.thisWorkflowHasNoTriggerNodes') }}</div>
<el-switch
@@ -113,10 +121,21 @@ export default mixins(
);
</script>
<style lang="scss" scoped>
.workflow-activator {
<style lang="scss" module>
.activeStatusText {
width: 64px; // Required to avoid jumping when changing active state
padding-right: var(--spacing-2xs);
box-sizing: border-box;
display: inline-block;
text-align: right;
}
</style>
<style lang="scss" scoped>
.workflow-activator {
display: inline-flex;
flex-wrap: nowrap;
align-items: center;
}
.could-not-be-started {
@@ -128,5 +147,4 @@ export default mixins(
::v-deep .el-loading-spinner {
margin-top: -10px;
}
</style>

View File

@@ -1,66 +1,240 @@
<template>
<n8n-card
:class="$style.card"
v-on="$listeners"
:class="$style.cardLink"
@click="onClick"
>
<template #header v-if="!loading">
<span
v-text="title"
:class="$style.title"
/>
</template>
<n8n-loading :loading="loading" :rows="3" variant="p" />
<template #footer v-if="!loading">
<slot name="footer" />
</template>
<template #header>
<n8n-heading tag="h2" bold class="ph-no-capture" :class="$style.cardHeading">
{{ data.name }}
</n8n-heading>
</template>
<div :class="$style.cardDescription">
<n8n-text color="text-light" size="small">
<span v-show="data">{{$locale.baseText('workflows.item.updated')}} <time-ago :date="data.updatedAt" /> | </span>
<span v-show="data" class="mr-2xs">{{$locale.baseText('workflows.item.created')}} {{ formattedCreatedAtDate }} </span>
<span v-if="areTagsEnabled && data.tags && data.tags.length > 0" v-show="data">
<n8n-tags
:tags="data.tags"
:truncateAt="3"
truncate
@click="onClickTag"
/>
</span>
</n8n-text>
</div>
<template #append>
<div :class="$style.cardActions">
<enterprise-edition :features="[EnterpriseEditionFeature.Sharing]" v-show="false">
<n8n-badge
v-if="credentialPermissions.isOwner"
class="mr-xs"
theme="tertiary"
bold
>
{{$locale.baseText('workflows.item.owner')}}
</n8n-badge>
</enterprise-edition>
<workflow-activator
class="mr-s"
:workflow-active="data.active"
:workflow-id="data.id"
ref="activator"
/>
<n8n-action-toggle
:actions="actions"
theme="dark"
@action="onAction"
/>
</div>
</template>
</n8n-card>
</template>
<script lang="ts">
import { genericHelpers } from '@/components/mixins/genericHelpers';
import mixins from 'vue-typed-mixins';
import {IWorkflowDb, IUser, ITag} from "@/Interface";
import {DUPLICATE_MODAL_KEY, EnterpriseEditionFeature, VIEWS} from '@/constants';
import {showMessage} from "@/components/mixins/showMessage";
import {getWorkflowPermissions, IPermissions} from "@/permissions";
import dateformat from "dateformat";
import { restApi } from '@/components/mixins/restApi';
import WorkflowActivator from '@/components/WorkflowActivator.vue';
import Vue from "vue";
export default mixins(genericHelpers).extend({
name: 'Card',
export const WORKFLOW_LIST_ITEM_ACTIONS = {
OPEN: 'open',
DUPLICATE: 'duplicate',
DELETE: 'delete',
};
export default mixins(
showMessage,
restApi,
).extend({
data() {
return {
EnterpriseEditionFeature,
};
},
components: {
WorkflowActivator,
},
props: {
loading: {
type: Boolean,
data: {
type: Object,
required: true,
default: (): IWorkflowDb => ({
id: '',
createdAt: '',
updatedAt: '',
active: false,
connections: {},
nodes: [],
name: '',
sharedWith: [],
ownedBy: {} as IUser,
}),
},
title: {
type: String,
readonly: {
type: Boolean,
default: false,
},
},
computed: {
currentUser (): IUser {
return this.$store.getters['users/currentUser'];
},
areTagsEnabled(): boolean {
return this.$store.getters['settings/areTagsEnabled'];
},
credentialPermissions(): IPermissions {
return getWorkflowPermissions(this.currentUser, this.data, this.$store);
},
actions(): Array<{ label: string; value: string; }> {
return [
{
label: this.$locale.baseText('workflows.item.open'),
value: WORKFLOW_LIST_ITEM_ACTIONS.OPEN,
},
{
label: this.$locale.baseText('workflows.item.duplicate'),
value: WORKFLOW_LIST_ITEM_ACTIONS.DUPLICATE,
},
].concat(this.credentialPermissions.delete ? [{
label: this.$locale.baseText('workflows.item.delete'),
value: WORKFLOW_LIST_ITEM_ACTIONS.DELETE,
}]: []);
},
formattedCreatedAtDate(): string {
const currentYear = new Date().getFullYear();
return dateformat(this.data.createdAt, `d mmmm${this.data.createdAt.startsWith(currentYear) ? '' : ', yyyy'}`);
},
},
methods: {
async onClick(event?: PointerEvent) {
if (event) {
if ((this.$refs.activator as Vue)?.$el.contains(event.target as HTMLElement)) {
return;
}
if (event.metaKey || event.ctrlKey) {
const route = this.$router.resolve({name: VIEWS.WORKFLOW, params: { name: this.data.id }});
window.open(route.href, '_blank');
return;
}
}
this.$router.push({
name: VIEWS.WORKFLOW,
params: { name: this.data.id },
});
},
onClickTag(tagId: string, event: PointerEvent) {
event.stopPropagation();
this.$emit('click:tag', tagId, event);
},
async onAction(action: string) {
if (action === WORKFLOW_LIST_ITEM_ACTIONS.OPEN) {
await this.onClick();
} else if (action === WORKFLOW_LIST_ITEM_ACTIONS.DUPLICATE) {
await this.$store.dispatch('ui/openModalWithData', {
name: DUPLICATE_MODAL_KEY,
data: {
id: this.data.id,
name: this.data.name,
tags: (this.data.tags || []).map((tag: ITag) => tag.id),
},
});
} else if (action === WORKFLOW_LIST_ITEM_ACTIONS.DELETE) {
const deleteConfirmed = await this.confirmMessage(
this.$locale.baseText(
'mainSidebar.confirmMessage.workflowDelete.message',
{ interpolate: { workflowName: this.data.name } },
),
this.$locale.baseText('mainSidebar.confirmMessage.workflowDelete.headline'),
'warning',
this.$locale.baseText('mainSidebar.confirmMessage.workflowDelete.confirmButtonText'),
this.$locale.baseText('mainSidebar.confirmMessage.workflowDelete.cancelButtonText'),
);
if (deleteConfirmed === false) {
return;
}
try {
await this.restApi().deleteWorkflow(this.data.id);
this.$store.commit('deleteWorkflow', this.data.id);
} catch (error) {
this.$showError(
error,
this.$locale.baseText('mainSidebar.showError.stopExecution.title'),
);
return;
}
// Reset tab title since workflow is deleted.
this.$showMessage({
title: this.$locale.baseText('mainSidebar.showMessage.handleSelect1.title'),
type: 'success',
});
}
},
},
});
</script>
<style lang="scss" module>
.card {
width: 240px !important;
height: 140px;
margin-right: var(--spacing-2xs);
.cardLink {
transition: box-shadow 0.3s ease;
cursor: pointer;
&:last-child {
margin-right: var(--spacing-5xs);
}
&:hover {
box-shadow: 0 2px 4px rgba(68,28,23,0.07);
}
> div {
height: 100%;
box-shadow: 0 2px 8px rgba(#441C17, 0.1);
}
}
.title {
display: -webkit-box;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
.cardHeading {
font-size: var(--font-size-s);
line-height: var(--font-line-height-regular);
font-weight: var(--font-weight-bold);
overflow: hidden;
white-space: normal;
word-break: break-word;
}
.cardDescription {
min-height: 19px;
display: flex;
align-items: center;
}
.cardActions {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
</style>

View File

@@ -1,333 +0,0 @@
<template>
<Modal
:name="WORKFLOW_OPEN_MODAL_KEY"
width="80%"
minWidth="620px"
:classic="true"
>
<template v-slot:header>
<div class="workflows-header">
<n8n-heading tag="h1" size="xlarge" class="title">
{{ $locale.baseText('workflowOpen.openWorkflow') }}
</n8n-heading>
<div class="tags-filter" v-if="areTagsEnabled">
<TagsDropdown
:placeholder="$locale.baseText('workflowOpen.filterWorkflows')"
:currentTagIds="filterTagIds"
:createEnabled="false"
@update="updateTagsFilter"
@esc="onTagsFilterEsc"
@blur="onTagsFilterBlur"
/>
</div>
<div class="search-filter">
<n8n-input :placeholder="$locale.baseText('workflowOpen.searchWorkflows')" ref="inputFieldFilter" v-model="filterText">
<font-awesome-icon slot="prefix" icon="search"></font-awesome-icon>
</n8n-input>
</div>
<div class="open-wf-button">
<n8n-button
:label="$locale.baseText('workflowOpen.newWFButton.label')"
:title="$locale.baseText('workflowOpen.newWFButton.title')"
size="large"
icon="plus"
type="primary"
@click="onNewWFClick"
/>
</div>
</div>
</template>
<template v-slot:content>
<el-table class="search-table" :data="filteredWorkflows" stripe @cell-click="openWorkflow" :default-sort = "{prop: 'updatedAt', order: 'descending'}" v-loading="isDataLoading">
<el-table-column property="name" :label="$locale.baseText('workflowOpen.name')" class-name="clickable" sortable>
<template slot-scope="scope">
<div class="ph-no-capture" :key="scope.row.id">
<span class="name">{{scope.row.name}}</span>
<TagsContainer v-if="areTagsEnabled" class="hidden-sm-and-down" :tagIds="getIds(scope.row.tags)" :limit="3" @click="onTagClick" :clickable="true" :hoverable="true" />
</div>
</template>
</el-table-column>
<el-table-column property="createdAt" :label="$locale.baseText('workflowOpen.created')" class-name="clickable" width="155" sortable></el-table-column>
<el-table-column property="updatedAt" :label="$locale.baseText('workflowOpen.updated')" class-name="clickable" width="155" sortable></el-table-column>
<el-table-column :label="$locale.baseText('workflowOpen.active')" width="75">
<template slot-scope="scope">
<workflow-activator :workflow-active="scope.row.active" :workflow-id="scope.row.id" @workflowActiveChanged="workflowActiveChanged" />
</template>
</el-table-column>
</el-table>
</template>
</Modal>
</template>
<script lang="ts">
import Vue from 'vue';
import mixins from 'vue-typed-mixins';
import { ITag, IWorkflowShortResponse } from '@/Interface';
import { restApi } from '@/components/mixins/restApi';
import { genericHelpers } from '@/components/mixins/genericHelpers';
import { workflowHelpers } from '@/components/mixins/workflowHelpers';
import { showMessage } from '@/components/mixins/showMessage';
import Modal from '@/components/Modal.vue';
import TagsContainer from '@/components/TagsContainer.vue';
import TagsDropdown from '@/components/TagsDropdown.vue';
import WorkflowActivator from '@/components/WorkflowActivator.vue';
import { convertToDisplayDate } from './helpers';
import { mapGetters } from 'vuex';
import { MODAL_CANCEL, MODAL_CLOSE, MODAL_CONFIRMED, VIEWS, WORKFLOW_OPEN_MODAL_KEY } from '../constants';
import { titleChange } from './mixins/titleChange';
export default mixins(
genericHelpers,
restApi,
showMessage,
workflowHelpers,
titleChange,
).extend({
name: 'WorkflowOpen',
components: {
WorkflowActivator,
TagsContainer,
TagsDropdown,
Modal,
},
props: ['modalName'],
data () {
return {
filterText: '',
isDataLoading: false,
workflows: [] as IWorkflowShortResponse[],
filterTagIds: [] as string[],
prevFilterTagIds: [] as string[],
WORKFLOW_OPEN_MODAL_KEY,
};
},
computed: {
...mapGetters('settings', ['areTagsEnabled']),
filteredWorkflows (): IWorkflowShortResponse[] {
return this.workflows
.filter((workflow: IWorkflowShortResponse) => {
if (this.filterText && !workflow.name.toLowerCase().includes(this.filterText.toLowerCase())) {
return false;
}
if (this.filterTagIds.length === 0) {
return true;
}
if (!workflow.tags || workflow.tags.length === 0) {
return false;
}
return this.filterTagIds.reduce((accu: boolean, id: string) => accu && !!workflow.tags.find(tag => tag.id === id), true);
});
},
},
async mounted() {
this.filterText = '';
this.filterTagIds = [];
this.isDataLoading = true;
await this.loadActiveWorkflows();
await this.loadWorkflows();
this.isDataLoading = false;
Vue.nextTick(() => {
// Make sure that users can directly type in the filter
(this.$refs.inputFieldFilter as HTMLInputElement).focus();
});
},
methods: {
getIds(tags: ITag[] | undefined) {
return (tags || []).map((tag) => tag.id);
},
updateTagsFilter(tags: string[]) {
this.filterTagIds = tags;
},
onTagClick(tagId: string) {
if (tagId !== 'count' && !this.filterTagIds.includes(tagId)) {
this.filterTagIds.push(tagId);
}
},
async openWorkflow (data: IWorkflowShortResponse, column: any, cell: any, e: PointerEvent) { // tslint:disable-line:no-any
if (column.label !== 'Active') {
const currentWorkflowId = this.$store.getters.workflowId;
if (e.metaKey || e.ctrlKey) {
const route = this.$router.resolve({name: VIEWS.WORKFLOW, params: {name: data.id}});
window.open(route.href, '_blank');
return;
}
if (data.id === currentWorkflowId) {
this.$showMessage({
title: this.$locale.baseText('workflowOpen.showMessage.title'),
message: this.$locale.baseText('workflowOpen.showMessage.message'),
type: 'error',
duration: 1500,
});
// Do nothing if current workflow is the one user chose to open
return;
}
const result = this.$store.getters.getStateIsDirty;
if(result) {
const confirmModal = await this.confirmModal(
this.$locale.baseText('generic.unsavedWork.confirmMessage.message'),
this.$locale.baseText('generic.unsavedWork.confirmMessage.headline'),
'warning',
this.$locale.baseText('generic.unsavedWork.confirmMessage.confirmButtonText'),
this.$locale.baseText('generic.unsavedWork.confirmMessage.cancelButtonText'),
true,
);
if (confirmModal === MODAL_CONFIRMED) {
const saved = await this.saveCurrentWorkflow({}, false);
if (saved) this.$store.dispatch('settings/fetchPromptsData');
this.$router.push({
name: VIEWS.WORKFLOW,
params: { name: data.id },
});
} else if (confirmModal === MODAL_CANCEL) {
this.$store.commit('setStateDirty', false);
this.$router.push({
name: VIEWS.WORKFLOW,
params: { name: data.id },
});
} else if (confirmModal === MODAL_CLOSE) {
return;
}
} else {
this.$router.push({
name: VIEWS.WORKFLOW,
params: { name: data.id },
});
}
this.$store.commit('ui/closeAllModals');
}
},
async loadWorkflows () {
try {
this.workflows = await this.restApi().getWorkflows();
this.workflows.forEach((workflowData: IWorkflowShortResponse) => {
workflowData.createdAt = convertToDisplayDate(workflowData.createdAt as number);
workflowData.updatedAt = convertToDisplayDate(workflowData.updatedAt as number);
});
} catch (error) {
this.$showError(
error,
this.$locale.baseText('workflowOpen.showError.title'),
);
}
},
async loadActiveWorkflows () {
try {
const activeWorkflows = await this.restApi().getActiveWorkflows();
this.$store.commit('setActiveWorkflows', activeWorkflows);
} catch (error) {
this.$showError(
error,
this.$locale.baseText('workflowOpen.couldNotLoadActiveWorkflows'),
);
}
},
async onNewWFClick () {
const result = this.$store.getters.getStateIsDirty;
if(result) {
const confirmModal = await this.confirmModal(
this.$locale.baseText('generic.unsavedWork.confirmMessage.message'),
this.$locale.baseText('generic.unsavedWork.confirmMessage.headline'),
'warning',
this.$locale.baseText('generic.unsavedWork.confirmMessage.confirmButtonText'),
this.$locale.baseText('generic.unsavedWork.confirmMessage.cancelButtonText'),
true,
);
if (confirmModal === MODAL_CONFIRMED) {
const saved = await this.saveCurrentWorkflow({}, false);
if (saved) this.$store.dispatch('settings/fetchPromptsData');
if (this.$router.currentRoute.name === VIEWS.NEW_WORKFLOW) {
this.$root.$emit('newWorkflow');
} else {
this.$router.push({ name: VIEWS.NEW_WORKFLOW });
}
this.$showMessage({
title: this.$locale.baseText('mainSidebar.showMessage.handleSelect2.title'),
type: 'success',
});
} else if (confirmModal === MODAL_CANCEL) {
this.$store.commit('setStateDirty', false);
if (this.$router.currentRoute.name === VIEWS.NEW_WORKFLOW) {
this.$root.$emit('newWorkflow');
} else {
this.$router.push({ name: VIEWS.NEW_WORKFLOW });
}
this.$showMessage({
title: this.$locale.baseText('mainSidebar.showMessage.handleSelect2.title'),
type: 'success',
});
} else if (confirmModal === MODAL_CLOSE) {
return;
}
} else {
if (this.$router.currentRoute.name !== VIEWS.NEW_WORKFLOW) {
this.$router.push({ name: VIEWS.NEW_WORKFLOW });
}
this.$showMessage({
title: this.$locale.baseText('mainSidebar.showMessage.handleSelect3.title'),
type: 'success',
});
}
this.$titleReset();
this.$store.commit('ui/closeModal', WORKFLOW_OPEN_MODAL_KEY);
},
workflowActiveChanged (data: { id: string, active: boolean }) {
for (const workflow of this.workflows) {
if (workflow.id === data.id) {
workflow.active = data.active;
}
}
},
onTagsFilterBlur() {
this.prevFilterTagIds = this.filterTagIds;
},
onTagsFilterEsc() {
// revert last applied tags
this.filterTagIds = this.prevFilterTagIds;
},
},
});
</script>
<style scoped lang="scss">
.workflows-header {
display: flex;
> *:first-child {
flex-grow: 1;
}
.search-filter {
margin-left: 12px;
margin-right: 24px;
min-width: 160px;
}
.tags-filter {
flex-grow: 1;
max-width: 270px;
min-width: 220px;
}
}
.search-table .name {
font-weight: 400;
margin-right: 10px;
}
</style>

View File

@@ -0,0 +1,173 @@
<template>
<n8n-popover
trigger="click"
>
<template slot="reference">
<n8n-button
icon="filter"
type="tertiary"
size="medium"
:active="hasFilters"
:class="[$style['filter-button'], 'ml-2xs']"
>
<n8n-badge
v-show="filtersLength > 0"
theme="primary"
class="mr-4xs"
>
{{ filtersLength }}
</n8n-badge>
{{ $locale.baseText('forms.resourceFiltersDropdown.filters') }}
</n8n-button>
</template>
<div :class="$style['filters-dropdown']">
<slot :filters="value" :setKeyValue="setKeyValue" />
<enterprise-edition class="mb-s" :features="[EnterpriseEditionFeature.Sharing]" v-if="shareable">
<n8n-input-label
:label="$locale.baseText('forms.resourceFiltersDropdown.ownedBy')"
:bold="false"
size="small"
color="text-base"
class="mb-3xs"
/>
<n8n-user-select
:users="ownedByUsers"
:currentUserId="currentUser.id"
:value="value.ownedBy"
size="small"
@input="setKeyValue('ownedBy', $event)"
/>
</enterprise-edition>
<enterprise-edition :features="[EnterpriseEditionFeature.Sharing]" v-if="shareable">
<n8n-input-label
:label="$locale.baseText('forms.resourceFiltersDropdown.sharedWith')"
:bold="false"
size="small"
color="text-base"
class="mb-3xs"
/>
<n8n-user-select
:users="sharedWithUsers"
:currentUserId="currentUser.id"
:value="value.sharedWith"
size="small"
@input="setKeyValue('sharedWith', $event)"
/>
</enterprise-edition>
<div :class="[$style['filters-dropdown-footer'], 'mt-s']" v-if="hasFilters">
<n8n-link @click="resetFilters">
{{ $locale.baseText('forms.resourceFiltersDropdown.reset') }}
</n8n-link>
</div>
</div>
</n8n-popover>
</template>
<script lang="ts">
import Vue, { PropType } from 'vue';
import {EnterpriseEditionFeature} from "@/constants";
import {IResource} from "@/components/layouts/ResourcesListLayout.vue";
import {IUser} from "@/Interface";
export type IResourceFiltersType = Record<string, boolean | string | string[]>;
export default Vue.extend({
props: {
value: {
type: Object as PropType<IResourceFiltersType>,
default: () => ({}),
},
keys: {
type: Array as PropType<string[]>,
default: () => [],
},
shareable: {
type: Boolean,
default: true,
},
reset: {
type: Function as PropType<() => void>,
},
},
data() {
return {
EnterpriseEditionFeature,
};
},
computed: {
currentUser(): IUser {
return this.$store.getters['users/currentUser'];
},
allUsers(): IUser[] {
return this.$store.getters['users/allUsers'];
},
ownedByUsers(): IUser[] {
return this.allUsers.map((user) => user.id === this.value.sharedWith ? { ...user, disabled: true } : user);
},
sharedWithUsers(): IUser[] {
return this.allUsers.map((user) => user.id === this.value.ownedBy ? { ...user, disabled: true } : user);
},
filtersLength(): number {
let length = 0;
(this.keys as string[]).forEach((key) => {
if (key === 'search') {
return;
}
length += (Array.isArray(this.value[key]) ? this.value[key].length > 0 : this.value[key] !== '') ? 1 : 0;
});
return length;
},
hasFilters(): boolean {
return this.filtersLength > 0;
},
},
methods: {
setKeyValue(key: string, value: unknown) {
const filters = {
...this.value,
[key]: value,
};
this.$emit('input', filters);
},
resetFilters() {
if (this.reset) {
this.reset();
} else {
const filters = { ...this.value };
(this.keys as string[]).forEach((key) => {
filters[key] = Array.isArray(this.value[key]) ? [] : '';
});
this.$emit('input', filters);
}
},
},
watch: {
filtersLength(value: number) {
this.$emit('update:filtersLength', value);
},
},
});
</script>
<style lang="scss" module>
.filter-button {
height: 36px;
align-items: center;
}
.filters-dropdown {
width: 280px;
}
.filters-dropdown-footer {
display: flex;
justify-content: space-between;
align-items: center;
}
</style>

View File

@@ -0,0 +1,59 @@
<template>
<n8n-menu
:items="menuItems"
mode="tabs"
:value="value ? 'owner' : 'all'"
@input="onSelectOwner"
/>
</template>
<script lang="ts">
import Vue from 'vue';
import { IMenuItem } from 'n8n-design-system';
export default Vue.extend({
props: {
value: {
type: Boolean,
default: true,
},
myResourcesLabel: {
type: String,
default: '',
},
allResourcesLabel: {
type: String,
default: '',
},
},
computed: {
menuItems(): IMenuItem[] {
return [
{
id: 'owner',
icon: 'user',
label: this.myResourcesLabel,
position: 'top',
},
{
id: 'all',
icon: 'globe-americas',
label: this.allResourcesLabel,
position: 'top',
},
];
},
},
methods: {
onSelectOwner(type: string) {
this.$emit('input', type === 'owner');
},
},
});
</script>
<style lang="scss" scoped>
.menu-container {
--menu-padding: 0;
}
</style>

View File

@@ -0,0 +1,408 @@
<template>
<page-view-layout>
<template #aside v-if="showAside">
<div :class="[$style['heading-wrapper'], 'mb-xs']">
<n8n-heading size="2xlarge">
{{ $locale.baseText(`${resourceKey}.heading`) }}
</n8n-heading>
</div>
<div class="mt-xs mb-l">
<n8n-button size="large" block @click="$emit('click:add', $event)">
{{ $locale.baseText(`${resourceKey}.add`) }}
</n8n-button>
</div>
<enterprise-edition :features="[EnterpriseEditionFeature.Sharing]" v-if="shareable">
<resource-ownership-select
v-model="isOwnerSubview"
:my-resources-label="$locale.baseText(`${resourceKey}.menu.my`)"
:all-resources-label="$locale.baseText(`${resourceKey}.menu.all`)"
/>
</enterprise-edition>
</template>
<div v-if="loading">
<n8n-loading :class="[$style['header-loading'], 'mb-l']" variant="custom"/>
<n8n-loading :class="[$style['card-loading'], 'mb-2xs']" variant="custom"/>
<n8n-loading :class="$style['card-loading']" variant="custom"/>
</div>
<template v-else>
<div class="ph-no-capture" v-if="resources.length === 0">
<slot name="empty">
<n8n-action-box
emoji="👋"
:heading="$locale.baseText(currentUser.firstName ? `${resourceKey}.empty.heading` : `${resourceKey}.empty.heading.userNotSetup`, {
interpolate: { name: currentUser.firstName }
})"
:description="$locale.baseText(`${resourceKey}.empty.description`)"
:buttonText="$locale.baseText(`${resourceKey}.empty.button`)"
buttonType="secondary"
@click="$emit('click:add', $event)"
/>
</slot>
</div>
<page-view-layout-list v-else>
<template #header>
<div class="mb-xs">
<div :class="$style['filters-row']">
<n8n-input
:class="[$style['search'], 'mr-2xs']"
:placeholder="$locale.baseText(`${resourceKey}.search.placeholder`)"
v-model="filters.search"
size="medium"
clearable
ref="search"
>
<n8n-icon icon="search" slot="prefix"/>
</n8n-input>
<div :class="$style['sort-and-filter']">
<n8n-select
v-model="sortBy"
size="medium"
>
<n8n-option value="lastUpdated" :label="$locale.baseText(`${resourceKey}.sort.lastUpdated`)"/>
<n8n-option value="lastCreated" :label="$locale.baseText(`${resourceKey}.sort.lastCreated`)"/>
<n8n-option value="nameAsc" :label="$locale.baseText(`${resourceKey}.sort.nameAsc`)"/>
<n8n-option value="nameDesc" :label="$locale.baseText(`${resourceKey}.sort.nameDesc`)"/>
</n8n-select>
<resource-filters-dropdown
:keys="filterKeys"
:reset="resetFilters"
:value="filters"
:shareable="shareable"
@input="$emit('update:filters', $event)"
@update:filtersLength="onUpdateFiltersLength"
>
<template v-slot="resourceFiltersSlotProps">
<slot name="filters" v-bind="resourceFiltersSlotProps" />
</template>
</resource-filters-dropdown>
</div>
</div>
</div>
</template>
<div v-show="hasFilters" class="mt-xs">
<n8n-info-tip :bold="false">
{{ $locale.baseText(`${resourceKey}.filters.active`) }}
<n8n-link @click="resetFilters" size="small">
{{ $locale.baseText(`${resourceKey}.filters.active.reset`) }}
</n8n-link>
</n8n-info-tip>
</div>
<div class="mt-xs mb-l">
<ul :class="[$style.list, 'list-style-none']" v-if="filteredAndSortedSubviewResources.length > 0">
<li v-for="resource in filteredAndSortedSubviewResources" :key="resource.id" class="mb-2xs">
<slot :data="resource" />
</li>
</ul>
<n8n-text color="text-base" size="medium" v-else>
{{ $locale.baseText(`${resourceKey}.noResults`) }}
<template v-if="!hasFilters && isOwnerSubview && resourcesNotOwned.length > 0">
<span v-if="!filters.search">
({{ $locale.baseText(`${resourceKey}.noResults.switchToShared.preamble`) }}
<n8n-link @click="setOwnerSubview(false)">{{$locale.baseText(`${resourceKey}.noResults.switchToShared.link`) }}</n8n-link>)
</span>
<span v-else>
({{ $locale.baseText(`${resourceKey}.noResults.withSearch.switchToShared.preamble`) }}
<n8n-link @click="setOwnerSubview(false)">{{$locale.baseText(`${resourceKey}.noResults.withSearch.switchToShared.link`) }}</n8n-link>)
</span>
</template>
</n8n-text>
</div>
</page-view-layout-list>
</template>
</page-view-layout>
</template>
<script lang="ts">
import {showMessage} from '@/components/mixins/showMessage';
import {IUser} from '@/Interface';
import mixins from 'vue-typed-mixins';
import PageViewLayout from "@/components/layouts/PageViewLayout.vue";
import PageViewLayoutList from "@/components/layouts/PageViewLayoutList.vue";
import {EnterpriseEditionFeature} from "@/constants";
import TemplateCard from "@/components/TemplateCard.vue";
import Vue, {PropType} from "vue";
import {debounceHelper} from '@/components/mixins/debounce';
import ResourceOwnershipSelect from "@/components/forms/ResourceOwnershipSelect.ee.vue";
import ResourceFiltersDropdown from "@/components/forms/ResourceFiltersDropdown.vue";
export interface IResource {
id: string;
name: string;
updatedAt: string;
createdAt: string;
ownedBy?: Partial<IUser>;
sharedWith?: Array<Partial<IUser>>;
}
interface IFilters {
search: string;
ownedBy: string;
sharedWith: string;
[key: string]: boolean | string | string[];
}
type IResourceKeyType = 'credentials' | 'workflows';
const filterKeys = ['ownedBy', 'sharedWith'];
export default mixins(
showMessage,
debounceHelper,
).extend({
name: 'resources-list-layout',
components: {
TemplateCard,
PageViewLayout,
PageViewLayoutList,
ResourceOwnershipSelect,
ResourceFiltersDropdown,
},
props: {
resourceKey: {
type: String,
default: '' as IResourceKeyType,
},
resources: {
type: Array,
default: (): IResource[] => [],
},
initialize: {
type: Function as PropType<() => Promise<void>>,
default: () => () => Promise.resolve(),
},
filters: {
type: Object,
default: (): IFilters => ({ search: '', ownedBy: '', sharedWith: '' }),
},
additionalFiltersHandler: {
type: Function,
},
showAside: {
type: Boolean,
default: true,
},
shareable: {
type: Boolean,
default: true,
},
},
data() {
return {
loading: true,
isOwnerSubview: true,
sortBy: 'lastUpdated',
hasFilters: false,
resettingFilters: false,
EnterpriseEditionFeature,
};
},
computed: {
currentUser(): IUser {
return this.$store.getters['users/currentUser'];
},
allUsers(): IUser[] {
return this.$store.getters['users/allUsers'];
},
subviewResources(): IResource[] {
if (!this.shareable) {
return this.resources as IResource[];
}
return (this.resources as IResource[]).filter((resource) => {
if (this.isOwnerSubview && this.$store.getters['settings/isEnterpriseFeatureEnabled'](EnterpriseEditionFeature.Sharing)) {
return !!(resource.ownedBy && resource.ownedBy.id === this.currentUser.id);
}
return true;
});
},
filterKeys(): string[] {
return Object.keys(this.filters);
},
filteredAndSortedSubviewResources(): IResource[] {
const filtered: IResource[] = this.subviewResources.filter((resource: IResource) => {
let matches = true;
if (this.filters.ownedBy) {
matches = matches && !!(resource.ownedBy && resource.ownedBy.id === this.filters.ownedBy);
}
if (this.filters.sharedWith) {
matches = matches && !!(resource.sharedWith && resource.sharedWith.find((sharee) => sharee.id === this.filters.sharedWith));
}
if (this.filters.search) {
const searchString = this.filters.search.toLowerCase();
matches = matches && resource.name.toLowerCase().includes(searchString);
}
if (this.additionalFiltersHandler) {
matches = this.additionalFiltersHandler(resource, this.filters, matches);
}
return matches;
});
return filtered.sort((a, b) => {
switch (this.sortBy) {
case 'lastUpdated':
return (new Date(b.updatedAt)).valueOf() - (new Date(a.updatedAt)).valueOf();
case 'lastCreated':
return (new Date(b.createdAt)).valueOf() - (new Date(a.createdAt)).valueOf();
case 'nameAsc':
return a.name.trim().localeCompare(b.name.trim());
case 'nameDesc':
return b.name.localeCompare(a.name);
default:
return 0;
}
});
},
resourcesNotOwned(): IResource[] {
return (this.resources as IResource[]).filter((resource) => {
return resource.ownedBy && resource.ownedBy.id !== this.currentUser.id;
});
},
},
methods: {
async onMounted() {
await this.initialize();
this.loading = false;
this.$nextTick(this.focusSearchInput);
},
resetFilters() {
Object.keys(this.filters).forEach((key) => {
this.filters[key] = Array.isArray(this.filters[key]) ? [] : '';
});
this.resettingFilters = true;
this.sendFiltersTelemetry('reset');
},
focusSearchInput() {
if (this.$refs.search) {
(this.$refs.search as Vue & { focus: () => void }).focus();
}
},
setOwnerSubview(active: boolean) {
this.isOwnerSubview = active;
},
getTelemetrySubview(): string {
return this.$locale.baseText(`${this.resourceKey as IResourceKeyType}.menu.${this.isOwnerSubview ? 'my' : 'all'}`);
},
sendSubviewTelemetry() {
this.$telemetry.track(`User changed ${this.resourceKey} sub view`, {
sub_view: this.getTelemetrySubview(),
});
},
sendSortingTelemetry() {
this.$telemetry.track(`User changed sorting in ${this.resourceKey} list`, {
sub_view: this.getTelemetrySubview(),
sorting: this.sortBy,
});
},
sendFiltersTelemetry(source: string) {
// Prevent sending multiple telemetry events when resetting filters
// Timeout is required to wait for search debounce to be over
if (this.resettingFilters) {
if (source !== 'reset') {
return;
}
setTimeout(() => this.resettingFilters = false, 1500);
}
const filters = this.filters as Record<string, string[] | string | boolean>;
const filtersSet: string[] = [];
const filterValues: Array<string[] | string | boolean | null> = [];
Object.keys(filters).forEach((key) => {
if (filters[key]) {
filtersSet.push(key);
filterValues.push(key === 'search' ? null : filters[key]);
}
});
this.$telemetry.track(`User set filters in ${this.resourceKey} list`, {
filters_set: filtersSet,
filter_values: filterValues,
sub_view: this.getTelemetrySubview(),
[`${this.resourceKey}_total_in_view`]: this.subviewResources.length,
[`${this.resourceKey}_after_filtering`]: this.filteredAndSortedSubviewResources.length,
});
},
onUpdateFiltersLength(length: number) {
this.hasFilters = length > 0;
},
},
mounted() {
this.onMounted();
},
watch: {
isOwnerSubview() {
this.sendSubviewTelemetry();
},
'filters.ownedBy'(value) {
if (value) {
this.setOwnerSubview(false);
}
this.sendFiltersTelemetry('ownedBy');
},
'filters.sharedWith'() {
this.sendFiltersTelemetry('sharedWith');
},
'filters.search'() {
this.callDebounced('sendFiltersTelemetry', {debounceTime: 1000, trailing: true}, 'search');
},
sortBy() {
this.sendSortingTelemetry();
},
},
});
</script>
<style lang="scss" module>
.heading-wrapper {
padding-bottom: 1px; // Match input height
}
.filters-row {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.search {
max-width: 240px;
}
.list {
display: flex;
flex-direction: column;
}
.sort-and-filter {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.header-loading {
height: 36px;
}
.card-loading {
height: 69px;
}
</style>

View File

@@ -35,7 +35,6 @@ export const workflowActivate = mixins(
}
currWorkflowId = this.$store.getters.workflowId as string;
}
const isCurrentWorkflow = currWorkflowId === this.$store.getters['workflowId'];
const activeWorkflows = this.$store.getters.getActiveWorkflows;

View File

@@ -730,11 +730,11 @@ export const workflowHelpers = mixins(
}
},
async saveAsNewWorkflow ({name, tags, resetWebhookUrls, resetNodeIds, openInNewWindow}: {name?: string, tags?: string[], resetWebhookUrls?: boolean, openInNewWindow?: boolean, resetNodeIds?: boolean} = {}, redirect = true): Promise<boolean> {
async saveAsNewWorkflow ({ name, tags, resetWebhookUrls, resetNodeIds, openInNewWindow, data }: {name?: string, tags?: string[], resetWebhookUrls?: boolean, openInNewWindow?: boolean, resetNodeIds?: boolean, data?: IWorkflowDataUpdate} = {}, redirect = true): Promise<boolean> {
try {
this.$store.commit('addActiveAction', 'workflowSaving');
const workflowDataRequest: IWorkflowDataUpdate = await this.getWorkflowDataToSave();
const workflowDataRequest: IWorkflowDataUpdate = data || await this.getWorkflowDataToSave();
// make sure that the new ones are not active
workflowDataRequest.active = false;
const changedNodes = {} as IDataObject;
@@ -765,6 +765,9 @@ export const workflowHelpers = mixins(
workflowDataRequest.tags = tags;
}
const workflowData = await this.restApi().createNewWorkflow(workflowDataRequest);
this.$store.commit('addWorkflow', workflowData);
if (openInNewWindow) {
const routeData = this.$router.resolve({name: VIEWS.WORKFLOW, params: {name: workflowData.id}});
window.open(routeData.href, '_blank');