Skip to content

Commit

Permalink
feat: add namespace field to form and table column
Browse files Browse the repository at this point in the history
fix: fix failing tests

fix: fix default namespace issues
  • Loading branch information
mainawycliffe committed Nov 16, 2023
1 parent 178444f commit 53b1d1a
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 247 deletions.
34 changes: 19 additions & 15 deletions src/components/Connections/ConnectionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ export function ConnectionForm({
(item) => item.value === connectionType.value
);
if (connection) {
return connection.convertToFormSpecificValue
const res = connection.convertToFormSpecificValue
? connection.convertToFormSpecificValue(formValue as any)
: formValue;
return {
...res,
namespace: res?.namespace ?? "default"
};
}
}, [connectionType.value, formValue]);

Expand Down Expand Up @@ -70,20 +74,20 @@ export function ConnectionForm({

return (
<Formik
initialValues={
formInitialValue || {
name: "",
type: undefined,
url: "",
username: "",
password: "",
certificate: "",
domain: "",
region: "",
profile: "",
insecure_tls: false
}
}
initialValues={{
name: "",
type: undefined,
url: "",
username: "",
password: "",
certificate: "",
domain: "",
region: "",
profile: "",
insecure_tls: false,
namespace: "default",
...formInitialValue
}}
onSubmit={handleSubmit}
>
<Form className="flex flex-col flex-1 overflow-y-auto">
Expand Down
1 change: 1 addition & 0 deletions src/components/Connections/ConnectionFormModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export type Connection = {
workstation?: string;
properties?: Record<string, any>;
ref?: string;
namespace?: string;
};

type ConnectionFormProps = React.HTMLProps<HTMLDivElement> & {
Expand Down
4 changes: 4 additions & 0 deletions src/components/Connections/ConnectionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const columns: ColumnDef<Connection>[] = [
accessorKey: "name",
cell: NameCell
},
{
header: "Namespace",
accessorKey: "namespace"
},
{
header: "Type",
accessorKey: "type"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ describe("ConnectionForm", () => {
expect(onConnectionSubmit).toHaveBeenCalledWith({
certificate: "test",
name: "Test Connection",
password: undefined,
password: "",
properties: {
ref: "ref"
},
type: "git",
url: "https://test.com",
username: undefined
username: "",
namespace: "default"
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ describe("ConnectionForm", () => {
expect(onConnectionSubmit).toHaveBeenCalledWith({
certificate: "test",
name: "Test Connection",
password: undefined,
password: "",
properties: {
ref: "ref"
},
type: "git",
url: "https://test.com",
username: undefined
username: "",
namespace: "default"
});
});
});
Expand Down
Loading

0 comments on commit 53b1d1a

Please sign in to comment.