fix(editor): Fix workflows filter resetting (#8411)

This commit is contained in:
Csaba Tuncsik
2024-01-26 06:55:08 +01:00
committed by GitHub
parent caab97e667
commit ad4b298be3
15 changed files with 251 additions and 0 deletions

View File

@@ -6,6 +6,8 @@ import { routesForVariables } from './variable';
import { routesForSettings } from './settings';
import { routesForSSO } from './sso';
import { routesForSourceControl } from './sourceControl';
import { routesForWorkflows } from './workflow';
import { routesForTags } from './tag';
const endpoints: Array<(server: Server) => void> = [
routesForCredentials,
@@ -15,6 +17,8 @@ const endpoints: Array<(server: Server) => void> = [
routesForSettings,
routesForSSO,
routesForSourceControl,
routesForWorkflows,
routesForTags,
];
export { endpoints };

View File

@@ -0,0 +1,11 @@
import type { Server } from 'miragejs';
import { Response } from 'miragejs';
import type { AppSchema } from '../types';
export function routesForTags(server: Server) {
server.get('/rest/tags', (schema: AppSchema) => {
const { models: data } = schema.all('tag');
return new Response(200, {}, { data });
});
}

View File

@@ -0,0 +1,16 @@
import type { Server } from 'miragejs';
import { Response } from 'miragejs';
import type { AppSchema } from '../types';
export function routesForWorkflows(server: Server) {
server.get('/rest/workflows', (schema: AppSchema) => {
const { models: data } = schema.all('workflow');
return new Response(200, {}, { data });
});
server.get('/rest/active-workflows', (schema: AppSchema) => {
const { models: data } = schema.all('workflow');
return new Response(200, {}, { data });
});
}

View File

@@ -2,6 +2,8 @@ import { userFactory } from './user';
import { credentialFactory } from './credential';
import { credentialTypeFactory } from './credentialType';
import { variableFactory } from './variable';
import { workflowFactory } from './workflow';
import { tagFactory } from './tag';
export * from './user';
export * from './credential';
@@ -13,4 +15,6 @@ export const factories = {
credentialType: credentialTypeFactory,
user: userFactory,
variable: variableFactory,
workflow: workflowFactory,
tag: tagFactory,
};

View File

@@ -0,0 +1,12 @@
import { Factory } from 'miragejs';
import type { ITag } from '@/Interface';
import { faker } from '@faker-js/faker';
export const tagFactory = Factory.extend<ITag>({
id(i: string) {
return i;
},
name() {
return faker.lorem.word();
},
});

View File

@@ -0,0 +1,18 @@
import { Factory } from 'miragejs';
import type { IWorkflowDb } from '@/Interface';
import { faker } from '@faker-js/faker';
export const workflowFactory = Factory.extend<IWorkflowDb>({
id(i: string) {
return i;
},
name() {
return faker.lorem.word();
},
createdAt() {
return faker.date.recent().toISOString();
},
tags() {
return faker.lorem.words(2.5).split(' ');
},
});

View File

@@ -0,0 +1,7 @@
import { tags } from './tags';
import { workflows } from './workflows';
export const fixtures = {
tags,
workflows,
};

View File

@@ -0,0 +1,15 @@
import type { ITag } from '@/Interface';
export const tags: ITag[] = [
{
id: '1',
name: 'tag1',
},
{
id: '2',
name: 'tag2',
},
{
id: '3',
name: 'tag3',
},
];

View File

@@ -0,0 +1,47 @@
import type { IWorkflowDb } from '@/Interface';
import { faker } from '@faker-js/faker';
export const workflows = [
{
id: '1',
name: 'workflow1',
tags: [],
},
{
id: '2',
name: 'workflow2',
tags: [
{ id: '1', name: 'tag1' },
{ id: '2', name: 'tag2' },
],
},
{
id: '3',
name: 'workflow3',
tags: [
{ id: '1', name: 'tag1' },
{ id: '3', name: 'tag3' },
],
},
{
id: '4',
name: 'workflow4',
tags: [
{ id: '2', name: 'tag2' },
{ id: '3', name: 'tag3' },
],
},
{
id: '5',
name: 'workflow5',
tags: [
{ id: '1', name: 'tag1' },
{ id: '2', name: 'tag2' },
{ id: '3', name: 'tag3' },
],
},
].map((wf, idx) => ({
...wf,
createdAt: faker.date.recent().toISOString(),
updatedAt: new Date(`2024-1-${idx + 1}`).toISOString(),
})) as IWorkflowDb[];

View File

@@ -2,12 +2,15 @@ import { createServer } from 'miragejs';
import { endpoints } from './endpoints';
import { models } from './models';
import { factories } from './factories';
import { fixtures } from './fixtures';
export function setupServer() {
const server = createServer({
models,
factories,
fixtures,
seeds(server) {
server.loadFixtures('tags', 'workflows');
server.createList('credentialType', 8);
server.create('user', {
firstName: 'Nathan',

View File

@@ -2,10 +2,14 @@ import { UserModel } from './user';
import { CredentialModel } from './credential';
import { CredentialTypeModel } from './credentialType';
import { VariableModel } from './variable';
import { WorkflowModel } from './workflow';
import { TagModel } from './tag';
export const models = {
credential: CredentialModel,
credentialType: CredentialTypeModel,
user: UserModel,
variable: VariableModel,
workflow: WorkflowModel,
tag: TagModel,
};

View File

@@ -0,0 +1,5 @@
import type { ITag } from '@/Interface';
import { Model } from 'miragejs';
import type { ModelDefinition } from 'miragejs/-types';
export const TagModel: ModelDefinition<ITag> = Model.extend({});

View File

@@ -0,0 +1,5 @@
import type { IWorkflowDb } from '@/Interface';
import { Model } from 'miragejs';
import type { ModelDefinition } from 'miragejs/-types';
export const WorkflowModel: ModelDefinition<IWorkflowDb> = Model.extend({});