-
Notifications
You must be signed in to change notification settings - Fork 702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Context Selector #1857
Context Selector #1857
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general. There are some comments before I approve this PR :)
const currentCluster = clusters.clusters[clusters.currentCluster]; | ||
const namespaceSelected = currentCluster.currentNamespace || defaultNamespace; | ||
const [cluster, setCluster] = useState(clusters.currentCluster); | ||
const [namespace, setNS] = useState(namespaceSelected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be consistent with the naming:
const [namespace, setNS] = useState(namespaceSelected); | |
const [namespace, setNamespace] = useState(namespaceSelected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setNamespace
is already used (by a function of the props)
className={`dropdown kubeapps-align-center kubeapps-dropdown ${open ? "open" : ""}`} | ||
ref={ref} | ||
> | ||
<button className="kubeapps-nav-link" onClick={toggleOpen} aria-expanded={open}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad to see aria-expanded
here :). I'm missing here the other aria
property to link this button with the content: aria-haspopup
. This property must use the same value as the role
of the element with the content that it's placed next to the button:
<button className="kubeapps-nav-link" onClick={toggleOpen} aria-expanded={open}> | |
<button className="kubeapps-nav-link" onClick={toggleOpen} aria-expanded={open} aria-haspopup="menu"> |
<Column span={10}> | ||
<span>Current Context</span> | ||
<div> | ||
<CdsIcon size="sm" shape="cluster" inverse={true} /> | ||
<span className="kubeapps-dropdown-text">{clusters.currentCluster}</span> | ||
<CdsIcon size="sm" shape="file-group" inverse={true} /> | ||
<span className="kubeapps-dropdown-text">{namespaceSelected}</span> | ||
</div> | ||
</Column> | ||
<Column span={2}> | ||
<div | ||
className={`kubeapps-align-center angle ${open ? "angle-opened" : "angle-closed"}`} | ||
> | ||
<CdsIcon shape="angle" inverse={true} /> | ||
</div> | ||
</Column> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
</span> | ||
<div className="dropdown-menu-padding" role="menuitem"> | ||
<CdsIcon size="sm" shape="cluster" inverse={true} /> | ||
<span className="kubeapps-dropdown-text">Cluster</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set this span
as a label
and link it with the select
via htmlFor
</div> | ||
<div className="dropdown-menu-padding" role="menuitem"> | ||
<CdsIcon size="sm" shape="file-group" inverse={true} /> | ||
<span className="kubeapps-dropdown-text">Namespace</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same about the label.
&-closed { | ||
transform: rotate(180deg); | ||
margin-left: -1rem; | ||
} | ||
&-opened { | ||
position: relative; | ||
left: 10px; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try to use the rotate
property of the icon component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmh, I tried but there was no rotate
property, turns out it's called direction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol 😂
<select name="clusters" className="clr-page-size-select" onChange={selectCluster}> | ||
{Object.keys(clusters.clusters).map(c => { | ||
return ( | ||
<option key={`kubeapps-dropdown-cluster-${c}`} value={c}> | ||
{c} | ||
</option> | ||
); | ||
})} | ||
</select> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh I see! Completely forgot that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Description of the change
Context Selector for Clarity UI. It allows to select the cluster and the namespace used.
Applicable issues
Additional information
Note that the
cluster
selector is still not working. That's a WIP in a different branch.