Skip to content

Commit

Permalink
UI prototype for #956
Browse files Browse the repository at this point in the history
  • Loading branch information
mgubaidullin committed Nov 29, 2023
1 parent a51f59c commit 6290498
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 16 deletions.
9 changes: 7 additions & 2 deletions karavan-space/src/designer/editor/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ export function CodeEditor () {
const [code, setCode] = useState<string>('');

useEffect(() => {
const c = CamelDefinitionYaml.integrationToYaml(integration);
setCode(c);
try {
const c = CamelDefinitionYaml.integrationToYaml(integration);
setCode(c);
} catch (e: any) {
const message: string = e?.message ? e.message : e.reason;
setNotification(true, ['Error in YAML, Integration can not be saved!', message]);
}
return () => {
setNotification(false, ['', '']);
}
Expand Down
17 changes: 16 additions & 1 deletion karavan-space/src/designer/route/DslElement.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
.disabled {
opacity: 0.5;
}
}
.menu-button {
position: absolute;
top: 26px;
line-height: 1;
border: 0;
padding: 0;
margin: 0 0 0 10px;
background: transparent;
color: var(--pf-v5-global--primary-color--100);
visibility: hidden;
}

.dsl-element:hover .menu-button {
visibility: visible;
}
39 changes: 34 additions & 5 deletions karavan-space/src/designer/route/DslElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
* limitations under the License.
*/
import React, {CSSProperties, useMemo, useState} from 'react';
import {
Text, Tooltip,
} from '@patternfly/react-core';
import {Menu, MenuContent, MenuItem, MenuList, Popover, Text, Tooltip,} from '@patternfly/react-core';
import '../karavan.css';
import './DslElement.css';
import AddIcon from "@patternfly/react-icons/dist/js/icons/plus-circle-icon";
import DeleteIcon from "@patternfly/react-icons/dist/js/icons/times-circle-icon";
import SyncIcon from "@patternfly/react-icons/dist/js/icons/sync-icon";
import TurnIcon from "@patternfly/react-icons/dist/js/icons/chevron-circle-right-icon";
import InsertIcon from "@patternfly/react-icons/dist/js/icons/arrow-alt-circle-right-icon";
import {CamelElement} from "karavan-core/lib/model/IntegrationDefinition";
import {CamelUi} from "../utils/CamelUi";
Expand Down Expand Up @@ -222,7 +222,7 @@ export function DslElement(props: Props) {
const headerClass = ['RouteConfigurationDefinition', 'RouteDefinition'].includes(step.dslName) ? "header-route" : "header"
const headerClasses = isElementSelected() ? headerClass + " selected" : headerClass;
return (
<div className={headerClasses} style={getHeaderStyle()} ref={headerRef}>
<div className={"dsl-element " + headerClasses} style={getHeaderStyle()} ref={headerRef}>
{!['RouteConfigurationDefinition', 'RouteDefinition'].includes(props.step.dslName) &&
<div
ref={el => sendPosition(el)}
Expand All @@ -237,6 +237,7 @@ export function DslElement(props: Props) {
</div>
{showInsertButton && getInsertElementButton()}
{getDeleteButton()}
{/*{getMenuButton()}*/}
{showAddButton && getAddElementButton()}
</div>
)
Expand Down Expand Up @@ -408,11 +409,39 @@ export function DslElement(props: Props) {
return (
<Tooltip position={"right"} content={<div>{"Delete element"}</div>}>
<button type="button" aria-label="Delete" onClick={e => onDeleteElement(e)} className="delete-button">
<DeleteIcon/></button>
<DeleteIcon/>
</button>
</Tooltip>
)
}

function getMenuButton() {
return (
<Popover
aria-label="Convert Popover"
hasNoPadding
position={"right"}
hideOnOutsideClick={true}
showClose={false}
bodyContent={
<Menu activeItemId={''} onSelect={event => {}} isPlain>
<MenuContent>
<MenuList>
<MenuItem itemId={0} icon={<SyncIcon aria-hidden />}>Convert to SetHeader</MenuItem>
{/*<MenuItem itemId={1}>Action</MenuItem>*/}
{/*<MenuItem itemId={2}>Action</MenuItem>*/}
</MenuList>
</MenuContent>
</Menu>
}
>
<button type="button" aria-label="Menu" onClick={e => {}} className="menu-button">
<TurnIcon/>
</button>
</Popover>
)
}

const element: CamelElement = props.step;
const className = "step-element"
+ (isElementSelected() ? " step-element-selected" : "") + (!props.step.showChildren ? " hidden-step" : "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ export function CodeEditor () {
const [code, setCode] = useState<string>('');

useEffect(() => {
const c = CamelDefinitionYaml.integrationToYaml(integration);
setCode(c);
try {
const c = CamelDefinitionYaml.integrationToYaml(integration);
setCode(c);
} catch (e: any) {
const message: string = e?.message ? e.message : e.reason;
setNotification(true, ['Error in YAML, Integration can not be saved!', message]);
}
return () => {
setNotification(false, ['', '']);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
.disabled {
opacity: 0.5;
}
}
.menu-button {
position: absolute;
top: 26px;
line-height: 1;
border: 0;
padding: 0;
margin: 0 0 0 10px;
background: transparent;
color: var(--pf-v5-global--primary-color--100);
visibility: hidden;
}

.dsl-element:hover .menu-button {
visibility: visible;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
* limitations under the License.
*/
import React, {CSSProperties, useMemo, useState} from 'react';
import {
Text, Tooltip,
} from '@patternfly/react-core';
import {Menu, MenuContent, MenuItem, MenuList, Popover, Text, Tooltip,} from '@patternfly/react-core';
import '../karavan.css';
import './DslElement.css';
import AddIcon from "@patternfly/react-icons/dist/js/icons/plus-circle-icon";
import DeleteIcon from "@patternfly/react-icons/dist/js/icons/times-circle-icon";
import SyncIcon from "@patternfly/react-icons/dist/js/icons/sync-icon";
import TurnIcon from "@patternfly/react-icons/dist/js/icons/chevron-circle-right-icon";
import InsertIcon from "@patternfly/react-icons/dist/js/icons/arrow-alt-circle-right-icon";
import {CamelElement} from "karavan-core/lib/model/IntegrationDefinition";
import {CamelUi} from "../utils/CamelUi";
Expand Down Expand Up @@ -222,7 +222,7 @@ export function DslElement(props: Props) {
const headerClass = ['RouteConfigurationDefinition', 'RouteDefinition'].includes(step.dslName) ? "header-route" : "header"
const headerClasses = isElementSelected() ? headerClass + " selected" : headerClass;
return (
<div className={headerClasses} style={getHeaderStyle()} ref={headerRef}>
<div className={"dsl-element " + headerClasses} style={getHeaderStyle()} ref={headerRef}>
{!['RouteConfigurationDefinition', 'RouteDefinition'].includes(props.step.dslName) &&
<div
ref={el => sendPosition(el)}
Expand All @@ -237,6 +237,7 @@ export function DslElement(props: Props) {
</div>
{showInsertButton && getInsertElementButton()}
{getDeleteButton()}
{/*{getMenuButton()}*/}
{showAddButton && getAddElementButton()}
</div>
)
Expand Down Expand Up @@ -408,11 +409,39 @@ export function DslElement(props: Props) {
return (
<Tooltip position={"right"} content={<div>{"Delete element"}</div>}>
<button type="button" aria-label="Delete" onClick={e => onDeleteElement(e)} className="delete-button">
<DeleteIcon/></button>
<DeleteIcon/>
</button>
</Tooltip>
)
}

function getMenuButton() {
return (
<Popover
aria-label="Convert Popover"
hasNoPadding
position={"right"}
hideOnOutsideClick={true}
showClose={false}
bodyContent={
<Menu activeItemId={''} onSelect={event => {}} isPlain>
<MenuContent>
<MenuList>
<MenuItem itemId={0} icon={<SyncIcon aria-hidden />}>Convert to SetHeader</MenuItem>
{/*<MenuItem itemId={1}>Action</MenuItem>*/}
{/*<MenuItem itemId={2}>Action</MenuItem>*/}
</MenuList>
</MenuContent>
</Menu>
}
>
<button type="button" aria-label="Menu" onClick={e => {}} className="menu-button">
<TurnIcon/>
</button>
</Popover>
)
}

const element: CamelElement = props.step;
const className = "step-element"
+ (isElementSelected() ? " step-element-selected" : "") + (!props.step.showChildren ? " hidden-step" : "")
Expand Down

0 comments on commit 6290498

Please sign in to comment.