Skip to content
Merged
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
22 changes: 15 additions & 7 deletions cyclops-ui/src/components/shared/CreateModule/CreateModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const CreateModuleComponent = ({

const [namespaces, setNamespaces] = useState<string[]>([]);

const [gitopsToggle, SetGitopsToggle] = useState(false);
const [gitopsToggle, setGitopsToggle] = useState(false);

const [notificationApi, contextHolder] = notification.useNotification();
const openNotification = (errors: FeedbackError[]) => {
Expand All @@ -146,16 +146,20 @@ export const CreateModuleComponent = ({

const [form] = Form.useForm();

const resolveGitOpsWrite = (values: any) => {
const resolveGitOpsWrite = (
writeRepo: string,
writePath: string,
writeBranch: string,
) => {
if (template.enforceGitOpsWrite !== undefined) {
return template.enforceGitOpsWrite;
}

return gitopsToggle
? {
repo: values["gitops-repo"],
path: values["gitops-path"],
branch: values["gitops-branch"],
repo: writeRepo,
path: writePath,
branch: writeBranch,
}
: null;
};
Expand Down Expand Up @@ -189,6 +193,10 @@ export const CreateModuleComponent = ({
const moduleName = values["cyclops_module_name"];
const moduleNamespace = values["cyclops_module_namespace"];

const gitopsWriteRepo = values["gitops-repo"];
const gitopsWritePath = values["gitops-path"];
const gitopsWriteBranch = values["gitops-branch"];

values = findMaps(config.root.properties, values, initialValuesRaw);

submitModule(
Expand All @@ -201,7 +209,7 @@ export const CreateModuleComponent = ({
sourceType: template.ref.sourceType,
},
values,
resolveGitOpsWrite(values),
resolveGitOpsWrite(gitopsWriteRepo, gitopsWritePath, gitopsWriteBranch),
)
.then(() => {
onSubmitModuleSuccess(moduleName);
Expand Down Expand Up @@ -612,7 +620,7 @@ export const CreateModuleComponent = ({
>
<Switch
onChange={(e) => {
SetGitopsToggle(e);
setGitopsToggle(e);
}}
/>
</Form.Item>
Expand Down