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

Commit 486a02e

Browse files
myan9starpit
authored andcommitted
fix(plugins/plugin-client-common): externalize PatternFly TreeView component to SPI
Fixes #6134
1 parent 85ea2d5 commit 486a02e

File tree

6 files changed

+64
-12
lines changed

6 files changed

+64
-12
lines changed

packages/test/src/api/selectors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ export const INVERTED_COLORS = '.kui--inverted-color-context'
121121
* Tree
122122
*
123123
*/
124-
export const TREE = (N: number) => `${SIDECAR_TAB_CONTENT(N)} .kui--treeview`
125-
export const TREE_VIEWS_AND_BODY = (N: number) => `${TREE(N)} .kui--treeview-nav-and-body`
124+
export const TREE = (N: number) => `${SIDECAR_TAB_CONTENT(N)} .kui--tree`
125+
export const TREE_VIEWS_AND_BODY = (N: number) => `${TREE(N)} .kui--tree-nav-and-body`
126126
export const TREE_VIEWS = (N: number) => `${TREE_VIEWS_AND_BODY(N)} ul[role="tree"]`
127127
export const _TREE_LIST = (id: string) => `li[id="${id}"]`
128128
export const TREE_LIST = (N: number, id: string) => `${TREE_VIEWS(N)} ${_TREE_LIST(id)}`

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
import Eval from './Eval'
3939
import Editor from './Editor'
4040
import renderTable from './Table'
41-
import TreeView from './TreeView'
41+
import Tree from './Tree'
4242
import Markdown from './Markdown'
4343
import HTMLString from './HTMLString'
4444
import HTMLDom from './Scalar/HTMLDom'
@@ -131,7 +131,7 @@ export default class KuiMMRContent extends React.Component<KuiMMRProps, State> {
131131
} else if (isHTML(mode.content)) {
132132
return <HTMLDom content={mode.content} />
133133
} else if (isTreeResponse(mode.content)) {
134-
return <TreeView tab={this.props.tab} data={mode.content.data} response={this.props.response} />
134+
return <Tree tab={this.props.tab} data={mode.content.data} response={this.props.response} />
135135
} else {
136136
console.error('Unsupported scalar content', mode)
137137
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
*/
1616

1717
import React from 'react'
18-
import { TreeView } from '@patternfly/react-core'
1918

2019
import { MultiModalResponse, Tab, TreeItem, TreeResponse } from '@kui-shell/core'
21-
import Editor from '../Content/Editor'
20+
import TreeView from '../spi/TreeView'
21+
import Editor from './Editor'
2222

23-
import '../../../web/scss/components/TreeView/PatternFly.scss'
23+
import '../../../web/scss/components/Tree/index.scss'
2424

2525
interface Props {
2626
response: MultiModalResponse
@@ -75,8 +75,8 @@ export default class KuiTreeView extends React.PureComponent<Props, State> {
7575

7676
public render() {
7777
return (
78-
<div className="kui--treeview">
79-
<div className="kui--treeview-nav-and-body">
78+
<div className="kui--tree">
79+
<div className="kui--tree-nav-and-body">
8080
{this.tree()}
8181
{this.editor()}
8282
</div>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2020 IBM Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import React from 'react'
18+
import { TreeView, TreeViewProps } from '@patternfly/react-core'
19+
20+
export default function KuiTreeView(props: TreeViewProps): React.ReactElement {
21+
return <TreeView {...props} />
22+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2020 IBM Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@mixin Tree {
18+
.kui--tree {
19+
@content;
20+
}
21+
}
22+
23+
@mixin TreeNavAndBody {
24+
.kui--tree-nav-and-body {
25+
@content;
26+
}
27+
}

plugins/plugin-client-common/web/scss/components/TreeView/PatternFly.scss renamed to plugins/plugin-client-common/web/scss/components/Tree/index.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
@import '_mixins';
17+
@import '_mixin.scss';
18+
@import '../TreeView/mixins';
1819

19-
.kui--treeview-nav-and-body {
20-
display: flex;
20+
@include Tree {
21+
@include TreeNavAndBody {
22+
display: flex;
23+
}
2124

2225
@include TreeViewNav {
2326
background-color: var(--color-sidecar-header);

0 commit comments

Comments
 (0)