mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CommandPalette: Remove topnav command palette feature flag (#63620)
* CommandPalette: Remove topnav command palette feature flag * Restore search shortcuts if topnav isnt enabled * fix unused imports
This commit is contained in:
parent
09e523eef2
commit
91d2df59fc
@ -46,7 +46,6 @@ Some stable features are enabled by default. You can disable a stable feature by
|
|||||||
| `topnav` | Displays new top nav and page layouts |
|
| `topnav` | Displays new top nav and page layouts |
|
||||||
| `accessControlOnCall` | Access control primitives for OnCall |
|
| `accessControlOnCall` | Access control primitives for OnCall |
|
||||||
| `alertingNoNormalState` | Stop maintaining state of alerts that are not firing |
|
| `alertingNoNormalState` | Stop maintaining state of alerts that are not firing |
|
||||||
| `topNavCommandPalette` | Launch the Command Palette from the top navigation search box |
|
|
||||||
|
|
||||||
## Alpha feature toggles
|
## Alpha feature toggles
|
||||||
|
|
||||||
|
@ -77,7 +77,6 @@ export interface FeatureToggles {
|
|||||||
alertingBacktesting?: boolean;
|
alertingBacktesting?: boolean;
|
||||||
editPanelCSVDragAndDrop?: boolean;
|
editPanelCSVDragAndDrop?: boolean;
|
||||||
alertingNoNormalState?: boolean;
|
alertingNoNormalState?: boolean;
|
||||||
topNavCommandPalette?: boolean;
|
|
||||||
logsSampleInExplore?: boolean;
|
logsSampleInExplore?: boolean;
|
||||||
logsContextDatasourceUi?: boolean;
|
logsContextDatasourceUi?: boolean;
|
||||||
lokiQuerySplitting?: boolean;
|
lokiQuerySplitting?: boolean;
|
||||||
|
@ -341,12 +341,6 @@ var (
|
|||||||
State: FeatureStateBeta,
|
State: FeatureStateBeta,
|
||||||
RequiresRestart: false,
|
RequiresRestart: false,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Name: "topNavCommandPalette",
|
|
||||||
Description: "Launch the Command Palette from the top navigation search box",
|
|
||||||
State: FeatureStateBeta,
|
|
||||||
FrontendOnly: true,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
|
|
||||||
Name: "logsSampleInExplore",
|
Name: "logsSampleInExplore",
|
||||||
|
@ -251,10 +251,6 @@ const (
|
|||||||
// Stop maintaining state of alerts that are not firing
|
// Stop maintaining state of alerts that are not firing
|
||||||
FlagAlertingNoNormalState = "alertingNoNormalState"
|
FlagAlertingNoNormalState = "alertingNoNormalState"
|
||||||
|
|
||||||
// FlagTopNavCommandPalette
|
|
||||||
// Launch the Command Palette from the top navigation search box
|
|
||||||
FlagTopNavCommandPalette = "topNavCommandPalette"
|
|
||||||
|
|
||||||
// FlagLogsSampleInExplore
|
// FlagLogsSampleInExplore
|
||||||
// Enables access to the logs sample feature in Explore
|
// Enables access to the logs sample feature in Explore
|
||||||
FlagLogsSampleInExplore = "logsSampleInExplore"
|
FlagLogsSampleInExplore = "logsSampleInExplore"
|
||||||
|
@ -22,7 +22,6 @@ export function AppChrome({ children }: Props) {
|
|||||||
const styles = useStyles2(getStyles);
|
const styles = useStyles2(getStyles);
|
||||||
const { chrome } = useGrafana();
|
const { chrome } = useGrafana();
|
||||||
const state = chrome.useState();
|
const state = chrome.useState();
|
||||||
const featureToggles = config.featureToggles;
|
|
||||||
|
|
||||||
if (!config.featureToggles.topnav) {
|
if (!config.featureToggles.topnav) {
|
||||||
return (
|
return (
|
||||||
@ -73,7 +72,6 @@ export function AppChrome({ children }: Props) {
|
|||||||
<div className={contentClass}>{children}</div>
|
<div className={contentClass}>{children}</div>
|
||||||
<MegaMenu searchBarHidden={searchBarHidden} onClose={() => chrome.setMegaMenu(false)} />
|
<MegaMenu searchBarHidden={searchBarHidden} onClose={() => chrome.setMegaMenu(false)} />
|
||||||
<CommandPalette />
|
<CommandPalette />
|
||||||
{!featureToggles.topNavCommandPalette && <SearchWrapper />}
|
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import React from 'react';
|
|||||||
|
|
||||||
import { GrafanaTheme2 } from '@grafana/data';
|
import { GrafanaTheme2 } from '@grafana/data';
|
||||||
import { Dropdown, ToolbarButton, useStyles2 } from '@grafana/ui';
|
import { Dropdown, ToolbarButton, useStyles2 } from '@grafana/ui';
|
||||||
import { config } from 'app/core/config';
|
|
||||||
import { contextSrv } from 'app/core/core';
|
import { contextSrv } from 'app/core/core';
|
||||||
import { useSelector } from 'app/types';
|
import { useSelector } from 'app/types';
|
||||||
|
|
||||||
@ -16,7 +15,6 @@ import { SignInLink } from './TopBar/SignInLink';
|
|||||||
import { TopNavBarMenu } from './TopBar/TopNavBarMenu';
|
import { TopNavBarMenu } from './TopBar/TopNavBarMenu';
|
||||||
import { TopSearchBarSection } from './TopBar/TopSearchBarSection';
|
import { TopSearchBarSection } from './TopBar/TopSearchBarSection';
|
||||||
import { TopSearchBarCommandPaletteTrigger } from './TopSearchBarCommandPaletteTrigger';
|
import { TopSearchBarCommandPaletteTrigger } from './TopSearchBarCommandPaletteTrigger';
|
||||||
import { TopSearchBarInput } from './TopSearchBarInput';
|
|
||||||
import { TOP_BAR_LEVEL_HEIGHT } from './types';
|
import { TOP_BAR_LEVEL_HEIGHT } from './types';
|
||||||
|
|
||||||
export function TopSearchBar() {
|
export function TopSearchBar() {
|
||||||
@ -26,12 +24,6 @@ export function TopSearchBar() {
|
|||||||
const helpNode = navIndex['help'];
|
const helpNode = navIndex['help'];
|
||||||
const profileNode = navIndex['profile'];
|
const profileNode = navIndex['profile'];
|
||||||
|
|
||||||
const search = config.featureToggles.topNavCommandPalette ? (
|
|
||||||
<TopSearchBarCommandPaletteTrigger />
|
|
||||||
) : (
|
|
||||||
<TopSearchBarInput />
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.layout}>
|
<div className={styles.layout}>
|
||||||
<TopSearchBarSection>
|
<TopSearchBarSection>
|
||||||
@ -41,7 +33,9 @@ export function TopSearchBar() {
|
|||||||
<OrganizationSwitcher />
|
<OrganizationSwitcher />
|
||||||
</TopSearchBarSection>
|
</TopSearchBarSection>
|
||||||
|
|
||||||
<TopSearchBarSection>{search}</TopSearchBarSection>
|
<TopSearchBarSection>
|
||||||
|
<TopSearchBarCommandPaletteTrigger />
|
||||||
|
</TopSearchBarSection>
|
||||||
|
|
||||||
<TopSearchBarSection align="right">
|
<TopSearchBarSection align="right">
|
||||||
<QuickAdd />
|
<QuickAdd />
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
import React, { useState } from 'react';
|
|
||||||
|
|
||||||
import { locationService } from '@grafana/runtime';
|
|
||||||
import { FilterInput, ToolbarButton, useTheme2 } from '@grafana/ui';
|
|
||||||
import { useMediaQueryChange } from 'app/core/hooks/useMediaQueryChange';
|
|
||||||
import { t } from 'app/core/internationalization';
|
|
||||||
import { getSearchStateManager } from 'app/features/search/state/SearchStateManager';
|
|
||||||
|
|
||||||
export function TopSearchBarInput() {
|
|
||||||
const theme = useTheme2();
|
|
||||||
const stateManager = getSearchStateManager();
|
|
||||||
const state = stateManager.useState();
|
|
||||||
const breakpoint = theme.breakpoints.values.sm;
|
|
||||||
|
|
||||||
const [isSmallScreen, setIsSmallScreen] = useState(window.matchMedia(`(max-width: ${breakpoint}px)`).matches);
|
|
||||||
|
|
||||||
useMediaQueryChange({
|
|
||||||
breakpoint,
|
|
||||||
onChange: (e) => {
|
|
||||||
setIsSmallScreen(e.matches);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const onOpenSearch = () => {
|
|
||||||
locationService.partial({ search: 'open' });
|
|
||||||
};
|
|
||||||
|
|
||||||
const onSearchChange = (value: string) => {
|
|
||||||
stateManager.onQueryChange(value);
|
|
||||||
if (value) {
|
|
||||||
onOpenSearch();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (isSmallScreen) {
|
|
||||||
return <ToolbarButton iconOnly icon="search" aria-label="Search Grafana" onClick={onOpenSearch} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FilterInput
|
|
||||||
onClick={onOpenSearch}
|
|
||||||
placeholder={t('nav.search.placeholder', 'Search Grafana')}
|
|
||||||
value={state.query ?? ''}
|
|
||||||
onChange={onSearchChange}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
@ -41,7 +41,7 @@ export class KeybindingSrv {
|
|||||||
this.bind('g a', this.openAlerting);
|
this.bind('g a', this.openAlerting);
|
||||||
this.bind('g p', this.goToProfile);
|
this.bind('g p', this.goToProfile);
|
||||||
this.bind('g e', this.goToExplore);
|
this.bind('g e', this.goToExplore);
|
||||||
if (!config.featureToggles.topNavCommandPalette) {
|
if (!config.featureToggles.topnav) {
|
||||||
this.bind('s o', this.openSearch);
|
this.bind('s o', this.openSearch);
|
||||||
this.bind('f', this.openSearch);
|
this.bind('f', this.openSearch);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import {
|
|||||||
import React, { useEffect, useMemo, useRef } from 'react';
|
import React, { useEffect, useMemo, useRef } from 'react';
|
||||||
|
|
||||||
import { GrafanaTheme2 } from '@grafana/data';
|
import { GrafanaTheme2 } from '@grafana/data';
|
||||||
import { config, reportInteraction } from '@grafana/runtime';
|
import { reportInteraction } from '@grafana/runtime';
|
||||||
import { Icon, Spinner, useStyles2 } from '@grafana/ui';
|
import { Icon, Spinner, useStyles2 } from '@grafana/ui';
|
||||||
import { t } from 'app/core/internationalization';
|
import { t } from 'app/core/internationalization';
|
||||||
|
|
||||||
@ -135,13 +135,11 @@ const RenderResults = ({ searchResults }: RenderResultsProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getSearchStyles = (theme: GrafanaTheme2) => {
|
const getSearchStyles = (theme: GrafanaTheme2) => {
|
||||||
const topNavCommandPalette = Boolean(config.featureToggles.topNavCommandPalette);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
positioner: css({
|
positioner: css({
|
||||||
zIndex: theme.zIndex.portal,
|
zIndex: theme.zIndex.portal,
|
||||||
marginTop: '0px',
|
marginTop: '0px',
|
||||||
paddingTop: topNavCommandPalette ? '4px !important' : undefined,
|
paddingTop: '4px !important',
|
||||||
'&::before': {
|
'&::before': {
|
||||||
content: '""',
|
content: '""',
|
||||||
position: 'fixed',
|
position: 'fixed',
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { locationUtil, NavModelItem } from '@grafana/data';
|
import { locationUtil, NavModelItem } from '@grafana/data';
|
||||||
import { config, locationService } from '@grafana/runtime';
|
|
||||||
import { t } from 'app/core/internationalization';
|
import { t } from 'app/core/internationalization';
|
||||||
import { changeTheme } from 'app/core/services/theme';
|
import { changeTheme } from 'app/core/services/theme';
|
||||||
|
|
||||||
@ -75,17 +74,6 @@ export default (navBarTree: NavModelItem[]): CommandPaletteAction[] => {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!config.featureToggles.topNavCommandPalette) {
|
|
||||||
globalActions.unshift({
|
|
||||||
id: 'go/search',
|
|
||||||
name: t('command-palette.action.search', 'Search'),
|
|
||||||
keywords: 'navigate',
|
|
||||||
perform: () => locationService.push('?search=open'),
|
|
||||||
section: t('command-palette.section.pages', 'Pages'),
|
|
||||||
priority: DEFAULT_PRIORITY,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const navBarActions = navTreeToActions(navBarTree);
|
const navBarActions = navTreeToActions(navBarTree);
|
||||||
|
|
||||||
return [...globalActions, ...navBarActions];
|
return [...globalActions, ...navBarActions];
|
||||||
|
Loading…
Reference in New Issue
Block a user