mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 15:59:23 +08:00

* ref: ds picker events added * ref: track opendropdown only on click * ref: update/update all payload added to the event * ref: configure more ds button event path to from path * ref: result count fix, enable/disable track * ref: debounce search tracks * ref: track connections_plugin_card_clicked * ref: call tracking from the child comp with result count * ref: change event names, add creator_team and schema version
24 lines
905 B
TypeScript
24 lines
905 B
TypeScript
import { useCallback } from 'react';
|
|
|
|
import { config } from '@grafana/runtime';
|
|
import { LinkButton } from '@grafana/ui';
|
|
import { contextSrv } from 'app/core/core';
|
|
import { Trans } from 'app/core/internationalization';
|
|
import { ROUTES } from 'app/features/connections/constants';
|
|
import { AccessControlAction } from 'app/types';
|
|
|
|
import { trackAddNewDsClicked } from '../tracking';
|
|
|
|
export function DataSourceAddButton(): JSX.Element | null {
|
|
const canCreateDataSource = contextSrv.hasPermission(AccessControlAction.DataSourcesCreate);
|
|
const handleClick = useCallback(() => {
|
|
trackAddNewDsClicked({ path: location.pathname });
|
|
}, []);
|
|
|
|
return canCreateDataSource ? (
|
|
<LinkButton icon="plus" href={config.appSubUrl + ROUTES.DataSourcesNew} onClick={handleClick}>
|
|
<Trans i18nKey="data-sources.datasource-add-button.label">Add new data source</Trans>
|
|
</LinkButton>
|
|
) : null;
|
|
}
|