2023-03-10 06:55:38 -06:00
|
|
|
import {
|
|
|
|
PanelMenuItem,
|
|
|
|
PluginExtension,
|
|
|
|
PluginExtensionLink,
|
|
|
|
PluginExtensionTypes,
|
|
|
|
PluginExtensionPlacements,
|
|
|
|
} from '@grafana/data';
|
2023-03-02 08:42:00 -06:00
|
|
|
import {
|
|
|
|
PluginExtensionPanelContext,
|
|
|
|
PluginExtensionRegistryItem,
|
|
|
|
setPluginsExtensionRegistry,
|
|
|
|
} from '@grafana/runtime';
|
2023-01-12 03:10:09 -06:00
|
|
|
import { LoadingState } from '@grafana/schema';
|
2020-09-23 23:15:57 -05:00
|
|
|
import config from 'app/core/config';
|
2020-11-09 07:48:24 -06:00
|
|
|
import * as actions from 'app/features/explore/state/main';
|
2022-04-22 08:33:13 -05:00
|
|
|
import { setStore } from 'app/store/store';
|
|
|
|
|
2022-12-20 08:04:14 -06:00
|
|
|
import { PanelModel } from '../state';
|
|
|
|
import { createDashboardModelFixture } from '../state/__fixtures__/dashboardFixtures';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
|
|
|
import { getPanelMenu } from './getPanelMenu';
|
2020-09-23 23:15:57 -05:00
|
|
|
|
|
|
|
jest.mock('app/core/services/context_srv', () => ({
|
|
|
|
contextSrv: {
|
|
|
|
hasAccessToExplore: () => true,
|
|
|
|
},
|
|
|
|
}));
|
2020-02-09 03:53:34 -06:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
describe('getPanelMenu()', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
setPluginsExtensionRegistry({});
|
|
|
|
});
|
|
|
|
|
2020-02-09 03:53:34 -06:00
|
|
|
it('should return the correct panel menu items', () => {
|
|
|
|
const panel = new PanelModel({});
|
2022-12-20 08:04:14 -06:00
|
|
|
const dashboard = createDashboardModelFixture({});
|
2020-02-09 03:53:34 -06:00
|
|
|
|
|
|
|
const menuItems = getPanelMenu(dashboard, panel);
|
|
|
|
expect(menuItems).toMatchInlineSnapshot(`
|
2022-11-24 08:00:41 -06:00
|
|
|
[
|
|
|
|
{
|
@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3: Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-08 07:33:31 -05:00
|
|
|
"iconClassName": "eye",
|
2020-02-09 03:53:34 -06:00
|
|
|
"onClick": [Function],
|
|
|
|
"shortcut": "v",
|
|
|
|
"text": "View",
|
|
|
|
},
|
2022-11-24 08:00:41 -06:00
|
|
|
{
|
@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3: Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-08 07:33:31 -05:00
|
|
|
"iconClassName": "edit",
|
2020-02-09 03:53:34 -06:00
|
|
|
"onClick": [Function],
|
|
|
|
"shortcut": "e",
|
|
|
|
"text": "Edit",
|
|
|
|
},
|
2022-11-24 08:00:41 -06:00
|
|
|
{
|
@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3: Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-08 07:33:31 -05:00
|
|
|
"iconClassName": "share-alt",
|
2020-02-09 03:53:34 -06:00
|
|
|
"onClick": [Function],
|
|
|
|
"shortcut": "p s",
|
|
|
|
"text": "Share",
|
|
|
|
},
|
2022-11-24 08:00:41 -06:00
|
|
|
{
|
2020-09-23 23:15:57 -05:00
|
|
|
"iconClassName": "compass",
|
|
|
|
"onClick": [Function],
|
|
|
|
"shortcut": "x",
|
|
|
|
"text": "Explore",
|
|
|
|
},
|
2022-11-24 08:00:41 -06:00
|
|
|
{
|
@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3: Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-08 07:33:31 -05:00
|
|
|
"iconClassName": "info-circle",
|
2020-04-03 13:24:50 -05:00
|
|
|
"onClick": [Function],
|
2020-04-15 09:51:51 -05:00
|
|
|
"shortcut": "i",
|
2022-11-24 08:00:41 -06:00
|
|
|
"subMenu": [
|
|
|
|
{
|
2020-04-15 09:51:51 -05:00
|
|
|
"onClick": [Function],
|
|
|
|
"text": "Panel JSON",
|
|
|
|
},
|
|
|
|
],
|
2020-04-03 13:24:50 -05:00
|
|
|
"text": "Inspect",
|
2020-04-15 09:51:51 -05:00
|
|
|
"type": "submenu",
|
2020-04-03 13:24:50 -05:00
|
|
|
},
|
2022-11-24 08:00:41 -06:00
|
|
|
{
|
@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3: Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-08 07:33:31 -05:00
|
|
|
"iconClassName": "cube",
|
2020-02-09 03:53:34 -06:00
|
|
|
"onClick": [Function],
|
2022-11-24 08:00:41 -06:00
|
|
|
"subMenu": [
|
|
|
|
{
|
2020-02-09 03:53:34 -06:00
|
|
|
"onClick": [Function],
|
|
|
|
"shortcut": "p d",
|
|
|
|
"text": "Duplicate",
|
|
|
|
},
|
2022-11-24 08:00:41 -06:00
|
|
|
{
|
2020-02-09 03:53:34 -06:00
|
|
|
"onClick": [Function],
|
|
|
|
"text": "Copy",
|
|
|
|
},
|
2022-11-24 08:00:41 -06:00
|
|
|
{
|
2021-04-13 10:55:31 -05:00
|
|
|
"onClick": [Function],
|
2021-05-04 03:00:44 -05:00
|
|
|
"text": "Create library panel",
|
2021-04-13 10:55:31 -05:00
|
|
|
},
|
2020-02-09 03:53:34 -06:00
|
|
|
],
|
|
|
|
"text": "More...",
|
|
|
|
"type": "submenu",
|
|
|
|
},
|
2022-11-24 08:00:41 -06:00
|
|
|
{
|
2020-07-09 08:16:35 -05:00
|
|
|
"text": "",
|
2020-02-09 03:53:34 -06:00
|
|
|
"type": "divider",
|
|
|
|
},
|
2022-11-24 08:00:41 -06:00
|
|
|
{
|
@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3: Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-08 07:33:31 -05:00
|
|
|
"iconClassName": "trash-alt",
|
2020-02-09 03:53:34 -06:00
|
|
|
"onClick": [Function],
|
|
|
|
"shortcut": "p r",
|
|
|
|
"text": "Remove",
|
|
|
|
},
|
|
|
|
]
|
|
|
|
`);
|
|
|
|
});
|
2020-05-20 06:56:28 -05:00
|
|
|
|
2023-01-12 03:10:09 -06:00
|
|
|
it('should return the correct panel menu items when data is streaming', () => {
|
|
|
|
const panel = new PanelModel({});
|
|
|
|
const dashboard = createDashboardModelFixture({});
|
|
|
|
|
|
|
|
const menuItems = getPanelMenu(dashboard, panel, LoadingState.Streaming);
|
|
|
|
expect(menuItems).toEqual(
|
|
|
|
expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
iconClassName: 'circle',
|
|
|
|
text: 'Stop query',
|
|
|
|
}),
|
|
|
|
])
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return the correct panel menu items when data is loading', () => {
|
|
|
|
const panel = new PanelModel({});
|
|
|
|
const dashboard = createDashboardModelFixture({});
|
|
|
|
|
|
|
|
const menuItems = getPanelMenu(dashboard, panel, LoadingState.Loading);
|
|
|
|
expect(menuItems).toEqual(
|
|
|
|
expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
iconClassName: 'circle',
|
|
|
|
text: 'Stop query',
|
|
|
|
}),
|
|
|
|
])
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
describe('when extending panel menu from plugins', () => {
|
|
|
|
it('should contain menu item from link extension', () => {
|
|
|
|
setPluginsExtensionRegistry({
|
2023-03-10 06:55:38 -06:00
|
|
|
[PluginExtensionPlacements.DashboardPanelMenu]: [
|
2023-03-02 08:42:00 -06:00
|
|
|
createRegistryItem<PluginExtensionLink>({
|
|
|
|
type: PluginExtensionTypes.link,
|
|
|
|
title: 'Declare incident',
|
|
|
|
description: 'Declaring an incident in the app',
|
|
|
|
path: '/a/grafana-basic-app/declare-incident',
|
|
|
|
key: 1,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
});
|
2023-01-12 03:10:09 -06:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
const panel = new PanelModel({});
|
|
|
|
const dashboard = createDashboardModelFixture({});
|
|
|
|
const menuItems = getPanelMenu(dashboard, panel, LoadingState.Loading);
|
|
|
|
const moreSubMenu = menuItems.find((i) => i.text === 'More...')?.subMenu;
|
|
|
|
|
|
|
|
expect(moreSubMenu).toEqual(
|
|
|
|
expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
text: 'Declare incident',
|
|
|
|
href: '/a/grafana-basic-app/declare-incident',
|
|
|
|
}),
|
|
|
|
])
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should truncate menu item title to 25 chars', () => {
|
|
|
|
setPluginsExtensionRegistry({
|
2023-03-10 06:55:38 -06:00
|
|
|
[PluginExtensionPlacements.DashboardPanelMenu]: [
|
2023-03-02 08:42:00 -06:00
|
|
|
createRegistryItem<PluginExtensionLink>({
|
|
|
|
type: PluginExtensionTypes.link,
|
|
|
|
title: 'Declare incident when pressing this amazing menu item',
|
|
|
|
description: 'Declaring an incident in the app',
|
|
|
|
path: '/a/grafana-basic-app/declare-incident',
|
|
|
|
key: 1,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
const panel = new PanelModel({});
|
|
|
|
const dashboard = createDashboardModelFixture({});
|
|
|
|
const menuItems = getPanelMenu(dashboard, panel, LoadingState.Loading);
|
|
|
|
const moreSubMenu = menuItems.find((i) => i.text === 'More...')?.subMenu;
|
|
|
|
|
|
|
|
expect(moreSubMenu).toEqual(
|
|
|
|
expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
text: 'Declare incident when...',
|
|
|
|
href: '/a/grafana-basic-app/declare-incident',
|
|
|
|
}),
|
|
|
|
])
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should use extension for panel menu returned by configure function', () => {
|
2023-03-08 07:23:29 -06:00
|
|
|
const configure: PluginExtensionRegistryItem<PluginExtensionLink> = () => ({
|
2023-03-02 08:42:00 -06:00
|
|
|
title: 'Wohoo',
|
|
|
|
type: PluginExtensionTypes.link,
|
|
|
|
description: 'Declaring an incident in the app',
|
|
|
|
path: '/a/grafana-basic-app/declare-incident',
|
|
|
|
key: 1,
|
|
|
|
});
|
|
|
|
|
|
|
|
setPluginsExtensionRegistry({
|
2023-03-10 06:55:38 -06:00
|
|
|
[PluginExtensionPlacements.DashboardPanelMenu]: [
|
2023-03-02 08:42:00 -06:00
|
|
|
createRegistryItem<PluginExtensionLink>(
|
|
|
|
{
|
|
|
|
type: PluginExtensionTypes.link,
|
|
|
|
title: 'Declare incident when pressing this amazing menu item',
|
|
|
|
description: 'Declaring an incident in the app',
|
|
|
|
path: '/a/grafana-basic-app/declare-incident',
|
|
|
|
key: 1,
|
|
|
|
},
|
|
|
|
configure
|
|
|
|
),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
const panel = new PanelModel({});
|
|
|
|
const dashboard = createDashboardModelFixture({});
|
|
|
|
const menuItems = getPanelMenu(dashboard, panel, LoadingState.Loading);
|
|
|
|
const moreSubMenu = menuItems.find((i) => i.text === 'More...')?.subMenu;
|
|
|
|
|
|
|
|
expect(moreSubMenu).toEqual(
|
|
|
|
expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
text: 'Wohoo',
|
|
|
|
href: '/a/grafana-basic-app/declare-incident',
|
|
|
|
}),
|
|
|
|
])
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should hide menu item if configure function returns undefined', () => {
|
|
|
|
setPluginsExtensionRegistry({
|
2023-03-10 06:55:38 -06:00
|
|
|
[PluginExtensionPlacements.DashboardPanelMenu]: [
|
2023-03-02 08:42:00 -06:00
|
|
|
createRegistryItem<PluginExtensionLink>(
|
|
|
|
{
|
|
|
|
type: PluginExtensionTypes.link,
|
|
|
|
title: 'Declare incident when pressing this amazing menu item',
|
|
|
|
description: 'Declaring an incident in the app',
|
|
|
|
path: '/a/grafana-basic-app/declare-incident',
|
|
|
|
key: 1,
|
|
|
|
},
|
|
|
|
() => undefined
|
|
|
|
),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
const panel = new PanelModel({});
|
|
|
|
const dashboard = createDashboardModelFixture({});
|
|
|
|
const menuItems = getPanelMenu(dashboard, panel, LoadingState.Loading);
|
|
|
|
const moreSubMenu = menuItems.find((i) => i.text === 'More...')?.subMenu;
|
|
|
|
|
|
|
|
expect(moreSubMenu).toEqual(
|
|
|
|
expect.not.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
text: 'Declare incident when...',
|
|
|
|
href: '/a/grafana-basic-app/declare-incident',
|
|
|
|
}),
|
|
|
|
])
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should pass context with correct values when configuring extension', () => {
|
|
|
|
const configure = jest.fn();
|
|
|
|
|
|
|
|
setPluginsExtensionRegistry({
|
2023-03-10 06:55:38 -06:00
|
|
|
[PluginExtensionPlacements.DashboardPanelMenu]: [
|
2023-03-02 08:42:00 -06:00
|
|
|
createRegistryItem<PluginExtensionLink>(
|
|
|
|
{
|
|
|
|
type: PluginExtensionTypes.link,
|
|
|
|
title: 'Declare incident when pressing this amazing menu item',
|
|
|
|
description: 'Declaring an incident in the app',
|
|
|
|
path: '/a/grafana-basic-app/declare-incident',
|
|
|
|
key: 1,
|
|
|
|
},
|
|
|
|
configure
|
|
|
|
),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
const panel = new PanelModel({
|
|
|
|
type: 'timeseries',
|
|
|
|
id: 1,
|
|
|
|
title: 'My panel',
|
|
|
|
targets: [
|
|
|
|
{
|
|
|
|
refId: 'A',
|
|
|
|
datasource: {
|
|
|
|
type: 'testdata',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
const dashboard = createDashboardModelFixture({
|
|
|
|
timezone: 'utc',
|
|
|
|
time: {
|
|
|
|
from: 'now-5m',
|
|
|
|
to: 'now',
|
2023-01-12 03:10:09 -06:00
|
|
|
},
|
2023-03-02 08:42:00 -06:00
|
|
|
tags: ['database', 'panel'],
|
|
|
|
uid: '123',
|
|
|
|
title: 'My dashboard',
|
|
|
|
});
|
|
|
|
|
|
|
|
getPanelMenu(dashboard, panel, LoadingState.Loading);
|
|
|
|
|
|
|
|
const context: PluginExtensionPanelContext = {
|
|
|
|
pluginId: 'timeseries',
|
|
|
|
id: 1,
|
|
|
|
title: 'My panel',
|
|
|
|
timeZone: 'utc',
|
|
|
|
timeRange: {
|
|
|
|
from: 'now-5m',
|
|
|
|
to: 'now',
|
2023-01-12 03:10:09 -06:00
|
|
|
},
|
2023-03-02 08:42:00 -06:00
|
|
|
targets: [
|
|
|
|
{
|
|
|
|
refId: 'A',
|
|
|
|
pluginId: 'testdata',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
dashboard: {
|
|
|
|
tags: ['database', 'panel'],
|
|
|
|
uid: '123',
|
|
|
|
title: 'My dashboard',
|
2023-01-12 03:10:09 -06:00
|
|
|
},
|
2023-03-02 08:42:00 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
expect(configure).toBeCalledWith(context);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should pass context that can not be edited in configure function', () => {
|
2023-03-08 07:23:29 -06:00
|
|
|
const configure: PluginExtensionRegistryItem<PluginExtensionLink> = (context) => {
|
2023-03-02 08:42:00 -06:00
|
|
|
// trying to change values in the context
|
|
|
|
// @ts-ignore
|
|
|
|
context.pluginId = 'changed';
|
|
|
|
|
|
|
|
return {
|
|
|
|
type: PluginExtensionTypes.link,
|
|
|
|
title: 'Declare incident when pressing this amazing menu item',
|
|
|
|
description: 'Declaring an incident in the app',
|
|
|
|
path: '/a/grafana-basic-app/declare-incident',
|
|
|
|
key: 1,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
setPluginsExtensionRegistry({
|
2023-03-10 06:55:38 -06:00
|
|
|
[PluginExtensionPlacements.DashboardPanelMenu]: [
|
2023-03-02 08:42:00 -06:00
|
|
|
createRegistryItem<PluginExtensionLink>(
|
2023-01-12 03:10:09 -06:00
|
|
|
{
|
2023-03-02 08:42:00 -06:00
|
|
|
type: PluginExtensionTypes.link,
|
|
|
|
title: 'Declare incident when pressing this amazing menu item',
|
|
|
|
description: 'Declaring an incident in the app',
|
|
|
|
path: '/a/grafana-basic-app/declare-incident',
|
|
|
|
key: 1,
|
2023-01-12 03:10:09 -06:00
|
|
|
},
|
2023-03-02 08:42:00 -06:00
|
|
|
configure
|
|
|
|
),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
const panel = new PanelModel({
|
|
|
|
type: 'timeseries',
|
|
|
|
id: 1,
|
|
|
|
title: 'My panel',
|
|
|
|
targets: [
|
|
|
|
{
|
|
|
|
refId: 'A',
|
|
|
|
datasource: {
|
|
|
|
type: 'testdata',
|
2023-01-12 03:10:09 -06:00
|
|
|
},
|
2023-03-02 08:42:00 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
const dashboard = createDashboardModelFixture({
|
|
|
|
timezone: 'utc',
|
|
|
|
time: {
|
|
|
|
from: 'now-5m',
|
|
|
|
to: 'now',
|
2023-01-12 03:10:09 -06:00
|
|
|
},
|
2023-03-02 08:42:00 -06:00
|
|
|
tags: ['database', 'panel'],
|
|
|
|
uid: '123',
|
|
|
|
title: 'My dashboard',
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(() => getPanelMenu(dashboard, panel, LoadingState.Loading)).toThrowError(TypeError);
|
|
|
|
});
|
2020-05-20 06:56:28 -05:00
|
|
|
});
|
2020-09-23 23:15:57 -05:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
describe('when panel is in view mode', () => {
|
|
|
|
it('should return the correct panel menu items', () => {
|
|
|
|
const getExtendedMenu = () => [{ text: 'Toggle legend', shortcut: 'p l', click: jest.fn() }];
|
|
|
|
const ctrl: any = { getExtendedMenu };
|
|
|
|
const scope: any = { $$childHead: { ctrl } };
|
|
|
|
const angularComponent: any = { getScope: () => scope };
|
|
|
|
const panel = new PanelModel({ isViewing: true });
|
|
|
|
const dashboard = createDashboardModelFixture({});
|
2020-09-23 23:15:57 -05:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
const menuItems = getPanelMenu(dashboard, panel, undefined, angularComponent);
|
|
|
|
expect(menuItems).toMatchInlineSnapshot(`
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"iconClassName": "eye",
|
|
|
|
"onClick": [Function],
|
|
|
|
"shortcut": "v",
|
|
|
|
"text": "View",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"iconClassName": "edit",
|
|
|
|
"onClick": [Function],
|
|
|
|
"shortcut": "e",
|
|
|
|
"text": "Edit",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"iconClassName": "share-alt",
|
|
|
|
"onClick": [Function],
|
|
|
|
"shortcut": "p s",
|
|
|
|
"text": "Share",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"iconClassName": "compass",
|
|
|
|
"onClick": [Function],
|
|
|
|
"shortcut": "x",
|
|
|
|
"text": "Explore",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"iconClassName": "info-circle",
|
|
|
|
"onClick": [Function],
|
|
|
|
"shortcut": "i",
|
|
|
|
"subMenu": [
|
|
|
|
{
|
|
|
|
"onClick": [Function],
|
|
|
|
"text": "Panel JSON",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
"text": "Inspect",
|
|
|
|
"type": "submenu",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"iconClassName": "cube",
|
|
|
|
"onClick": [Function],
|
|
|
|
"subMenu": [
|
|
|
|
{
|
|
|
|
"href": undefined,
|
|
|
|
"onClick": [Function],
|
|
|
|
"shortcut": "p l",
|
|
|
|
"text": "Toggle legend",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
"text": "More...",
|
|
|
|
"type": "submenu",
|
|
|
|
},
|
|
|
|
]
|
|
|
|
`);
|
|
|
|
});
|
|
|
|
});
|
2020-09-23 23:15:57 -05:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
describe('onNavigateToExplore', () => {
|
|
|
|
const testSubUrl = '/testSubUrl';
|
|
|
|
const testUrl = '/testUrl';
|
|
|
|
const windowOpen = jest.fn();
|
|
|
|
let event: any;
|
|
|
|
let explore: PanelMenuItem;
|
|
|
|
let navigateSpy: any;
|
2020-09-23 23:15:57 -05:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
beforeAll(() => {
|
|
|
|
const panel = new PanelModel({});
|
|
|
|
const dashboard = createDashboardModelFixture({});
|
|
|
|
const menuItems = getPanelMenu(dashboard, panel);
|
|
|
|
explore = menuItems.find((item) => item.text === 'Explore') as PanelMenuItem;
|
|
|
|
navigateSpy = jest.spyOn(actions, 'navigateToExplore');
|
|
|
|
window.open = windowOpen;
|
2020-09-23 23:15:57 -05:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
event = {
|
|
|
|
ctrlKey: true,
|
|
|
|
preventDefault: jest.fn(),
|
|
|
|
};
|
2020-09-23 23:15:57 -05:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
setStore({ dispatch: jest.fn() } as any);
|
|
|
|
});
|
2020-09-23 23:15:57 -05:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
it('should navigate to url without subUrl', () => {
|
|
|
|
explore.onClick!(event);
|
2020-09-23 23:15:57 -05:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
const openInNewWindow = navigateSpy.mock.calls[0][1].openInNewWindow;
|
2020-09-23 23:15:57 -05:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
openInNewWindow(testUrl);
|
2020-09-23 23:15:57 -05:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
expect(windowOpen).toHaveBeenLastCalledWith(testUrl);
|
|
|
|
});
|
2020-09-23 23:15:57 -05:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
it('should navigate to url with subUrl', () => {
|
|
|
|
config.appSubUrl = testSubUrl;
|
|
|
|
explore.onClick!(event);
|
2020-09-23 23:15:57 -05:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
const openInNewWindow = navigateSpy.mock.calls[0][1].openInNewWindow;
|
|
|
|
|
|
|
|
openInNewWindow(testUrl);
|
|
|
|
|
|
|
|
expect(windowOpen).toHaveBeenLastCalledWith(`${testSubUrl}${testUrl}`);
|
|
|
|
});
|
2020-09-23 23:15:57 -05:00
|
|
|
});
|
2020-02-09 03:53:34 -06:00
|
|
|
});
|
2023-03-02 08:42:00 -06:00
|
|
|
|
2023-03-08 07:23:29 -06:00
|
|
|
function createRegistryItem<T extends PluginExtension, C extends object = object>(
|
2023-03-02 08:42:00 -06:00
|
|
|
extension: T,
|
2023-03-08 07:23:29 -06:00
|
|
|
configure?: PluginExtensionRegistryItem<T, C>
|
|
|
|
): PluginExtensionRegistryItem<T, C> {
|
|
|
|
const defaultConfigure = () => extension;
|
|
|
|
return configure || defaultConfigure;
|
2023-03-02 08:42:00 -06:00
|
|
|
}
|