DatasourceList: Fixes using sub path on datasources URL (#59597)

This commit is contained in:
Joao Silva 2022-12-21 14:21:04 +01:00 committed by GitHub
parent 70dd5b42ce
commit bf541ee3d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -1,5 +1,6 @@
import React from 'react';
import { config } from '@grafana/runtime';
import { LinkButton } from '@grafana/ui';
import { contextSrv } from 'app/core/core';
import { AccessControlAction } from 'app/types';
@ -11,7 +12,7 @@ export function DataSourceAddButton(): JSX.Element | null {
const dataSourcesRoutes = useDataSourcesRoutes();
return canCreateDataSource ? (
<LinkButton icon="plus" href={dataSourcesRoutes.New}>
<LinkButton icon="plus" href={config.appSubUrl + dataSourcesRoutes.New}>
Add new data source
</LinkButton>
) : null;

View File

@ -2,6 +2,7 @@ import { css } from '@emotion/css';
import React from 'react';
import { DataSourceSettings, GrafanaTheme2 } from '@grafana/data';
import { config } from '@grafana/runtime';
import { LinkButton, Card, Tag, useStyles2 } from '@grafana/ui';
import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA';
import PageLoader from 'app/core/components/PageLoader/PageLoader';
@ -71,9 +72,10 @@ export function DataSourcesListView({ dataSources, dataSourcesCount, isLoading,
{/* List */}
<ul className={styles.list}>
{dataSources.map((dataSource) => {
const dsLink = config.appSubUrl + dataSourcesRoutes.Edit.replace(/:uid/gi, dataSource.uid);
return (
<li key={dataSource.uid}>
<Card href={dataSourcesRoutes.Edit.replace(/:uid/gi, dataSource.uid)}>
<Card href={dsLink}>
<Card.Heading>{dataSource.name}</Card.Heading>
<Card.Figure>
<img src={dataSource.typeLogoUrl} alt="" height="40px" width="40px" className={styles.logo} />
@ -86,7 +88,7 @@ export function DataSourcesListView({ dataSources, dataSourcesCount, isLoading,
]}
</Card.Meta>
<Card.Tags>
<LinkButton icon="apps" fill="outline" variant="secondary" href="/dashboard/new">
<LinkButton icon="apps" fill="outline" variant="secondary" href={config.appSubUrl + '/dashboard/new'}>
Build a Dashboard
</LinkButton>
{canExploreDataSources && (