mirror of
https://github.com/directus/directus.git
synced 2026-02-17 13:01:21 -05:00
* Remove unused nested folders from components * Remove nested folders * Standardize composables output * Fix import inconsistencies * Same trick for directives * Same for routes * Replace reliance root grouped export in favor of explicit imports * Replace reliance on implicit imports * Remove nested folder structure * Consistent use of non-default exports in utils * Remove nested folder structure from private components * Fix test mock * Remove extraneous component registration for valuenull * Fix stores provider * Fix logo sprite
39 lines
1018 B
TypeScript
39 lines
1018 B
TypeScript
import { FlowRaw } from '@directus/shared/types';
|
|
import api from '@/api';
|
|
import { defineStore } from 'pinia';
|
|
import { useUserStore } from '@/stores/user';
|
|
import { usePermissionsStore } from '@/stores/permissions';
|
|
|
|
export const useFlowsStore = defineStore({
|
|
id: 'flowsStore',
|
|
state: () => ({
|
|
flows: [] as FlowRaw[],
|
|
}),
|
|
actions: {
|
|
async hydrate() {
|
|
const { isAdmin } = useUserStore();
|
|
const { hasPermission } = usePermissionsStore();
|
|
|
|
if (isAdmin !== true && !hasPermission('directus_flows', 'read')) {
|
|
this.flows = [];
|
|
} else {
|
|
try {
|
|
const response = await api.get<any>('/flows', {
|
|
params: { limit: -1, fields: ['*', 'operations.*'] },
|
|
});
|
|
|
|
this.flows = response.data.data;
|
|
} catch {
|
|
this.flows = [];
|
|
}
|
|
}
|
|
},
|
|
async dehydrate() {
|
|
this.$reset();
|
|
},
|
|
getManualFlowsForCollection(collection: string): FlowRaw[] {
|
|
return this.flows.filter((flow) => flow.trigger === 'manual' && flow.options?.collections?.includes(collection));
|
|
},
|
|
},
|
|
});
|