Skip to content

Commit ac4c58a

Browse files
authored
☘️ decouple gitops write from module values (#857)
1 parent ce72cef commit ac4c58a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

cyclops-ui/src/components/shared/CreateModule/CreateModule.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export const CreateModuleComponent = ({
130130

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

133-
const [gitopsToggle, SetGitopsToggle] = useState(false);
133+
const [gitopsToggle, setGitopsToggle] = useState(false);
134134

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

147147
const [form] = Form.useForm();
148148

149-
const resolveGitOpsWrite = (values: any) => {
149+
const resolveGitOpsWrite = (
150+
writeRepo: string,
151+
writePath: string,
152+
writeBranch: string,
153+
) => {
150154
if (template.enforceGitOpsWrite !== undefined) {
151155
return template.enforceGitOpsWrite;
152156
}
153157

154158
return gitopsToggle
155159
? {
156-
repo: values["gitops-repo"],
157-
path: values["gitops-path"],
158-
branch: values["gitops-branch"],
160+
repo: writeRepo,
161+
path: writePath,
162+
branch: writeBranch,
159163
}
160164
: null;
161165
};
@@ -189,6 +193,10 @@ export const CreateModuleComponent = ({
189193
const moduleName = values["cyclops_module_name"];
190194
const moduleNamespace = values["cyclops_module_namespace"];
191195

196+
const gitopsWriteRepo = values["gitops-repo"];
197+
const gitopsWritePath = values["gitops-path"];
198+
const gitopsWriteBranch = values["gitops-branch"];
199+
192200
values = findMaps(config.root.properties, values, initialValuesRaw);
193201

194202
submitModule(
@@ -201,7 +209,7 @@ export const CreateModuleComponent = ({
201209
sourceType: template.ref.sourceType,
202210
},
203211
values,
204-
resolveGitOpsWrite(values),
212+
resolveGitOpsWrite(gitopsWriteRepo, gitopsWritePath, gitopsWriteBranch),
205213
)
206214
.then(() => {
207215
onSubmitModuleSuccess(moduleName);
@@ -612,7 +620,7 @@ export const CreateModuleComponent = ({
612620
>
613621
<Switch
614622
onChange={(e) => {
615-
SetGitopsToggle(e);
623+
setGitopsToggle(e);
616624
}}
617625
/>
618626
</Form.Item>

0 commit comments

Comments
 (0)