Skip to content

Commit

Permalink
feat(targets): include target ID in dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Nov 2, 2022
1 parent ff8f6f7 commit 922edd8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/app/Shared/Services/Target.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const indexOfTarget = (arr: Target[], target: Target): number => {
};

export interface Target {
id?: string; // present in responses, but we do not need to provide it in requests
connectUrl: string;
alias: string;
labels?: {};
Expand Down
2 changes: 1 addition & 1 deletion src/app/TargetSelect/TargetSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const TargetSelect: React.FunctionComponent<TargetSelectProps> = (props)
].concat(
targets.map((t: Target) => (
<SelectOption key={t.connectUrl} value={t} isPlaceholder={false}>
{!t.alias || t.alias === t.connectUrl ? `${t.connectUrl}` : `${t.alias} (${t.connectUrl})`}
{!t.alias || t.alias === t.connectUrl ? `${t.connectUrl}: ${t.id}` : `${t.alias} (${t.connectUrl}): ${t.id}`}
</SelectOption>
))
),
Expand Down
7 changes: 4 additions & 3 deletions src/test/TargetSelect/TargetSelect.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ const cryostatAnnotation = {
REALM: CUSTOM_TARGETS_REALM,
};
const mockFooTarget: Target = {
id: 'abcd',
connectUrl: mockFooConnectUrl,
alias: 'fooTarget',
annotations: {
cryostat: cryostatAnnotation,
platform: {},
},
};
const mockBarTarget: Target = { ...mockFooTarget, connectUrl: mockBarConnectUrl, alias: 'barTarget' };
const mockBarTarget: Target = { ...mockFooTarget, id: 'efgh', connectUrl: mockBarConnectUrl, alias: 'barTarget' };
const mockBazTarget: Target = { connectUrl: mockBazConnectUrl, alias: 'bazTarget' };

const history = createMemoryHistory();
Expand Down Expand Up @@ -150,8 +151,8 @@ describe('<TargetSelect />', () => {
userEvent.click(screen.getByLabelText('Options menu'));
expect(screen.getByLabelText('Select Target')).toBeInTheDocument();
expect(screen.getByText(`Select target...`)).toBeInTheDocument();
expect(screen.getByText(`fooTarget (service:jmx:rmi://someFooUrl)`)).toBeInTheDocument();
expect(screen.getByText(`barTarget (service:jmx:rmi://someBarUrl)`)).toBeInTheDocument();
expect(screen.getByText(`fooTarget (service:jmx:rmi://someFooUrl): abcd`)).toBeInTheDocument();
expect(screen.getByText(`barTarget (service:jmx:rmi://someBarUrl): efgh`)).toBeInTheDocument();
expect(screen.getByText('2')).toBeInTheDocument(); // Number of discoverable targets
});

Expand Down

0 comments on commit 922edd8

Please sign in to comment.