-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: update preview panel for external models Signed-off-by: tygao <[email protected]> * feat: update preview panel for external models Signed-off-by: tygao <[email protected]> --------- Signed-off-by: tygao <[email protected]> (cherry picked from commit 9bbd25f) Co-authored-by: raintygao <[email protected]>
- Loading branch information
1 parent
0710c49
commit 728fcb1
Showing
6 changed files
with
231 additions
and
55 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
public/components/preview_panel/__tests__/connector_details.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,36 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { render, screen } from '../../../../test/test_utils'; | ||
import { ConnectorDetails } from '../connector_details'; | ||
|
||
function setup({ name = 'name', id = 'id', description = 'description' }) { | ||
const user = userEvent.setup({}); | ||
render(<ConnectorDetails name={name} id={id} description={description} />); | ||
return { user }; | ||
} | ||
|
||
describe('<ConnectorDetails />', () => { | ||
it('should render connector details', () => { | ||
setup({}); | ||
expect(screen.getByText('Connector name')).toBeInTheDocument(); | ||
expect(screen.getByText('Connector ID')).toBeInTheDocument(); | ||
expect(screen.getByText('Connector description')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render - when id is empty', () => { | ||
setup({ id: '' }); | ||
expect(screen.getByText('-')).toBeInTheDocument(); | ||
expect(screen.queryByTestId('copyable-text-div')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should render id and copy id button when id is not empty', () => { | ||
setup({ id: 'connector-id' }); | ||
expect(screen.getByText('connector-id')).toBeInTheDocument(); | ||
expect(screen.queryByTestId('copyable-text-div')).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { | ||
EuiDescriptionList, | ||
EuiDescriptionListTitle, | ||
EuiTitle, | ||
EuiSpacer, | ||
EuiDescriptionListDescription, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
} from '@elastic/eui'; | ||
import { CopyableText } from '../common'; | ||
|
||
export const ConnectorDetails = (props: { name?: string; id?: string; description?: string }) => { | ||
const { name, id, description } = props; | ||
return ( | ||
<> | ||
<EuiSpacer size="m" /> | ||
<EuiTitle size="s"> | ||
<h3>Connector details</h3> | ||
</EuiTitle> | ||
<EuiSpacer size="m" /> | ||
<EuiDescriptionList> | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
<EuiDescriptionListTitle> | ||
<EuiTitle size="xxs"> | ||
<h5>Connector name</h5> | ||
</EuiTitle> | ||
</EuiDescriptionListTitle> | ||
<EuiDescriptionListDescription>{name}</EuiDescriptionListDescription> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiDescriptionListTitle> | ||
<EuiTitle size="xxs"> | ||
<h5>Connector ID</h5> | ||
</EuiTitle> | ||
</EuiDescriptionListTitle> | ||
<EuiDescriptionListDescription> | ||
{id ? ( | ||
<CopyableText text={id} iconLeft={false} tooltipText="Copy connector ID" /> | ||
) : ( | ||
'-' | ||
)} | ||
</EuiDescriptionListDescription> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<EuiSpacer size="m" /> | ||
<EuiDescriptionListTitle> | ||
<EuiTitle size="xxs"> | ||
<h5>Connector description</h5> | ||
</EuiTitle> | ||
</EuiDescriptionListTitle> | ||
<EuiDescriptionListDescription>{description}</EuiDescriptionListDescription> | ||
</EuiDescriptionList> | ||
</> | ||
); | ||
}; |
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