-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cluster node status frontend (#2345)
* Add ClusterNodeName component * Use the new component in cluster detail views * Add e2e tests
- Loading branch information
Showing
8 changed files
with
126 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import { | ||
EOS_BOLT_FILLED, | ||
EOS_WARNING_OUTLINED, | ||
EOS_BUILD_OUTLINED, | ||
EOS_POWER_OFF_OUTLINED, | ||
} from 'eos-icons-react'; | ||
|
||
import Tooltip from '@common/Tooltip'; | ||
import ClusterNodeLink from './ClusterNodeLink'; | ||
|
||
const getNodeStatusIcon = (status) => { | ||
switch (status) { | ||
case 'Online': { | ||
return <EOS_BOLT_FILLED className="tn-online" />; | ||
} | ||
case 'Offline': { | ||
return <EOS_POWER_OFF_OUTLINED className="tn-offline" />; | ||
} | ||
case 'Maintenance': { | ||
return <EOS_BUILD_OUTLINED className="tn-maintenance" />; | ||
} | ||
default: { | ||
return <EOS_WARNING_OUTLINED className="tn-unknown" />; | ||
} | ||
} | ||
}; | ||
|
||
function ClusterNodeName({ status, hostId, children }) { | ||
return ( | ||
<span className="group flex items-center relative space-x-2"> | ||
<Tooltip content={status} place="bottom"> | ||
{getNodeStatusIcon(status)} | ||
</Tooltip> | ||
<ClusterNodeLink hostId={hostId}>{children}</ClusterNodeLink> | ||
</span> | ||
); | ||
} | ||
|
||
export default ClusterNodeName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import { screen, act } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import '@testing-library/jest-dom'; | ||
import { renderWithRouter } from '@lib/test-utils'; | ||
import { hostFactory } from '@lib/test-utils/factories'; | ||
|
||
import ClusterNodeName from './ClusterNodeName'; | ||
|
||
describe('ClusterNodeName', () => { | ||
it.each([ | ||
{ | ||
status: 'Online', | ||
testID: 'tn-online', | ||
}, | ||
{ | ||
status: 'Offline', | ||
testID: 'tn-offline', | ||
}, | ||
{ | ||
status: 'Maintenance', | ||
testID: 'tn-maintenance', | ||
}, | ||
{ | ||
status: 'Other', | ||
testID: 'tn-unknown', | ||
}, | ||
])('renders correct icon', async ({ status, testID }) => { | ||
const user = userEvent.setup(); | ||
|
||
const { id, hostname } = hostFactory.build(); | ||
|
||
renderWithRouter( | ||
<ClusterNodeName status={status} hostId={id}> | ||
{hostname} | ||
</ClusterNodeName> | ||
); | ||
|
||
const icon = screen.getByTestId('eos-svg-component'); | ||
expect(icon).toHaveClass(testID); | ||
await act(async () => user.hover(icon)); | ||
|
||
expect(screen.getByText(status)).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters