Skip to content

Commit

Permalink
Merge branch 'n8n-update-editor' of https://github.com/Deep-Consultin…
Browse files Browse the repository at this point in the history
…g-Solutions/n8n-fork into n8n-update-editor
  • Loading branch information
horpeazy committed May 14, 2024
2 parents 47d4aa4 + 2283bb9 commit 9d62431
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 76 deletions.
18 changes: 14 additions & 4 deletions packages/editor-ui/src/api/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
IWorkflowDb,
NewWorkflowResponse,
NodeOutputDb,
TestSuiteDb,
} from '@/Interface';
import type { ExecutionFilters, ExecutionOptions, IDataObject } from 'n8n-workflow';
import { makeRestApiRequest } from '@/utils/apiUtils';
Expand Down Expand Up @@ -61,7 +62,10 @@ export async function getExecutionData(context: IRestApiContext, executionId: st
);
}

export async function getTestSuite(context: IRestApiContext, workFlowId: string) {
export async function getTestSuite(
context: IRestApiContext,
workFlowId: string,
): Promise<TestSuiteDb[]> {
return await makeRestApiRequest(context, 'GET', `/workflow-tests/${workFlowId}`);
}

Expand All @@ -71,11 +75,14 @@ export async function postTestSuite(
workflowId: string;
description: string;
},
) {
): Promise<TestSuiteDb[]> {
return await makeRestApiRequest(context, 'POST', '/workflow-tests', payload);
}

export async function patchTestSuite(context: IRestApiContext, payload: NodeOutputDb) {
export async function patchTestSuite(
context: IRestApiContext,
payload: NodeOutputDb,
): Promise<NodeOutputDb[]> {
return await makeRestApiRequest(
context,
'PUT',
Expand All @@ -84,7 +91,10 @@ export async function patchTestSuite(context: IRestApiContext, payload: NodeOutp
);
}

export async function createTestSuite(context: IRestApiContext, payload: Omit<NodeOutputDb, 'id'>) {
export async function createTestSuite(
context: IRestApiContext,
payload: Omit<NodeOutputDb, 'id'>,
): Promise<NodeOutputDb[]> {
return await makeRestApiRequest(
context,
'POST',
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/SettingsSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default defineComponent({
});
menuItems.push({
id: 'test-suites',
id: 'settings-test-suites',
icon: 'chart-bar',
label: this.$locale.baseText('settings.testSuites'),
position: 'top',
Expand Down
25 changes: 25 additions & 0 deletions packages/editor-ui/src/components/TestSuiteCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,28 @@ export default {
},
};
</script>

<style lang="scss" module>
.cardLink {
transition: box-shadow 0.3s ease;
cursor: pointer;
&:hover {
box-shadow: 0 2px 8px rgba(#441c17, 0.1);
}
}
.cardHeading {
font-size: var(--font-size-s);
word-break: break-word;
}
.cardDescription {
display: flex;
justify-content: flex-end;
}
.flex1 {
flex: 1;
}
</style>
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/WorkflowsListLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export default {
currentPage: 1,
rowsPerPage: 10 as number | '*',
resettingFilters: false,
EnterpriseEditionFeature,
// EnterpriseEditionFeature,
};
},
computed: {
Expand Down
104 changes: 52 additions & 52 deletions packages/editor-ui/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,63 +708,63 @@ export const routes = [
},
},
},
],
},
{
path: 'test-suites',
name: VIEWS.TEST_SUITES,
components: {
settingsView: TestSuitesView,
},
meta: {
telemetry: {
pageCategory: 'settings',
},
meta: {
middleware: ['authenticated'],
},
},
},
{
path: 'test-suites/:workflow',
name: VIEWS.TEST_SUITE,
components: {
settingsView: TestSuiteView,
},
meta: {
telemetry: {
pageCategory: 'settings',
getProperties(route: RouteLocation) {
return {
workflow: route.params['workflow'],
};
{
path: 'test-suites',
name: VIEWS.TEST_SUITES,
components: {
settingsView: TestSuitesView,
},
meta: {
telemetry: {
pageCategory: 'settings',
},
meta: {
middleware: ['authenticated'],
},
},
},
meta: {
middleware: ['authenticated'],
},
},
},
{
path: 'test-suites/:workflow/:test',
name: VIEWS.TEST_SUITE_NODES,
components: {
settingsView: TestSuiteNodeView,
},
meta: {
telemetry: {
pageCategory: 'settings',
getProperties(route: RouteLocation) {
return {
workflow: route.params['workflow'],
test: route.params['test'],
};
{
path: 'test-suites/:workflow',
name: VIEWS.TEST_SUITE,
components: {
settingsView: TestSuiteView,
},
meta: {
telemetry: {
pageCategory: 'settings',
getProperties(route: RouteLocation) {
return {
workflow: route.params['workflow'],
};
},
},
meta: {
middleware: ['authenticated'],
},
},
},
meta: {
middleware: ['authenticated'],
{
path: 'test-suites/:workflow/:test',
name: VIEWS.TEST_SUITE_NODES,
components: {
settingsView: TestSuiteNodeView,
},
meta: {
telemetry: {
pageCategory: 'settings',
getProperties(route: RouteLocation) {
return {
workflow: route.params['workflow'],
test: route.params['test'],
};
},
},
meta: {
middleware: ['authenticated'],
},
},
},
},
],
},
{
path: '/saml/onboarding',
Expand Down
36 changes: 21 additions & 15 deletions packages/editor-ui/src/stores/workflows.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
const workflowExecutionData = ref<IExecutionResponse | null>(null);
const workflowExecutionPairedItemMappings = ref<Record<string, Set<string>>>({});
const activeExecutionId = ref<string | null>(null);
const testSuitesById = ref<Record<string, Set<string>>>({});
const nodeOutputsById = ref<Record<string, Set<string>>>({});
const testSuitesById = ref<Record<string, TestSuiteDb>>({});
const nodeOutputsById = ref<Record<string, NodeOutputDb>>({});
const subWorkflowExecutionError = ref<Error | null>(null);
const executionWaitingForWebhook = ref(false);
const executingNode = ref<string[]>([]);
Expand All @@ -141,7 +141,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
);

const allTestSuites = computed(() =>
Object.values(testSuitesById).sort((a, b) => a.name.localeCompare(b.name)),
Object.values(testSuitesById.value).sort((a, b) => a.name.localeCompare(b.name)),
);

const isNewWorkflow = computed(() => workflow.value.id === PLACEHOLDER_EMPTY_WORKFLOW_ID);
Expand Down Expand Up @@ -282,8 +282,8 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
async function fetchWorkflowTestSuites(workflowId: string): Promise<TestSuiteDb[]> {
const rootStore = useRootStore();
const testSuites = await workflowsApi.getTestSuite(rootStore.getRestApiContext, workflowId);
this.setTestSuites(testSuites);
return testSuites as TestSuiteDb[];
setTestSuites(testSuites);
return testSuites;
}

async function addWorkflowTestSuite(
Expand All @@ -293,32 +293,32 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
const rootStore = useRootStore();
const payload = { workflowId, description };
const testSuites = await workflowsApi.postTestSuite(rootStore.getRestApiContext, payload);
this.setTestSuites(testSuites);
return testSuites as TestSuiteDb[];
setTestSuites(testSuites);
return testSuites;
}

async function fetchWorkflowNodeOutput(id: string): Promise<any> {
async function fetchWorkflowNodeOutput(id: string): Promise<NodeOutputDb[]> {
const rootStore = useRootStore();
const nodeOutputs = await makeRestApiRequest(
const nodeOutputs = await makeRestApiRequest<NodeOutputDb[]>(
rootStore.getRestApiContext,
'GET',
`/workflow-tests/nodes-output/${id}`,
);
this.setNodeOutputs(nodeOutputs);
setNodeOutputs(nodeOutputs);
return nodeOutputs;
}

async function createWorkflowTestSuite(payload: Omit<NodeOutputDb, 'id'>) {
const rootStore = useRootStore();
const nodeOutputs = await workflowsApi.createTestSuite(rootStore.getRestApiContext, payload);
this.setNodeOutputs(nodeOutputs);
setNodeOutputs(nodeOutputs);
return nodeOutputs;
}

async function updateWorkflowTestSuite(payload: NodeOutputDb) {
const rootStore = useRootStore();
const nodeOutputs = await workflowsApi.patchTestSuite(rootStore.getRestApiContext, payload);
this.setNodeOutputs(nodeOutputs);
setNodeOutputs(nodeOutputs);
return nodeOutputs;
}

Expand Down Expand Up @@ -359,7 +359,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
}

function setTestSuites(testSuites: TestSuiteDb[]): void {
this.testSuitesById = testSuites.reduce<TestSuiteDbMap>((acc, testSuite: TestSuiteDb) => {
testSuitesById.value = testSuites.reduce<TestSuiteDbMap>((acc, testSuite: TestSuiteDb) => {
if (testSuite.id) {
acc[testSuite.id] = testSuite;
}
Expand All @@ -368,7 +368,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
}

function setNodeOutputs(nodeOutputs: NodeOutputDb[]): void {
this.nodeOutputsById = nodeOutputs.reduce<NodeOutputDbMap>((acc, nodeOutput: NodeOutputDb) => {
nodeOutputsById.value = nodeOutputs.reduce<NodeOutputDbMap>((acc, nodeOutput: NodeOutputDb) => {
if (nodeOutput.nodeId) {
if (nodeOutput.errorMessage) {
nodeOutput.data = null;
Expand All @@ -380,7 +380,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
}

function resetWorkflowTestSuites(): void {
this.testSuitesById = {};
testSuitesById.value = {};
}

function getWorkflow(nodes: INodeUi[], connections: IConnections, copyData?: boolean): Workflow {
Expand Down Expand Up @@ -1645,5 +1645,11 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
resetChatMessages,
appendChatMessage,
checkIfNodeHasChatParent,
fetchWorkflowTestSuites,
addWorkflowTestSuite,
fetchWorkflowNodeOutput,
createWorkflowTestSuite,
updateWorkflowTestSuite,
resetWorkflowTestSuites,
};
});
2 changes: 1 addition & 1 deletion packages/editor-ui/src/views/SettingsUsersView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export default defineComponent({
}
.setupInfoContainer {
max-width: 728px;
max-width: 1280px;
}
.alert {
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/views/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default SettingsView;
.content {
height: 100%;
width: 100%;
max-width: 800px;
max-width: 1280px;
padding: 0 var(--spacing-2xl);
}
</style>
1 change: 0 additions & 1 deletion packages/editor-ui/src/views/TestSuiteNodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

<script lang="ts">
import { defineComponent } from 'vue';
// eslint-disable-next-line import/no-unresolved
import TestsListNodeLayout from '../components/TestsListNodeLayout.vue';
import TestSuiteNodeCard from '@/components/TestSuiteNodeCard.vue';
import type { IWorkflowDb, TestSuiteDb } from '@/Interface';
Expand Down

0 comments on commit 9d62431

Please sign in to comment.