diff --git a/packages/web/src/app/capture/Subscription.tsx b/packages/web/src/app/capture/Subscription.tsx index 91fd0add5..413de7d93 100644 --- a/packages/web/src/app/capture/Subscription.tsx +++ b/packages/web/src/app/capture/Subscription.tsx @@ -8,7 +8,7 @@ import { useGetSubscriptionQuery } from "../../features/http-client/freemiumd-ap import ProgressBar from "./ProgressBar"; import Button from "../../new-components/Button"; import { useAppDispatch, useAppSelector } from "./store"; -import { openLink } from "../../features/config/slice"; +import { openLink } from "./slice"; export default function Subscription({ token, diff --git a/packages/web/src/app/capture/index.tsx b/packages/web/src/app/capture/index.tsx index 8bbdf0ea2..2585fb52e 100644 --- a/packages/web/src/app/capture/index.tsx +++ b/packages/web/src/app/capture/index.tsx @@ -6,8 +6,6 @@ import { Webapp } from "@xliic/common/webapp/capture"; import { ThemeState } from "../../features/theme/slice"; import { RouterContext, Routes } from "../../features/router/RouterContext"; -import GeneralError from "../../features/general-error/GeneralError"; -import { showGeneralError } from "../../features/general-error/slice"; import { makeWebappMessageHandler, RouterApp } from "../webapp"; import { createListener } from "./listener"; import { initStore, messageHandlers } from "./store"; diff --git a/packages/web/src/app/scanconf/authorizationTests/TestContents.tsx b/packages/web/src/app/scanconf/authorizationTests/TestContents.tsx index d6a7a7d76..a0866e687 100644 --- a/packages/web/src/app/scanconf/authorizationTests/TestContents.tsx +++ b/packages/web/src/app/scanconf/authorizationTests/TestContents.tsx @@ -1,5 +1,10 @@ +import { useFieldArray } from "react-hook-form"; +import styled from "styled-components"; + +import { ThemeColorVariables } from "@xliic/common/theme"; import { Playbook } from "@xliic/scanconf"; +import { Plus, TrashCan } from "../../../icons"; import DownshiftSelect from "../../../new-components/fat-fields/DownshiftSelect"; export default function TestContents({ credentials }: { credentials: Playbook.Credentials }) { @@ -16,13 +21,54 @@ export default function TestContents({ credentials }: { credentials: Playbook.Cr ]} /> - + - + ); } +function AuthArrayField({ + label, + name, + options, +}: { + label: string; + name: string; + options: { label: string; value: string }[]; +}) { + const { fields, append, remove } = useFieldArray({ name }); + + return ( + + {label} + {fields.map((field, index) => ( + + + { + e.preventDefault(); + e.stopPropagation(); + remove(index); + }} + > + + + + ))} + { + e.preventDefault(); + e.stopPropagation(); + append(""); + }} + > + Add {label.toLowerCase()} + + + ); +} + function flattenCredentials(credentials: Playbook.Credentials) { return Object.entries(credentials) .map(([credentialName, credential]) => { @@ -33,3 +79,52 @@ function flattenCredentials(credentials: Playbook.Credentials) { }) .flat(); } + +const Group = styled.div` + display: flex; + flex-direction: column; + gap: 8px; +`; + +const GroupLabel = styled.div` + font-weight: 500; + font-size: 12px; + line-height: 16px; + color: var(${ThemeColorVariables.inputPlaceholderForeground}); +`; + +const Row = styled.div` + display: flex; + align-items: center; + gap: 8px; + > :first-child { + flex: 1; + } +`; + +const Remove = styled.button` + background: none; + border: none; + padding: 0; + width: 1.5em; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + > svg { + fill: var(${ThemeColorVariables.foreground}); + } +`; + +const Add = styled.div` + display: flex; + padding: 8px 12px; + gap: 4px; + cursor: pointer; + align-items: center; + border: 1px dashed var(${ThemeColorVariables.border}); + color: var(${ThemeColorVariables.linkForeground}); + > svg { + fill: var(${ThemeColorVariables.linkForeground}); + } +`; diff --git a/packages/web/src/new-components/fat-fields/DownshiftSelect.tsx b/packages/web/src/new-components/fat-fields/DownshiftSelect.tsx index 017fa5a9c..d62817d44 100644 --- a/packages/web/src/new-components/fat-fields/DownshiftSelect.tsx +++ b/packages/web/src/new-components/fat-fields/DownshiftSelect.tsx @@ -12,7 +12,7 @@ export default function DownshiftSelect({ }: { name: string; options: SelectOption[]; - label: string; + label?: string; description?: string; placeholder?: string; }) { @@ -22,7 +22,7 @@ export default function DownshiftSelect({ return ( -
{label}
+ {label !== undefined &&
{label}
}