Skip to content

Commit

Permalink
chore(ui): updates
Browse files Browse the repository at this point in the history
Signed-off-by: Mayursinh Sarvaiya <[email protected]>
  • Loading branch information
Marvin9 committed Oct 10, 2024
1 parent 2d48e9a commit 5a7f0d4
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions ui/src/features/stage/create-stage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PlainMessage } from '@bufbuild/protobuf';
import { useMutation } from '@connectrpc/connect-query';
import {
faBook,
Expand All @@ -21,7 +22,7 @@ import { YamlEditor } from '@ui/features/common/code-editor/yaml-editor';
import { FieldContainer } from '@ui/features/common/form/field-container';
import schema from '@ui/gen/schema/stages.kargo.akuity.io_v1alpha1.json';
import { createResource } from '@ui/gen/service/v1alpha1/service-KargoService_connectquery';
import { Stage } from '@ui/gen/v1alpha1/generated_pb';
import { PromotionStep, Stage } from '@ui/gen/v1alpha1/generated_pb';
import { zodValidators } from '@ui/utils/validators';

import { getStageYAMLExample } from '../project/pipelines/utils/stage-yaml-example';
Expand All @@ -48,7 +49,7 @@ const wizardSchema = z.object({
const stageFormToYAML = (
data: z.infer<typeof wizardSchema>,
namespace: string,
promotionTemplateSteps: string
promotionTemplateSteps: PlainMessage<PromotionStep>[]
) => {
return yaml.stringify({
kind: 'Stage',
Expand All @@ -65,8 +66,8 @@ const stageFormToYAML = (
},
spec: {
requestedFreight: data.requestedFreight,
...(promotionTemplateSteps && {
promotionTemplate: { spec: { steps: yaml.parse(promotionTemplateSteps) } }
...(promotionTemplateSteps?.length > 0 && {
promotionTemplate: { spec: { steps: promotionTemplateSteps } }
})
}
});
Expand Down Expand Up @@ -119,7 +120,11 @@ export const CreateStage = ({
const unmarshalled = stageFormToYAML(
getWizardValues(),
project || '',
promotionWizardStepsState.getYAML()
promotionWizardStepsState.state?.map((step) => ({
uses: step?.identifier,
as: step?.as,
config: step?.state
}))
);
setValue('value', unmarshalled);
value = unmarshalled;
Expand Down Expand Up @@ -163,7 +168,15 @@ export const CreateStage = ({
if (tab === 'wizard' && newTab === 'yaml') {
setValue(
'value',
stageFormToYAML(getWizardValues(), project || '', promotionWizardStepsState.getYAML())
stageFormToYAML(
getWizardValues(),
project || '',
promotionWizardStepsState.state?.map((step) => ({
uses: step?.identifier,
as: step?.as,
config: step?.state
}))
)
);
} else {
const yaml = getValues('value');
Expand Down

0 comments on commit 5a7f0d4

Please sign in to comment.