Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Headlamp
Commits
c6fa8aec
Commit
c6fa8aec
authored
4 years ago
by
René Dudfield
Browse files
Options
Download
Email Patches
Plain Diff
frontend: add src/components/account/Auth stories.
parent
21ce708b
main
a11y-reporting
action-button-improvements
add-cluster-to-notification-area
add-clusters-dynamically
add-direct-c-o-c
add-fullscreen-to-editor
add-labs
add-max-window-size
add-more-log-options
add-msi-installer
add-namespace-to-events-table
add-network-policy-api
add-notification-area
add-notification-page
add-pod-list-deployments
add-ports-to-pods
add-proper-backlinks
add-proxy-endpoint
add-router-to-pluginLib
add_manual_trigger_docker_action
add_more_resources_details2
add_more_resources_details3
allow-listing-per-namespace
allow-popups-in-app
allow-to-build-without-checking-for-updates
app-menus
app_updates
apply-multiple-resources
autoscalers_resource_quota
backend-dependencies
better-info-for-workloads
branding-change
build-app-with-plugins
bump-chocolatey-0.13.0
center-cluster-chooser
centralize_list_calls
change-logo
chart-0.10.1
choco-bump-0.12.1
close-server-win
cluster_chooser
codegen
config_from_env
create-react-5
custom-resource-fixing
de-de
dep-docs
dep-updates2
dependabot/npm_and_yarn/app/electron-13.6.6
dependabot/npm_and_yarn/app/electron-15.5.5
dependabot/npm_and_yarn/app/minimist-1.2.6
dependabot/npm_and_yarn/frontend/async-2.6.4
dependabot/npm_and_yarn/frontend/d3-color-and-recharts-3.1.0
dependabot/npm_and_yarn/frontend/deep-object-diff-1.1.9
dependabot/npm_and_yarn/frontend/follow-redirects-1.14.7
dependabot/npm_and_yarn/frontend/follow-redirects-1.14.8
dependabot/npm_and_yarn/frontend/loader-utils-1.4.2
dependabot/npm_and_yarn/frontend/minimist-1.2.6
dependabot/npm_and_yarn/frontend/nanoid-3.2.0
dependabot/npm_and_yarn/frontend/terser-4.8.1
dependabot/npm_and_yarn/frontend/url-parse-1.5.10
dependabot/npm_and_yarn/plugins/examples/app-menus/terser-5.14.2
dependabot/npm_and_yarn/plugins/examples/change-logo/glob-parent-and-kinvolk/headlamp-plugin-5.1.2
dependabot/npm_and_yarn/plugins/examples/change-logo/terser-5.14.2
dependabot/npm_and_yarn/plugins/examples/cluster-chooser/glob-parent-and-kinvolk/headlamp-plugin-5.1.2
dependabot/npm_and_yarn/plugins/examples/cluster-chooser/terser-5.14.2
dependabot/npm_and_yarn/plugins/examples/dynamic-clusters/glob-parent-and-kinvolk/headlamp-plugin-5.1.2
dependabot/npm_and_yarn/plugins/examples/dynamic-clusters/terser-5.14.2
dependabot/npm_and_yarn/plugins/examples/pod-counter/browserslist-4.19.1
dependabot/npm_and_yarn/plugins/examples/pod-counter/path-parse-1.0.7
dependabot/npm_and_yarn/plugins/examples/pod-counter/ssri-6.0.2
dependabot/npm_and_yarn/plugins/examples/pod-counter/y18n-4.0.3
dependabot/npm_and_yarn/plugins/examples/sidebar/terser-5.14.2
dependabot/npm_and_yarn/plugins/headlamp-plugin/async-3.2.3
dependabot/npm_and_yarn/plugins/headlamp-plugin/minimist-1.2.6
dependabot/npm_and_yarn/plugins/headlamp-plugin/terser-5.14.2
docker_desktop_ext
docs-allow-to-build-without-checking-for-updates
dont-cache-plugin-requests-on-desktop
dont-require-bumping-charts
dont-use-a-one-click-installer-on-windows
dont-wrap-header-cells
e2e-container
e2e-login
e2e-playwright
endpoints
errcb-fix
event-sorting
example-fixes
export-charts
export-resource-chart-and-lib
export_all_k8s_modules
fetch-pods-by-labels
fix-applying-ingresses
fix-applying-non-group-apis
fix-cluster-chooser
fix-configmap-editor-theme
fix-crash-in-label-selector
fix-default-page-rows
fix-filter-when-items-are-numbers
fix-front-start
fix-issue-in-page-grid-children-type
fix-kubeconfig
fix-multiple-detail-view-render
fix-navigating-during-delete-op
fix-plugin-imports-again
fix-plugin-reinitialization
fix-quitting-server-again
fix-release-note-stuck-issue
fix-simple-table
fix-some-a11y-issues-on-dark-theme
fix-table-filter
fix-ui-warnings
fix-unexpected-null-in-getOwnedPods
fix_manual_trigger_gh_action
fr-fr
fullscreen_dialog
gh_action_automate_pr
go-back-through-location-stack
golang-17
handle-custom-auth-desktop
headlamp-plugin-0.5.1-b
headlamp-plugin-0.5.2-b
headlamp-plugin-upgrade
headlamp-upgrade-audit
headless-fix
headless-ux
helm-charts
helm-fixes
helm-typo-docs-fix
hide-appbar
http-bug-fix
improve-app-menus
improve-pod-matcher
improve-pod-status
inno-setup
jrocha/app-generation
jrocha/flatpak
jrocha/wip/show-build-version
localefix
log-viewer-scroll-fix
mui-v5-upgrade
namespaces-filter
new-chart
new-chooser-style
new-iconify
new-k8s-secret
new-terminal-fixes
new_chart
no-cluster-no-auth-required
no-objects-in-plugins-redux
node-upgrade
notification-clear-and-all-read
oidc-fix
oidc-state-len-fix
optimize-use-get
persist-rows-per-page
persist-url-params
plugin-demo
plugin-docs
plugin-error-handling
plugin-fixes
plugin-improvements
plugin-polishing
plugin-source
plugin-tests-in-js
plugin/allow-cluster-chooser-overriding
plugins-in-style
plugins-module
port-forwarding
push-asset
rc
rc-0.10.0
rc-0.10.1
rc-0.11.0
rc-0.11.1
rc-0.12.0
rc-0.12.1
rc-0.13.0
rc-0.6.0
rc-0.7.0
rc-0.8.0
rc-0.9.0
rc-phony-test
rc_0.5.3
redux-extension
reflect-views-in-url
refresh_token
releasec
remove-plugin-video
rename-server
render-logs-using-xterm
resource-class-issue
resources-json
role_bind_info
scaling-ui
search-involved-object-type-events-table
set-default-namespace
shorter-resource-age
show-build-version
show-dialog-if-release-fetch-failed
show-external-ips
sidebar-icons
sidebarroutefilter
simple-table-details-from-url
simplify-testing
terminal-fixes
test-cleanup
test-stuff
typedoc-plugin-upgrade
update-examples-052
update-i18n
update-release-draft
update-signing-email
updates
upgrade-new-things
use-fixed-date-on-tests
use-shipped-tsconfig-for-plugins
wait-for-plugins
width-cosmetic-fixes
win_target
windows-app
windows-testing
xterm-windows-mode
v0.13.0
v0.12.1
v0.12.0
v0.11.1
v0.11.0
v0.10.1
v0.10.0
v0.9.0
v0.8.0
v0.7.0
v0.6.0
v0.5.3
v0.5.2
v0.5.1
v0.5.0
v0.4.0
v0.3.0
v0.3.0-beta1
v0.3.0-beta
v0.2.1
headlamp-plugin-0.5.3
headlamp-plugin-0.5.2
headlamp-plugin-0.5.1
headlamp-plugin-0.5.0
headlamp-plugin-0.4.9
headlamp-plugin-0.4.8
headlamp-plugin-0.4.7
headlamp-helm-0.8.0
headlamp-helm-0.7.0
headlamp-helm-0.6.0
headlamp-helm-0.5.0
headlamp-helm-0.4.0
headlamp-helm-0.3.0
headlamp-helm-0.2.0
headlamp-helm-0.1.5
headlamp-helm-0.1.4
headlamp-helm-0.1.3
headlamp-helm-0.1.2
headlamp-helm-0.1.1
headlamp-helm-0.1.0
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/components/account/Auth.tsx
+69
-23
frontend/src/components/account/Auth.tsx
frontend/src/components/account/AuthToken.stories.tsx
+34
-0
frontend/src/components/account/AuthToken.stories.tsx
with
103 additions
and
23 deletions
+103
-23
frontend/src/components/account/Auth.tsx
+
69
-
23
View file @
c6fa8aec
...
...
@@ -19,7 +19,7 @@ interface ReactRouterLocationStateIface {
from
?:
Location
;
}
function
Auth
()
{
export
default
function
Auth
Token
()
{
const
history
=
useHistory
();
const
clusterConf
=
useClustersConf
();
const
[
token
,
setToken
]
=
React
.
useState
(
''
);
...
...
@@ -27,10 +27,14 @@ function Auth() {
const
clusters
=
useClustersConf
();
function
onAuthClicked
()
{
loginWithToken
(
token
).
then
(
code
=>
{
loginWithToken
(
token
).
then
(
(
code
)
=>
{
// If successful, redirect.
if
(
code
===
200
)
{
history
.
replace
(
generatePath
(
getClusterPrefixedPath
(),
{
cluster
:
getCluster
()
as
string
}));
history
.
replace
(
generatePath
(
getClusterPrefixedPath
(),
{
cluster
:
getCluster
()
as
string
,
})
);
}
else
{
setToken
(
''
);
setShowError
(
true
);
...
...
@@ -38,16 +42,60 @@ function Auth() {
});
}
return
(
<
PureAuthToken
onCancel
=
{
()
=>
history
.
replace
(
'
/
'
)
}
title
=
{
Object
.
keys
(
clusterConf
||
{}).
length
>
1
?
`Authentication:
${
getCluster
()}
`
:
'
Authentication
'
}
token
=
{
token
}
showError
=
{
showError
}
showActions
=
{
Object
.
keys
(
clusters
||
{}).
length
>
1
}
onChangeToken
=
{
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
setToken
(
event
.
target
.
value
)
}
onAuthClicked
=
{
onAuthClicked
}
onCloseError
=
{
()
=>
{
setShowError
(
false
);
}
}
/>
);
}
interface
clickCallbackType
{
(
event
:
React
.
MouseEvent
<
HTMLElement
>
):
void
;
}
interface
changeCallbackType
{
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
):
void
;
}
export
interface
PureAuthTokenProps
{
title
:
string
;
token
:
string
;
showActions
:
boolean
;
showError
:
boolean
;
onCancel
:
clickCallbackType
;
onChangeToken
:
changeCallbackType
;
onAuthClicked
:
clickCallbackType
;
onCloseError
:
(
event
:
React
.
SyntheticEvent
<
any
,
Event
>
,
reason
:
string
)
=>
void
;
}
export
function
PureAuthToken
({
title
,
token
,
showActions
,
showError
,
onCancel
,
onAuthClicked
,
onChangeToken
,
onCloseError
,
}:
PureAuthTokenProps
)
{
return
(
<
Box
>
<
ClusterDialog
useCover
disableEscapeKeyDown
disableBackdropClick
>
<
DialogTitle
id
=
"responsive-dialog-title"
>
{
Object
.
keys
(
clusterConf
||
{}).
length
>
1
?
`Authentication:
${
getCluster
()}
`
:
'
Authentication
'
}
</
DialogTitle
>
<
ClusterDialog
useCover
disableEscapeKeyDown
disableBackdropClick
>
<
DialogTitle
id
=
"responsive-dialog-title"
>
{
title
}
</
DialogTitle
>
<
DialogContent
>
<
DialogContentText
>
Please paste your authentication token.
...
...
@@ -59,19 +107,19 @@ function Auth() {
label
=
"ID token"
type
=
"password"
value
=
{
token
}
onChange
=
{
event
=>
setToken
(
event
.
target
.
value
)
}
onChange
=
{
onChangeToken
}
fullWidth
/>
</
DialogContent
>
<
DialogActions
>
{
Object
.
keys
(
clusters
||
{}).
length
>
1
&&
<>
<
Button
onClick
=
{
()
=>
history
.
replace
(
'
/
'
)
}
color
=
"primary"
>
Cancel
</
Button
>
<
div
style
=
{
{
flex
:
'
1 0 0
'
}
}
/>
</>
}
{
showActions
&&
(
<>
<
Button
onClick
=
{
onCancel
}
color
=
"primary"
>
Cancel
</
Button
>
<
div
style
=
{
{
flex
:
'
1 0 0
'
}
}
/>
</>
)
}
<
Button
onClick
=
{
onAuthClicked
}
color
=
"primary"
>
Authenticate
</
Button
>
...
...
@@ -84,7 +132,7 @@ function Auth() {
}
}
open
=
{
showError
}
autoHideDuration
=
{
5000
}
onClose
=
{
()
=>
{
setShowError
(
false
);
}
}
onClose
=
{
onCloseError
}
ContentProps
=
{
{
'
aria-describedby
'
:
'
message-id
'
,
}
}
...
...
@@ -112,5 +160,3 @@ async function loginWithToken(token: string) {
return
err
.
status
;
}
}
export
default
Auth
;
This diff is collapsed.
Click to expand it.
frontend/src/components/account/AuthToken.stories.tsx
0 → 100644
+
34
-
0
View file @
c6fa8aec
import
{
Meta
,
Story
}
from
'
@storybook/react/types-6-0
'
;
import
React
from
'
react
'
;
import
{
PureAuthToken
,
PureAuthTokenProps
}
from
'
./Auth
'
;
export
default
{
title
:
'
AuthToken
'
,
component
:
PureAuthToken
,
argTypes
:
{
onCancel
:
{
action
:
'
cancel clicked
'
},
onAuthClicked
:
{
action
:
'
auth clicked
'
},
onChangeToken
:
{
action
:
'
token changed
'
},
onCloseError
:
{
action
:
'
error closed
'
},
},
}
as
Meta
;
const
Template
:
Story
<
PureAuthTokenProps
>
=
(
args
)
=>
(
<
PureAuthToken
{
...
args
}
/>
);
export
const
ShowError
=
Template
.
bind
({});
ShowError
.
args
=
{
title
:
'
a title
'
,
token
:
'
a token
'
,
showError
:
true
,
showActions
:
false
,
};
export
const
ShowActions
=
Template
.
bind
({});
ShowActions
.
args
=
{
title
:
'
a title
'
,
token
:
'
a token
'
,
showError
:
false
,
showActions
:
true
,
};
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help