-
Notifications
You must be signed in to change notification settings - Fork 185
/
Copy pathindex.tsx
150 lines (134 loc) · 5.38 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* Copyright 2020 The Kubernetes Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react'
import { isOffline } from '@kui-shell/core/mdist/api/Client'
import { inBrowser } from '@kui-shell/core/mdist/api/Capabilities'
import Kui, { Props as KuiProps } from '@kui-shell/plugin-client-common/mdist/components/Client/Kui'
const Settings = React.lazy(
() => import('@kui-shell/plugin-client-common/mdist/components/Client/StatusStripe/Settings')
)
const GitHubIcon = React.lazy(
() => import('@kui-shell/plugin-client-common/mdist/components/Client/StatusStripe/GitHubIcon')
)
const ContextWidgets = React.lazy(
() => import('@kui-shell/plugin-client-common/mdist/components/Client/StatusStripe/ContextWidgets')
)
const MeterWidgets = React.lazy(
() => import('@kui-shell/plugin-client-common/mdist/components/Client/StatusStripe/MeterWidgets')
)
const CurrentWorkingDirectory = React.lazy(
() => import('@kui-shell/plugin-client-common/mdist/components/Client/StatusStripe/CurrentWorkingDirectory')
)
const SpaceFiller = React.lazy(
() => import('@kui-shell/plugin-client-common/mdist/components/Client/StatusStripe/SpaceFiller')
)
const CurrentContext = React.lazy(() => import('@kui-shell/plugin-kubectl/components/mdist/CurrentContext'))
const CurrentNamespace = React.lazy(() => import('@kui-shell/plugin-kubectl/components/mdist/CurrentNamespace'))
const Search = React.lazy(() => import('@kui-shell/plugin-electron-components/mdist/components/Search'))
const CurrentGitBranch = React.lazy(() => import('@kui-shell/plugin-git').then(_ => ({ default: _.CurrentGitBranch })))
const UpdateChecker = React.lazy(() => import('@kui-shell/plugin-electron-components/mdist/components/UpdateChecker'))
const ProxyOfflineIndicator = React.lazy(() =>
import('@kui-shell/plugin-proxy-support').then(_ => ({ default: _.ProxyOfflineIndicator }))
)
import { version } from '@kui-shell/client/package.json'
import guidebooks from '@kui-shell/client/config.d/notebooks.json'
import { productName } from '@kui-shell/client/config.d/name.json'
/**
* We will set this bit when the user dismisses the Welcome to Kui
* tab, so as to avoid opening it again and bothering that user for
* every new Kui window.
*
*/
const welcomeBit = 'plugin-client-default.welcome-was-dismissed'
/** Are we executing the given command? */
function isExecuting(props: KuiProps, ...cmds: string[]) {
return props.commandLine && cmds.includes(props.commandLine[0])
}
/**
* Format our body, with extra status stripe widgets
* - <CurrentGitBranch />
* - <ProxyOfflineIndicator />
*
*/
export default class Client extends React.PureComponent<KuiProps> {
public render() {
const { props } = this
const title = 'Welcome to Kui'
// Important: don't use popup for commands that need tabs,
// e.g. replaying notebooks, since `replay` currently needs tabs,
// and the Popup client doesn't offer that feature
const avoidPopupCommands = ['browse']
const doNotUsePopupClientVariant = isExecuting(props, ...avoidPopupCommands)
const isPopup = !(!props.isPopup || doNotUsePopupClientVariant)
const quietExecCommand =
props.quietExecCommand !== undefined
? props.quietExecCommand
: props.isPopup && doNotUsePopupClientVariant
? false
: undefined
const offline = isOffline()
return (
<Kui
noHelp
noSettings
version={version}
productName={productName}
lightweightTables
{...props}
isPopup={isPopup}
quietExecCommand={quietExecCommand}
toplevel={!inBrowser() && <Search />}
guidebooks={guidebooks.submenu}
commandLine={
props.commandLine ||
(!isPopup && [
'tab',
'new',
'--cmdline',
'commentary --readonly -f /kui/welcome.md',
'--bg',
'--title',
title,
'--status-stripe-type',
'blue',
'--status-stripe-message',
title,
'--if',
`kuiconfig not set ${welcomeBit}`,
'--onClose',
`kuiconfig set ${welcomeBit}`
])
}
>
<ContextWidgets>
{!isPopup && <CurrentWorkingDirectory className="kui--hide-in-guidebook" />}
{!offline && <CurrentGitBranch className="kui--hide-in-narrower-windows kui--hide-in-guidebook" />}
{!offline && <CurrentContext />}
{!offline && <CurrentNamespace />}
</ContextWidgets>
{!isPopup && <SpaceFiller />}
<MeterWidgets className="kui--hide-in-narrower-windows">
{/* <ClusterUtilization /> */}
{/* !isPopup && <OpenWhiskGridWidget /> */}
{!offline && inBrowser() && <ProxyOfflineIndicator />}
{!offline && !isPopup && !inBrowser() && <UpdateChecker />}
<Settings />
<GitHubIcon />
</MeterWidgets>
</Kui>
)
}
}