mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 02:23:31 -06:00
* Fix: PageHeader & PageHeaderTabs & NavBarItem & DashboardActions & PanelMenu is displayed in default_language (#60719) * I18N: update strings (#60719) Co-authored-by: TaitChan <1441645821@qq.coom>
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import React, { FC } from 'react';
|
|
|
|
import { config } from '@grafana/runtime';
|
|
import { Menu, Dropdown, Button, Icon } from '@grafana/ui';
|
|
import { t } from 'app/core/internationalization';
|
|
|
|
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={t('search.dashboard-actions.new-dashboard', 'New Dashboard')} />
|
|
)}
|
|
{canCreateFolders && (config.featureToggles.nestedFolders || !folderUid) && (
|
|
<Menu.Item url={actionUrl('new_folder')} label={t('search.dashboard-actions.new-folder', 'New Folder')} />
|
|
)}
|
|
{canCreateDashboards && (
|
|
<Menu.Item url={actionUrl('import')} label={t('search.dashboard-actions.import', 'Import')} />
|
|
)}
|
|
</Menu>
|
|
);
|
|
};
|
|
|
|
return (
|
|
<div>
|
|
<Dropdown overlay={MenuActions} placement="bottom-start">
|
|
<Button variant="primary">
|
|
{t('search.dashboard-actions.new', 'New')}
|
|
<Icon name="angle-down" />
|
|
</Button>
|
|
</Dropdown>
|
|
</div>
|
|
);
|
|
};
|