mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 02:23:31 -06:00
* added post installation steps. * changes according to feedback. * removing return union null type. * added tests. * changing the wording of the button to 'create a..' * updated tests to check for the updated copy. * changing the back to be a regular back button. * updated snapshot
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import React, { FC } from 'react';
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
|
|
import { Button, LinkButton } from '@grafana/ui';
|
|
|
|
import { AccessControlAction } from 'app/types/';
|
|
import { contextSrv } from 'app/core/core';
|
|
|
|
export interface Props {
|
|
exploreUrl: string;
|
|
isReadOnly: boolean;
|
|
onDelete: () => void;
|
|
onSubmit: (event: any) => void;
|
|
onTest: (event: any) => void;
|
|
}
|
|
|
|
const ButtonRow: FC<Props> = ({ isReadOnly, onDelete, onSubmit, onTest, exploreUrl }) => {
|
|
const canEditDataSources = !isReadOnly && contextSrv.hasPermission(AccessControlAction.DataSourcesWrite);
|
|
const canDeleteDataSources = !isReadOnly && contextSrv.hasPermission(AccessControlAction.DataSourcesDelete);
|
|
const canExploreDataSources = contextSrv.hasPermission(AccessControlAction.DataSourcesExplore);
|
|
|
|
return (
|
|
<div className="gf-form-button-row">
|
|
<Button variant="secondary" fill="solid" type="button" onClick={() => history.back()}>
|
|
Back
|
|
</Button>
|
|
<LinkButton variant="secondary" fill="solid" href={exploreUrl} disabled={!canExploreDataSources}>
|
|
Explore
|
|
</LinkButton>
|
|
<Button
|
|
type="button"
|
|
variant="destructive"
|
|
disabled={!canDeleteDataSources}
|
|
onClick={onDelete}
|
|
aria-label={selectors.pages.DataSource.delete}
|
|
>
|
|
Delete
|
|
</Button>
|
|
{canEditDataSources && (
|
|
<Button
|
|
type="submit"
|
|
variant="primary"
|
|
disabled={!canEditDataSources}
|
|
onClick={(event) => onSubmit(event)}
|
|
aria-label={selectors.pages.DataSource.saveAndTest}
|
|
>
|
|
Save & test
|
|
</Button>
|
|
)}
|
|
{!canEditDataSources && (
|
|
<Button type="submit" variant="primary" onClick={onTest}>
|
|
Test
|
|
</Button>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default ButtonRow;
|