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

Commit e10f7f2

Browse files
myan9starpit
authored andcommitted
feat: show buttons of related resources in sidecar footer
Fixes #6856
1 parent 6f68a98 commit e10f7f2

File tree

8 files changed

+61
-14
lines changed

8 files changed

+61
-14
lines changed

packages/core/src/models/mmr/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ export type DrilldownButton<T = MetadataBearing> = Label &
122122

123123
/** Execute the command in place of the current block? Default: execute in a new block */
124124
inPlace?: boolean
125+
126+
/** Drilldown to related resource? */
127+
showRelatedResource?: boolean
125128
}
126129

127130
export type ViewButton<T = MetadataBearing> = Label &

packages/test/src/api/sidecar-expect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export const badge = (title: string, css?: string, absent = false) => async (res
9898

9999
export const button = (button: { mode: string; label?: string }) => async (res: AppAndCount) => {
100100
await res.app.client
101-
.$(Selectors.SIDECAR_TOOLBAR_BUTTON(res.count, button.mode, res.splitIndex))
101+
.$(Selectors.SIDECAR_MODE_BUTTON(res.count, button.mode, res.splitIndex))
102102
.then(_ => _.waitForDisplayed({ timeout: waitTimeout }))
103103
return res
104104
}

plugins/plugin-client-common/src/components/Views/Sidecar/Toolbar.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export type Props = LocationProps & {
2727
response: MultiModalResponse
2828
toolbarText?: ToolbarText
2929
noAlerts?: boolean
30+
bottom?: boolean
3031
args: {
3132
argvNoOptions: string[]
3233
parsedOptions: ParsedOptions
@@ -63,6 +64,7 @@ export default class Toolbar extends React.PureComponent<Props> {
6364
private buttons() {
6465
if (this.props.buttons) {
6566
return this.props.buttons
67+
.sort() // sort alphabetically first
6668
.sort((a, b) => {
6769
return (a.order || 0) - (b.order || 0)
6870
})
@@ -83,7 +85,11 @@ export default class Toolbar extends React.PureComponent<Props> {
8385
try {
8486
return (
8587
<div className="sidecar-bottom-stripe-toolbar">
86-
<div className="sidecar-toolbar-text" data-type={this.props.toolbarText && this.props.toolbarText.type}>
88+
<div
89+
className="sidecar-toolbar-text"
90+
data-location-bottom={this.props.bottom}
91+
data-type={this.props.toolbarText && this.props.toolbarText.type}
92+
>
8793
<div className="sidecar-toolbar-text-icon">{this.icon()}</div>
8894
{this.props.toolbarText &&
8995
(typeof this.props.toolbarText.text === 'string' ? (
@@ -98,7 +104,10 @@ export default class Toolbar extends React.PureComponent<Props> {
98104
))}
99105
</div>
100106

101-
<div className="sidecar-bottom-stripe-mode-bits sidecar-bottom-stripe-button-container">
107+
<div
108+
className="sidecar-bottom-stripe-mode-bits sidecar-bottom-stripe-button-container"
109+
data-location-bottom={this.props.bottom}
110+
>
102111
<div className="fill-container flex-layout flush-right">{this.buttons()}</div>
103112
</div>
104113
</div>

plugins/plugin-client-common/src/components/Views/Sidecar/TopNavSidecarV2.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
import Badge from './Badge'
3636
import KuiContext from '../../Client/context'
3737
import ToolbarContainer from './ToolbarContainer'
38+
import Toolbar from './Toolbar'
3839
import { BreadcrumbView } from '../../spi/Breadcrumb'
3940
import BaseSidecar, { Props, State } from './BaseSidecarV2'
4041

@@ -291,7 +292,7 @@ export default class TopNavSidecar extends BaseSidecar<MultiModalResponse, TopNa
291292
didUpdateToolbar={this._didUpdateToolbar}
292293
toolbarText={this.state.toolbarText}
293294
noAlerts={this.current.currentTabIndex !== this.current.defaultMode}
294-
buttons={this.current.buttons}
295+
buttons={this.current.buttons.filter(_ => !(_.kind === 'drilldown' && _.showRelatedResource))}
295296
>
296297
{this.bodyContent(idx)}
297298
</ToolbarContainer>
@@ -347,6 +348,19 @@ export default class TopNavSidecar extends BaseSidecar<MultiModalResponse, TopNa
347348
}
348349
}
349350

351+
private footer() {
352+
return (
353+
<Toolbar
354+
bottom={true}
355+
tab={this.props.tab}
356+
execUUID={this.props.execUUID}
357+
response={this.state.response}
358+
args={{ argvNoOptions: this.props.argvNoOptions, parsedOptions: this.props.parsedOptions }}
359+
buttons={this.current.buttons.filter(_ => _.kind === 'drilldown' && _.showRelatedResource)}
360+
/>
361+
)
362+
}
363+
350364
private kindBreadcrumb(): BreadcrumbView {
351365
const { kind, onclick } = this.state.response
352366
return { label: kind, command: onclick && onclick.kind, className: 'kui--sidecar-kind' }
@@ -434,6 +448,7 @@ export default class TopNavSidecar extends BaseSidecar<MultiModalResponse, TopNa
434448
<div className="kui--sidecar-header-and-body" style={{ flexDirection: 'column' }}>
435449
{this.header()}
436450
{this.tabs()}
451+
{this.footer()}
437452
</div>
438453
</div>
439454
)

plugins/plugin-client-common/web/css/static/sidecar-main.css

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ $toolbar-height: 1.5rem;
119119
flex: 1;
120120
overflow: visible; /* for tooltip visibility */
121121
}
122+
123+
.sidecar-toolbar-text[data-location-bottom="true"],
124+
.sidecar-bottom-stripe-mode-bits[data-location-bottom="true"] {
125+
background-color: var(--color-sidecar-header);
126+
color: var(--color-text-01);
127+
font-size: calc(12em / 16);
128+
}
129+
122130
.sidecar-toolbar-text svg path {
123131
fill: var(--color-sidecar-toolbar-foreground);
124132
&[data-icon-path="inner-path"] {
@@ -168,7 +176,7 @@ $toolbar-height: 1.5rem;
168176
.sidecar-bottom-stripe-button {
169177
display: flex;
170178
line-height: 1.5em;
171-
padding: 0 0.5em;
179+
padding: 0 0.25em;
172180

173181
& > button {
174182
padding: 0;
@@ -193,6 +201,24 @@ $toolbar-height: 1.5rem;
193201
display: flex;
194202
}
195203
}
204+
.sidecar-bottom-stripe-mode-bits[data-location-bottom="true"] {
205+
.sidecar-bottom-stripe-button {
206+
padding: 1em;
207+
208+
&:hover {
209+
background-color: var(--color-table-border3);
210+
}
211+
212+
a,
213+
button {
214+
&:hover {
215+
[role="tab"] {
216+
color: var(--color-text-01);
217+
}
218+
}
219+
}
220+
}
221+
}
196222
.graphical-icon svg {
197223
fill: var(--color-sidecar-toolbar-foreground);
198224
}

plugins/plugin-kubectl/src/lib/view/modes/Events.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const eventsMode: ModeRegistration<KubeResource> = {
6969
mode: 'events',
7070
label: strings('Show Events'),
7171
kind: 'drilldown',
72-
order: 110,
72+
showRelatedResource: true,
7373
command
7474
}
7575
}

plugins/plugin-kubectl/src/lib/view/modes/ShowNodeOfPodButton.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React from 'react'
18-
import { Icons } from '@kui-shell/plugin-client-common'
1917
import { i18n, Tab, ModeRegistration } from '@kui-shell/core'
2018

2119
import { isPod, Pod } from '../../model/resource'
@@ -40,9 +38,8 @@ const mode: ModeRegistration<Pod> = {
4038
mode: {
4139
mode: 'show-node',
4240
kind: 'drilldown',
43-
order: 80, // we want this to appear before DeleteButton, but after others...
41+
showRelatedResource: true,
4442
label: strings('Show Node'),
45-
icon: <Icons icon="Server" />,
4643
command
4744
}
4845
}

plugins/plugin-kubectl/src/lib/view/modes/ShowOwnerButton.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React from 'react'
18-
import { Icons } from '@kui-shell/plugin-client-common'
1917
import { i18n, encodeComponent, Tab, ModeRegistration } from '@kui-shell/core'
2018

2119
import { fqn } from '../../../controller/kubectl/fqn'
@@ -55,9 +53,8 @@ const mode: ModeRegistration<KubeResourceWithOwnerReferences> = {
5553
mode: {
5654
mode: 'ownerReference',
5755
kind: 'drilldown',
58-
order: 90, // we want this to appear before DeleteButton, but after others...
56+
showRelatedResource: true,
5957
label: strings('Show Owner Reference'),
60-
icon: <Icons icon="Up" />,
6158
command
6259
}
6360
}

0 commit comments

Comments
 (0)