2022-10-18 06:28:21 -07:00
|
|
|
<template>
|
|
|
|
<resources-list-layout
|
|
|
|
ref="layout"
|
|
|
|
resource-key="workflows"
|
|
|
|
:resources="allWorkflows"
|
|
|
|
:filters="filters"
|
|
|
|
:additional-filters-handler="onFilter"
|
|
|
|
:show-aside="allWorkflows.length > 0"
|
2022-11-15 04:25:04 -08:00
|
|
|
:shareable="isShareable"
|
2023-03-08 06:11:13 -08:00
|
|
|
:initialize="initialize"
|
2022-10-18 06:28:21 -07:00
|
|
|
@click:add="addWorkflow"
|
|
|
|
@update:filters="filters = $event"
|
|
|
|
>
|
2023-01-13 02:56:29 -08:00
|
|
|
<template #callout v-if="!hasActiveWorkflows && isDemoTest">
|
|
|
|
<n8n-callout theme="secondary" icon="graduation-cap" class="mb-xs">
|
|
|
|
{{ $locale.baseText('workflows.viewDemoNotice') }}
|
|
|
|
|
|
|
|
<template #trailingContent>
|
|
|
|
<n8n-link size="small" theme="secondary" bold underline @click="goToTemplates">
|
|
|
|
{{ $locale.baseText('workflows.viewDemo') }}
|
|
|
|
</n8n-link>
|
|
|
|
</template>
|
|
|
|
</n8n-callout>
|
|
|
|
</template>
|
2023-01-26 23:51:32 -08:00
|
|
|
<template #default="{ data, updateItemSize }">
|
|
|
|
<workflow-card
|
|
|
|
data-test-id="resources-list-item"
|
|
|
|
class="mb-2xs"
|
|
|
|
:data="data"
|
|
|
|
@expand:tags="updateItemSize(data)"
|
|
|
|
@click:tag="onClickTag"
|
|
|
|
/>
|
2022-10-18 06:28:21 -07:00
|
|
|
</template>
|
|
|
|
<template #empty>
|
|
|
|
<div class="text-center mt-s">
|
|
|
|
<n8n-heading tag="h2" size="xlarge" class="mb-2xs">
|
2022-12-14 01:04:10 -08:00
|
|
|
{{
|
|
|
|
$locale.baseText(
|
|
|
|
currentUser.firstName
|
|
|
|
? 'workflows.empty.heading'
|
|
|
|
: 'workflows.empty.heading.userNotSetup',
|
|
|
|
{ interpolate: { name: currentUser.firstName } },
|
|
|
|
)
|
|
|
|
}}
|
2022-10-18 06:28:21 -07:00
|
|
|
</n8n-heading>
|
|
|
|
<n8n-text size="large" color="text-base">
|
|
|
|
{{ $locale.baseText('workflows.empty.description') }}
|
|
|
|
</n8n-text>
|
|
|
|
</div>
|
2023-01-13 02:56:29 -08:00
|
|
|
<div :class="['text-center', 'mt-2xl', $style.actionsContainer]">
|
2022-12-14 01:04:10 -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-12-14 01:04:10 -08:00
|
|
|
<n8n-card
|
|
|
|
:class="$style.emptyStateCard"
|
|
|
|
hoverable
|
|
|
|
@click="goToTemplates"
|
|
|
|
data-test-id="new-workflow-template-card"
|
|
|
|
>
|
2023-01-13 02:56:29 -08:00
|
|
|
<n8n-icon
|
|
|
|
:class="$style.emptyStateCardIcon"
|
|
|
|
:icon="isDemoTest ? 'graduation-cap' : 'box-open'"
|
|
|
|
/>
|
2022-10-18 06:28:21 -07:00
|
|
|
<n8n-text size="large" class="mt-xs" color="text-base">
|
2023-01-13 02:56:29 -08:00
|
|
|
{{
|
|
|
|
$locale.baseText(
|
|
|
|
isDemoTest ? 'workflows.empty.viewDemo' : 'workflows.empty.browseTemplates',
|
|
|
|
)
|
|
|
|
}}
|
2022-10-18 06:28:21 -07:00
|
|
|
</n8n-text>
|
|
|
|
</n8n-card>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-11-18 05:59:31 -08:00
|
|
|
<template #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>
|
2022-11-22 04:44:12 -08:00
|
|
|
<div class="mb-s">
|
|
|
|
<n8n-input-label
|
|
|
|
:label="$locale.baseText('workflows.filters.status')"
|
|
|
|
:bold="false"
|
|
|
|
size="small"
|
|
|
|
color="text-base"
|
|
|
|
class="mb-3xs"
|
|
|
|
/>
|
2022-11-29 01:03:43 -08:00
|
|
|
<n8n-select :value="filters.status" @input="setKeyValue('status', $event)" size="medium">
|
2022-11-22 04:44:12 -08:00
|
|
|
<n8n-option
|
|
|
|
v-for="option in statusFilterOptions"
|
|
|
|
:key="option.label"
|
|
|
|
:label="option.label"
|
2022-12-14 01:04:10 -08:00
|
|
|
:value="option.value"
|
|
|
|
>
|
2022-11-22 04:44:12 -08:00
|
|
|
</n8n-option>
|
|
|
|
</n8n-select>
|
|
|
|
</div>
|
2022-10-18 06:28:21 -07:00
|
|
|
</template>
|
|
|
|
</resources-list-layout>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2022-12-14 01:04:10 -08:00
|
|
|
import { showMessage } from '@/mixins/showMessage';
|
2023-02-23 02:43:03 -08:00
|
|
|
import { newVersions } from '@/mixins/newVersions';
|
2022-10-18 06:28:21 -07:00
|
|
|
import mixins from 'vue-typed-mixins';
|
|
|
|
|
|
|
|
import SettingsView from './SettingsView.vue';
|
2022-12-14 01:04:10 -08:00
|
|
|
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';
|
2023-02-21 00:35:35 -08:00
|
|
|
import { EnterpriseEditionFeature, ASSUMPTION_EXPERIMENT, VIEWS } from '@/constants';
|
2022-11-23 04:41:53 -08:00
|
|
|
import { debounceHelper } from '@/mixins/debounce';
|
2022-12-14 01:04:10 -08:00
|
|
|
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';
|
2023-02-28 02:44:37 -08:00
|
|
|
import { usePostHog } from '@/stores/posthog';
|
2022-10-18 06:28:21 -07:00
|
|
|
|
|
|
|
type IResourcesListLayoutInstance = Vue & { sendFiltersTelemetry: (source: string) => void };
|
|
|
|
|
2022-11-22 04:44:12 -08:00
|
|
|
const StatusFilter = {
|
|
|
|
ACTIVE: true,
|
|
|
|
DEACTIVATED: false,
|
|
|
|
ALL: '',
|
|
|
|
};
|
|
|
|
|
2023-03-08 06:11:13 -08:00
|
|
|
const WorkflowsView = mixins(showMessage, debounceHelper, newVersions).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: '',
|
2022-11-22 04:44:12 -08:00
|
|
|
status: StatusFilter.ALL,
|
2022-10-18 06:28:21 -07:00
|
|
|
tags: [] as string[],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2022-12-14 01:04:10 -08:00
|
|
|
...mapStores(useSettingsStore, useUIStore, useUsersStore, useWorkflowsStore),
|
2022-10-18 06:28:21 -07:00
|
|
|
currentUser(): IUser {
|
2022-12-14 01:04:10 -08: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
|
|
|
},
|
2022-11-15 04:25:04 -08:00
|
|
|
isShareable(): boolean {
|
2022-12-21 07:42:07 -08:00
|
|
|
return this.settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.Sharing);
|
2022-11-15 04:25:04 -08:00
|
|
|
},
|
2023-01-13 02:56:29 -08:00
|
|
|
hasActiveWorkflows(): boolean {
|
|
|
|
return !!this.workflowsStore.activeWorkflows.length;
|
|
|
|
},
|
|
|
|
isDemoTest(): boolean {
|
2023-02-28 02:44:37 -08:00
|
|
|
return usePostHog().isVariantEnabled(ASSUMPTION_EXPERIMENT.name, ASSUMPTION_EXPERIMENT.demo);
|
2023-01-13 02:56:29 -08:00
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
statusFilterOptions(): Array<{ label: string; value: string | boolean }> {
|
2022-11-22 04:44:12 -08:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
label: this.$locale.baseText('workflows.filters.status.all'),
|
|
|
|
value: StatusFilter.ALL,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: this.$locale.baseText('workflows.filters.status.active'),
|
|
|
|
value: StatusFilter.ACTIVE,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: this.$locale.baseText('workflows.filters.status.deactivated'),
|
|
|
|
value: StatusFilter.DEACTIVATED,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
},
|
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() {
|
2023-01-13 02:56:29 -08:00
|
|
|
if (this.isDemoTest) {
|
|
|
|
this.$router.push({ name: VIEWS.COLLECTION, params: { id: '7' } });
|
|
|
|
this.$telemetry.track('User clicked on inspect demo workflow', {
|
|
|
|
location: this.allWorkflows.length ? 'workflows' : 'start_page',
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.$router.push({ name: VIEWS.TEMPLATES });
|
|
|
|
}
|
2022-10-18 06:28:21 -07:00
|
|
|
},
|
|
|
|
async initialize() {
|
2023-03-08 06:11:13 -08:00
|
|
|
await Promise.all([
|
|
|
|
this.usersStore.fetchUsers(),
|
2022-11-04 06:04:31 -07:00
|
|
|
this.workflowsStore.fetchAllWorkflows(),
|
|
|
|
this.workflowsStore.fetchActiveWorkflows(),
|
2022-10-18 06:28:21 -07:00
|
|
|
]);
|
2023-03-08 06:11:13 -08:00
|
|
|
|
|
|
|
// If the user has no workflows and is not participating in the demo experiment,
|
|
|
|
// redirect to the new workflow view
|
|
|
|
if (!this.isDemoTest && this.allWorkflows.length === 0) {
|
|
|
|
this.uiStore.nodeViewInitialized = false;
|
|
|
|
this.$router.replace({ name: VIEWS.NEW_WORKFLOW });
|
|
|
|
}
|
|
|
|
|
|
|
|
return Promise.resolve();
|
2022-10-18 06:28:21 -07:00
|
|
|
},
|
|
|
|
onClickTag(tagId: string, event: PointerEvent) {
|
|
|
|
if (!this.filters.tags.includes(tagId)) {
|
|
|
|
this.filters.tags.push(tagId);
|
|
|
|
}
|
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
onFilter(
|
|
|
|
resource: IWorkflowDb,
|
|
|
|
filters: { tags: string[]; search: string; status: string | boolean },
|
|
|
|
matches: boolean,
|
|
|
|
): boolean {
|
2022-11-04 06:04:31 -07:00
|
|
|
if (this.settingsStore.areTagsEnabled && filters.tags.length > 0) {
|
2022-12-14 01:04:10 -08:00
|
|
|
matches =
|
|
|
|
matches &&
|
|
|
|
filters.tags.every((tag) =>
|
|
|
|
(resource.tags as ITag[])?.find((resourceTag) =>
|
|
|
|
typeof resourceTag === 'object'
|
|
|
|
? `${resourceTag.id}` === `${tag}`
|
|
|
|
: `${resourceTag}` === `${tag}`,
|
|
|
|
),
|
|
|
|
);
|
2022-10-18 06:28:21 -07:00
|
|
|
}
|
|
|
|
|
2022-11-22 04:44:12 -08:00
|
|
|
if (filters.status !== '') {
|
|
|
|
matches = matches && resource.active === filters.status;
|
|
|
|
}
|
|
|
|
|
2022-10-18 06:28:21 -07:00
|
|
|
return matches;
|
|
|
|
},
|
|
|
|
sendFiltersTelemetry(source: string) {
|
|
|
|
(this.$refs.layout as IResourcesListLayoutInstance).sendFiltersTelemetry(source);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
'filters.tags'() {
|
|
|
|
this.sendFiltersTelemetry('tags');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
2023-02-23 02:43:03 -08:00
|
|
|
this.checkForNewVersions();
|
2022-11-04 06:04:31 -07:00
|
|
|
this.usersStore.showPersonalizationSurvey();
|
2022-10-18 06:28:21 -07:00
|
|
|
},
|
|
|
|
});
|
2023-03-08 06:11:13 -08:00
|
|
|
|
|
|
|
export default WorkflowsView;
|
2022-10-18 06:28:21 -07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" module>
|
2023-01-13 02:56:29 -08:00
|
|
|
.actionsContainer {
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
|
2022-10-18 06:28:21 -07:00
|
|
|
.emptyStateCard {
|
|
|
|
width: 192px;
|
|
|
|
text-align: center;
|
|
|
|
display: inline-flex;
|
|
|
|
height: 230px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
svg {
|
|
|
|
color: var(--color-primary);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.emptyStateCardIcon {
|
|
|
|
font-size: 48px;
|
|
|
|
|
|
|
|
svg {
|
2022-12-14 01:04:10 -08:00
|
|
|
width: 48px !important;
|
2022-10-18 06:28:21 -07:00
|
|
|
color: var(--color-foreground-dark);
|
2022-12-14 01:04:10 -08:00
|
|
|
transition: color 0.3s ease;
|
|
|
|
}
|
2022-10-18 06:28:21 -07:00
|
|
|
}
|
|
|
|
</style>
|