Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 2f21e22

Browse files
myan9starpit
authored andcommitted
fix(plugins/plugin-client-common): Tree Component tweaks
- Tree View: use fix width, and only render the selected tree node as active - Tree Events: fix background color, border-top, message formatting and use fix-height - Tree View Text: fix font-family Fixes #6158 Fixes #6157
1 parent cc2e177 commit 2f21e22

File tree

7 files changed

+32
-45
lines changed

7 files changed

+32
-45
lines changed

plugins/plugin-client-common/src/components/Content/Events.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ export default class Events extends React.PureComponent<Props, State> {
181181

182182
const kind = kindCol !== undefined ? row[kindCol].value : ''
183183

184-
const ago = agos ? `[${agos[idx]}]` : ''
184+
const ago = agos ? `[[${agos[idx]}]]()` : ''
185185

186186
return {
187-
message: `${ago}${name}${message}`,
187+
message: `${ago}${name} ${message}`,
188188
involvedObjects: {
189189
name: row[nameCol].value,
190190
kind
@@ -248,7 +248,7 @@ export default class Events extends React.PureComponent<Props, State> {
248248
return streams.map(({ message }, idx) => (
249249
<div key={`${message}-${idx}`} className="kui--tree-event-messages">
250250
<div className="kui--tree-event-message">
251-
<Markdown source={message} noExternalLinks repl={this.props.tab.REPL} />
251+
<Markdown tab={this.props.tab} source={message} noExternalLinks repl={this.props.tab.REPL} />
252252
</div>
253253
</div>
254254
))

plugins/plugin-client-common/src/components/Content/Markdown.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export default class Markdown extends React.PureComponent<Props> {
8080
link: props => {
8181
const isLocal = !/^http/i.test(props.href)
8282
const target = !isLocal ? '_blank' : undefined
83-
const href = isLocal ? '#' : props.href
8483
const onClick = !isLocal
8584
? (evt: React.MouseEvent) => evt.stopPropagation()
8685
: async (evt: React.MouseEvent) => {
@@ -100,18 +99,23 @@ export default class Markdown extends React.PureComponent<Props> {
10099
if (elt) {
101100
return elt.scrollIntoView()
102101
}
103-
} else if (this.props.fullpath) {
104-
const absoluteHref = join(dirname(this.props.fullpath), props.href)
105-
const relativeToCWD = relative(process.cwd() || process.env.PWD, absoluteHref)
106-
file = relativeToCWD
102+
} else if (file) {
103+
if (this.props.fullpath) {
104+
const absoluteHref = join(dirname(this.props.fullpath), props.href)
105+
const relativeToCWD = relative(process.cwd() || process.env.PWD, absoluteHref)
106+
file = relativeToCWD
107+
}
108+
109+
return this.props.repl.pexec(`open ${this.props.repl.encodeComponent(file)}`)
107110
}
108-
return this.props.repl.pexec(`open ${this.props.repl.encodeComponent(file)}`)
109111
}
110112

111-
if (!isLocal && this.props.noExternalLinks) {
112-
return <span className={this.props.className}>{href}</span>
113+
if (!props.href) {
114+
return <a className={this.props.className}>{props.children}</a>
115+
} else if (!isLocal && this.props.noExternalLinks) {
116+
return <span className={this.props.className}>{props.href}</span>
113117
} else {
114-
return <Link {...props} href={href} target={target} onClick={onClick} />
118+
return <Link {...props} href={props.href} target={target} onClick={onClick} />
115119
}
116120
},
117121
code: props => (

plugins/plugin-client-common/src/components/Content/Tree.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ type Props = {
3030
}
3131

3232
interface State {
33-
activeItems: TreeItem[]
33+
activeItem: TreeItem
3434
}
3535

3636
export default class KuiTreeView extends React.PureComponent<Props, State> {
3737
public constructor(props) {
3838
super(props)
3939

4040
this.state = {
41-
activeItems: [this.props.data[0]]
41+
activeItem: this.props.data[0]
4242
}
4343
}
4444

@@ -47,8 +47,8 @@ export default class KuiTreeView extends React.PureComponent<Props, State> {
4747
return (
4848
<React.Suspense fallback={<div />}>
4949
<Editor
50-
key={this.state.activeItems[0].id}
51-
content={{ content: this.state.activeItems[0].content, contentType: this.state.activeItems[0].contentType }}
50+
key={this.state.activeItem.id}
51+
content={{ content: this.state.activeItem.content, contentType: this.state.activeItem.contentType }}
5252
readOnly={false}
5353
sizeToFit
5454
response={this.props.response}
@@ -63,10 +63,10 @@ export default class KuiTreeView extends React.PureComponent<Props, State> {
6363
return (
6464
<TreeView
6565
data={this.props.data}
66-
activeItems={this.state.activeItems}
67-
onSelect={(_, treeViewItem, parentItem) => {
66+
activeItems={[this.state.activeItem]}
67+
onSelect={(_, treeViewItem) => {
6868
this.setState({
69-
activeItems: [treeViewItem as TreeItem, parentItem as TreeItem]
69+
activeItem: treeViewItem as TreeItem
7070
})
7171
}}
7272
hasBadges
@@ -75,15 +75,15 @@ export default class KuiTreeView extends React.PureComponent<Props, State> {
7575
}
7676

7777
private events() {
78-
if (this.state.activeItems[0].eventArgs) {
79-
const { command, schema } = this.state.activeItems[0].eventArgs
78+
if (this.state.activeItem.eventArgs) {
79+
const { command, schema } = this.state.activeItem.eventArgs
8080

8181
return (
8282
<Events
8383
tab={this.props.tab}
8484
command={command}
8585
schema={schema}
86-
involvedObjects={this.state.activeItems[0].extends}
86+
involvedObjects={this.state.activeItem.extends}
8787
/>
8888
)
8989
}

plugins/plugin-client-common/src/components/spi/TreeView/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import React from 'react'
1818
import { TreeView, TreeViewProps } from '@patternfly/react-core'
1919

20-
import '../../../../web/scss/components/TreeView/PatternFly.scss'
21-
2220
export default function KuiTreeView(props: TreeViewProps): React.ReactElement {
2321
return <TreeView {...props} />
2422
}

plugins/plugin-client-common/web/scss/components/Table/Events.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ $inter-message-spacing: 0.1875rem;
6565
p {
6666
line-height: initial;
6767
white-space: pre-wrap;
68-
font-family: monospace;
68+
font-family: var(--font-monospace);
6969
font-size: 0.75rem;
7070
padding: 0;
7171
}

plugins/plugin-client-common/web/scss/components/Tree/index.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
}
2626

2727
@include TreeViewNav {
28+
width: 19rem;
2829
background-color: var(--color-sidecar-header);
2930

3031
@include TreeViewItemNotSelected {
@@ -38,7 +39,10 @@
3839
}
3940

4041
.kui--tree-events {
41-
background-color: var(--color-base03);
42+
background-color: var(--color-base00);
43+
border-top: 1px soild var(--color-base02);
44+
overflow-y: auto;
45+
height: 9rem;
4246

4347
.kui--tree-event-messages:first-child {
4448
.kui--tree-event-message {

plugins/plugin-client-common/web/scss/components/TreeView/PatternFly.scss

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)