-
Notifications
You must be signed in to change notification settings - Fork 15
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
Handle linking to unregistered hosts #1560
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
226438b
Handle linking to unregistered hosts
rtorrero 1269527
Add host link test for unregistered nodes
rtorrero 3a6a626
Update hostId field to id
rtorrero cf6f9b2
Fix broken test
rtorrero b1bf11b
Add ClusterNodeLink component
rtorrero f2a6a28
Use ClusterNodeLink component for cluster node linking
rtorrero ae2a3dd
Use slice instead of pop
rtorrero d8348bf
Improve tests
rtorrero 9900b4c
Use factories when possible
rtorrero f5fb747
Use children instead of separate name property
rtorrero 52c61f6
Remove unused hostFactory import
rtorrero e7d6649
Apply prettier formatting
rtorrero 8488e8a
Run prettier
rtorrero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
we need to at some point move this
render
to the mainexport default
to avoid not needed repetition.Could we do it in a next PR?
It would we as simple as moving this exact
render
up