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
pull/63071/head
Josh Hunt 2 years ago committed by GitHub
parent 8684fa75c7
commit 5564b93e2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      public/app/core/components/NavBar/navBarItem-translations.ts
  2. 15
      public/app/features/commandPalette/actions/staticActions.ts
  3. 3
      public/app/features/commandPalette/values.ts
  4. 4
      public/locales/en-US/grafana.json
  5. 6
      public/locales/pseudo-LOCALE/grafana.json

@ -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':

@ -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);

@ -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

@ -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": {

@ -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": "Đäşĥþőäřđ"

Loading…
Cancel
Save