From 0f9c8ad900bae8c8a27ecd2f586ab82006352fd8 Mon Sep 17 00:00:00 2001 From: tygao Date: Thu, 29 Aug 2024 17:08:15 +0800 Subject: [PATCH 1/7] feat: update header description for dsm when in workspace Signed-off-by: tygao --- .../data_source_home_panel.tsx | 67 ++++++++++++------- .../acceleration_table.test.tsx.snap | 2 +- .../mount_management_section.tsx | 13 +++- .../data_source_management/public/types.ts | 2 + 4 files changed, 57 insertions(+), 27 deletions(-) diff --git a/src/plugins/data_source_management/public/components/data_source_home_panel/data_source_home_panel.tsx b/src/plugins/data_source_management/public/components/data_source_home_panel/data_source_home_panel.tsx index dfb3fc0ae188..918d85d8b2cc 100644 --- a/src/plugins/data_source_management/public/components/data_source_home_panel/data_source_home_panel.tsx +++ b/src/plugins/data_source_management/public/components/data_source_home_panel/data_source_home_panel.tsx @@ -14,11 +14,11 @@ import { EuiPageHeader, EuiPanel, EuiButtonGroup, - EuiText, - EuiLink, } from '@elastic/eui'; import { TopNavControlButtonData, TopNavControlComponentData } from 'src/plugins/navigation/public'; -import { FormattedMessage } from '@osd/i18n/react'; +import { i18n } from '@osd/i18n'; +import { useObservable } from 'react-use'; +import { of } from 'rxjs'; import { DataSourceHeader } from './data_source_page_header'; import { DataSourceTableWithRouter } from '../data_source_table/data_source_table'; import { ManageDirectQueryDataConnectionsTable } from '../direct_query_data_sources_components/direct_query_data_connection/manage_direct_query_data_connections_table'; @@ -26,6 +26,7 @@ import { CreateButton } from '../create_button'; import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public'; import { getListBreadcrumbs } from '../breadcrumbs'; import { DataSourceManagementContext } from '../../types'; +import { TopNavControlDescriptionData } from '../../../../navigation/public'; interface DataSourceHomePanelProps extends RouteComponentProps { featureFlagStatus: boolean; @@ -44,6 +45,7 @@ export const DataSourceHomePanel: React.FC = ({ savedObjects, uiSettings, application, + workspaces, docLinks, navigation, } = useOpenSearchDashboards().services; @@ -54,6 +56,7 @@ export const DataSourceHomePanel: React.FC = ({ const [selectedTabId, setSelectedTabId] = useState(defaultTabId); const canManageDataSource = !!application.capabilities?.dataSource?.canManage; const { HeaderControl } = navigation.ui; + const currentWorkspace = useObservable(workspaces ? workspaces.currentWorkspace$ : of(null)); useEffect(() => { setBreadcrumbs(getListBreadcrumbs()); @@ -63,27 +66,6 @@ export const DataSourceHomePanel: React.FC = ({ setSelectedTabId(id); }; - const description = [ - { - renderComponent: ( - - - - Learn more - - - ), - }, - ]; - const createDataSourceButton = [ { id: 'Create data source', @@ -156,7 +138,42 @@ export const DataSourceHomePanel: React.FC = ({ )} )} diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap index 088b43734609..69f5e6c63bbc 100644 --- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap +++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AccelerationTable Component matches snapshot 1`] = `"

Accelerations

Accelerations optimize query performance by indexing external data into OpenSearch.
Last updated at:
3/14/2024, 4:05:53 AM

Actions
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view_alt
Name
Status
Deleted
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_logs
Name
Status
Active
Type
skipping
Database
default
Table
http_logs
Refresh Type
Manual
Destination Index
-
Name
Status
Refreshing
Type
materialized
Database
other
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_other_http_count_view
"`; +exports[`AccelerationTable Component matches snapshot 1`] = `"

Accelerations

Accelerations optimize query performance by indexing external data into OpenSearch.
Last updated at:
2024/3/14 04:05:53

Actions
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view_alt
Name
Status
Deleted
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_logs
Name
Status
Active
Type
skipping
Database
default
Table
http_logs
Refresh Type
Manual
Destination Index
-
Name
Status
Refreshing
Type
materialized
Database
other
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_other_http_count_view
"`; diff --git a/src/plugins/data_source_management/public/management_app/mount_management_section.tsx b/src/plugins/data_source_management/public/management_app/mount_management_section.tsx index 545a76ec2736..e31f8e2eef17 100644 --- a/src/plugins/data_source_management/public/management_app/mount_management_section.tsx +++ b/src/plugins/data_source_management/public/management_app/mount_management_section.tsx @@ -36,7 +36,17 @@ export async function mountManagementSection( featureFlagStatus: boolean ) { const [ - { chrome, application, savedObjects, uiSettings, notifications, overlays, http, docLinks }, + { + chrome, + application, + savedObjects, + uiSettings, + notifications, + overlays, + http, + docLinks, + workspaces, + }, { navigation }, ] = await getStartServices(); @@ -52,6 +62,7 @@ export async function mountManagementSection( navigation, setBreadcrumbs: params.setBreadcrumbs, authenticationMethodRegistry: authMethodsRegistry, + workspaces, }; const canManageDataSource = !!application.capabilities?.dataSource?.canManage; diff --git a/src/plugins/data_source_management/public/types.ts b/src/plugins/data_source_management/public/types.ts index dc3c54505acc..2a54f67aea5d 100644 --- a/src/plugins/data_source_management/public/types.ts +++ b/src/plugins/data_source_management/public/types.ts @@ -12,6 +12,7 @@ import { NotificationsStart, DocLinksStart, HttpSetup, + WorkspacesStart, } from 'src/core/public'; import { ManagementAppMountParams } from 'src/plugins/management/public'; import { i18n } from '@osd/i18n'; @@ -37,6 +38,7 @@ export interface DataSourceManagementContext { navigation: NavigationPublicPluginStart; setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs']; authenticationMethodRegistry: AuthenticationMethodRegistry; + workspaces: WorkspacesStart; } export interface DataSourceTableItem { From 584160f9edbe8b01914b27c9646ebd774d0ebfd2 Mon Sep 17 00:00:00 2001 From: "opensearch-changeset-bot[bot]" <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Date: Fri, 30 Aug 2024 08:23:34 +0000 Subject: [PATCH 2/7] Changeset file for PR #7916 created/updated --- changelogs/fragments/7916.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/7916.yml diff --git a/changelogs/fragments/7916.yml b/changelogs/fragments/7916.yml new file mode 100644 index 000000000000..fff0da1eb6e9 --- /dev/null +++ b/changelogs/fragments/7916.yml @@ -0,0 +1,2 @@ +refactor: +- Update header description for data source management ([#7916](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7916)) \ No newline at end of file From 0a3c56eb16dd666465fa1d2cc095468d56f4997a Mon Sep 17 00:00:00 2001 From: "opensearch-changeset-bot[bot]" <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Date: Fri, 30 Aug 2024 08:24:13 +0000 Subject: [PATCH 3/7] Changeset file for PR #7916 created/updated --- changelogs/fragments/7916.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/7916.yml b/changelogs/fragments/7916.yml index fff0da1eb6e9..03fd121e878c 100644 --- a/changelogs/fragments/7916.yml +++ b/changelogs/fragments/7916.yml @@ -1,2 +1,2 @@ refactor: -- Update header description for data source management ([#7916](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7916)) \ No newline at end of file +- Update header for data source management when in workspace ([#7916](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7916)) \ No newline at end of file From 616a5a2880fa1d5d40f59c14e9df02d2399b7352 Mon Sep 17 00:00:00 2001 From: tygao Date: Fri, 30 Aug 2024 17:51:41 +0800 Subject: [PATCH 4/7] test: update snapshots Signed-off-by: tygao --- .../__snapshots__/acceleration_table.test.tsx.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap index 69f5e6c63bbc..f5eea2cb2c2b 100644 --- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap +++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AccelerationTable Component matches snapshot 1`] = `"

Accelerations

Accelerations optimize query performance by indexing external data into OpenSearch.
Last updated at:
2024/3/14 04:05:53

Actions
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view_alt
Name
Status
Deleted
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_logs
Name
Status
Active
Type
skipping
Database
default
Table
http_logs
Refresh Type
Manual
Destination Index
-
Name
Status
Refreshing
Type
materialized
Database
other
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_other_http_count_view
"`; +exports[`AccelerationTable Component matches snapshot 1`] = `"

Accelerations

Accelerations optimize query performance by indexing external data into OpenSearch.
Last updated at:
3/14/2024, 4:05:53 AM

Actions
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view_alt
Name
Status
Deleted
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_logs
Name
Status
Active
Type
skipping
Database
default
Table
http_logs
Refresh Type
Manual
Destination Index
-
Name
Status
Refreshing
Type
materialized
Database
other
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_other_http_count_view
"`; From 496ca7ef88c4caf82d5936cd968c5d6d3f411fdd Mon Sep 17 00:00:00 2001 From: tygao Date: Fri, 30 Aug 2024 18:32:14 +0800 Subject: [PATCH 5/7] test: recover snapshot Signed-off-by: tygao --- .../__snapshots__/acceleration_table.test.tsx.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap index f5eea2cb2c2b..43b456594a14 100644 --- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap +++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AccelerationTable Component matches snapshot 1`] = `"

Accelerations

Accelerations optimize query performance by indexing external data into OpenSearch.
Last updated at:
3/14/2024, 4:05:53 AM

Actions
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view_alt
Name
Status
Deleted
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_logs
Name
Status
Active
Type
skipping
Database
default
Table
http_logs
Refresh Type
Manual
Destination Index
-
Name
Status
Refreshing
Type
materialized
Database
other
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_other_http_count_view
"`; +exports[`AccelerationTable Component matches snapshot 1`] = `"

Accelerations

Accelerations optimize query performance by indexing external data into OpenSearch.
Last updated at:
3/14/2024, 4:05:53 AM

Actions
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view_alt
Name
Status
Deleted
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_logs
Name
Status
Active
Type
skipping
Database
default
Table
http_logs
Refresh Type
Manual
Destination Index
-
Name
Status
Refreshing
Type
materialized
Database
other
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_other_http_count_view
"`; From ad769f6d497ff6218e898e3af6fe7b13f6151693 Mon Sep 17 00:00:00 2001 From: tygao Date: Fri, 30 Aug 2024 19:05:44 +0800 Subject: [PATCH 6/7] test: commit transpiled snapshot Signed-off-by: tygao --- .../__snapshots__/acceleration_table.test.tsx.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap index 43b456594a14..f5eea2cb2c2b 100644 --- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap +++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AccelerationTable Component matches snapshot 1`] = `"

Accelerations

Accelerations optimize query performance by indexing external data into OpenSearch.
Last updated at:
3/14/2024, 4:05:53 AM

Actions
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view_alt
Name
Status
Deleted
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_logs
Name
Status
Active
Type
skipping
Database
default
Table
http_logs
Refresh Type
Manual
Destination Index
-
Name
Status
Refreshing
Type
materialized
Database
other
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_other_http_count_view
"`; +exports[`AccelerationTable Component matches snapshot 1`] = `"

Accelerations

Accelerations optimize query performance by indexing external data into OpenSearch.
Last updated at:
3/14/2024, 4:05:53 AM

Actions
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view_alt
Name
Status
Deleted
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_logs
Name
Status
Active
Type
skipping
Database
default
Table
http_logs
Refresh Type
Manual
Destination Index
-
Name
Status
Refreshing
Type
materialized
Database
other
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_other_http_count_view
"`; From 570107acb795a5e7cb8f5e3c819d1ed46247e864 Mon Sep 17 00:00:00 2001 From: tygao Date: Fri, 30 Aug 2024 20:34:01 +0800 Subject: [PATCH 7/7] test: update render method in test to avoid the slash in snapshot content is translated which causes the comparison to fail in CI env Signed-off-by: tygao --- .../acceleration_table.test.tsx.snap | 345 +++++++++++++++++- .../acceleration_table.test.tsx | 16 +- 2 files changed, 350 insertions(+), 11 deletions(-) diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap index f5eea2cb2c2b..29ee4665d5dc 100644 --- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap +++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/__snapshots__/acceleration_table.test.tsx.snap @@ -1,3 +1,346 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AccelerationTable Component matches snapshot 1`] = `"

Accelerations

Accelerations optimize query performance by indexing external data into OpenSearch.
Last updated at:
3/14/2024, 4:05:53 AM

Actions
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view
Name
Status
Refreshing
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_count_view_alt
Name
Status
Deleted
Type
materialized
Database
default
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_default_http_logs
Name
Status
Active
Type
skipping
Database
default
Table
http_logs
Refresh Type
Manual
Destination Index
-
Name
Status
Refreshing
Type
materialized
Database
other
Table
-
Refresh Type
Auto refresh
Destination Index
flint_mys3_other_http_count_view
"`; +exports[`AccelerationTable Component render result matches snapshot 1`] = ` +Array [ +
, +
+
+
+
+

+ Accelerations +

+ Accelerations optimize query performance by indexing external data into OpenSearch. +
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + Actions + + +
+
+ + No items found + +
+
+
+
+
, +] +`; diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/acceleration_table.test.tsx b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/acceleration_table.test.tsx index 70da8e25def1..c345e74116fe 100644 --- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/acceleration_table.test.tsx +++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_management/acceleration_table.test.tsx @@ -4,7 +4,7 @@ */ import React from 'react'; -import { mount, configure } from 'enzyme'; +import { mount, configure, render } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; import { EuiLoadingSpinner } from '@elastic/eui'; import { AccelerationTable } from './acceleration_table'; @@ -180,18 +180,14 @@ describe('AccelerationTable Component', () => { expect(wrapper!.text()).toContain(expectedLocalizedTime); }); - it('matches snapshot', async () => { - let wrapper: ReactWrapper; - await act(async () => { - wrapper = mount( + it('render result matches snapshot', async () => { + expect( + render( - ); - }); - wrapper!.update(); - - expect(wrapper!.html()).toMatchSnapshot(); + ) + ).toMatchSnapshot(); }); });