Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1451-connection-properties-need-stored-mapstring-string #1465

Merged
Merged
Show file tree
Hide file tree
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
24 changes: 17 additions & 7 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 Expand Up @@ -180,13 +191,12 @@ export default function ConnectionForm({
});
}}
>
<Form>
<Form className="flex flex-col flex-1 overflow-y-auto">
<div
className={clsx(
"flex flex-col h-full my-2 overflow-y-auto",
"flex flex-col flex-1 my-2 overflow-y-auto",
className
)}
style={{ maxHeight: "calc(65vh)" }}
{...props}
>
<div className={clsx("flex flex-col px-2 mb-2")}>
Expand Down Expand Up @@ -269,7 +279,7 @@ export default function ConnectionForm({
title={
connectionType ? (
<div
className="flex flex-row items-center space-x-2"
className="flex flex-row items-center gap-2 overflow-y-auto"
key={connectionType.title}
>
{typeof connectionType?.icon === "string" ? (
Expand Down
4 changes: 2 additions & 2 deletions src/components/Connections/connectionTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export const connectionTypes: ConnectionType[] = [
{
title: "Redis",
icon: "redis",
value: ConnectionValueType.AWS,
value: ConnectionValueType.Redis,
fields: [
{
label: "Name",
Expand Down 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
Loading