diff --git a/changelogs/fragments/7916.yml b/changelogs/fragments/7916.yml new file mode 100644 index 000000000000..03fd121e878c --- /dev/null +++ b/changelogs/fragments/7916.yml @@ -0,0 +1,2 @@ +refactor: +- 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 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..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(); }); }); 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 {