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 1 commit
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.5.0-alpha.11",
"@circleci/circleci-config-sdk": "0.5.0-alpha.14",
"@craco/craco": "^6.3.0",
"@monaco-editor/react": "^4.3.1",
"@testing-library/jest-dom": "^5.11.4",
Expand Down
2 changes: 1 addition & 1 deletion src/components/atoms/summaries/ExecutorSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReusableExecutor } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Executor';
import { ReusableExecutor } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Reusable';
import ExecutorIcon from '../../../icons/components/ExecutorIcon';

const ExecutorSummary: React.FunctionComponent<{ data: ReusableExecutor }> = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { executor } from '@circleci/circleci-config-sdk';
import { DockerExecutor, MachineExecutor, MacOSExecutor, WindowsExecutor } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Executor';
import { executors } from '@circleci/circleci-config-sdk';
import { SubTypeMapping } from '../../../../mappings/ComponentMapping';
import InspectorProperty from '../../../atoms/form/InspectorProperty';

export interface ExecutorSubTypes {
[type: string]: SubTypeMapping & {
resourceClasses: string[];
};
};
}

const executorSubtypes: ExecutorSubTypes = {
docker: {
text: 'Docker',
component: executor.DockerExecutor,
component: executors.DockerExecutor,
resourceClasses: [
'small',
'medium',
Expand All @@ -30,15 +29,15 @@ const executorSubtypes: ExecutorSubTypes = {
},
machine: {
text: 'Machine',
component: executor.MachineExecutor,
component: executors.MachineExecutor,
resourceClasses: ['medium', 'large', 'xlarge', '2xlarge'],
fields: <InspectorProperty label="Image" name="executor.image" required />,
docsLink: 'https://circleci.com/docs/2.0/executor-types/#using-machine',
description: 'Steps run on Linux Virtual Machine',
},
macos: {
text: 'MacOS',
component: executor.MacOSExecutor,
component: executors.MacOSExecutor,
resourceClasses: ['medium', 'large'],
fields: <InspectorProperty label="Xcode" name="executor.xcode" required />,
docsLink: 'https://circleci.com/docs/2.0/executor-types/#using-macos',
Expand All @@ -47,10 +46,11 @@ const executorSubtypes: ExecutorSubTypes = {
},
windows: {
text: 'Windows',
component: executor.WindowsExecutor,
component: executors.WindowsExecutor,
resourceClasses: ['medium', 'large', 'xlarge', '2xlarge'],
fields: <InspectorProperty label="Image" name="executor.image" required />,
docsLink: 'https://circleci.com/docs/2.0/executor-types/#using-the-windows-executor',
docsLink:
'https://circleci.com/docs/2.0/executor-types/#using-the-windows-executor',
description: 'Steps run on Windows Virtual Machine',
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReusableExecutor } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Executor';
import { ReusableExecutor } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Reusable';
import { SubTypeMapping } from '../../../../mappings/ComponentMapping';
import InspectorProperty from '../../../atoms/form/InspectorProperty';

Expand Down
19 changes: 9 additions & 10 deletions src/components/menus/definitions/StepDefinitionMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import { commands } from '@circleci/circleci-config-sdk';
import { CustomCommand } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Commands/exports/Reusable';
import { reusable } from '@circleci/circleci-config-sdk';
import { Form, Formik } from 'formik';
import { useStoreActions } from '../../../state/Hooks';
import BreadCrumbs from '../../containers/BreadCrumbs';
import { commandSubtypes } from '../../containers/inspector/subtypes/CommandSubtypes';
import TabbedMenu from '../TabbedMenu';
import { SubTypeMenuPageProps } from '../SubTypeMenu';
import TabbedMenu from '../TabbedMenu';

const StepPropertiesMenu = (
props: SubTypeMenuPageProps<string | CustomCommand>,
props: SubTypeMenuPageProps<string | reusable.CustomCommand>,
) => {
const navigateBack = useStoreActions((actions) => actions.navigateBack);
const builtIn = typeof props.subtype === 'string';
const builtInSubtype = builtIn
? commandSubtypes[props.subtype as string]
: undefined;
const customCommand = !builtIn ? (props.subtype as CustomCommand) : undefined;
const customCommand = !builtIn
? (props.subtype as reusable.CustomCommand)
: undefined;

return (
<div className="h-full flex flex-col">
Expand All @@ -34,8 +35,8 @@ const StepPropertiesMenu = (
...values.steps,
builtInSubtype
? builtInSubtype.generate(parameters)
: new commands.reusable.ReusableCommand(
props.subtype as CustomCommand,
: new reusable.ReusableCommand(
props.subtype as reusable.CustomCommand,
values.parameters,
),
];
Expand Down Expand Up @@ -67,9 +68,7 @@ const StepPropertiesMenu = (
: customCommand?.description}
</p>
</button>
{builtInSubtype
? builtInSubtype?.fields
: 'custom fields'}
{builtInSubtype ? builtInSubtype?.fields : 'custom fields'}
</div>
</TabbedMenu>

Expand Down
8 changes: 2 additions & 6 deletions src/mappings/CommandMapping.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { commands } from '@circleci/circleci-config-sdk';
import { reusable } from '@circleci/circleci-config-sdk';
import { CustomCommand } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Commands/exports/Reusable';
import CommandSummary from '../components/atoms/summaries/CommandSummary';
import CommandInspector from '../components/containers/inspector/CommandInspector';
Expand All @@ -18,11 +18,7 @@ const CommandMapping: ComponentMapping<CustomCommand> = {
},
parameters: componentParametersSubtypes.command,
transform: (values: any) =>
new commands.reusable.CustomCommand(
values.name,
values.steps,
values.parameters,
),
new reusable.CustomCommand(values.name, values.steps, values.parameters),
store: {
get: (state) => state.definitions.commands,
add: (actions) => actions.defineCommand,
Expand Down
14 changes: 7 additions & 7 deletions src/mappings/ComponentMapping.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
commands,
executor,
executors,
Job,
parameters,
reusable,
} from '@circleci/circleci-config-sdk';
import { ActionCreator, Actions, State } from 'easy-peasy';
import { FormikValues } from 'formik';
Expand Down Expand Up @@ -36,10 +36,10 @@ const dataMappings: DataMapping[] = [
{
type: 'executors',
component: [
executor.DockerExecutor,
executor.MacOSExecutor,
executor.MachineExecutor,
executor.WindowsExecutor,
executors.DockerExecutor,
executors.MacOSExecutor,
executors.MachineExecutor,
executors.WindowsExecutor,
],
mapping: ExecutorMapping,
},
Expand All @@ -50,7 +50,7 @@ const dataMappings: DataMapping[] = [
},
{
type: 'commands',
component: [commands.reusable.CustomCommand],
component: [reusable.CustomCommand],
mapping: CommandMapping,
},
{
Expand Down
30 changes: 13 additions & 17 deletions src/mappings/ExecutorMapping.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { executor, Job, WorkflowJob } from '@circleci/circleci-config-sdk';
import {
ReusableExecutor
} from '@circleci/circleci-config-sdk/dist/src/lib/Components/Executor';
import { Executor } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Executor/exports/Executor';
import { executors, Job, reusable, WorkflowJob } from '@circleci/circleci-config-sdk';
import ExecutorSummary from '../components/atoms/summaries/ExecutorSummary';
import ExecutorInspector from '../components/containers/inspector/ExecutorInspector';
import { executorSubtypes } from '../components/containers/inspector/subtypes/ExecutorSubtypes';
Expand All @@ -13,44 +9,44 @@ import ComponentMapping from './ComponentMapping';
import JobMapping from './JobMapping';

export type AnyExecutor =
| executor.DockerExecutor
| executor.MacOSExecutor
| executor.MachineExecutor
| executor.WindowsExecutor
| Executor;
| executors.DockerExecutor
| executors.MacOSExecutor
| executors.MachineExecutor
| executors.WindowsExecutor
| executors.Executor;

const transform = (values: any) => {
const subtypes: { [type: string]: () => AnyExecutor } = {
docker: () =>
new executor.DockerExecutor(
new executors.DockerExecutor(
values.executor.image.image || 'cimg/base:stable',
values.executor.resource_class,
values.executor.parameters,
),
machine: () =>
new executor.MachineExecutor(
new executors.MachineExecutor(
values.executor.resource_class,
values.executor.image || 'cimg/base:latest',
values.executor.parameters,
),
macos: () =>
new executor.MacOSExecutor(
new executors.MacOSExecutor(
values.executor.xcode,
values.executor.resource_class,
values.executor.parameters,
),
windows: () =>
new executor.WindowsExecutor(
new executors.WindowsExecutor(
values.executor.image,
values.executor.resource_class,
values.executor.parameters,
),
};

return new executor.ReusableExecutor(values.name, subtypes[values.type]());
return new reusable.ReusableExecutor(values.name, subtypes[values.type]());
};

const ExecutorMapping: ComponentMapping<ReusableExecutor, WorkflowJob> = {
const ExecutorMapping: ComponentMapping<reusable.ReusableExecutor, WorkflowJob> = {
type: 'executors',
name: {
singular: 'Executor',
Expand Down Expand Up @@ -111,7 +107,7 @@ const ExecutorMapping: ComponentMapping<ReusableExecutor, WorkflowJob> = {
},
subtypes: {
component: ExecutorTypePageNav,
getSubtype: (reusableExec: ReusableExecutor) => {
getSubtype: (reusableExec: reusable.ReusableExecutor) => {
return Object.keys(executorSubtypes).find(
(subtype) =>
reusableExec.executor instanceof executorSubtypes[subtype].component,
Expand Down
17 changes: 9 additions & 8 deletions src/state/Store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {
Config,
Job,
parameters,
reusable,
Workflow,
} from '@circleci/circleci-config-sdk';
import { CustomCommand } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Commands/exports/Reusable';
import { ReusableExecutor } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Executor';
import { CustomParameter } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Parameters';
import { PipelineParameterLiteral } from '@circleci/circleci-config-sdk/dist/src/lib/Components/Parameters/types/CustomParameterLiterals.types';
import { Action, action } from 'easy-peasy';
Expand All @@ -32,7 +32,7 @@ export interface WorkflowModel {
/** Reusable definitions of CircleCIConfigObject */
export interface DefinitionModel /*extends CircleCIConfigObject*/ {
parameters: CustomParameter<PipelineParameterLiteral>[];
executors: ReusableExecutor[];
executors: reusable.ReusableExecutor[];
jobs: Job[];
commands: CustomCommand[];
workflows: Workflow[];
Expand Down Expand Up @@ -149,9 +149,9 @@ export interface StoreActions {
updateCommand: Action<StoreModel, UpdateType<CustomCommand>>;
undefineCommand: Action<StoreModel, CustomCommand>;

defineExecutor: Action<StoreModel, ReusableExecutor>;
updateExecutor: Action<StoreModel, UpdateType<ReusableExecutor>>;
undefineExecutor: Action<StoreModel, ReusableExecutor>;
defineExecutor: Action<StoreModel, reusable.ReusableExecutor>;
updateExecutor: Action<StoreModel, UpdateType<reusable.ReusableExecutor>>;
undefineExecutor: Action<StoreModel, reusable.ReusableExecutor>;

/** @todo implement parameters */
defineParameter: Action<
Expand Down Expand Up @@ -286,9 +286,10 @@ const Actions: StoreActions = {
removeWorkflowElement: action((state, payload) => {
const workflow = state.workflows[state.selectedWorkflow];

state.workflows[state.selectedWorkflow] = {...workflow, elements: workflow.elements.filter(
(element) => element.id !== payload,
)}
state.workflows[state.selectedWorkflow] = {
...workflow,
elements: workflow.elements.filter((element) => element.id !== payload),
};
}),
setWorkflowElements: action((state, payload) => {
state.workflows[state.selectedWorkflow].elements = payload;
Expand Down
16 changes: 8 additions & 8 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.5.0-alpha.11":
version "0.5.0-alpha.11"
resolved "https://registry.yarnpkg.com/@circleci/circleci-config-sdk/-/circleci-config-sdk-0.5.0-alpha.11.tgz#9fdc9fa7311311b8cf6225180b303d3edd1f7dab"
integrity sha512-YlRmF7uqWpzd9Ar0Hx/nbvQ+3LnQMg4ON+YRoau8IvHz/T1f/KbVZB7wO/+PQKrAMXp3+Mut36maYqvwJ7dIYQ==
"@circleci/circleci-config-sdk@0.5.0-alpha.14":
version "0.5.0-alpha.14"
resolved "https://registry.yarnpkg.com/@circleci/circleci-config-sdk/-/circleci-config-sdk-0.5.0-alpha.14.tgz#fa91961fd804b65e97c0928ca781b05b57ecc17a"
integrity sha512-N88pfNylhrcxtytihrx+N67Jq2R3lRqN2Dza8zRkvaTvswPBHWENr4gqhbcyGsYUBOhHY4uPOUj8gAVl55cclQ==
dependencies:
ajv "^8.8.2"
ajv-merge-patch "^5.0.1"
Expand Down Expand Up @@ -12149,10 +12149,10 @@ yallist@^4.0.0:
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==

yaml@2.0.0-9:
version "2.0.0-9"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.0.0-9.tgz#0099f0645d1ffa686a2c5141b6da340f545d3634"
integrity sha512-Bf2KowHjyVkIIiGMt7+fbhmlvKOaE8DWuD07bnL4+FQ9sPmEl/5IzGpBpoxPqOaHuyasBjJhyXDcISpJWfhCGw==
yaml@*:
version "2.1.0"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.1.0.tgz#96ba62ff4dd990c0eb16bd96c6254a085d288b80"
integrity sha512-OuAINfTsoJrY5H7CBWnKZhX6nZciXBydrMtTHr1dC4nP40X5jyTIVlogZHxSlVZM8zSgXRfgZGsaHF4+pV+JRw==

yaml@^1.10.0, yaml@^1.10.2:
version "1.10.2"
Expand Down