2023-06-20 11:13:49 -05:00
|
|
|
import { Store } from 'redux';
|
|
|
|
|
2023-05-12 07:12:00 -05:00
|
|
|
import {
|
|
|
|
dateTime,
|
|
|
|
FieldType,
|
|
|
|
LoadingState,
|
|
|
|
PanelData,
|
|
|
|
PanelMenuItem,
|
|
|
|
PluginExtensionPanelContext,
|
|
|
|
PluginExtensionTypes,
|
|
|
|
toDataFrame,
|
|
|
|
} from '@grafana/data';
|
2023-06-20 11:13:49 -05:00
|
|
|
import { AngularComponent, getPluginExtensions } from '@grafana/runtime';
|
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-04-03 03:42:15 -05:00
|
|
|
jest.mock('@grafana/runtime', () => ({
|
|
|
|
...jest.requireActual('@grafana/runtime'),
|
|
|
|
setPluginExtensionGetter: jest.fn(),
|
|
|
|
getPluginExtensions: jest.fn(),
|
|
|
|
}));
|
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
describe('getPanelMenu()', () => {
|
|
|
|
beforeEach(() => {
|
2023-04-03 03:42:15 -05:00
|
|
|
(getPluginExtensions as jest.Mock).mockRestore();
|
|
|
|
(getPluginExtensions as jest.Mock).mockReturnValue({ extensions: [] });
|
2023-03-02 08:42:00 -06:00
|
|
|
});
|
|
|
|
|
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-03-02 08:42:00 -06:00
|
|
|
describe('when extending panel menu from plugins', () => {
|
|
|
|
it('should contain menu item from link extension', () => {
|
2023-04-03 03:42:15 -05:00
|
|
|
(getPluginExtensions as jest.Mock).mockReturnValue({
|
|
|
|
extensions: [
|
|
|
|
{
|
|
|
|
pluginId: '...',
|
2023-03-02 08:42:00 -06:00
|
|
|
type: PluginExtensionTypes.link,
|
|
|
|
title: 'Declare incident',
|
|
|
|
description: 'Declaring an incident in the app',
|
|
|
|
path: '/a/grafana-basic-app/declare-incident',
|
2023-04-03 03:42:15 -05:00
|
|
|
},
|
2023-03-02 08:42:00 -06:00
|
|
|
],
|
|
|
|
});
|
2023-01-12 03:10:09 -06:00
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
const panel = new PanelModel({});
|
|
|
|
const dashboard = createDashboardModelFixture({});
|
2023-03-16 07:56:58 -05:00
|
|
|
const menuItems = getPanelMenu(dashboard, panel);
|
2023-04-03 03:42:15 -05:00
|
|
|
const extensionsSubMenu = menuItems.find((i) => i.text === 'Extensions')?.subMenu;
|
2023-03-02 08:42:00 -06:00
|
|
|
|
2023-04-03 03:42:15 -05:00
|
|
|
expect(extensionsSubMenu).toEqual(
|
2023-03-02 08:42:00 -06:00
|
|
|
expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
text: 'Declare incident',
|
|
|
|
href: '/a/grafana-basic-app/declare-incident',
|
|
|
|
}),
|
|
|
|
])
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should truncate menu item title to 25 chars', () => {
|
2023-04-03 03:42:15 -05:00
|
|
|
(getPluginExtensions as jest.Mock).mockReturnValue({
|
|
|
|
extensions: [
|
|
|
|
{
|
|
|
|
pluginId: '...',
|
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',
|
2023-04-03 03:42:15 -05:00
|
|
|
},
|
2023-03-02 08:42:00 -06:00
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
const panel = new PanelModel({});
|
|
|
|
const dashboard = createDashboardModelFixture({});
|
2023-03-16 07:56:58 -05:00
|
|
|
const menuItems = getPanelMenu(dashboard, panel);
|
2023-04-03 03:42:15 -05:00
|
|
|
const extensionsSubMenu = menuItems.find((i) => i.text === 'Extensions')?.subMenu;
|
2023-03-02 08:42:00 -06:00
|
|
|
|
2023-04-03 03:42:15 -05:00
|
|
|
expect(extensionsSubMenu).toEqual(
|
2023-03-02 08:42:00 -06:00
|
|
|
expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
text: 'Declare incident when...',
|
|
|
|
href: '/a/grafana-basic-app/declare-incident',
|
|
|
|
}),
|
|
|
|
])
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2023-04-03 10:27:55 -05:00
|
|
|
it('should pass onClick from plugin extension link to menu item', () => {
|
|
|
|
const expectedOnClick = jest.fn();
|
|
|
|
|
|
|
|
(getPluginExtensions as jest.Mock).mockReturnValue({
|
|
|
|
extensions: [
|
|
|
|
{
|
|
|
|
pluginId: '...',
|
|
|
|
type: PluginExtensionTypes.link,
|
|
|
|
title: 'Declare incident when pressing this amazing menu item',
|
|
|
|
description: 'Declaring an incident in the app',
|
|
|
|
onClick: expectedOnClick,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
const panel = new PanelModel({});
|
|
|
|
const dashboard = createDashboardModelFixture({});
|
|
|
|
const menuItems = getPanelMenu(dashboard, panel);
|
|
|
|
const extensionsSubMenu = menuItems.find((i) => i.text === 'Extensions')?.subMenu;
|
|
|
|
const menuItem = extensionsSubMenu?.find((i) => (i.text = 'Declare incident when...'));
|
|
|
|
|
|
|
|
menuItem?.onClick?.({} as React.MouseEvent);
|
|
|
|
expect(expectedOnClick).toBeCalledTimes(1);
|
|
|
|
});
|
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
it('should pass context with correct values when configuring extension', () => {
|
2023-05-12 07:12:00 -05:00
|
|
|
const data: PanelData = {
|
|
|
|
series: [
|
|
|
|
toDataFrame({
|
|
|
|
fields: [
|
|
|
|
{ name: 'time', type: FieldType.time },
|
|
|
|
{ name: 'score', type: FieldType.number },
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
timeRange: {
|
|
|
|
from: dateTime(),
|
|
|
|
to: dateTime(),
|
|
|
|
raw: {
|
|
|
|
from: 'now',
|
|
|
|
to: 'now-1h',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
state: LoadingState.Done,
|
|
|
|
};
|
|
|
|
|
2023-03-02 08:42:00 -06:00
|
|
|
const panel = new PanelModel({
|
|
|
|
type: 'timeseries',
|
|
|
|
id: 1,
|
|
|
|
title: 'My panel',
|
|
|
|
targets: [
|
|
|
|
{
|
|
|
|
refId: 'A',
|
|
|
|
datasource: {
|
|
|
|
type: 'testdata',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2023-05-11 05:58:19 -05:00
|
|
|
scopedVars: {
|
|
|
|
a: {
|
|
|
|
text: 'a',
|
|
|
|
value: 'a',
|
|
|
|
},
|
|
|
|
},
|
2023-05-12 07:12:00 -05:00
|
|
|
queryRunner: {
|
|
|
|
getLastResult: jest.fn(() => data),
|
|
|
|
},
|
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',
|
|
|
|
});
|
|
|
|
|
2023-03-16 07:56:58 -05:00
|
|
|
getPanelMenu(dashboard, panel);
|
2023-03-02 08:42:00 -06:00
|
|
|
|
|
|
|
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',
|
2023-04-04 00:17:10 -05:00
|
|
|
datasource: {
|
|
|
|
type: 'testdata',
|
|
|
|
},
|
2023-03-02 08:42:00 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
dashboard: {
|
|
|
|
tags: ['database', 'panel'],
|
|
|
|
uid: '123',
|
|
|
|
title: 'My dashboard',
|
2023-01-12 03:10:09 -06:00
|
|
|
},
|
2023-05-11 05:58:19 -05:00
|
|
|
scopedVars: {
|
|
|
|
a: {
|
|
|
|
text: 'a',
|
|
|
|
value: 'a',
|
|
|
|
},
|
|
|
|
},
|
2023-05-12 07:12:00 -05:00
|
|
|
data,
|
2023-03-02 08:42:00 -06:00
|
|
|
};
|
|
|
|
|
2023-04-03 03:42:15 -05:00
|
|
|
expect(getPluginExtensions).toBeCalledWith(expect.objectContaining({ context }));
|
2023-03-02 08:42:00 -06:00
|
|
|
});
|
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() }];
|
2023-06-20 11:13:49 -05:00
|
|
|
const ctrl = { getExtendedMenu };
|
|
|
|
const scope = { $$childHead: { ctrl } };
|
|
|
|
const angularComponent = { getScope: () => scope } as AngularComponent;
|
2023-03-02 08:42:00 -06:00
|
|
|
const panel = new PanelModel({ isViewing: true });
|
|
|
|
const dashboard = createDashboardModelFixture({});
|
2020-09-23 23:15:57 -05:00
|
|
|
|
2023-03-16 07:56:58 -05:00
|
|
|
const menuItems = getPanelMenu(dashboard, panel, angularComponent);
|
2023-03-02 08:42:00 -06:00
|
|
|
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;
|
2023-06-20 11:13:49 -05:00
|
|
|
let navigateSpy: jest.SpyInstance;
|
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-06-20 11:13:49 -05:00
|
|
|
setStore({ dispatch: jest.fn() } as unknown as Store);
|
2023-03-02 08:42:00 -06:00
|
|
|
});
|
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
|
|
|
});
|