Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"homepage": "https://circleci-public.github.io/visual-config-editor/",
"dependencies": {
"@circleci/circleci-config-sdk": "0.7.0",
"@circleci/circleci-config-sdk": "0.8.0",
"@craco/craco": "^6.3.0",
"@monaco-editor/react": "^4.3.1",
"@testing-library/jest-dom": "^5.11.4",
Expand Down
9 changes: 6 additions & 3 deletions src/components/atoms/nodes/JobNode.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Job, WorkflowJob } from '@circleci/circleci-config-sdk';
import { Job } from '@circleci/circleci-config-sdk';
import { WorkflowJob } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Workflow';
import { WorkflowJobParameters } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Workflow/types/WorkflowJob.types';
import React, { useRef } from 'react';
import { Handle, isNode, NodeProps, Position } from 'react-flow-renderer';
Expand All @@ -20,8 +21,10 @@ const JobNode: React.FunctionComponent<NodeProps & { data: WorkflowJob }> = (
// );
const updateJob = useStoreActions((actions) => actions.updateJob);
const setConnecting = useStoreActions((actions) => actions.setConnecting);
const removeWorkflowElement = useStoreActions((actions) => actions.removeWorkflowElement);

const removeWorkflowElement = useStoreActions(
(actions) => actions.removeWorkflowElement,
);

const connecting = useStoreState((state) => state.connecting);
const updateConnecting = useStoreActions(
(actions) => actions.updateConnecting,
Expand Down
6 changes: 3 additions & 3 deletions src/mappings/ExecutorMapping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
Job,
parsers,
reusable,
WorkflowJob,
workflow,
} from '@circleci/circleci-config-sdk';
import ExecutorSummary from '../components/atoms/summaries/ExecutorSummary';
import ExecutorInspector from '../components/containers/inspector/ExecutorInspector';
Expand All @@ -23,7 +23,7 @@ export type AnyExecutor =

const ExecutorMapping: ComponentMapping<
reusable.ReusableExecutor,
WorkflowJob
workflow.WorkflowJob
> = {
type: 'executors',
name: {
Expand Down Expand Up @@ -79,7 +79,7 @@ const ExecutorMapping: ComponentMapping<
applyToNode: (data, nodeData) => {
const oldJob = nodeData.job;

return new WorkflowJob(
return new workflow.WorkflowJob(
new Job(oldJob.name, data.reuse(), oldJob.steps),
nodeData.parameters,
);
Expand Down
8 changes: 4 additions & 4 deletions src/mappings/JobMapping.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Job, parsers, WorkflowJob } from '@circleci/circleci-config-sdk';
import { Job, parsers, workflow } from '@circleci/circleci-config-sdk';
import JobNode from '../components/atoms/nodes/JobNode';
import JobSummary from '../components/atoms/summaries/JobSummary';
import JobInspector from '../components/containers/inspector/JobInspector';
import { componentParametersSubtypes } from '../components/containers/inspector/subtypes/ParameterSubtypes';
import JobIcon from '../icons/components/JobIcon';
import ComponentMapping from './ComponentMapping';

const JobMapping: ComponentMapping<Job, WorkflowJob> = {
const JobMapping: ComponentMapping<Job, workflow.WorkflowJob> = {
type: 'jobs',
name: {
singular: 'Job',
Expand All @@ -22,7 +22,7 @@ const JobMapping: ComponentMapping<Job, WorkflowJob> = {
dependsOn: (definitions) => [definitions.commands, definitions.executors],
*/
transform: ({ name, ...values }, definitions) => {
console.log(values)
console.log(values);

return parsers.parseJob(
name,
Expand All @@ -42,7 +42,7 @@ const JobMapping: ComponentMapping<Job, WorkflowJob> = {
dragTarget: 'workflow',
node: {
transform: (data, params) => {
return new WorkflowJob(data, params);
return new workflow.WorkflowJob(data, params);
},
component: JobNode,
},
Expand Down
21 changes: 15 additions & 6 deletions src/state/Store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
parsers,
reusable,
Workflow,
WorkflowJob,
workflow,
} from '@circleci/circleci-config-sdk';
import { CustomCommand } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Commands/exports/Reusable';
import { CustomParameter } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Parameters';
Expand Down Expand Up @@ -379,28 +379,37 @@ const Actions: StoreActions = {
const nodeWidth = 250; // Make this dynamic
const nodeHeight = 60; // Make this dynamic

const getJobName = (workflowJob: workflow.WorkflowJobAbstract) => {
const baseName =
workflowJob instanceof workflow.WorkflowJob
? workflowJob.job.name
: (workflowJob as workflow.WorkflowJobApproval).name;

return workflowJob.parameters?.name || baseName;
};

state.workflows = config.workflows.map(({ name, jobs }) => {
const jobTable: Record<string, WorkflowJob> = {};
const jobTable: Record<string, workflow.WorkflowJobAbstract> = {};

jobs.forEach((workflowJob) => {
const jobName = workflowJob.parameters.name || workflowJob.job.name;
const jobName = getJobName(workflowJob);
jobTable[jobName] = workflowJob;
});

const elements: Elements = [];
const columns: Array<number> = [];
const solved: Record<ElementId, number> = {};

const solve = (workflowJob: WorkflowJob) => {
const jobName = workflowJob.parameters.name || workflowJob.job.name;
const solve = (workflowJob: workflow.WorkflowJobAbstract) => {
const jobName = getJobName(workflowJob);

if (solved[jobName] !== undefined) {
return solved[jobName];
}

let column = 0;

if (workflowJob.parameters.requires) {
if (workflowJob.parameters?.requires) {
let greatestColumn = 0;

workflowJob.parameters.requires.forEach((requiredJob) => {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1081,10 +1081,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@circleci/circleci-config-sdk@0.7.0":
version "0.7.0"
resolved "https://registry.yarnpkg.com/@circleci/circleci-config-sdk/-/circleci-config-sdk-0.7.0.tgz#561584b8ab18fd9e92d40f357e5d3086d976fe9a"
integrity sha512-43+WMaMlmmwOJdhSCi7OELukCwkedskw8XLGFNHKR2kmH/ADEbeOurkB0wefZq9mOe9h2zpmnYRi1lYnIndpMQ==
"@circleci/circleci-config-sdk@0.8.0":
version "0.8.0"
resolved "https://registry.yarnpkg.com/@circleci/circleci-config-sdk/-/circleci-config-sdk-0.8.0.tgz#85fe0c1accdcc189a2b24cf02fcab772ee166ba5"
integrity sha512-euVMPlejGzREZvsHdmPMidgcabAAlu+bQhUsxFfRjPjo55nAUWMe4Sxwb3gKeSKe8R3sJFvKsFfKprDW1fIDVQ==
dependencies:
ajv "^8.8.2"
ajv-merge-patch "^5.0.1"
Expand Down