mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
NestedFolders: Button for creating new dashboards and and folders (#67260)
* Add CreateNewButton and tests * Add translation support * Move reused phrases to temp common file * Use just a simple button --------- Co-authored-by: joshhunt <josh@trtr.co>
This commit is contained in:
@@ -2,10 +2,10 @@ import React, { useMemo, useState } from 'react';
|
||||
|
||||
import { config, reportInteraction } from '@grafana/runtime';
|
||||
import { Menu, Dropdown, Button, Icon, HorizontalGroup } from '@grafana/ui';
|
||||
import { t } from 'app/core/internationalization';
|
||||
import { FolderDTO } from 'app/types';
|
||||
|
||||
import { MoveToFolderModal } from '../page/components/MoveToFolderModal';
|
||||
import { getImportPhrase, getNewDashboardPhrase, getNewFolderPhrase, getNewPhrase } from '../tempI18nPhrases';
|
||||
|
||||
export interface Props {
|
||||
folder: FolderDTO | undefined;
|
||||
@@ -43,7 +43,7 @@ export const DashboardActions = ({ folder, canCreateFolders = false, canCreateDa
|
||||
{canCreateDashboards && (
|
||||
<Menu.Item
|
||||
url={actionUrl('new')}
|
||||
label={t('search.dashboard-actions.new-dashboard', 'New Dashboard')}
|
||||
label={getNewDashboardPhrase()}
|
||||
onClick={() =>
|
||||
reportInteraction('grafana_menu_item_clicked', { url: actionUrl('new'), from: '/dashboards' })
|
||||
}
|
||||
@@ -52,7 +52,7 @@ export const DashboardActions = ({ folder, canCreateFolders = false, canCreateDa
|
||||
{canCreateFolders && (config.featureToggles.nestedFolders || !folder?.uid) && (
|
||||
<Menu.Item
|
||||
url={actionUrl('new_folder')}
|
||||
label={t('search.dashboard-actions.new-folder', 'New Folder')}
|
||||
label={getNewFolderPhrase()}
|
||||
onClick={() =>
|
||||
reportInteraction('grafana_menu_item_clicked', { url: actionUrl('new_folder'), from: '/dashboards' })
|
||||
}
|
||||
@@ -61,7 +61,7 @@ export const DashboardActions = ({ folder, canCreateFolders = false, canCreateDa
|
||||
{canCreateDashboards && (
|
||||
<Menu.Item
|
||||
url={actionUrl('import')}
|
||||
label={t('search.dashboard-actions.import', 'Import')}
|
||||
label={getImportPhrase()}
|
||||
onClick={() =>
|
||||
reportInteraction('grafana_menu_item_clicked', { url: actionUrl('import'), from: '/dashboards' })
|
||||
}
|
||||
@@ -82,7 +82,7 @@ export const DashboardActions = ({ folder, canCreateFolders = false, canCreateDa
|
||||
)}
|
||||
<Dropdown overlay={MenuActions} placement="bottom-start">
|
||||
<Button variant="primary">
|
||||
{t('search.dashboard-actions.new', 'New')}
|
||||
{getNewPhrase()}
|
||||
<Icon name="angle-down" />
|
||||
</Button>
|
||||
</Dropdown>
|
||||
|
||||
@@ -8,3 +8,19 @@ export function getSearchPlaceholder(includePanels = false) {
|
||||
? t('search.search-input.include-panels-placeholder', 'Search for dashboards, folders, and panels')
|
||||
: t('search.search-input.placeholder', 'Search for dashboards and folders');
|
||||
}
|
||||
|
||||
export function getNewDashboardPhrase() {
|
||||
return t('search.dashboard-actions.new-dashboard', 'New Dashboard');
|
||||
}
|
||||
|
||||
export function getNewFolderPhrase() {
|
||||
return t('search.dashboard-actions.new-folder', 'New Folder');
|
||||
}
|
||||
|
||||
export function getImportPhrase() {
|
||||
return t('search.dashboard-actions.import', 'Import');
|
||||
}
|
||||
|
||||
export function getNewPhrase() {
|
||||
return t('search.dashboard-actions.new', 'New');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user