From 65574ba8aa41b356963c4f8594feb4b9d023c218 Mon Sep 17 00:00:00 2001 From: Riccardo Forina Date: Wed, 20 Nov 2024 11:51:22 +0100 Subject: [PATCH] Improve legibility on design view --- .../ui/src/codeEditor/CodeEditorMachine.ts | 2 +- packages/ui/src/components/InlineEdit.tsx | 3 +- packages/ui/src/components/Markdown.tsx | 59 +++--- .../ui/src/components/SearchableTable.tsx | 6 +- packages/ui/src/components/ServerRow.tsx | 47 +---- packages/ui/src/components/SourceEditor.tsx | 1 + .../ui/src/dataTypeDesigner/Properties.tsx | 180 ++++++++---------- .../src/documentDesigner/SecurityScheme.tsx | 7 +- packages/ui/src/documentDesigner/Servers.tsx | 1 - .../src/documentDesigner/TagDefinitions.tsx | 38 +--- packages/ui/src/pathDesigner/Servers.tsx | 25 ++- 11 files changed, 161 insertions(+), 208 deletions(-) diff --git a/packages/ui/src/codeEditor/CodeEditorMachine.ts b/packages/ui/src/codeEditor/CodeEditorMachine.ts index 0a362c5..7f0aad9 100644 --- a/packages/ui/src/codeEditor/CodeEditorMachine.ts +++ b/packages/ui/src/codeEditor/CodeEditorMachine.ts @@ -90,7 +90,7 @@ export const CodeEditorMachine = setup({ idle: { on: { DOCUMENT_CHANGED: { - target: "idle", + target: "loading", reenter: true, }, CHANGE_SOURCE_TYPE: { diff --git a/packages/ui/src/components/InlineEdit.tsx b/packages/ui/src/components/InlineEdit.tsx index 3461327..f26b681 100644 --- a/packages/ui/src/components/InlineEdit.tsx +++ b/packages/ui/src/components/InlineEdit.tsx @@ -28,6 +28,7 @@ type ValidationResult = { interface IInlineEdit { value?: string; + label?: string; validator?: (value: string) => ValidationResult; onChange?: (value: string) => void; onClick?: () => void; @@ -131,7 +132,7 @@ export const InlineEdit: FunctionComponent = (props) => { ) : (
- + void; editing?: boolean; }) { const darkMode = useDarkMode(); @@ -55,27 +62,35 @@ export function Markdown({ {children} ) : ( - } - aria-label="Save changes" - tooltipProps={{ content: "Save changes" }} - onClick={() => {}} - // isDisabled={isDisabled || source === code} - />, - ]} - isLanguageLabelVisible={false} - isLineNumbersVisible={false} - // onChange={(code) => setCode(code)} - language={Language.markdown} - height={"sizeToFit"} - // onEditorDidMount={onEditorDidMount} - emptyState={} - isDarkTheme={darkMode} - code={children} - /> + + + {children ? ( + } + aria-label="Save changes" + tooltipProps={{ content: "Save changes" }} + onClick={() => {}} + // isDisabled={isDisabled || source === code} + />, + ]} + isLanguageLabelVisible={false} + isLineNumbersVisible={false} + // onChange={(code) => setCode(code)} + language={Language.markdown} + height={"sizeToFit"} + // onEditorDidMount={onEditorDidMount} + isDarkTheme={darkMode} + code={children} + onChange={onChange ?? (() => {})} + /> + ) : ( + + )} + + ); } diff --git a/packages/ui/src/components/SearchableTable.tsx b/packages/ui/src/components/SearchableTable.tsx index eb3bcaa..6e5823c 100644 --- a/packages/ui/src/components/SearchableTable.tsx +++ b/packages/ui/src/components/SearchableTable.tsx @@ -79,7 +79,11 @@ export function SearchableTable({ )} {filteredData.length > 0 && ( - + {filteredData.map((t, idx) => { return {onRenderRow(t, idx)}; })} diff --git a/packages/ui/src/components/ServerRow.tsx b/packages/ui/src/components/ServerRow.tsx index c6f8c8a..1916306 100644 --- a/packages/ui/src/components/ServerRow.tsx +++ b/packages/ui/src/components/ServerRow.tsx @@ -1,45 +1,42 @@ -import { useState } from "react"; import { + Button, DataListAction, DataListCell, DataListItem, DataListItemCells, DataListItemRow, - Dropdown, - DropdownItem, - DropdownList, - MenuToggle, } from "@patternfly/react-core"; import { Markdown } from "./Markdown.tsx"; -import { EllipsisVIcon } from "@patternfly/react-icons"; +import { TrashIcon } from "@patternfly/react-icons"; +import { InlineEdit } from "./InlineEdit.tsx"; export function ServerRow({ id, url, description, editing, - onRename, onRemove, }: { id: string; url: string; description: string; editing: boolean; - onRename: () => void; onRemove: () => void; }) { - const [isMenuOpen, setIsMenuOpen] = useState(false); - const toggleMenu = () => setIsMenuOpen((v) => !v); return ( - {url} + + + , - {description} + + {description} + , ]} /> @@ -49,31 +46,7 @@ export function ServerRow({ id={`${id}-actions`} aria-label="Actions" > - ( - - - )} - isOpen={isMenuOpen} - onOpenChange={(isOpen: boolean) => setIsMenuOpen(isOpen)} - > - - - Rename - - - Delete - - - + - - - - - - setEnableInlineEditing(checked)} - hasCheckIcon={false} - label={"Edit properties"} - /> - - - - - {properties.map((p, idx) => ( - - - - - - <InlineEdit - onChange={(newName) => { - actorRef.send({ - type: "CHANGE_NAME", - prevName: p.name, - newName, - }); - }} - value={p.name} - editing={!enableInlineEditing} - /> - - , - - {p.type} - , - - - , - ]} - /> - - {(p.description || enableInlineEditing) && ( - + + p.name.toLowerCase().includes(filter.toLowerCase()) || + p.type.toLowerCase().includes(filter.toLowerCase()) + } + onRenderRow={(p, idx) => } + onAdd={() => {}} + onRemoveAll={() => {}} + /> + ); +} + +function Property({ + idx, + editing, + p, +}: { + idx: number; + editing: boolean; + p: DataTypeProperty; +}) { + return ( + + + + <InlineEdit - onChange={(newName) => { - actorRef.send({ - type: "CHANGE_DESCRIPTION", - prevName: p.description, - newName, - }); - }} - value={p.description} - editing={!enableInlineEditing} + label={"Name"} + onChange={() => {}} + value={p.name} + editing={editing} /> - </DataListContent> - )} - </DataListItem> - ))} - </DataList> - </> + + , + + {p.type} + , + + + , + ]} + /> + {editing && ( + +