Skip to content

Commit

Permalink
fix: fix insecure_tls to string and back from boolean
Browse files Browse the repository at this point in the history
Closes #1451
  • Loading branch information
mainawycliffe committed Oct 27, 2023
1 parent faa30b7 commit 7573ea2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/components/Connections/ConnectionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Icon } from "../Icon";
import React from "react";
import { FaTrash } from "react-icons/fa";
import { Button } from "../Button";
import { mapValues, method } from "lodash";

export type Connection = {
altID?: string;
Expand Down Expand Up @@ -56,6 +57,7 @@ export type Connection = {
username?: string;
webhook?: string;
workstation?: string;
properties?: Record<string, any>;
};

type ConnectionFormProps = React.HTMLProps<HTMLDivElement> & {
Expand Down Expand Up @@ -98,13 +100,22 @@ export default function ConnectionForm({

const convertData = (data: Connection) => {
if (connectionType?.preSubmitConverter) {
return connectionType.preSubmitConverter(data as any) as Connection;
const x = connectionType.preSubmitConverter(data as any) as Connection;
return {
...x,
properties: mapValues(x.properties, method("toString"))
};
}
const result: Record<string, string | undefined | boolean | number> = {};
connectionType?.fields.forEach((field) => {
result[field.key] = data[field.key as keyof Connection]!;
result[field.key] =
data[field.key as keyof Omit<Connection, "properties">]!;
});
return result as Connection;
return {
...result,
name: data.name,
properties: mapValues(data.properties, method("toString"))
} as Connection;
};

const getFieldView = (field: Field) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Connections/connectionTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ export const connectionTypes: ConnectionType[] = [
...data,
region: data.properties?.region,
profile: data.properties?.profile,
insecure_tls: data.properties?.insecureTLS
insecure_tls: data.properties?.insecureTLS === "true"
} as Connection;
},
preSubmitConverter: (data: Record<string, string>) => {
Expand Down

0 comments on commit 7573ea2

Please sign in to comment.