2022-10-18 06:28:21 -07:00
|
|
|
<template>
|
|
|
|
<resources-list-layout
|
|
|
|
ref="layout"
|
|
|
|
resource-key="workflows"
|
|
|
|
:resources="allWorkflows"
|
|
|
|
:initialize="initialize"
|
|
|
|
:filters="filters"
|
|
|
|
:additional-filters-handler="onFilter"
|
|
|
|
:show-aside="allWorkflows.length > 0"
|
|
|
|
:shareable="false"
|
|
|
|
@click:add="addWorkflow"
|
|
|
|
@update:filters="filters = $event"
|
|
|
|
>
|
|
|
|
<template v-slot="{ data }">
|
|
|
|
<workflow-card :data="data" @click:tag="onClickTag" />
|
|
|
|
</template>
|
|
|
|
<template #empty>
|
|
|
|
<div class="text-center mt-s">
|
|
|
|
<n8n-heading tag="h2" size="xlarge" class="mb-2xs">
|
|
|
|
{{ $locale.baseText(currentUser.firstName ? 'workflows.empty.heading' : 'workflows.empty.heading.userNotSetup', { interpolate: { name: currentUser.firstName } }) }}
|
|
|
|
</n8n-heading>
|
|
|
|
<n8n-text size="large" color="text-base">
|
|
|
|
{{ $locale.baseText('workflows.empty.description') }}
|
|
|
|
</n8n-text>
|
|
|
|
</div>
|
|
|
|
<div class="text-center mt-2xl">
|
2022-11-11 00:07:14 -08:00
|
|
|
<n8n-card :class="[$style.emptyStateCard, 'mr-s']" hoverable @click="addWorkflow" data-test-id="new-workflow-card">
|
2022-10-18 06:28:21 -07:00
|
|
|
<n8n-icon :class="$style.emptyStateCardIcon" icon="file" />
|
|
|
|
<n8n-text size="large" class="mt-xs" color="text-base">
|
|
|
|
{{ $locale.baseText('workflows.empty.startFromScratch') }}
|
|
|
|
</n8n-text>
|
|
|
|
</n8n-card>
|
2022-11-11 00:07:14 -08:00
|
|
|
<n8n-card :class="$style.emptyStateCard" hoverable @click="goToTemplates" data-test-id="new-workflow-template-card">
|
2022-10-18 06:28:21 -07:00
|
|
|
<n8n-icon :class="$style.emptyStateCardIcon" icon="box-open" />
|
|
|
|
<n8n-text size="large" class="mt-xs" color="text-base">
|
|
|
|
{{ $locale.baseText('workflows.empty.browseTemplates') }}
|
|
|
|
</n8n-text>
|
|
|
|
</n8n-card>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template v-slot:filters="{ setKeyValue }">
|
2022-11-04 06:04:31 -07:00
|
|
|
<div class="mb-s" v-if="settingsStore.areTagsEnabled">
|
2022-10-18 06:28:21 -07:00
|
|
|
<n8n-input-label
|
|
|
|
:label="$locale.baseText('workflows.filters.tags')"
|
|
|
|
:bold="false"
|
|
|
|
size="small"
|
|
|
|
color="text-base"
|
|
|
|
class="mb-3xs"
|
|
|
|
/>
|
|
|
|
<TagsDropdown
|
|
|
|
:placeholder="$locale.baseText('workflowOpen.filterWorkflows')"
|
|
|
|
:currentTagIds="filters.tags"
|
|
|
|
:createEnabled="false"
|
|
|
|
@update="setKeyValue('tags', $event)"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</resources-list-layout>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import {showMessage} from '@/components/mixins/showMessage';
|
|
|
|
import mixins from 'vue-typed-mixins';
|
|
|
|
|
|
|
|
import SettingsView from './SettingsView.vue';
|
|
|
|
import ResourcesListLayout from "@/components/layouts/ResourcesListLayout.vue";
|
|
|
|
import PageViewLayout from "@/components/layouts/PageViewLayout.vue";
|
|
|
|
import PageViewLayoutList from "@/components/layouts/PageViewLayoutList.vue";
|
|
|
|
import WorkflowCard from "@/components/WorkflowCard.vue";
|
|
|
|
import TemplateCard from "@/components/TemplateCard.vue";
|
|
|
|
import { debounceHelper } from '@/components/mixins/debounce';
|
|
|
|
import {VIEWS} from '@/constants';
|
|
|
|
import Vue from "vue";
|
|
|
|
import {ITag, IUser, IWorkflowDb} from "@/Interface";
|
|
|
|
import TagsDropdown from "@/components/TagsDropdown.vue";
|
2022-11-04 06:04:31 -07:00
|
|
|
import { mapStores } from 'pinia';
|
|
|
|
import { useUIStore } from '@/stores/ui';
|
|
|
|
import { useSettingsStore } from '@/stores/settings';
|
|
|
|
import { useUsersStore } from '@/stores/users';
|
|
|
|
import { useWorkflowsStore } from '@/stores/workflows';
|
2022-10-18 06:28:21 -07:00
|
|
|
|
|
|
|
type IResourcesListLayoutInstance = Vue & { sendFiltersTelemetry: (source: string) => void };
|
|
|
|
|
|
|
|
export default mixins(
|
|
|
|
showMessage,
|
|
|
|
debounceHelper,
|
|
|
|
).extend({
|
2022-11-11 00:07:14 -08:00
|
|
|
name: 'WorkflowsView',
|
2022-10-18 06:28:21 -07:00
|
|
|
components: {
|
|
|
|
ResourcesListLayout,
|
|
|
|
TemplateCard,
|
|
|
|
PageViewLayout,
|
|
|
|
PageViewLayoutList,
|
|
|
|
SettingsView,
|
|
|
|
WorkflowCard,
|
|
|
|
TagsDropdown,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
filters: {
|
|
|
|
search: '',
|
|
|
|
ownedBy: '',
|
|
|
|
sharedWith: '',
|
|
|
|
tags: [] as string[],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2022-11-04 06:04:31 -07:00
|
|
|
...mapStores(
|
|
|
|
useSettingsStore,
|
|
|
|
useUIStore,
|
|
|
|
useUsersStore,
|
|
|
|
useWorkflowsStore,
|
|
|
|
),
|
2022-10-18 06:28:21 -07:00
|
|
|
currentUser(): IUser {
|
2022-11-04 06:04:31 -07:00
|
|
|
return this.usersStore.currentUser || {} as IUser;
|
2022-10-18 06:28:21 -07:00
|
|
|
},
|
|
|
|
allWorkflows(): IWorkflowDb[] {
|
2022-11-04 06:04:31 -07:00
|
|
|
return this.workflowsStore.allWorkflows;
|
2022-10-18 06:28:21 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
addWorkflow() {
|
2022-11-04 06:04:31 -07:00
|
|
|
this.uiStore.nodeViewInitialized = false;
|
2022-10-18 06:28:21 -07:00
|
|
|
this.$router.push({ name: VIEWS.NEW_WORKFLOW });
|
|
|
|
|
|
|
|
this.$telemetry.track('User clicked add workflow button', {
|
|
|
|
source: 'Workflows list',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
goToTemplates() {
|
|
|
|
this.$router.push({ name: VIEWS.TEMPLATES });
|
|
|
|
},
|
|
|
|
async initialize() {
|
2022-11-04 06:04:31 -07:00
|
|
|
this.usersStore.fetchUsers(); // Can be loaded in the background, used for filtering
|
2022-10-18 06:28:21 -07:00
|
|
|
|
|
|
|
return await Promise.all([
|
2022-11-04 06:04:31 -07:00
|
|
|
this.workflowsStore.fetchAllWorkflows(),
|
|
|
|
this.workflowsStore.fetchActiveWorkflows(),
|
2022-10-18 06:28:21 -07:00
|
|
|
]);
|
|
|
|
},
|
|
|
|
onClickTag(tagId: string, event: PointerEvent) {
|
|
|
|
if (!this.filters.tags.includes(tagId)) {
|
|
|
|
this.filters.tags.push(tagId);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onFilter(resource: IWorkflowDb, filters: { tags: string[]; search: string; }, matches: boolean): boolean {
|
2022-11-04 06:04:31 -07:00
|
|
|
if (this.settingsStore.areTagsEnabled && filters.tags.length > 0) {
|
2022-10-18 06:28:21 -07:00
|
|
|
matches = matches && filters.tags.every(
|
|
|
|
(tag) => (resource.tags as ITag[])?.find((resourceTag) => typeof resourceTag === 'object' ? `${resourceTag.id}` === `${tag}` : `${resourceTag}` === `${tag}`),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return matches;
|
|
|
|
},
|
|
|
|
sendFiltersTelemetry(source: string) {
|
|
|
|
(this.$refs.layout as IResourcesListLayoutInstance).sendFiltersTelemetry(source);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
'filters.tags'() {
|
|
|
|
this.sendFiltersTelemetry('tags');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
2022-11-04 06:04:31 -07:00
|
|
|
this.usersStore.showPersonalizationSurvey();
|
2022-10-18 06:28:21 -07:00
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
.emptyStateCard {
|
|
|
|
width: 192px;
|
|
|
|
text-align: center;
|
|
|
|
display: inline-flex;
|
|
|
|
height: 230px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
svg {
|
|
|
|
color: var(--color-primary);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.emptyStateCardIcon {
|
|
|
|
font-size: 48px;
|
|
|
|
|
|
|
|
svg {
|
|
|
|
width: 48px!important;
|
|
|
|
color: var(--color-foreground-dark);
|
|
|
|
transition: color 0.3s ease;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|