[v9.4.x] CommandPalette: Move quick add actions to top level (#63049)

CommandPalette: Move quick add actions to top level (#62900)

* Move quick actions to top level

* Change quick action verb to "Create"

* create to 'new'

* fix comment

* update translations

* undo changing alerting

(cherry picked from commit 5564b93e2f)

Co-authored-by: Josh Hunt <joshhunt@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2023-02-07 16:21:49 +00:00
committed by GitHub
co-authored by Josh Hunt
parent 63f1d95ed6
commit 3c7cfecf50
5 changed files with 17 additions and 18 deletions
@@ -5,11 +5,8 @@
import { config } from '@grafana/runtime'; import { config } from '@grafana/runtime';
import { t } from 'app/core/internationalization'; import { t } from 'app/core/internationalization';
// The keys of the TRANSLATED_MENU_ITEMS object (NOT the id inside the defineMessage function)
// must match the ID of the navigation item, as defined in the backend nav model
// see pkg/api/index.go
export function getNavTitle(navId: string | undefined) { export function getNavTitle(navId: string | undefined) {
// the switch cases must match the ID of the navigation item, as defined in the backend nav model
switch (navId) { switch (navId) {
case 'home': case 'home':
return t('nav.home.title', 'Home'); return t('nav.home.title', 'Home');
@@ -24,7 +21,7 @@ export function getNavTitle(navId: string | undefined) {
case 'import': case 'import':
return t('nav.create-import.title', 'Import'); return t('nav.create-import.title', 'Import');
case 'alert': case 'alert':
return t('nav.create-alert.title', 'New alert rule'); return t('nav.create-alert.title', 'Create alert rule');
case 'starred': case 'starred':
return t('nav.starred.title', 'Starred'); return t('nav.starred.title', 'Starred');
case 'starred-empty': case 'starred-empty':
@@ -4,10 +4,7 @@ import { t } from 'app/core/internationalization';
import { changeTheme } from 'app/core/services/theme'; import { changeTheme } from 'app/core/services/theme';
import { CommandPaletteAction } from '../types'; import { CommandPaletteAction } from '../types';
import { DEFAULT_PRIORITY, PREFERENCES_PRIORITY } from '../values'; import { ACTIONS_PRIORITY, DEFAULT_PRIORITY, PREFERENCES_PRIORITY } from '../values';
// We reuse this, but translations cannot be in module scope (t must be called after i18n has set up,)
const getPagesSectionTranslation = () => t('command-palette.section.pages', 'Pages');
// TODO: Clean this once ID is mandatory on nav items // TODO: Clean this once ID is mandatory on nav items
function idForNavItem(navItem: NavModelItem) { function idForNavItem(navItem: NavModelItem) {
@@ -25,15 +22,19 @@ function navTreeToActions(navTree: NavModelItem[], parent?: NavModelItem): Comma
continue; continue;
} }
const section = isCreateAction ? t('command-palette.section.actions', 'Actions') : getPagesSectionTranslation(); const section = isCreateAction
? t('command-palette.section.actions', 'Actions')
: t('command-palette.section.pages', 'Pages');
const priority = isCreateAction ? ACTIONS_PRIORITY : DEFAULT_PRIORITY;
const action = { const action = {
id: idForNavItem(navItem), id: idForNavItem(navItem),
name: text, // TODO: translate name: text, // TODO: translate
section: section, section: section,
url: url && locationUtil.stripBaseFromUrl(url), url: url && locationUtil.stripBaseFromUrl(url),
parent: parent && idForNavItem(parent), parent: parent && !isCreateAction && idForNavItem(parent),
priority: DEFAULT_PRIORITY, priority: priority,
}; };
navActions.push(action); navActions.push(action);
+2 -1
View File
@@ -1,4 +1,5 @@
export const RECENT_DASHBOARDS_PRORITY = 4; export const RECENT_DASHBOARDS_PRORITY = 5;
export const ACTIONS_PRIORITY = 4;
export const DEFAULT_PRIORITY = 3; export const DEFAULT_PRIORITY = 3;
export const PREFERENCES_PRIORITY = 2; export const PREFERENCES_PRIORITY = 2;
export const SEARCH_RESULTS_PRORITY = 1; // Dynamic actions should be below static ones so the list doesn't 'jump' when they come in export const SEARCH_RESULTS_PRORITY = 1; // Dynamic actions should be below static ones so the list doesn't 'jump' when they come in
+2 -2
View File
@@ -13,7 +13,7 @@
"search": "Search" "search": "Search"
}, },
"search-box": { "search-box": {
"placeholder": "Search Grafana" "placeholder": "Search or jump to..."
}, },
"section": { "section": {
"actions": "Actions", "actions": "Actions",
@@ -160,7 +160,7 @@
"title": "Alert rules" "title": "Alert rules"
}, },
"alerting-receivers": { "alerting-receivers": {
"subtitle": "Choose how to notify your contact points when an alert instance fires", "subtitle": "Choose how to notify your contact points when an alert instance fires",
"title": "Contact points" "title": "Contact points"
}, },
"alerting-silences": { "alerting-silences": {
+3 -3
View File
@@ -13,7 +13,7 @@
"search": "Ŝęäřčĥ" "search": "Ŝęäřčĥ"
}, },
"search-box": { "search-box": {
"placeholder": "Ŝęäřčĥ Ğřäƒäʼnä" "placeholder": "Ŝęäřčĥ őř ĵūmp ŧő..."
}, },
"section": { "section": {
"actions": "Åčŧįőʼnş", "actions": "Åčŧįőʼnş",
@@ -160,7 +160,7 @@
"title": "Åľęřŧ řūľęş" "title": "Åľęřŧ řūľęş"
}, },
"alerting-receivers": { "alerting-receivers": {
"subtitle": "Đęčįđę ĥőŵ yőūř čőʼnŧäčŧş äřę ʼnőŧįƒįęđ ŵĥęʼn äʼn äľęřŧ ƒįřęş", "subtitle": "Cĥőőşę ĥőŵ ŧő ʼnőŧįƒy yőūř čőʼnŧäčŧ pőįʼnŧş ŵĥęʼn äʼn äľęřŧ įʼnşŧäʼnčę ƒįřęş",
"title": "Cőʼnŧäčŧ pőįʼnŧş" "title": "Cőʼnŧäčŧ pőįʼnŧş"
}, },
"alerting-silences": { "alerting-silences": {
@@ -191,7 +191,7 @@
"title": "Cřęäŧę" "title": "Cřęäŧę"
}, },
"create-alert": { "create-alert": {
"title": "Ńęŵ äľęřŧ řūľę" "title": "Cřęäŧę äľęřŧ řūľę"
}, },
"create-dashboard": { "create-dashboard": {
"title": "Đäşĥþőäřđ" "title": "Đäşĥþőäřđ"