Skip to content

Commit 6099260

Browse files
committed
run ui page refinements
Signed-off-by: Nick Mitchell <[email protected]>
1 parent 342c385 commit 6099260

File tree

4 files changed

+143
-50
lines changed

4 files changed

+143
-50
lines changed

pdl-live-react/package-lock.json

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pdl-live-react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"start": "npm run tauri dev"
2424
},
2525
"dependencies": {
26+
"@patternfly/react-code-editor": "^6.1.0",
2627
"@patternfly/react-core": "^6.1.0",
2728
"@tauri-apps/api": "^2.3.0",
2829
"@tauri-apps/plugin-cli": "^2.2.0",

pdl-live-react/src/page/Run.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@import "../view/term/RunTerminal.css";
2+
3+
.pdl-run-page-section {
4+
.pdl-run-split-item-card-header,
5+
.pdl-run-split-item-card-body {
6+
padding-inline-start: 0;
7+
padding-right: 0;
8+
}
9+
}

pdl-live-react/src/page/Run.tsx

Lines changed: 61 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,32 @@ import { invoke } from "@tauri-apps/api/core"
33
import { Terminal } from "@xterm/xterm"
44
import { FitAddon } from "@xterm/addon-fit"
55
import { ClipboardAddon } from "@xterm/addon-clipboard"
6+
import { CodeEditor, Language } from "@patternfly/react-code-editor"
67
import {
78
Button,
8-
Panel,
9-
PanelHeader,
10-
PanelMain,
11-
PanelMainBody,
9+
Card,
10+
CardBody,
11+
CardHeader,
12+
CardTitle,
1213
PageSection,
13-
Split,
14-
SplitItem,
15-
TextArea,
14+
Flex,
15+
FlexItem,
1616
Toolbar,
17+
ToolbarContent,
1718
ToolbarItem,
1819
} from "@patternfly/react-core"
1920

2021
import Page from "./Page"
21-
import "../view/term/RunTerminal.css"
22+
import "./Run.css"
2223

2324
export default function Run() {
24-
const [input, setInput] = useState("")
25-
const [error, setError] = useState(false)
25+
const [input, setInput] = useState(`text:
26+
- text:
27+
- '{"key": "value"}'
28+
parser: json
29+
def: foo
30+
- \${ foo.key }`)
31+
const [_error, setError] = useState(false)
2632

2733
const ref = createRef<HTMLDivElement>()
2834
const [term, setTerm] = useState<null | Terminal>(null)
@@ -34,7 +40,6 @@ export default function Run() {
3440
const term = new Terminal({
3541
fontFamily:
3642
'"Red Hat Mono", RedHatMono, "Courier New", Courier, monospace',
37-
fontSize: 12,
3843
convertEol: true,
3944
})
4045
setTerm(term)
@@ -67,59 +72,65 @@ export default function Run() {
6772
program: input,
6873
debug: false,
6974
})
70-
term.write(result)
71-
console.error(result)
75+
term?.write(String(result))
76+
console.error(true)
7277
} catch (err) {
73-
term.write(err)
78+
term?.write(String(err))
7479
setError(true)
7580
}
7681
}
7782

7883
return (
7984
<Page breadcrumb1="Run">
80-
<PageSection>
81-
<Split hasGutter>
82-
<SplitItem isFilled>
83-
<Panel>
84-
<PanelHeader>Program</PanelHeader>
85-
<PanelMain>
86-
<PanelMainBody>
87-
<TextArea
85+
<PageSection className="pdl-run-page-section">
86+
<Flex>
87+
<FlexItem flex={{ default: "flex_1" }}>
88+
<Card isPlain>
89+
<CardHeader className="pdl-run-split-item-card-header">
90+
<CardTitle>Program</CardTitle>
91+
</CardHeader>
92+
<CardBody className="pdl-run-split-item-card-body">
93+
<div style={{ height: "600px" }}>
94+
<CodeEditor
95+
options={{ fontSize: 16 }}
8896
aria-label="text area to provide PDL program source"
89-
validated={!!error ? "error" : undefined}
90-
value={input}
91-
style={{ height: "600px" }}
92-
onChange={(_event, value) => {
93-
setError(null)
97+
code={input}
98+
isDarkTheme
99+
isFullHeight
100+
language={Language.yaml}
101+
onChange={(value) => {
102+
setError(false)
94103
setInput(value)
95-
term.clear()
104+
term?.clear()
96105
}}
97106
/>
98-
</PanelMainBody>
99-
</PanelMain>
100-
</Panel>
101-
</SplitItem>
107+
</div>
108+
</CardBody>
109+
</Card>
110+
</FlexItem>
102111

103-
<SplitItem>
104-
<Panel>
105-
<PanelHeader>Output</PanelHeader>
106-
<PanelMain>
107-
<PanelMainBody>
108-
<div
109-
className="pdl-run-terminal"
110-
ref={ref}
111-
style={{ height: "600px" }}
112-
/>
113-
</PanelMainBody>
114-
</PanelMain>
115-
</Panel>
116-
</SplitItem>
117-
</Split>
112+
<FlexItem flex={{ default: "flex_1" }}>
113+
<Card isPlain>
114+
<CardHeader className="pdl-run-split-item-card-header">
115+
<CardTitle>Output</CardTitle>
116+
</CardHeader>
117+
<CardBody className="pdl-run-split-item-card-body">
118+
<div
119+
className="pdl-run-terminal"
120+
ref={ref}
121+
style={{ height: "600px" }}
122+
/>
123+
</CardBody>
124+
</Card>
125+
</FlexItem>
126+
</Flex>
118127

119128
<Toolbar>
120-
<ToolbarItem>
121-
<Button onClick={run}>Run</Button>
122-
</ToolbarItem>
129+
<ToolbarContent>
130+
<ToolbarItem>
131+
<Button onClick={run}>Run</Button>
132+
</ToolbarItem>
133+
</ToolbarContent>
123134
</Toolbar>
124135
</PageSection>
125136
</Page>

0 commit comments

Comments
 (0)