-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix index management link issue for both stacks
- Loading branch information
1 parent
6550193
commit 43f8d50
Showing
9 changed files
with
162 additions
and
79 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
48 changes: 48 additions & 0 deletions
48
...rence_endpoints/render_table_columns/render_actions/actions/component/index_item.test.tsx
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,48 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { render, fireEvent, screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import { IndexItem } from './index_item'; | ||
import { InferenceUsageInfo } from '../../../../types'; | ||
import { useKibana } from '../../../../../../hooks/use_kibana'; | ||
|
||
jest.mock('../../../../../../hooks/use_kibana'); | ||
const mockUseKibana = useKibana as jest.Mock; | ||
const mockNavigateToApp = jest.fn(); | ||
|
||
describe('Index Item', () => { | ||
const item: InferenceUsageInfo = { | ||
id: 'index-1', | ||
type: 'Index', | ||
}; | ||
beforeEach(() => { | ||
mockUseKibana.mockReturnValue({ | ||
services: { | ||
application: { | ||
navigateToApp: mockNavigateToApp, | ||
}, | ||
}, | ||
}); | ||
|
||
render(<IndexItem usageItem={item} />); | ||
}); | ||
|
||
it('renders', () => { | ||
expect(screen.getByText('index-1')).toBeInTheDocument(); | ||
expect(screen.getByText('Index')).toBeInTheDocument(); | ||
}); | ||
|
||
it('opens index in a new tab', () => { | ||
fireEvent.click(screen.getByRole('button')); | ||
expect(mockNavigateToApp).toHaveBeenCalledWith('enterpriseSearchContent', { | ||
openInNewTab: true, | ||
path: 'search_indices/index-1', | ||
}); | ||
}); | ||
}); |
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
69 changes: 69 additions & 0 deletions
69
...ference_endpoints/render_table_columns/render_actions/actions/component/pipeline_item.tsx
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,69 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { | ||
EuiBadge, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiHorizontalRule, | ||
EuiLink, | ||
EuiText, | ||
EuiTextTruncate, | ||
EuiIcon, | ||
EuiSpacer, | ||
} from '@elastic/eui'; | ||
import React from 'react'; | ||
import { MANAGEMENT_APP_ID } from '@kbn/deeplinks-management/constants'; | ||
|
||
import { useKibana } from '../../../../../../hooks/use_kibana'; | ||
import { InferenceUsageInfo } from '../../../../types'; | ||
import { PIPELINE_URL } from '../../../../constants'; | ||
|
||
interface UsageProps { | ||
usageItem: InferenceUsageInfo; | ||
} | ||
export const PipelineItem: React.FC<UsageProps> = ({ usageItem }) => { | ||
const { | ||
services: { application }, | ||
} = useKibana(); | ||
const navigateToPipeline = () => { | ||
application?.navigateToApp(MANAGEMENT_APP_ID, { | ||
path: `${PIPELINE_URL}?pipeline=${usageItem.id}`, | ||
openInNewTab: true, | ||
}); | ||
}; | ||
|
||
return ( | ||
<EuiFlexGroup gutterSize="s" direction="column" data-test-subj="usageItem"> | ||
<EuiFlexItem grow={false}> | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
<EuiFlexGroup gutterSize="xs" justifyContent="spaceBetween"> | ||
<EuiFlexItem> | ||
<EuiText size="s"> | ||
<EuiTextTruncate text={usageItem.id} /> | ||
</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiBadge color="hollow">{usageItem.type}</EuiBadge> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiLink data-test-subj="navigateToPipelinePage" onClick={navigateToPipeline}> | ||
<EuiIcon size="s" type="popout" /> | ||
</EuiLink> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiHorizontalRule margin="none" /> | ||
<EuiSpacer size="s" /> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
}; |
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