-
Notifications
You must be signed in to change notification settings - Fork 615
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
Add host status column #1774
Add host status column #1774
Conversation
status?: string; | ||
}; | ||
|
||
export const GenericStatus: React.FC<{ status?: string }> = ({ status, children }) => { |
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'm confused. Why are we copying all this logic from utils/status-icon.tsx
?
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.
This patch depends on #1697 which among other things lets plugins re-use the StatusIconAndText functionality (I've tried to cover the motivation here #1697 (comment))
/hold |
I've updated this PR to not depend on #1697 and used existing StatusIconAndText component to unblock this PR and work that depends on it. |
const hostStatus = getHostStatus(host); | ||
const { status, title } = hostStatus; | ||
|
||
switch (true) { |
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.
Clever, but is this really better than...?
if (status === HOST_STATUS_DISCOVERED) {
return <AddDiscoveredHostButton host={host} />;
}
if (HOST_PROGRESS_STATES.includes(status)) {
return <StatusIconAndText status={title} iconName="refresh" />;
}
// ...
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.
No strong opinion, but I find the switch statement a bit more readable
export const AddDiscoveredHostButton: React.FC<{ host: K8sResourceKind }> = ( | ||
{ host }, // eslint-disable-line @typescript-eslint/no-unused-vars | ||
) => ( | ||
<Button bsStyle="link"> |
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.
RBAC check?
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.
Done
title: 'Status', | ||
// sortField: 'spec.machineRef.name', | ||
// transforms: [sortable], | ||
props: { className: tableColumnClasses[1] }, |
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.
Would be nice if this is sortable, but I don't think there's a way to add sortFunc
from a plugin yet.
@@ -3,8 +3,8 @@ import * as _ from 'lodash'; | |||
import { K8sResourceKind, MachineKind } from '@console/internal/module/k8s'; | |||
import { getName } from '@console/shared'; | |||
|
|||
export const getOperationalStatus = (host) => _.get(host, 'status.operationalStatus'); | |||
export const getProvisioningState = (host) => _.get(host, 'status.provisioning.state'); | |||
export const getHostOperationalStatus = (host) => _.get(host, 'status.operationalStatus'); |
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.
Not new, but it would be better to add types to all of these helper functions
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.
Done, I'll create BaremetalHostKind for host in a separate PR.
// return NOT_HANDLED; | ||
// }; | ||
|
||
type HostStatusResult = { |
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 think this could be inferred from the return value, but I'm not against declaring it explicitly.
// node?: NodeKind, | ||
): string => getHostStatus(host).status; | ||
|
||
export const canHostAddMachine = (host) => [HOST_STATUS_READY].includes(getSimpleHostStatus(host)); |
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.
Declare types
/hold cancel |
* Introduces BaremetalHostStatus component which renders appropriate status component based on host status * Introduces utility functions to determine host status (optionally also from host's machine and node)
/approve |
@honza: changing LGTM is restricted to collaborators In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: honza, jtomasek, knowncitizen The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
/test e2e-aws |
/test frontend |
from host's machine and node)
Depends on #1697