Skip to content

Commit

Permalink
✨ Add mvn:// prefix to application binary value in post request (#1968)
Browse files Browse the repository at this point in the history
Resolves: #1967

Note: validation is not necessary since the ui already breaks up the
input into separate for fields and composes the binary coordinates under
the hood.

---------

Signed-off-by: Ian Bolton <[email protected]>
  • Loading branch information
ibolton336 authored Jun 20, 2024
1 parent ea2005b commit a3ef502
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ export const useApplicationFormHook = ({
application: Application | null,
fieldName: string
) => {
const fieldList = application?.binary?.split(":") || [];
const binaryString = application?.binary?.startsWith("mvn://")
? application.binary.substring(6)
: application?.binary;

const fieldList = binaryString?.split(":") || [];

switch (fieldName) {
case "group":
return fieldList[0] || "";
Expand Down Expand Up @@ -258,6 +263,13 @@ export const useApplicationFormHook = ({
});

const onValidSubmit = (formValues: FormValues) => {
let binaryValue = formValues.packaging
? `${formValues.group}:${formValues.artifact}:${formValues.version}:${formValues.packaging}`
: `${formValues.group}:${formValues.artifact}:${formValues.version}`;
if (!binaryValue.startsWith("mvn://")) {
binaryValue = `mvn://${binaryValue}`;
}

const payload: New<Application> = {
name: formValues.name.trim(),
description: formValues.description.trim(),
Expand All @@ -282,10 +294,7 @@ export const useApplicationFormHook = ({
path: formValues.rootPath.trim(),
}
: undefined,

binary: formValues.packaging
? `${formValues.group}:${formValues.artifact}:${formValues.version}:${formValues.packaging}`
: `${formValues.group}:${formValues.artifact}:${formValues.version}`,
binary: binaryValue,

// Values not editable on the form but still need to be passed through
identities: application?.identities ?? undefined,
Expand Down

0 comments on commit a3ef502

Please sign in to comment.