-
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.
Handle linking to unregistered hosts (#1560)
* Handle linking to unregistered hosts * Add host link test for unregistered nodes * Add ClusterNodeLink component * Use ClusterNodeLink component for cluster node linking
- Loading branch information
Showing
8 changed files
with
154 additions
and
12 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
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,23 @@ | ||
import React from 'react'; | ||
import { EOS_WARNING_OUTLINED } from 'eos-icons-react'; | ||
|
||
import Tooltip from '@components/Tooltip'; | ||
import HostLink from '@components/HostLink'; | ||
|
||
function ClusterNodeLink({ hostId, children }) { | ||
if (hostId) { | ||
return <HostLink hostId={hostId}>{children}</HostLink>; | ||
} | ||
return ( | ||
<span className="group flex items-center relative"> | ||
<EOS_WARNING_OUTLINED size="base" className="centered fill-yellow-500" /> | ||
<span className="ml-1 truncate max-w-[100px]">{children}</span> | ||
<Tooltip | ||
tooltipText="Host currently not registered." | ||
width="w-52 -translate-x-1/3" | ||
/> | ||
</span> | ||
); | ||
} | ||
|
||
export default ClusterNodeLink; |
28 changes: 28 additions & 0 deletions
28
assets/js/components/ClusterDetails/ClusterNodeLink.test.jsx
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,28 @@ | ||
import React from 'react'; | ||
import { screen, render } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import { renderWithRouter } from '@lib/test-utils'; | ||
import ClusterNodeLink from '@components/ClusterDetails/ClusterNodeLink'; | ||
import { hostFactory } from '@lib/test-utils/factories'; | ||
|
||
describe('ClusterNodeLink', () => { | ||
it('renders HostLink when hostId is provided', () => { | ||
const { id, hostname } = hostFactory.build(); | ||
|
||
renderWithRouter(<ClusterNodeLink hostId={id}>{hostname}</ClusterNodeLink>); | ||
|
||
const hostLinkElement = screen.getByRole('link', { hostname }); | ||
|
||
expect(hostLinkElement).toBeInTheDocument(); | ||
expect(hostLinkElement).toHaveAttribute('href', `/hosts/${id}`); | ||
}); | ||
|
||
it('renders warning span when hostId is not provided', () => { | ||
const { hostname } = hostFactory.build(); | ||
|
||
render(<ClusterNodeLink>{hostname}</ClusterNodeLink>); | ||
expect( | ||
screen.getByText('Host currently not registered.') | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
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