-
Notifications
You must be signed in to change notification settings - Fork 918
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: add home static list card * Changeset file for PR #7351 created/updated * update link property * add i18n and description --------- (cherry picked from commit e64de15) (cherry picked from commit 6685bce) Signed-off-by: tygao <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
a9fd071
commit 5708d4b
Showing
5 changed files
with
216 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feat: | ||
- Add home page static list card ([#7351](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7351)) |
51 changes: 51 additions & 0 deletions
51
src/plugins/home/public/application/components/__snapshots__/home_list_card.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
src/plugins/home/public/application/components/home_list_card.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,27 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import { HomeListCard } from './home_list_card'; | ||
|
||
describe('<HomeListCard />', () => { | ||
it('should render static content normally', async () => { | ||
const mockConfig = { | ||
title: `What's New`, | ||
list: [ | ||
{ | ||
label: 'Quickstart guide', | ||
href: 'https://opensearch.org/docs/latest/dashboards/quickstart/', | ||
target: '_blank', | ||
description: 'Get started in minutes with OpenSearch Dashboards', | ||
}, | ||
], | ||
}; | ||
const { baseElement } = render(<HomeListCard config={mockConfig} />); | ||
expect(baseElement).toMatchSnapshot(); | ||
}); | ||
}); |
102 changes: 102 additions & 0 deletions
102
src/plugins/home/public/application/components/home_list_card.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,102 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { | ||
EuiDescriptionList, | ||
EuiText, | ||
EuiLink, | ||
EuiTitle, | ||
EuiPanel, | ||
EuiDescriptionListTitle, | ||
EuiDescriptionListDescription, | ||
EuiSpacer, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@osd/i18n'; | ||
|
||
export const LEARN_OPENSEARCH_CONFIG = { | ||
title: i18n.translate('homepage.card.learnOpenSearch.title', { | ||
defaultMessage: 'Learn Opensearch', | ||
}), | ||
list: [ | ||
{ | ||
label: 'Quickstart guide', | ||
href: 'https://opensearch.org/docs/latest/dashboards/quickstart/', | ||
description: 'Get started in minutes with OpenSearch Dashboards', | ||
}, | ||
{ | ||
label: 'Building data visualizations', | ||
href: 'https://opensearch.org/docs/latest/dashboards/visualize/viz-index/', | ||
description: 'Design interactive charts and graphs to unlock insights form your data.', | ||
}, | ||
{ | ||
label: 'Creating dashboards', | ||
href: 'https://opensearch.org/docs/latest/dashboards/dashboard/index/', | ||
description: 'Build interactive dashboards to explore and analyze your data', | ||
}, | ||
], | ||
allLink: 'https://opensearch.org/docs/latest/', | ||
}; | ||
|
||
export const WHATS_NEW_CONFIG = { | ||
title: i18n.translate('homepage.card.whatsNew.title', { | ||
defaultMessage: `What's New`, | ||
}), | ||
list: [ | ||
{ | ||
label: 'Quickstart guide', | ||
href: 'https://opensearch.org/docs/latest/dashboards/quickstart/', | ||
description: 'Get started in minutes with OpenSearch Dashboards', | ||
}, | ||
], | ||
}; | ||
|
||
interface Config { | ||
title: string; | ||
list: Array<{ | ||
label: string; | ||
href: string; | ||
description: string; | ||
}>; | ||
allLink?: string; | ||
} | ||
|
||
export const HomeListCard = ({ config }: { config: Config }) => { | ||
return ( | ||
<> | ||
<EuiPanel paddingSize="s" hasBorder={false} hasShadow={false}> | ||
<EuiTitle> | ||
<h4>{config.title}</h4> | ||
</EuiTitle> | ||
<EuiSpacer /> | ||
{config.list.length > 0 && ( | ||
<EuiDescriptionList> | ||
{config.list.map((item) => ( | ||
<> | ||
<EuiDescriptionListTitle> | ||
<EuiLink href={item.href} target="_blank"> | ||
{item.label} | ||
</EuiLink> | ||
</EuiDescriptionListTitle> | ||
<EuiDescriptionListDescription>{item.description}</EuiDescriptionListDescription> | ||
</> | ||
))} | ||
</EuiDescriptionList> | ||
)} | ||
|
||
{config.allLink ? ( | ||
<> | ||
<EuiSpacer /> | ||
<EuiLink href={config.allLink} target="_blank"> | ||
<EuiText size="s" style={{ display: 'inline' }}> | ||
View all | ||
</EuiText> | ||
</EuiLink> | ||
</> | ||
) : null} | ||
</EuiPanel> | ||
</> | ||
); | ||
}; |
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