mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
* refactor(PluginDetails): use react-router hooks instead of props * Wip * refactor: remove unnecessary constant * feat: use the original plugin details page under connections * chore: use better wording in the not-found warning Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com> * chore: use the renderer utility everywhere in the test * chore: don't show a title while loading a plugin Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import * as React from 'react';
|
|
import { useParams } from 'react-router-dom';
|
|
|
|
import { Alert, Badge } from '@grafana/ui';
|
|
import { PluginDetailsPage } from 'app/features/plugins/admin/components/PluginDetailsPage';
|
|
import { StoreState, useSelector, AppNotificationSeverity } from 'app/types';
|
|
|
|
import { ROUTES } from '../constants';
|
|
|
|
export function DataSourceDetailsPage() {
|
|
const overrideNavId = 'standalone-plugin-page-/connections/connect-data';
|
|
const { id } = useParams<{ id: string }>();
|
|
const navIndex = useSelector((state: StoreState) => state.navIndex);
|
|
const isConnectDataPageOverriden = Boolean(navIndex[overrideNavId]);
|
|
const navId = isConnectDataPageOverriden ? overrideNavId : 'connections-connect-data'; // The nav id changes (gets a prefix) if it is overriden by a plugin
|
|
|
|
return (
|
|
<PluginDetailsPage
|
|
pluginId={id}
|
|
navId={navId}
|
|
notFoundComponent={<NotFoundDatasource />}
|
|
notFoundNavModel={{
|
|
text: 'Unknown datasource',
|
|
subTitle: 'No datasource with this ID could be found.',
|
|
active: true,
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
|
|
function NotFoundDatasource() {
|
|
const { id } = useParams<{ id: string }>();
|
|
|
|
return (
|
|
<Alert severity={AppNotificationSeverity.Warning} title="">
|
|
Maybe you mistyped the URL or the plugin with the id <Badge text={id} color="orange" /> is unavailable.
|
|
<br />
|
|
To see a list of available datasources please <a href={ROUTES.ConnectData}>click here</a>.
|
|
</Alert>
|
|
);
|
|
}
|