Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] refactor: update header description for data source management when in workspace #7956

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
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
Loading