Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Headlamp
Commits
5d225711
Commit
5d225711
authored
4 years ago
by
René Dudfield
Browse files
Options
Download
Email Patches
Plain Diff
frontend: Change cluster modal to focus first cluster button
parent
01335da0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/components/cluster/Chooser.tsx
+15
-14
frontend/src/components/cluster/Chooser.tsx
with
15 additions
and
14 deletions
+15
-14
frontend/src/components/cluster/Chooser.tsx
+
15
-
14
View file @
5d225711
...
...
@@ -103,18 +103,19 @@ const useClusterButtonStyles = makeStyles({
},
});
interface
ClusterButtonProps
{
interface
ClusterButtonProps
extends
PropsWithChildren
<
{}
>
{
cluster
:
Cluster
;
onClick
?:
(...
args
:
any
[])
=>
void
;
focusedRef
?:
(
node
:
any
)
=>
void
;
}
function
ClusterButton
(
props
:
ClusterButtonProps
)
{
const
classes
=
useClusterButtonStyles
();
const
theme
=
useTheme
();
const
{
cluster
,
onClick
=
undefined
}
=
props
;
const
{
cluster
,
onClick
=
undefined
,
focusedRef
}
=
props
;
return
(
<
ButtonBase
focusRipple
onClick
=
{
onClick
}
>
<
ButtonBase
focusRipple
ref
=
{
focusedRef
}
onClick
=
{
onClick
}
>
<
Card
className
=
{
classes
.
root
}
>
<
CardContent
className
=
{
classes
.
content
}
>
<
Icon
icon
=
{
kubernetesIcon
}
width
=
"50"
height
=
"50"
color
=
{
theme
.
palette
.
primaryColor
}
/>
...
...
@@ -134,12 +135,21 @@ interface ClusterListProps {
function
ClusterList
(
props
:
ClusterListProps
)
{
const
{
clusters
,
onButtonClick
}
=
props
;
const
focusedRef
=
React
.
useCallback
(
node
=>
{
if
(
node
!==
null
)
{
node
.
focus
();
}
},
[]);
return
(
<
Grid
container
alignItems
=
"center"
justify
=
"space-around"
spacing
=
{
2
}
>
{
clusters
.
map
((
cluster
,
i
)
=>
(
<
Grid
item
key
=
{
cluster
.
name
}
>
<
ClusterButton
cluster
=
{
cluster
}
onClick
=
{
()
=>
onButtonClick
(
cluster
)
}
/>
<
ClusterButton
focusedRef
=
{
i
===
0
?
focusedRef
:
undefined
}
cluster
=
{
cluster
}
onClick
=
{
()
=>
onButtonClick
(
cluster
)
}
/>
</
Grid
>
))
}
</
Grid
>
...
...
@@ -240,13 +250,6 @@ function Chooser(props: ClusterDialogProps) {
const
clusterList
=
Object
.
values
(
clusters
||
{});
const
focusedRef
=
React
.
useCallback
(
node
=>
{
if
(
node
!==
null
)
{
node
.
setAttribute
(
'
tabindex
'
,
'
-1
'
);
node
.
focus
();
}
},
[]);
return
(
<
ClusterDialog
open
=
{
show
}
...
...
@@ -255,9 +258,7 @@ function Chooser(props: ClusterDialogProps) {
aria-busy
=
{
clusterList
.
length
===
0
&&
clusters
===
null
}
{
...
otherProps
}
>
<
DialogTitle
id
=
"chooser-dialog-title"
ref
=
{
focusedRef
}
>
Choose a cluster
</
DialogTitle
>
<
DialogTitle
id
=
"chooser-dialog-title"
>
Choose a cluster
</
DialogTitle
>
{
clusterList
.
length
===
0
?
(
<
React
.
Fragment
>
...
...
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