From 5564b93e2f1482fd717cc6edcc7f2443ba472a71 Mon Sep 17 00:00:00 2001 From: Josh Hunt Date: Tue, 7 Feb 2023 16:10:43 +0000 Subject: [PATCH] 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 --- .../components/NavBar/navBarItem-translations.ts | 7 ++----- .../commandPalette/actions/staticActions.ts | 15 ++++++++------- public/app/features/commandPalette/values.ts | 3 ++- public/locales/en-US/grafana.json | 4 ++-- public/locales/pseudo-LOCALE/grafana.json | 6 +++--- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/public/app/core/components/NavBar/navBarItem-translations.ts b/public/app/core/components/NavBar/navBarItem-translations.ts index 30e2dfac8e3..c6fc386dce6 100644 --- a/public/app/core/components/NavBar/navBarItem-translations.ts +++ b/public/app/core/components/NavBar/navBarItem-translations.ts @@ -5,11 +5,8 @@ import { config } from '@grafana/runtime'; 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) { + // the switch cases must match the ID of the navigation item, as defined in the backend nav model switch (navId) { case 'home': return t('nav.home.title', 'Home'); @@ -24,7 +21,7 @@ export function getNavTitle(navId: string | undefined) { case 'import': return t('nav.create-import.title', 'Import'); case 'alert': - return t('nav.create-alert.title', 'New alert rule'); + return t('nav.create-alert.title', 'Create alert rule'); case 'starred': return t('nav.starred.title', 'Starred'); case 'starred-empty': diff --git a/public/app/features/commandPalette/actions/staticActions.ts b/public/app/features/commandPalette/actions/staticActions.ts index 0914c5d4435..a973e239111 100644 --- a/public/app/features/commandPalette/actions/staticActions.ts +++ b/public/app/features/commandPalette/actions/staticActions.ts @@ -4,10 +4,7 @@ import { t } from 'app/core/internationalization'; import { changeTheme } from 'app/core/services/theme'; import { CommandPaletteAction } from '../types'; -import { 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'); +import { ACTIONS_PRIORITY, DEFAULT_PRIORITY, PREFERENCES_PRIORITY } from '../values'; // TODO: Clean this once ID is mandatory on nav items function idForNavItem(navItem: NavModelItem) { @@ -25,15 +22,19 @@ function navTreeToActions(navTree: NavModelItem[], parent?: NavModelItem): Comma 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 = { id: idForNavItem(navItem), name: text, // TODO: translate section: section, url: url && locationUtil.stripBaseFromUrl(url), - parent: parent && idForNavItem(parent), - priority: DEFAULT_PRIORITY, + parent: parent && !isCreateAction && idForNavItem(parent), + priority: priority, }; navActions.push(action); diff --git a/public/app/features/commandPalette/values.ts b/public/app/features/commandPalette/values.ts index 6b529adee0d..48c30d0a93c 100644 --- a/public/app/features/commandPalette/values.ts +++ b/public/app/features/commandPalette/values.ts @@ -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 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 diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json index 77a5c56a413..19c2e183523 100644 --- a/public/locales/en-US/grafana.json +++ b/public/locales/en-US/grafana.json @@ -13,7 +13,7 @@ "search": "Search" }, "search-box": { - "placeholder": "Search Grafana" + "placeholder": "Search or jump to..." }, "section": { "actions": "Actions", @@ -160,7 +160,7 @@ "title": "Alert rules" }, "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" }, "alerting-silences": { diff --git a/public/locales/pseudo-LOCALE/grafana.json b/public/locales/pseudo-LOCALE/grafana.json index 4b20c33f43e..1c18fcd1207 100644 --- a/public/locales/pseudo-LOCALE/grafana.json +++ b/public/locales/pseudo-LOCALE/grafana.json @@ -13,7 +13,7 @@ "search": "Ŝęäřčĥ" }, "search-box": { - "placeholder": "Ŝęäřčĥ Ğřäƒäʼnä" + "placeholder": "Ŝęäřčĥ őř ĵūmp ŧő..." }, "section": { "actions": "Åčŧįőʼnş", @@ -160,7 +160,7 @@ "title": "Åľęřŧ řūľęş" }, "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ŧş" }, "alerting-silences": { @@ -191,7 +191,7 @@ "title": "Cřęäŧę" }, "create-alert": { - "title": "Ńęŵ äľęřŧ řūľę" + "title": "Cřęäŧę äľęřŧ řūľę" }, "create-dashboard": { "title": "Đäşĥþőäřđ"