mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-12 15:44:06 -08:00
feat(editor): Add workflows list status filter (#4690)
This commit is contained in:
parent
eafef019d7
commit
5364e7fc92
|
@ -1351,6 +1351,10 @@
|
||||||
"workflows.search.placeholder": "Search workflows...",
|
"workflows.search.placeholder": "Search workflows...",
|
||||||
"workflows.filters": "Filters",
|
"workflows.filters": "Filters",
|
||||||
"workflows.filters.tags": "Tags",
|
"workflows.filters.tags": "Tags",
|
||||||
|
"workflows.filters.status": "Status",
|
||||||
|
"workflows.filters.status.all": "All",
|
||||||
|
"workflows.filters.status.active": "Active",
|
||||||
|
"workflows.filters.status.deactivated": "Deactivated",
|
||||||
"workflows.filters.ownedBy": "Owned by",
|
"workflows.filters.ownedBy": "Owned by",
|
||||||
"workflows.filters.sharedWith": "Shared with",
|
"workflows.filters.sharedWith": "Shared with",
|
||||||
"workflows.filters.apply": "Apply filters",
|
"workflows.filters.apply": "Apply filters",
|
||||||
|
|
|
@ -54,6 +54,23 @@
|
||||||
@update="setKeyValue('tags', $event)"
|
@update="setKeyValue('tags', $event)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mb-s">
|
||||||
|
<n8n-input-label
|
||||||
|
:label="$locale.baseText('workflows.filters.status')"
|
||||||
|
:bold="false"
|
||||||
|
size="small"
|
||||||
|
color="text-base"
|
||||||
|
class="mb-3xs"
|
||||||
|
/>
|
||||||
|
<n8n-select :value="filters.status" @input="setKeyValue('status', $event)" size="small">
|
||||||
|
<n8n-option
|
||||||
|
v-for="option in statusFilterOptions"
|
||||||
|
:key="option.label"
|
||||||
|
:label="option.label"
|
||||||
|
:value="option.value">
|
||||||
|
</n8n-option>
|
||||||
|
</n8n-select>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</resources-list-layout>
|
</resources-list-layout>
|
||||||
</template>
|
</template>
|
||||||
|
@ -69,7 +86,7 @@ import PageViewLayoutList from "@/components/layouts/PageViewLayoutList.vue";
|
||||||
import WorkflowCard from "@/components/WorkflowCard.vue";
|
import WorkflowCard from "@/components/WorkflowCard.vue";
|
||||||
import TemplateCard from "@/components/TemplateCard.vue";
|
import TemplateCard from "@/components/TemplateCard.vue";
|
||||||
import { debounceHelper } from '@/components/mixins/debounce';
|
import { debounceHelper } from '@/components/mixins/debounce';
|
||||||
import {EnterpriseEditionFeature, VIEWS} from '@/constants';
|
import {EnterpriseEditionFeature, SAAS_COMPANY_TYPE, VIEWS} from '@/constants';
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
import {ITag, IUser, IWorkflowDb} from "@/Interface";
|
import {ITag, IUser, IWorkflowDb} from "@/Interface";
|
||||||
import TagsDropdown from "@/components/TagsDropdown.vue";
|
import TagsDropdown from "@/components/TagsDropdown.vue";
|
||||||
|
@ -81,6 +98,12 @@ import { useWorkflowsStore } from '@/stores/workflows';
|
||||||
|
|
||||||
type IResourcesListLayoutInstance = Vue & { sendFiltersTelemetry: (source: string) => void };
|
type IResourcesListLayoutInstance = Vue & { sendFiltersTelemetry: (source: string) => void };
|
||||||
|
|
||||||
|
const StatusFilter = {
|
||||||
|
ACTIVE: true,
|
||||||
|
DEACTIVATED: false,
|
||||||
|
ALL: '',
|
||||||
|
};
|
||||||
|
|
||||||
export default mixins(
|
export default mixins(
|
||||||
showMessage,
|
showMessage,
|
||||||
debounceHelper,
|
debounceHelper,
|
||||||
|
@ -101,6 +124,7 @@ export default mixins(
|
||||||
search: '',
|
search: '',
|
||||||
ownedBy: '',
|
ownedBy: '',
|
||||||
sharedWith: '',
|
sharedWith: '',
|
||||||
|
status: StatusFilter.ALL,
|
||||||
tags: [] as string[],
|
tags: [] as string[],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -121,6 +145,22 @@ export default mixins(
|
||||||
isShareable(): boolean {
|
isShareable(): boolean {
|
||||||
return this.settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.WorkflowSharing);
|
return this.settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.WorkflowSharing);
|
||||||
},
|
},
|
||||||
|
statusFilterOptions(): Array<{ label: string, value: string | boolean }> {
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addWorkflow() {
|
addWorkflow() {
|
||||||
|
@ -147,13 +187,17 @@ export default mixins(
|
||||||
this.filters.tags.push(tagId);
|
this.filters.tags.push(tagId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onFilter(resource: IWorkflowDb, filters: { tags: string[]; search: string; }, matches: boolean): boolean {
|
onFilter(resource: IWorkflowDb, filters: { tags: string[]; search: string; status: string | boolean }, matches: boolean): boolean {
|
||||||
if (this.settingsStore.areTagsEnabled && filters.tags.length > 0) {
|
if (this.settingsStore.areTagsEnabled && filters.tags.length > 0) {
|
||||||
matches = matches && filters.tags.every(
|
matches = matches && filters.tags.every(
|
||||||
(tag) => (resource.tags as ITag[])?.find((resourceTag) => typeof resourceTag === 'object' ? `${resourceTag.id}` === `${tag}` : `${resourceTag}` === `${tag}`),
|
(tag) => (resource.tags as ITag[])?.find((resourceTag) => typeof resourceTag === 'object' ? `${resourceTag.id}` === `${tag}` : `${resourceTag}` === `${tag}`),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filters.status !== '') {
|
||||||
|
matches = matches && resource.active === filters.status;
|
||||||
|
}
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
},
|
},
|
||||||
sendFiltersTelemetry(source: string) {
|
sendFiltersTelemetry(source: string) {
|
||||||
|
|
Loading…
Reference in a new issue