Skip to content

Commit

Permalink
Merge branch 'main' into feat-redirect-use-case-landing-after-workspa…
Browse files Browse the repository at this point in the history
…ce-create
  • Loading branch information
SuZhou-Joe authored Sep 2, 2024
2 parents 401d41e + 976c567 commit 3e65c96
Show file tree
Hide file tree
Showing 8 changed files with 411 additions and 40 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7916.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
refactor:
- Update header for data source management when in workspace ([#7916](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7916))
2 changes: 2 additions & 0 deletions changelogs/fragments/7954.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- [Workspace]dynamicConfigServiceMock not found in workspace routes UT ([#7954](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7954))
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@ 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';
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;
Expand All @@ -44,6 +45,7 @@ export const DataSourceHomePanel: React.FC<DataSourceHomePanelProps> = ({
savedObjects,
uiSettings,
application,
workspaces,
docLinks,
navigation,
} = useOpenSearchDashboards<DataSourceManagementContext>().services;
Expand All @@ -54,6 +56,7 @@ export const DataSourceHomePanel: React.FC<DataSourceHomePanelProps> = ({
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());
Expand All @@ -63,27 +66,6 @@ export const DataSourceHomePanel: React.FC<DataSourceHomePanelProps> = ({
setSelectedTabId(id);
};

const description = [
{
renderComponent: (
<EuiText size="s" color="subdued">
<FormattedMessage
id="dataSourcesManagement.dataSourcesTable.description"
defaultMessage="Create and manage data source connections. "
/>
<EuiLink
external={true}
href={docLinks.links.opensearchDashboards.dataSource.guide}
target="_blank"
className="external-link-inline-block"
>
Learn more
</EuiLink>
</EuiText>
),
},
];

const createDataSourceButton = [
{
id: 'Create data source',
Expand Down Expand Up @@ -156,7 +138,42 @@ export const DataSourceHomePanel: React.FC<DataSourceHomePanelProps> = ({
)}
<HeaderControl
setMountPoint={application.setAppDescriptionControls}
controls={description}
controls={[
currentWorkspace?.name
? {
description: i18n.translate(
'dataSourcesManagement.dataSourcesTable.workspace.description',
{
defaultMessage: 'View associated data sources for {name}.',
values: {
name: currentWorkspace.name,
},
}
),
}
: ({
description: i18n.translate(
'dataSourcesManagement.dataSourcesTable.description',
{
defaultMessage: 'Create and manage data source connections.',
}
),
links: [
{
href: docLinks.links.opensearchDashboards.dataSource.guide,
controlType: 'link',
target: '_blank',
className: 'external-link-inline-block',
label: i18n.translate(
'dataSourcesManagement.dataSourcesTable.documentation',
{
defaultMessage: 'Learn more',
}
),
},
],
} as TopNavControlDescriptionData),
]}
/>
</>
)}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
<AccelerationTable
dataSourceName="testDataSource"
cacheLoadingHooks={mockCacheLoadingHooks}
/>
);
});
wrapper!.update();

expect(wrapper!.html()).toMatchSnapshot();
)
).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -52,6 +62,7 @@ export async function mountManagementSection(
navigation,
setBreadcrumbs: params.setBreadcrumbs,
authenticationMethodRegistry: authMethodsRegistry,
workspaces,
};

const canManageDataSource = !!application.capabilities?.dataSource?.canManage;
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data_source_management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -37,6 +38,7 @@ export interface DataSourceManagementContext {
navigation: NavigationPublicPluginStart;
setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs'];
authenticationMethodRegistry: AuthenticationMethodRegistry;
workspaces: WorkspacesStart;
}

export interface DataSourceTableItem {
Expand Down
4 changes: 1 addition & 3 deletions src/plugins/workspace/server/routes/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import supertest from 'supertest';
import { UnwrapPromise } from '@osd/utility-types';

import { setupServer } from '../../../../core/server/test_utils';
import { loggingSystemMock } from '../../../../core/server/mocks';
// eslint-disable-next-line @osd/eslint/no-restricted-paths
import { dynamicConfigServiceMock } from '../../../../core/server/config';
import { loggingSystemMock, dynamicConfigServiceMock } from '../../../../core/server/mocks';

import { workspaceClientMock } from '../workspace_client.mock';

Expand Down

0 comments on commit 3e65c96

Please sign in to comment.