Skip to content

Commit

Permalink
update codeui
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardoperra committed Oct 26, 2024
1 parent 69549f7 commit f5a30e6
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@codemirror/search": "^6.5.6",
"@codemirror/state": "^6.4.1",
"@codemirror/view": "^6.34.1",
"@codeui/kit": "link:/Users/riccardoperra/WebstormProjects/codeui/packages/kit/",
"@codeui/kit": "^0.1.4",
"@corvu/resizable": "^0.2.3",
"@kobalte/core": "^0.13.6",
"@kobalte/utils": "^0.9.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {type GenericStoreApi, makePlugin} from 'statebuilder';
import type {YAMLDocument, YamlDocumentSessionPlugin} from './yamlSession';
import YAML, {Pair, Scalar, YAMLMap, YAMLSeq} from 'yaml';
import type {
JobEnvironment,
StringExpression,
WorkflowDispatchInput,
WorkflowStructureEnvItem,
WorkflowStructureJobStep,
WorkflowTypesTriggerEvent,
} from '../editor.types';
import type {YAMLDocument, YamlDocumentSessionPlugin} from './yamlSession';

export const withGithubYamlManager = () => {
return makePlugin.typed<GenericStoreApi & YamlDocumentSessionPlugin>()(
Expand Down Expand Up @@ -81,6 +82,29 @@ export const withGithubYamlManager = () => {
});
};

const setEventTriggerTypes = (data: WorkflowTypesTriggerEvent) => {
yamlSession.updater(yaml => {
modifyOnField(yaml, true, on => {
const map = new YAML.YAMLMap();

if (data.types?.length) {
map.set(new YAML.Scalar('types'), data.types);
on.set(new YAML.Scalar(data.type as string), map);
} else {
on.set(new YAML.Scalar(data.type as string), map);
}
});
});
};

const deleteEventTriggerTypes = (data: WorkflowTypesTriggerEvent) => {
yamlSession.updater(yaml => {
modifyOnField(yaml, true, on => {
on.delete(data.type);
});
});
};

const setWorkflowDispatch = (
index: number,
data: WorkflowDispatchInput,
Expand Down Expand Up @@ -540,10 +564,12 @@ export const withGithubYamlManager = () => {

return {
yamlSession: Object.assign(_.yamlSession, {
deleteWorkflowDispatchItem,
setEnvironmentVariable,
deleteEnvironmentVariable,
setWorkflowDispatch,
deleteWorkflowDispatchItem,
setEventTriggerTypes,
deleteEventTriggerTypes,
addNewJob,
removeJob,
setJobId,
Expand Down
Loading

0 comments on commit f5a30e6

Please sign in to comment.