-
Notifications
You must be signed in to change notification settings - Fork 0
Add non-canvas element management with controller and service integration #574
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
Open
stijnpotters1
wants to merge
14
commits into
master
Choose a base branch
from
feat/add-non-canvas-elements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,382
−206
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0fd3df2
Add non-canvas element management with DTOs and service integration
stijnpotters1 7b53bbb
Refactor drag-and-drop handling for non-canvas elements and added bac…
stijnpotters1 3aa1250
Refactor file reading stub in NonCanvasElementServiceTest for improve…
stijnpotters1 8bbd61f
Add DTOs and service for non-canvas component management with control…
stijnpotters1 fcf9a97
Refactor interface declarations to type aliases for consistency acros…
stijnpotters1 fe2d1bd
Refactor component properties to use type aliases and replace button …
stijnpotters1 0c140a4
fix and refactor sidebar layout
philipsens a8c2cba
flat configuration overview
philipsens 168f914
remove console log (woepsie)
philipsens 6059190
Refactor AddNonCanvasComponentMenu to use Dialog component for improv…
stijnpotters1 00c4701
add tile views and change add configuration file modal
philipsens 0a8bf89
refactor search input and layout for configuration overview
philipsens 7af66b2
Merge branch 'master' into feat/add-non-canvas-elements
philipsens 6600b72
refactor filename validation and improve tile layout
philipsens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/frontend/app/components/context-editor-footer.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { type ReactNode } from 'react' | ||
| import Button from '~/components/inputs/button' | ||
|
|
||
| type ContextEditorFooterProperties = { | ||
| onSave: () => void | ||
| onDelete: () => void | ||
| saveDisabled?: boolean | ||
| deleteDisabled?: boolean | ||
| saveLabel?: string | ||
| deleteLabel?: string | ||
| errorMessage?: string | ||
| leadingActions?: ReactNode | ||
| } | ||
|
|
||
| export default function ContextEditorFooter({ | ||
| onSave, | ||
| onDelete, | ||
| saveDisabled = false, | ||
| deleteDisabled = false, | ||
| saveLabel = 'Save & Close', | ||
| deleteLabel = 'Delete', | ||
| errorMessage, | ||
| leadingActions, | ||
| }: Readonly<ContextEditorFooterProperties>) { | ||
| return ( | ||
| <div className="border-t-border bg-background border-t p-4"> | ||
| <div className="flex w-full items-center justify-between"> | ||
| <Button | ||
| onClick={onSave} | ||
| disabled={saveDisabled} | ||
| className="disabled:text-foreground-muted w-auto disabled:cursor-not-allowed disabled:opacity-50" | ||
| > | ||
| {saveLabel} | ||
| </Button> | ||
|
|
||
| <div className="flex items-center gap-2"> | ||
| {leadingActions} | ||
| <Button className="w-auto" onClick={onDelete} disabled={deleteDisabled}> | ||
| {deleteLabel} | ||
| </Button> | ||
| </div> | ||
| </div> | ||
|
|
||
| {errorMessage && <p className="text-error mt-2 text-sm">{errorMessage}</p>} | ||
| </div> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { type MouseEvent, type ReactNode } from 'react' | ||
| import { createPortal } from 'react-dom' | ||
| import CloseButton from '~/components/inputs/close-button' | ||
|
|
||
| type DialogProperties = { | ||
| isOpen: boolean | ||
| onClose: () => void | ||
| title: string | ||
| children: ReactNode | ||
| className?: string | ||
| overlay?: ReactNode | ||
| } | ||
| export default function Dialog({ isOpen, onClose, title, children, className, overlay }: Readonly<DialogProperties>) { | ||
| if (!isOpen) return null | ||
|
|
||
| const handleBackdropClick = (event: MouseEvent<HTMLDivElement>) => { | ||
| if (event.target === event.currentTarget) onClose() | ||
| } | ||
|
|
||
| return createPortal( | ||
| <div className="bg-background/50 fixed inset-0 z-50 flex items-center justify-center" onClick={handleBackdropClick}> | ||
| <div className={`bg-background border-border relative rounded-lg border p-6 shadow-lg ${className ?? ''}`}> | ||
| <h2 className="mb-4 text-lg font-semibold">{title}</h2> | ||
| {children} | ||
| <CloseButton onClick={onClose} className="absolute top-3 right-3" /> | ||
| </div> | ||
| {overlay} | ||
| </div>, | ||
| document.body, | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/frontend/app/components/inputs/active-icon-button.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import React from 'react' | ||
| import clsx from 'clsx' | ||
|
|
||
| type IconComponent = React.FC<React.SVGProps<SVGSVGElement>> | ||
|
|
||
| type TileViewButtonProps = { | ||
| isActive: boolean | ||
| label: string | ||
| Icon: IconComponent | ||
| onClick: () => void | ||
| } | ||
|
|
||
| export function ActiveIconButton({ isActive, label, Icon, onClick }: Readonly<TileViewButtonProps>) { | ||
| return ( | ||
| <li className="m-0 list-none p-0"> | ||
| <button | ||
| type="button" | ||
| onClick={onClick} | ||
| className="group relative flex w-full cursor-pointer flex-col items-center py-1" | ||
| > | ||
| <div | ||
| className={clsx('absolute bottom-1 left-1/2 h-0.5 w-10/12 -translate-x-1/2 rounded', isActive && 'bg-brand')} | ||
| /> | ||
| <div className="hover:bg-hover rounded p-2"> | ||
| <Icon | ||
| className={clsx( | ||
| 'h-8 w-auto', | ||
| isActive ? 'fill-brand' : 'fill-foreground-muted group-hover:fill-foreground', | ||
| )} | ||
| /> | ||
| </div> | ||
| <span className="bg-backdrop text-foreground border-border absolute top-full left-1/2 z-10 mt-2 hidden -translate-x-1/2 rounded border px-2 py-1 text-sm whitespace-nowrap shadow-md group-hover:block"> | ||
| {label} | ||
| </span> | ||
| </button> | ||
| </li> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/frontend/app/components/sidebars-layout/sidebar-close.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/frontend/app/components/sidebars-layout/sidebar-content-close.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/main/frontend/app/routes/configurations/adapter-context.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import { useEffect, useState } from 'react' | ||
| import Input from '~/components/inputs/input' | ||
| import ContextEditorFooter from '~/components/context-editor-footer' | ||
| import { deleteAdapter, renameAdapter } from '~/services/adapter-service' | ||
|
|
||
| export type AdapterEditorState = { | ||
| configPath: string | ||
| adapterName: string | ||
| adapterPosition: number | ||
| } | ||
|
|
||
| type AdapterContextProperties = { | ||
| projectName: string | ||
| editor: AdapterEditorState | ||
| onSaved: () => void | ||
| onDeleted: () => void | ||
| onNameChange?: (name: string) => void | ||
| } | ||
|
|
||
| export default function AdapterContext({ | ||
| projectName, | ||
| editor, | ||
| onSaved, | ||
| onDeleted, | ||
| onNameChange, | ||
| }: Readonly<AdapterContextProperties>) { | ||
| const [name, setName] = useState(editor.adapterName) | ||
| const [isSaving, setIsSaving] = useState(false) | ||
| const [errorMessage, setErrorMessage] = useState('') | ||
|
|
||
| useEffect(() => { | ||
| onNameChange?.(name) | ||
| }, [name, onNameChange]) | ||
|
|
||
| const trimmedName = name.trim() | ||
| const canSave = trimmedName !== '' && trimmedName !== editor.adapterName && !isSaving | ||
|
|
||
| const handleSave = async () => { | ||
| if (!canSave) return | ||
| setIsSaving(true) | ||
| setErrorMessage('') | ||
| try { | ||
| await renameAdapter(projectName, editor.adapterName, trimmedName, editor.configPath) | ||
| onSaved() | ||
| } catch (error) { | ||
| setErrorMessage(error instanceof Error ? error.message : `Failed to rename ${editor.adapterName}`) | ||
| setIsSaving(false) | ||
| } | ||
| } | ||
|
|
||
| const handleDelete = async () => { | ||
| setIsSaving(true) | ||
| setErrorMessage('') | ||
| try { | ||
| await deleteAdapter(projectName, editor.adapterName, editor.configPath) | ||
| onDeleted() | ||
| } catch (error) { | ||
| setErrorMessage(error instanceof Error ? error.message : `Failed to delete ${editor.adapterName}`) | ||
| setIsSaving(false) | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <div className="flex min-h-0 flex-1 flex-col"> | ||
| <div className="flex-1 overflow-y-auto px-4"> | ||
| <div className="text-foreground-muted mt-2 text-xs font-semibold tracking-wider uppercase">{name}</div> | ||
|
|
||
| <div className="bg-background w-full space-y-4 rounded-md p-6"> | ||
| <div className="space-y-1"> | ||
| <label htmlFor="adapter-name" className="text-foreground text-sm"> | ||
| name | ||
| </label> | ||
| <Input | ||
| id="adapter-name" | ||
| value={name} | ||
| disabled={isSaving} | ||
| onChange={(event) => setName(event.target.value)} | ||
| /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <ContextEditorFooter | ||
| onSave={handleSave} | ||
| saveDisabled={!canSave} | ||
| saveLabel={isSaving ? 'Saving...' : 'Save & Close'} | ||
| onDelete={handleDelete} | ||
| deleteDisabled={isSaving} | ||
| errorMessage={errorMessage} | ||
| /> | ||
| </div> | ||
| ) | ||
| } |
32 changes: 32 additions & 0 deletions
32
src/main/frontend/app/routes/configurations/adapter-list-item.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import RulerCrossPenIcon from '/icons/solar/Ruler Cross Pen.svg?react' | ||
| import IconLabelButton from '~/components/inputs/icon-label-button' | ||
| import ComponentRow from './component-row' | ||
|
|
||
| type AdapterListItemProperties = { | ||
| adapterName: string | ||
| adapterPosition: number | ||
| onConfigure: () => void | ||
| onOpenInStudio: (adapterName: string, adapterPosition: number) => void | ||
| } | ||
|
|
||
| export default function AdapterListItem({ | ||
| adapterName, | ||
| adapterPosition, | ||
| onConfigure, | ||
| onOpenInStudio, | ||
| }: Readonly<AdapterListItemProperties>) { | ||
| return ( | ||
| <ComponentRow | ||
| typeLabel="Adapter" | ||
| primaryLabel={adapterName} | ||
| onConfigure={onConfigure} | ||
| action={ | ||
| <IconLabelButton | ||
| icon={<RulerCrossPenIcon className="h-4 w-4 fill-current" />} | ||
| label="Open in Studio" | ||
| onClick={() => onOpenInStudio(adapterName, adapterPosition)} | ||
| /> | ||
| } | ||
| /> | ||
| ) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of isOpen property I rather see this component wrapped in an if statement