The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/search/components/DashboardActions.tsx

50 lines
1.3 KiB

import React, { FC } from 'react';
import { config } from '@grafana/runtime';
import { Menu, Dropdown, Button, Icon } from '@grafana/ui';
export interface Props {
folderUid?: string;
canCreateFolders?: boolean;
canCreateDashboards?: boolean;
}
export const DashboardActions: FC<Props> = ({ folderUid, canCreateFolders = false, canCreateDashboards = false }) => {
const actionUrl = (type: string) => {
let url = `dashboard/${type}`;
const isTypeNewFolder = type === 'new_folder';
if (isTypeNewFolder) {
url = `dashboards/folder/new/`;
}
if (folderUid) {
url += `?folderUid=${folderUid}`;
}
return url;
};
const MenuActions = () => {
return (
<Menu>
{canCreateDashboards && <Menu.Item url={actionUrl('new')} label="New Dashboard" />}
{canCreateFolders && (config.featureToggles.nestedFolders || !folderUid) && (
<Menu.Item url={actionUrl('new_folder')} label="New Folder" />
)}
{canCreateDashboards && <Menu.Item url={actionUrl('import')} label="Import" />}
</Menu>
);
};
return (
<div>
<Dropdown overlay={MenuActions} placement="bottom-start">
<Button variant="primary">
New
<Icon name="angle-down" />
</Button>
</Dropdown>
</div>
);
};