2021-02-25 18:26:28 +08:00
|
|
|
import React, { useMemo, useState } from 'react';
|
|
|
|
|
import { connect, MapDispatchToProps } from 'react-redux';
|
2021-04-01 20:15:23 +08:00
|
|
|
import { css, cx, keyframes } from '@emotion/css';
|
2017-10-16 16:39:50 +08:00
|
|
|
import _ from 'lodash';
|
2021-02-25 18:26:28 +08:00
|
|
|
import tinycolor from 'tinycolor2';
|
Routing NG: Replace Angular routing with react-router (#31463)
* Add router packages
* Get react app root work instead of Angular one
* Logger util
* Patch Angular routing ($routeProvider, $routeParamsProvider)
* Use react-router-dom history instead of separate dependency
* Add test routes
* Sidemenu - use Link instead of anchors
* Patch Angular $location service (stub)
* WIP: geting rid of $location provider from TimeSrv
* Intercept anchor clicks to use history under the hood
* Sync Redux location slice with history state
* Make login/logout work
* Debug routes for testing
* Make force login work
* Make sure query param change does not recreate page components
* Hide side menu in specified locations
* Make the dashboar route query parameters work, make panel edit menu work
* Enable more routes
* Fix side menu
* Handle view modes
* Disable playlist routes
* Make SafeDynamicImport work again
* Bring back router-debug
* Separate redux location sync from route rendering
* Refactor updateLocation to thunk and move force refresh(login) to it
* Fixing init dashboard issue
* Support switching between dashboards without an unmount of DashboardPage
* More fixes for init dashboard and panel edit
* More type fixes
* Moving angular location wrapper out of main LocationService, and fixing typescript issues
* Fixed last typescript errors
* LocationService: Move to runtime and remove getLocationService and export singleston const instead (#31523)
* Moving location service implementation to runtime and removing get function and making it a package const singleton
* Added test that used locationService directly
* removed unused import
* AngularApp: Moving angular dependencies and the app boot out of the main app into it's own file (#31525)
* Fixes angular panels by calling the monkey patch
* Moving angular stuff to to it's own files
* udpated
* Fixing clicking on divs and spans inside anchor
* Moving app notifications out of angular app and removing angular directive wrapper
* Moving search from angular to react and removing angular search wrapper
* Clean up, tried to remove the redux location wrapper but requires a big update for DashboardPage, so adding it back
* Moving AppWrapper to root to limit circular dependencies (app/core -> app/routing and back)
* Open and close search now works
* Hide sidemenu when in kiosk mode
* Restoring some keybindings like ESC key
* Removed kiosk events and simplified it, just handled through updating URL
* Fixing typescript errors
* Simplified GrafanaRouteComponentProps and renamed to ContainerProps
* renamed back
* Changed AlertRuleList to use GrafanaRouteComponentProps and location.search passed to it
* Removing the reloadOnSearch property, this is not needed now for react as react by default does not unmount components when only url match or query parmas change
* SafeDynamicImport causing unmount un every search update, not sure how to fix yet
* Fix signature for SafeDynamicImport so we do not create new route components on every route render
* Removing the redux location wrapper as it was causing errors, and making dashboard page work with RouteProps (location, match) etc
* Updating DashboardPage and SoloPanelPage to use match params and history location
* Fixed DashboardPage tests
* Fixing solo route tests
* LocationService: Rename getCurrentLocation to just getLocation
* do not intercept link clicks with target blank or self
* Experimental useUrlParams hook
* Update DataSourceSettingsPage to use router match params
* fix links with urls that have no starting / to work like before
* Fix forceLogin
* Add queryParams to GrafanaRouteComponentProps
* PanelEditor get rid of updateLocation and location state
* Improve grafana route query params typing
* Add getSearchObject to LocationService
* Use DashboardPAge queryParams instead of location.search parsing
* Fix DashboardPage typing
* Fix some tests weirdness
* Bring back KeyboardSrv
* Fixes typescript issues
* Team pages now use router match params
* Get rid of from GrafanaRouteComponent props
* Removed unnessary calls to getSearchObject when calling locationService.partial
* Updated DashboardPage tests after queryParams was added
* Fixing dashboard settings back
* GrafanaRoute: Adding tests and remove use of global locationService
* Fixing tests and typescript errors
* Bring back kiosk modes and add tests
* Fix TimeSrv tests
* Fix typecheck errors
* Fixing tests
* Updated SideMenu test to react-testing and wrapped component in Router, and fixed issue importing createMemoryHistory
* Get rid of routeChange event from TimeSrv from
* Fixed TopSectionItem test
* Trying to make basename work but failing
* Update TopSectionItem snapshot
* Fix TopSectionItem snapshot test
* Fix API keys creation
* Remove Angular dependencies from KeybindingSrv (#31617)
* Remove Angular dependency from KeybindingsSrv
* Fix tests and typecheck issues
* basename is starting to work
* Make dashboard save work
* KeybindingSrv: Remove as angular service and no usage angular scope
* So long bridge_srv, we won't miss you
* Update snapshots
* Dashboard: Refactoring ChangeTracker to use History api and no angular (#31653)
* Dashboard: Refactoring ChangeTracker to use History api and no angular
* Updated
* Removed logging
* fixed unit tests
* updated snapshots
* Mechanism for force reloading routes (#31683)
* e2e: Fixes various things in e2e scenarios after router migration (#31685)
* Explore: Update reading query params from router props and updating location via locationService (ReactRouter) (#31688)
* RoutingNG: Initial explore redux location to router location migration
* Updated explore Wrapper tests
* Fixing more tests
* remove loggin
* rename back to make naming consistent
* Fixing return to dashboard button
* fixing navigation to explore from dashboard
* updated routeProps
* Updated tests
* Make DashboardListPage work
* Fixing navigation after add new data source, and fixes explore e2e
* Fixing solo panel page
* PluginsPage now works
* RoutingNG: When parsing and rendering url search/query params preseve old logic of handling booleans and arrays (#31725)
* RoutingNG: When parsing and rendering url search/query params preserve old logic of handling booleans and arrays
* Fixed test
* Make snapshots list work
* fixed alert notification channel edit page
* Simplify LocationService, did not need special handling for login or forceLogin as target _self on link already handles that
* fixed UserAdminPage
* fixed edit orgs page
* Fixing LdapPage
* fixing dashboard import
* Fixed new folder page
* Fixed data source dashboards page
* fixing Folder permissions and folder settings page
* fixing snapshot list page nav model
* remove unused file
* Added placeholder page for playlist
* Moved browser compatability to index-template
* Restored 404/default page
* Fixed reset password page
* Fixed SignUpInvited page
* Fixing CreateTeam, Create user page, add panel widget
* Restore browwser file to make tests happy
* Fixed unit tests
* Removed unused import
* Replacing usage of updateLocation
* Fixed test
* Updating search filters to use history / location service for filters
* remove unused file
* AppRootPage fixed
* Fixing test and search issue
* Changes to support enterprise extensions
* remove console.log
* Removing more use of redux location
* Fixed signup page
* removed unused old angular controllers
* Fixing bugs
* one final bugfix
* Removed location from redux state
* Fixing ts issues and tests
* Fixing test issue
* fixing tests
* Fixing tests
* removed unused stuff
* Fixed search test
* Adding some doc comments
* Routing NG: Angular location provider patch (#31773)
* Patch Angulars $location provider
* Update public/app/angular/bridgeReactAngularRouting.ts
* Remove only test
* Update tests, disable loggers in test env
* Routing NG: remove $location provider usage (#31816)
* Remove dashboard_loaders
* Remove $location from Analytics service, track page views form GrafanaRoute
* Remove NotificationsEditCtrl
* Remove Angular dependencies from uploadDashboardDirective
* Update public/app/features/dashboard/containers/DashboardPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/features/dashboard/containers/DashboardPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Remove unused test helpers (#31831)
* Playlist react (#31829)
* playlist list in react
* Playlist start
* Things started to work
* Updated
* Handle empty list
* Fix ts
* Fixes and kiosk mode stuff
* Removed unused events
* fixing ts issue
* Another ts issue
* Fixing tests
Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
* fixed test
* Update public/app/AppWrapper.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/AppWrapper.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Remove Angular dependency from DashboardLoaderSrv (#31863)
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-03-11 01:03:36 +08:00
|
|
|
import { locationService } from '@grafana/runtime';
|
2021-02-26 19:29:28 +08:00
|
|
|
import { Icon, IconButton, styleMixins, useStyles } from '@grafana/ui';
|
2020-04-27 15:09:05 +08:00
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
2021-03-25 15:33:13 +08:00
|
|
|
import { GrafanaTheme } from '@grafana/data';
|
2021-02-25 18:26:28 +08:00
|
|
|
|
2017-10-16 15:55:55 +08:00
|
|
|
import config from 'app/core/config';
|
2019-02-06 00:15:21 +08:00
|
|
|
import store from 'app/core/store';
|
2021-04-07 17:27:45 +08:00
|
|
|
import { FilterInput } from 'app/core/components/FilterInput/FilterInput';
|
2020-02-23 04:08:42 +08:00
|
|
|
import { addPanel } from 'app/features/dashboard/state/reducers';
|
2019-12-09 16:14:25 +08:00
|
|
|
import { DashboardModel, PanelModel } from '../../state';
|
2021-02-25 18:26:28 +08:00
|
|
|
import { LibraryPanelsView } from '../../../library-panels/components/LibraryPanelsView/LibraryPanelsView';
|
2017-12-26 20:20:45 +08:00
|
|
|
import { LS_PANEL_COPY_KEY } from 'app/core/constants';
|
2021-03-02 23:37:36 +08:00
|
|
|
import { LibraryPanelDTO } from '../../../library-panels/types';
|
|
|
|
|
import { toPanelModelLibraryPanel } from '../../../library-panels/utils';
|
2017-10-16 15:55:55 +08:00
|
|
|
|
2019-08-01 20:38:34 +08:00
|
|
|
export type PanelPluginInfo = { id: any; defaults: { gridPos: { w: any; h: any }; title: any } };
|
|
|
|
|
|
2020-02-10 21:23:54 +08:00
|
|
|
export interface OwnProps {
|
2017-10-16 15:55:55 +08:00
|
|
|
panel: PanelModel;
|
2018-01-03 20:33:54 +08:00
|
|
|
dashboard: DashboardModel;
|
2017-10-16 15:55:55 +08:00
|
|
|
}
|
|
|
|
|
|
2020-02-10 21:23:54 +08:00
|
|
|
export interface DispatchProps {
|
2020-02-23 04:08:42 +08:00
|
|
|
addPanel: typeof addPanel;
|
2020-02-10 21:23:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type Props = OwnProps & DispatchProps;
|
|
|
|
|
|
2020-04-21 19:40:49 +08:00
|
|
|
const getCopiedPanelPlugins = () => {
|
|
|
|
|
const panels = _.chain(config.panels)
|
|
|
|
|
.filter({ hideFromList: false })
|
2021-01-20 14:59:48 +08:00
|
|
|
.map((item) => item)
|
2020-04-21 19:40:49 +08:00
|
|
|
.value();
|
|
|
|
|
const copiedPanels = [];
|
|
|
|
|
|
|
|
|
|
const copiedPanelJson = store.get(LS_PANEL_COPY_KEY);
|
|
|
|
|
if (copiedPanelJson) {
|
|
|
|
|
const copiedPanel = JSON.parse(copiedPanelJson);
|
|
|
|
|
const pluginInfo: any = _.find(panels, { id: copiedPanel.type });
|
|
|
|
|
if (pluginInfo) {
|
|
|
|
|
const pluginCopy = _.cloneDeep(pluginInfo);
|
|
|
|
|
pluginCopy.name = copiedPanel.title;
|
|
|
|
|
pluginCopy.sort = -1;
|
|
|
|
|
pluginCopy.defaults = copiedPanel;
|
|
|
|
|
copiedPanels.push(pluginCopy);
|
|
|
|
|
}
|
2017-10-16 15:55:55 +08:00
|
|
|
}
|
|
|
|
|
|
2020-04-21 19:40:49 +08:00
|
|
|
return _.sortBy(copiedPanels, 'sort');
|
|
|
|
|
};
|
2019-02-05 19:47:42 +08:00
|
|
|
|
Routing NG: Replace Angular routing with react-router (#31463)
* Add router packages
* Get react app root work instead of Angular one
* Logger util
* Patch Angular routing ($routeProvider, $routeParamsProvider)
* Use react-router-dom history instead of separate dependency
* Add test routes
* Sidemenu - use Link instead of anchors
* Patch Angular $location service (stub)
* WIP: geting rid of $location provider from TimeSrv
* Intercept anchor clicks to use history under the hood
* Sync Redux location slice with history state
* Make login/logout work
* Debug routes for testing
* Make force login work
* Make sure query param change does not recreate page components
* Hide side menu in specified locations
* Make the dashboar route query parameters work, make panel edit menu work
* Enable more routes
* Fix side menu
* Handle view modes
* Disable playlist routes
* Make SafeDynamicImport work again
* Bring back router-debug
* Separate redux location sync from route rendering
* Refactor updateLocation to thunk and move force refresh(login) to it
* Fixing init dashboard issue
* Support switching between dashboards without an unmount of DashboardPage
* More fixes for init dashboard and panel edit
* More type fixes
* Moving angular location wrapper out of main LocationService, and fixing typescript issues
* Fixed last typescript errors
* LocationService: Move to runtime and remove getLocationService and export singleston const instead (#31523)
* Moving location service implementation to runtime and removing get function and making it a package const singleton
* Added test that used locationService directly
* removed unused import
* AngularApp: Moving angular dependencies and the app boot out of the main app into it's own file (#31525)
* Fixes angular panels by calling the monkey patch
* Moving angular stuff to to it's own files
* udpated
* Fixing clicking on divs and spans inside anchor
* Moving app notifications out of angular app and removing angular directive wrapper
* Moving search from angular to react and removing angular search wrapper
* Clean up, tried to remove the redux location wrapper but requires a big update for DashboardPage, so adding it back
* Moving AppWrapper to root to limit circular dependencies (app/core -> app/routing and back)
* Open and close search now works
* Hide sidemenu when in kiosk mode
* Restoring some keybindings like ESC key
* Removed kiosk events and simplified it, just handled through updating URL
* Fixing typescript errors
* Simplified GrafanaRouteComponentProps and renamed to ContainerProps
* renamed back
* Changed AlertRuleList to use GrafanaRouteComponentProps and location.search passed to it
* Removing the reloadOnSearch property, this is not needed now for react as react by default does not unmount components when only url match or query parmas change
* SafeDynamicImport causing unmount un every search update, not sure how to fix yet
* Fix signature for SafeDynamicImport so we do not create new route components on every route render
* Removing the redux location wrapper as it was causing errors, and making dashboard page work with RouteProps (location, match) etc
* Updating DashboardPage and SoloPanelPage to use match params and history location
* Fixed DashboardPage tests
* Fixing solo route tests
* LocationService: Rename getCurrentLocation to just getLocation
* do not intercept link clicks with target blank or self
* Experimental useUrlParams hook
* Update DataSourceSettingsPage to use router match params
* fix links with urls that have no starting / to work like before
* Fix forceLogin
* Add queryParams to GrafanaRouteComponentProps
* PanelEditor get rid of updateLocation and location state
* Improve grafana route query params typing
* Add getSearchObject to LocationService
* Use DashboardPAge queryParams instead of location.search parsing
* Fix DashboardPage typing
* Fix some tests weirdness
* Bring back KeyboardSrv
* Fixes typescript issues
* Team pages now use router match params
* Get rid of from GrafanaRouteComponent props
* Removed unnessary calls to getSearchObject when calling locationService.partial
* Updated DashboardPage tests after queryParams was added
* Fixing dashboard settings back
* GrafanaRoute: Adding tests and remove use of global locationService
* Fixing tests and typescript errors
* Bring back kiosk modes and add tests
* Fix TimeSrv tests
* Fix typecheck errors
* Fixing tests
* Updated SideMenu test to react-testing and wrapped component in Router, and fixed issue importing createMemoryHistory
* Get rid of routeChange event from TimeSrv from
* Fixed TopSectionItem test
* Trying to make basename work but failing
* Update TopSectionItem snapshot
* Fix TopSectionItem snapshot test
* Fix API keys creation
* Remove Angular dependencies from KeybindingSrv (#31617)
* Remove Angular dependency from KeybindingsSrv
* Fix tests and typecheck issues
* basename is starting to work
* Make dashboard save work
* KeybindingSrv: Remove as angular service and no usage angular scope
* So long bridge_srv, we won't miss you
* Update snapshots
* Dashboard: Refactoring ChangeTracker to use History api and no angular (#31653)
* Dashboard: Refactoring ChangeTracker to use History api and no angular
* Updated
* Removed logging
* fixed unit tests
* updated snapshots
* Mechanism for force reloading routes (#31683)
* e2e: Fixes various things in e2e scenarios after router migration (#31685)
* Explore: Update reading query params from router props and updating location via locationService (ReactRouter) (#31688)
* RoutingNG: Initial explore redux location to router location migration
* Updated explore Wrapper tests
* Fixing more tests
* remove loggin
* rename back to make naming consistent
* Fixing return to dashboard button
* fixing navigation to explore from dashboard
* updated routeProps
* Updated tests
* Make DashboardListPage work
* Fixing navigation after add new data source, and fixes explore e2e
* Fixing solo panel page
* PluginsPage now works
* RoutingNG: When parsing and rendering url search/query params preseve old logic of handling booleans and arrays (#31725)
* RoutingNG: When parsing and rendering url search/query params preserve old logic of handling booleans and arrays
* Fixed test
* Make snapshots list work
* fixed alert notification channel edit page
* Simplify LocationService, did not need special handling for login or forceLogin as target _self on link already handles that
* fixed UserAdminPage
* fixed edit orgs page
* Fixing LdapPage
* fixing dashboard import
* Fixed new folder page
* Fixed data source dashboards page
* fixing Folder permissions and folder settings page
* fixing snapshot list page nav model
* remove unused file
* Added placeholder page for playlist
* Moved browser compatability to index-template
* Restored 404/default page
* Fixed reset password page
* Fixed SignUpInvited page
* Fixing CreateTeam, Create user page, add panel widget
* Restore browwser file to make tests happy
* Fixed unit tests
* Removed unused import
* Replacing usage of updateLocation
* Fixed test
* Updating search filters to use history / location service for filters
* remove unused file
* AppRootPage fixed
* Fixing test and search issue
* Changes to support enterprise extensions
* remove console.log
* Removing more use of redux location
* Fixed signup page
* removed unused old angular controllers
* Fixing bugs
* one final bugfix
* Removed location from redux state
* Fixing ts issues and tests
* Fixing test issue
* fixing tests
* Fixing tests
* removed unused stuff
* Fixed search test
* Adding some doc comments
* Routing NG: Angular location provider patch (#31773)
* Patch Angulars $location provider
* Update public/app/angular/bridgeReactAngularRouting.ts
* Remove only test
* Update tests, disable loggers in test env
* Routing NG: remove $location provider usage (#31816)
* Remove dashboard_loaders
* Remove $location from Analytics service, track page views form GrafanaRoute
* Remove NotificationsEditCtrl
* Remove Angular dependencies from uploadDashboardDirective
* Update public/app/features/dashboard/containers/DashboardPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/features/dashboard/containers/DashboardPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Remove unused test helpers (#31831)
* Playlist react (#31829)
* playlist list in react
* Playlist start
* Things started to work
* Updated
* Handle empty list
* Fix ts
* Fixes and kiosk mode stuff
* Removed unused events
* fixing ts issue
* Another ts issue
* Fixing tests
Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
* fixed test
* Update public/app/AppWrapper.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/AppWrapper.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Remove Angular dependency from DashboardLoaderSrv (#31863)
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-03-11 01:03:36 +08:00
|
|
|
export const AddPanelWidgetUnconnected: React.FC<Props> = ({ panel, dashboard }) => {
|
2021-02-25 18:26:28 +08:00
|
|
|
const [addPanelView, setAddPanelView] = useState(false);
|
2021-04-07 17:27:45 +08:00
|
|
|
const [searchQuery, setSearchQuery] = useState('');
|
2018-12-14 21:33:49 +08:00
|
|
|
|
2021-02-25 18:26:28 +08:00
|
|
|
const onCancelAddPanel = (evt: React.MouseEvent<HTMLButtonElement>) => {
|
2018-12-14 21:33:49 +08:00
|
|
|
evt.preventDefault();
|
2020-04-21 19:40:49 +08:00
|
|
|
dashboard.removePanel(panel);
|
|
|
|
|
};
|
2017-12-26 20:20:45 +08:00
|
|
|
|
2021-02-25 18:26:28 +08:00
|
|
|
const onBack = () => {
|
|
|
|
|
setAddPanelView(false);
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-21 19:40:49 +08:00
|
|
|
const onCreateNewPanel = () => {
|
|
|
|
|
const { gridPos } = panel;
|
2017-10-16 15:55:55 +08:00
|
|
|
|
2021-02-25 18:26:28 +08:00
|
|
|
const newPanel: Partial<PanelModel> = {
|
2018-12-15 03:53:42 +08:00
|
|
|
type: 'graph',
|
2017-10-16 15:55:55 +08:00
|
|
|
title: 'Panel Title',
|
2017-12-22 01:10:24 +08:00
|
|
|
gridPos: { x: gridPos.x, y: gridPos.y, w: gridPos.w, h: gridPos.h },
|
2017-10-16 16:39:50 +08:00
|
|
|
};
|
|
|
|
|
|
2017-12-26 20:20:45 +08:00
|
|
|
dashboard.addPanel(newPanel);
|
2020-04-21 19:40:49 +08:00
|
|
|
dashboard.removePanel(panel);
|
2018-12-15 03:53:42 +08:00
|
|
|
|
Routing NG: Replace Angular routing with react-router (#31463)
* Add router packages
* Get react app root work instead of Angular one
* Logger util
* Patch Angular routing ($routeProvider, $routeParamsProvider)
* Use react-router-dom history instead of separate dependency
* Add test routes
* Sidemenu - use Link instead of anchors
* Patch Angular $location service (stub)
* WIP: geting rid of $location provider from TimeSrv
* Intercept anchor clicks to use history under the hood
* Sync Redux location slice with history state
* Make login/logout work
* Debug routes for testing
* Make force login work
* Make sure query param change does not recreate page components
* Hide side menu in specified locations
* Make the dashboar route query parameters work, make panel edit menu work
* Enable more routes
* Fix side menu
* Handle view modes
* Disable playlist routes
* Make SafeDynamicImport work again
* Bring back router-debug
* Separate redux location sync from route rendering
* Refactor updateLocation to thunk and move force refresh(login) to it
* Fixing init dashboard issue
* Support switching between dashboards without an unmount of DashboardPage
* More fixes for init dashboard and panel edit
* More type fixes
* Moving angular location wrapper out of main LocationService, and fixing typescript issues
* Fixed last typescript errors
* LocationService: Move to runtime and remove getLocationService and export singleston const instead (#31523)
* Moving location service implementation to runtime and removing get function and making it a package const singleton
* Added test that used locationService directly
* removed unused import
* AngularApp: Moving angular dependencies and the app boot out of the main app into it's own file (#31525)
* Fixes angular panels by calling the monkey patch
* Moving angular stuff to to it's own files
* udpated
* Fixing clicking on divs and spans inside anchor
* Moving app notifications out of angular app and removing angular directive wrapper
* Moving search from angular to react and removing angular search wrapper
* Clean up, tried to remove the redux location wrapper but requires a big update for DashboardPage, so adding it back
* Moving AppWrapper to root to limit circular dependencies (app/core -> app/routing and back)
* Open and close search now works
* Hide sidemenu when in kiosk mode
* Restoring some keybindings like ESC key
* Removed kiosk events and simplified it, just handled through updating URL
* Fixing typescript errors
* Simplified GrafanaRouteComponentProps and renamed to ContainerProps
* renamed back
* Changed AlertRuleList to use GrafanaRouteComponentProps and location.search passed to it
* Removing the reloadOnSearch property, this is not needed now for react as react by default does not unmount components when only url match or query parmas change
* SafeDynamicImport causing unmount un every search update, not sure how to fix yet
* Fix signature for SafeDynamicImport so we do not create new route components on every route render
* Removing the redux location wrapper as it was causing errors, and making dashboard page work with RouteProps (location, match) etc
* Updating DashboardPage and SoloPanelPage to use match params and history location
* Fixed DashboardPage tests
* Fixing solo route tests
* LocationService: Rename getCurrentLocation to just getLocation
* do not intercept link clicks with target blank or self
* Experimental useUrlParams hook
* Update DataSourceSettingsPage to use router match params
* fix links with urls that have no starting / to work like before
* Fix forceLogin
* Add queryParams to GrafanaRouteComponentProps
* PanelEditor get rid of updateLocation and location state
* Improve grafana route query params typing
* Add getSearchObject to LocationService
* Use DashboardPAge queryParams instead of location.search parsing
* Fix DashboardPage typing
* Fix some tests weirdness
* Bring back KeyboardSrv
* Fixes typescript issues
* Team pages now use router match params
* Get rid of from GrafanaRouteComponent props
* Removed unnessary calls to getSearchObject when calling locationService.partial
* Updated DashboardPage tests after queryParams was added
* Fixing dashboard settings back
* GrafanaRoute: Adding tests and remove use of global locationService
* Fixing tests and typescript errors
* Bring back kiosk modes and add tests
* Fix TimeSrv tests
* Fix typecheck errors
* Fixing tests
* Updated SideMenu test to react-testing and wrapped component in Router, and fixed issue importing createMemoryHistory
* Get rid of routeChange event from TimeSrv from
* Fixed TopSectionItem test
* Trying to make basename work but failing
* Update TopSectionItem snapshot
* Fix TopSectionItem snapshot test
* Fix API keys creation
* Remove Angular dependencies from KeybindingSrv (#31617)
* Remove Angular dependency from KeybindingsSrv
* Fix tests and typecheck issues
* basename is starting to work
* Make dashboard save work
* KeybindingSrv: Remove as angular service and no usage angular scope
* So long bridge_srv, we won't miss you
* Update snapshots
* Dashboard: Refactoring ChangeTracker to use History api and no angular (#31653)
* Dashboard: Refactoring ChangeTracker to use History api and no angular
* Updated
* Removed logging
* fixed unit tests
* updated snapshots
* Mechanism for force reloading routes (#31683)
* e2e: Fixes various things in e2e scenarios after router migration (#31685)
* Explore: Update reading query params from router props and updating location via locationService (ReactRouter) (#31688)
* RoutingNG: Initial explore redux location to router location migration
* Updated explore Wrapper tests
* Fixing more tests
* remove loggin
* rename back to make naming consistent
* Fixing return to dashboard button
* fixing navigation to explore from dashboard
* updated routeProps
* Updated tests
* Make DashboardListPage work
* Fixing navigation after add new data source, and fixes explore e2e
* Fixing solo panel page
* PluginsPage now works
* RoutingNG: When parsing and rendering url search/query params preseve old logic of handling booleans and arrays (#31725)
* RoutingNG: When parsing and rendering url search/query params preserve old logic of handling booleans and arrays
* Fixed test
* Make snapshots list work
* fixed alert notification channel edit page
* Simplify LocationService, did not need special handling for login or forceLogin as target _self on link already handles that
* fixed UserAdminPage
* fixed edit orgs page
* Fixing LdapPage
* fixing dashboard import
* Fixed new folder page
* Fixed data source dashboards page
* fixing Folder permissions and folder settings page
* fixing snapshot list page nav model
* remove unused file
* Added placeholder page for playlist
* Moved browser compatability to index-template
* Restored 404/default page
* Fixed reset password page
* Fixed SignUpInvited page
* Fixing CreateTeam, Create user page, add panel widget
* Restore browwser file to make tests happy
* Fixed unit tests
* Removed unused import
* Replacing usage of updateLocation
* Fixed test
* Updating search filters to use history / location service for filters
* remove unused file
* AppRootPage fixed
* Fixing test and search issue
* Changes to support enterprise extensions
* remove console.log
* Removing more use of redux location
* Fixed signup page
* removed unused old angular controllers
* Fixing bugs
* one final bugfix
* Removed location from redux state
* Fixing ts issues and tests
* Fixing test issue
* fixing tests
* Fixing tests
* removed unused stuff
* Fixed search test
* Adding some doc comments
* Routing NG: Angular location provider patch (#31773)
* Patch Angulars $location provider
* Update public/app/angular/bridgeReactAngularRouting.ts
* Remove only test
* Update tests, disable loggers in test env
* Routing NG: remove $location provider usage (#31816)
* Remove dashboard_loaders
* Remove $location from Analytics service, track page views form GrafanaRoute
* Remove NotificationsEditCtrl
* Remove Angular dependencies from uploadDashboardDirective
* Update public/app/features/dashboard/containers/DashboardPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/features/dashboard/containers/DashboardPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Remove unused test helpers (#31831)
* Playlist react (#31829)
* playlist list in react
* Playlist start
* Things started to work
* Updated
* Handle empty list
* Fix ts
* Fixes and kiosk mode stuff
* Removed unused events
* fixing ts issue
* Another ts issue
* Fixing tests
Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
* fixed test
* Update public/app/AppWrapper.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/AppWrapper.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Remove Angular dependency from DashboardLoaderSrv (#31863)
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-03-11 01:03:36 +08:00
|
|
|
locationService.partial({ editPanel: newPanel.id });
|
2017-12-26 20:20:45 +08:00
|
|
|
};
|
2017-12-22 01:10:24 +08:00
|
|
|
|
2020-04-21 19:40:49 +08:00
|
|
|
const onPasteCopiedPanel = (panelPluginInfo: PanelPluginInfo) => {
|
|
|
|
|
const { gridPos } = panel;
|
2018-02-21 22:39:15 +08:00
|
|
|
|
2018-12-14 21:33:49 +08:00
|
|
|
const newPanel: any = {
|
|
|
|
|
type: panelPluginInfo.id,
|
|
|
|
|
title: 'Panel Title',
|
2019-03-06 22:19:58 +08:00
|
|
|
gridPos: {
|
|
|
|
|
x: gridPos.x,
|
|
|
|
|
y: gridPos.y,
|
|
|
|
|
w: panelPluginInfo.defaults.gridPos.w,
|
|
|
|
|
h: panelPluginInfo.defaults.gridPos.h,
|
|
|
|
|
},
|
2018-12-14 21:33:49 +08:00
|
|
|
};
|
2017-10-16 15:55:55 +08:00
|
|
|
|
2018-12-14 21:33:49 +08:00
|
|
|
// apply panel template / defaults
|
|
|
|
|
if (panelPluginInfo.defaults) {
|
|
|
|
|
_.defaults(newPanel, panelPluginInfo.defaults);
|
|
|
|
|
newPanel.title = panelPluginInfo.defaults.title;
|
|
|
|
|
store.delete(LS_PANEL_COPY_KEY);
|
|
|
|
|
}
|
2018-02-22 16:58:52 +08:00
|
|
|
|
2018-12-14 21:33:49 +08:00
|
|
|
dashboard.addPanel(newPanel);
|
2020-04-21 19:40:49 +08:00
|
|
|
dashboard.removePanel(panel);
|
2018-12-14 21:33:49 +08:00
|
|
|
};
|
2018-06-07 09:08:39 +08:00
|
|
|
|
2021-02-25 18:26:28 +08:00
|
|
|
const onAddLibraryPanel = (panelInfo: LibraryPanelDTO) => {
|
|
|
|
|
const { gridPos } = panel;
|
|
|
|
|
|
|
|
|
|
const newPanel: PanelModel = {
|
|
|
|
|
...panelInfo.model,
|
|
|
|
|
gridPos,
|
2021-03-02 23:37:36 +08:00
|
|
|
libraryPanel: toPanelModelLibraryPanel(panelInfo),
|
2021-02-25 18:26:28 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
dashboard.addPanel(newPanel);
|
|
|
|
|
dashboard.removePanel(panel);
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-21 19:40:49 +08:00
|
|
|
const onCreateNewRow = () => {
|
2018-12-14 21:33:49 +08:00
|
|
|
const newRow: any = {
|
2018-12-15 03:53:42 +08:00
|
|
|
type: 'row',
|
2018-12-14 21:33:49 +08:00
|
|
|
title: 'Row title',
|
|
|
|
|
gridPos: { x: 0, y: 0 },
|
|
|
|
|
};
|
2018-02-21 21:51:28 +08:00
|
|
|
|
2018-12-14 21:33:49 +08:00
|
|
|
dashboard.addPanel(newRow);
|
2020-04-21 19:40:49 +08:00
|
|
|
dashboard.removePanel(panel);
|
2018-12-14 21:33:49 +08:00
|
|
|
};
|
2018-02-21 21:51:28 +08:00
|
|
|
|
2021-02-25 18:26:28 +08:00
|
|
|
const styles = useStyles(getStyles);
|
|
|
|
|
const copiedPanelPlugins = useMemo(() => getCopiedPanelPlugins(), []);
|
|
|
|
|
|
2020-04-21 19:40:49 +08:00
|
|
|
return (
|
|
|
|
|
<div className={cx('panel-container', styles.wrapper)}>
|
2021-02-26 19:29:28 +08:00
|
|
|
<AddPanelWidgetHandle onCancel={onCancelAddPanel} onBack={addPanelView ? onBack : undefined} styles={styles}>
|
2021-02-25 18:26:28 +08:00
|
|
|
{addPanelView ? 'Add panel from panel library' : 'Add panel'}
|
|
|
|
|
</AddPanelWidgetHandle>
|
|
|
|
|
{addPanelView ? (
|
2021-04-07 17:27:45 +08:00
|
|
|
<>
|
|
|
|
|
<div className={styles.panelSearchInput}>
|
|
|
|
|
<FilterInput width={0} value={searchQuery} onChange={setSearchQuery} placeholder={'Search global panels'} />
|
|
|
|
|
</div>
|
|
|
|
|
<LibraryPanelsView
|
|
|
|
|
className={styles.libraryPanelsWrapper}
|
|
|
|
|
onClickCard={(panel) => onAddLibraryPanel(panel)}
|
|
|
|
|
showSecondaryActions={false}
|
|
|
|
|
searchString={searchQuery}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
2021-02-25 18:26:28 +08:00
|
|
|
) : (
|
|
|
|
|
<div className={styles.actionsWrapper}>
|
|
|
|
|
<div className={styles.actionsRow}>
|
|
|
|
|
<div onClick={() => onCreateNewPanel()} aria-label={selectors.pages.AddDashboard.addNewPanel}>
|
|
|
|
|
<Icon name="file-blank" size="xl" />
|
|
|
|
|
Add an empty panel
|
|
|
|
|
</div>
|
|
|
|
|
<div onClick={onCreateNewRow}>
|
|
|
|
|
<Icon name="wrap-text" size="xl" />
|
|
|
|
|
Add a new row
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{(config.featureToggles.panelLibrary || copiedPanelPlugins.length === 1) && (
|
|
|
|
|
<div className={styles.actionsRow}>
|
|
|
|
|
{config.featureToggles.panelLibrary && (
|
|
|
|
|
<div onClick={() => setAddPanelView(true)}>
|
|
|
|
|
<Icon name="book-open" size="xl" />
|
|
|
|
|
Add a panel from the panel library
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{copiedPanelPlugins.length === 1 && (
|
|
|
|
|
<div onClick={() => onPasteCopiedPanel(copiedPanelPlugins[0])}>
|
|
|
|
|
<Icon name="clipboard-alt" size="xl" />
|
|
|
|
|
Paste panel from clipboard
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2017-12-02 03:11:55 +08:00
|
|
|
</div>
|
2021-02-25 18:26:28 +08:00
|
|
|
)}
|
2020-04-21 19:40:49 +08:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
2020-02-10 21:23:54 +08:00
|
|
|
|
Routing NG: Replace Angular routing with react-router (#31463)
* Add router packages
* Get react app root work instead of Angular one
* Logger util
* Patch Angular routing ($routeProvider, $routeParamsProvider)
* Use react-router-dom history instead of separate dependency
* Add test routes
* Sidemenu - use Link instead of anchors
* Patch Angular $location service (stub)
* WIP: geting rid of $location provider from TimeSrv
* Intercept anchor clicks to use history under the hood
* Sync Redux location slice with history state
* Make login/logout work
* Debug routes for testing
* Make force login work
* Make sure query param change does not recreate page components
* Hide side menu in specified locations
* Make the dashboar route query parameters work, make panel edit menu work
* Enable more routes
* Fix side menu
* Handle view modes
* Disable playlist routes
* Make SafeDynamicImport work again
* Bring back router-debug
* Separate redux location sync from route rendering
* Refactor updateLocation to thunk and move force refresh(login) to it
* Fixing init dashboard issue
* Support switching between dashboards without an unmount of DashboardPage
* More fixes for init dashboard and panel edit
* More type fixes
* Moving angular location wrapper out of main LocationService, and fixing typescript issues
* Fixed last typescript errors
* LocationService: Move to runtime and remove getLocationService and export singleston const instead (#31523)
* Moving location service implementation to runtime and removing get function and making it a package const singleton
* Added test that used locationService directly
* removed unused import
* AngularApp: Moving angular dependencies and the app boot out of the main app into it's own file (#31525)
* Fixes angular panels by calling the monkey patch
* Moving angular stuff to to it's own files
* udpated
* Fixing clicking on divs and spans inside anchor
* Moving app notifications out of angular app and removing angular directive wrapper
* Moving search from angular to react and removing angular search wrapper
* Clean up, tried to remove the redux location wrapper but requires a big update for DashboardPage, so adding it back
* Moving AppWrapper to root to limit circular dependencies (app/core -> app/routing and back)
* Open and close search now works
* Hide sidemenu when in kiosk mode
* Restoring some keybindings like ESC key
* Removed kiosk events and simplified it, just handled through updating URL
* Fixing typescript errors
* Simplified GrafanaRouteComponentProps and renamed to ContainerProps
* renamed back
* Changed AlertRuleList to use GrafanaRouteComponentProps and location.search passed to it
* Removing the reloadOnSearch property, this is not needed now for react as react by default does not unmount components when only url match or query parmas change
* SafeDynamicImport causing unmount un every search update, not sure how to fix yet
* Fix signature for SafeDynamicImport so we do not create new route components on every route render
* Removing the redux location wrapper as it was causing errors, and making dashboard page work with RouteProps (location, match) etc
* Updating DashboardPage and SoloPanelPage to use match params and history location
* Fixed DashboardPage tests
* Fixing solo route tests
* LocationService: Rename getCurrentLocation to just getLocation
* do not intercept link clicks with target blank or self
* Experimental useUrlParams hook
* Update DataSourceSettingsPage to use router match params
* fix links with urls that have no starting / to work like before
* Fix forceLogin
* Add queryParams to GrafanaRouteComponentProps
* PanelEditor get rid of updateLocation and location state
* Improve grafana route query params typing
* Add getSearchObject to LocationService
* Use DashboardPAge queryParams instead of location.search parsing
* Fix DashboardPage typing
* Fix some tests weirdness
* Bring back KeyboardSrv
* Fixes typescript issues
* Team pages now use router match params
* Get rid of from GrafanaRouteComponent props
* Removed unnessary calls to getSearchObject when calling locationService.partial
* Updated DashboardPage tests after queryParams was added
* Fixing dashboard settings back
* GrafanaRoute: Adding tests and remove use of global locationService
* Fixing tests and typescript errors
* Bring back kiosk modes and add tests
* Fix TimeSrv tests
* Fix typecheck errors
* Fixing tests
* Updated SideMenu test to react-testing and wrapped component in Router, and fixed issue importing createMemoryHistory
* Get rid of routeChange event from TimeSrv from
* Fixed TopSectionItem test
* Trying to make basename work but failing
* Update TopSectionItem snapshot
* Fix TopSectionItem snapshot test
* Fix API keys creation
* Remove Angular dependencies from KeybindingSrv (#31617)
* Remove Angular dependency from KeybindingsSrv
* Fix tests and typecheck issues
* basename is starting to work
* Make dashboard save work
* KeybindingSrv: Remove as angular service and no usage angular scope
* So long bridge_srv, we won't miss you
* Update snapshots
* Dashboard: Refactoring ChangeTracker to use History api and no angular (#31653)
* Dashboard: Refactoring ChangeTracker to use History api and no angular
* Updated
* Removed logging
* fixed unit tests
* updated snapshots
* Mechanism for force reloading routes (#31683)
* e2e: Fixes various things in e2e scenarios after router migration (#31685)
* Explore: Update reading query params from router props and updating location via locationService (ReactRouter) (#31688)
* RoutingNG: Initial explore redux location to router location migration
* Updated explore Wrapper tests
* Fixing more tests
* remove loggin
* rename back to make naming consistent
* Fixing return to dashboard button
* fixing navigation to explore from dashboard
* updated routeProps
* Updated tests
* Make DashboardListPage work
* Fixing navigation after add new data source, and fixes explore e2e
* Fixing solo panel page
* PluginsPage now works
* RoutingNG: When parsing and rendering url search/query params preseve old logic of handling booleans and arrays (#31725)
* RoutingNG: When parsing and rendering url search/query params preserve old logic of handling booleans and arrays
* Fixed test
* Make snapshots list work
* fixed alert notification channel edit page
* Simplify LocationService, did not need special handling for login or forceLogin as target _self on link already handles that
* fixed UserAdminPage
* fixed edit orgs page
* Fixing LdapPage
* fixing dashboard import
* Fixed new folder page
* Fixed data source dashboards page
* fixing Folder permissions and folder settings page
* fixing snapshot list page nav model
* remove unused file
* Added placeholder page for playlist
* Moved browser compatability to index-template
* Restored 404/default page
* Fixed reset password page
* Fixed SignUpInvited page
* Fixing CreateTeam, Create user page, add panel widget
* Restore browwser file to make tests happy
* Fixed unit tests
* Removed unused import
* Replacing usage of updateLocation
* Fixed test
* Updating search filters to use history / location service for filters
* remove unused file
* AppRootPage fixed
* Fixing test and search issue
* Changes to support enterprise extensions
* remove console.log
* Removing more use of redux location
* Fixed signup page
* removed unused old angular controllers
* Fixing bugs
* one final bugfix
* Removed location from redux state
* Fixing ts issues and tests
* Fixing test issue
* fixing tests
* Fixing tests
* removed unused stuff
* Fixed search test
* Adding some doc comments
* Routing NG: Angular location provider patch (#31773)
* Patch Angulars $location provider
* Update public/app/angular/bridgeReactAngularRouting.ts
* Remove only test
* Update tests, disable loggers in test env
* Routing NG: remove $location provider usage (#31816)
* Remove dashboard_loaders
* Remove $location from Analytics service, track page views form GrafanaRoute
* Remove NotificationsEditCtrl
* Remove Angular dependencies from uploadDashboardDirective
* Update public/app/features/dashboard/containers/DashboardPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/features/dashboard/containers/DashboardPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Remove unused test helpers (#31831)
* Playlist react (#31829)
* playlist list in react
* Playlist start
* Things started to work
* Updated
* Handle empty list
* Fix ts
* Fixes and kiosk mode stuff
* Removed unused events
* fixing ts issue
* Another ts issue
* Fixing tests
Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
* fixed test
* Update public/app/AppWrapper.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/AppWrapper.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Remove Angular dependency from DashboardLoaderSrv (#31863)
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-03-11 01:03:36 +08:00
|
|
|
const mapDispatchToProps: MapDispatchToProps<DispatchProps, OwnProps> = { addPanel };
|
2020-02-10 21:23:54 +08:00
|
|
|
|
2021-02-25 18:26:28 +08:00
|
|
|
export const AddPanelWidget = connect(undefined, mapDispatchToProps)(AddPanelWidgetUnconnected);
|
2020-04-21 19:40:49 +08:00
|
|
|
|
|
|
|
|
interface AddPanelWidgetHandleProps {
|
|
|
|
|
onCancel: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
2021-02-25 18:26:28 +08:00
|
|
|
onBack?: () => void;
|
|
|
|
|
children?: string;
|
2021-02-26 19:29:28 +08:00
|
|
|
styles: AddPanelStyles;
|
2020-04-21 19:40:49 +08:00
|
|
|
}
|
2021-02-25 18:26:28 +08:00
|
|
|
|
2021-02-26 19:29:28 +08:00
|
|
|
const AddPanelWidgetHandle: React.FC<AddPanelWidgetHandleProps> = ({ children, onBack, onCancel, styles }) => {
|
2020-04-21 19:40:49 +08:00
|
|
|
return (
|
2021-02-26 19:29:28 +08:00
|
|
|
<div className={cx(styles.headerRow, 'grid-drag-handle')}>
|
|
|
|
|
{onBack && (
|
|
|
|
|
<div className={styles.backButton}>
|
|
|
|
|
<IconButton name="arrow-left" onClick={onBack} surface="header" size="xl" />
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{!onBack && (
|
|
|
|
|
<div className={styles.backButton}>
|
|
|
|
|
<Icon name="panel-add" size="md" />
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2021-02-25 18:26:28 +08:00
|
|
|
{children && <span>{children}</span>}
|
2021-02-26 19:29:28 +08:00
|
|
|
<div className="flex-grow-1" />
|
|
|
|
|
<IconButton name="times" onClick={onCancel} surface="header" />
|
2020-04-21 19:40:49 +08:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-26 19:29:28 +08:00
|
|
|
const getStyles = (theme: GrafanaTheme) => {
|
2020-04-21 19:40:49 +08:00
|
|
|
const pulsate = keyframes`
|
|
|
|
|
0% {box-shadow: 0 0 0 2px ${theme.colors.bodyBg}, 0 0 0px 4px ${theme.colors.formFocusOutline};}
|
|
|
|
|
50% {box-shadow: 0 0 0 2px ${theme.colors.bodyBg}, 0 0 0px 4px ${tinycolor(theme.colors.formFocusOutline)
|
|
|
|
|
.darken(20)
|
|
|
|
|
.toHexString()};}
|
|
|
|
|
100% {box-shadow: 0 0 0 2px ${theme.colors.bodyBg}, 0 0 0px 4px ${theme.colors.formFocusOutline};}
|
|
|
|
|
`;
|
2021-02-26 19:29:28 +08:00
|
|
|
|
2020-04-21 19:40:49 +08:00
|
|
|
return {
|
2021-04-07 17:27:45 +08:00
|
|
|
panelSearchInput: css`
|
|
|
|
|
padding-left: ${theme.spacing.sm};
|
|
|
|
|
padding-right: ${theme.spacing.sm};
|
|
|
|
|
`,
|
2020-04-21 19:40:49 +08:00
|
|
|
wrapper: css`
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
outline: 2px dotted transparent;
|
|
|
|
|
outline-offset: 2px;
|
|
|
|
|
box-shadow: 0 0 0 2px black, 0 0 0px 4px #1f60c4;
|
|
|
|
|
animation: ${pulsate} 2s ease infinite;
|
|
|
|
|
`,
|
2021-02-25 18:26:28 +08:00
|
|
|
actionsRow: css`
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
column-gap: ${theme.spacing.sm};
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
|
|
> div {
|
|
|
|
|
justify-self: center;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
background: ${theme.colors.bg2};
|
|
|
|
|
border-radius: ${theme.border.radius.sm};
|
|
|
|
|
color: ${theme.colors.text};
|
|
|
|
|
width: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
background: ${styleMixins.hoverColor(theme.colors.bg2, theme)};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:hover > #book-icon {
|
|
|
|
|
background: linear-gradient(#f05a28 30%, #fbca0a 99%);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`,
|
2020-04-21 19:40:49 +08:00
|
|
|
actionsWrapper: css`
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
2021-02-25 18:26:28 +08:00
|
|
|
row-gap: ${theme.spacing.sm};
|
2021-02-26 19:29:28 +08:00
|
|
|
padding: 0 ${theme.spacing.sm} ${theme.spacing.sm} ${theme.spacing.sm};
|
2020-04-21 19:40:49 +08:00
|
|
|
height: 100%;
|
2021-02-25 18:26:28 +08:00
|
|
|
`,
|
|
|
|
|
libraryPanelsWrapper: css`
|
2021-02-26 19:29:28 +08:00
|
|
|
padding: ${theme.spacing.sm};
|
2020-04-21 19:40:49 +08:00
|
|
|
`,
|
2021-02-26 19:29:28 +08:00
|
|
|
headerRow: css`
|
2020-04-21 19:40:49 +08:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2021-02-26 19:29:28 +08:00
|
|
|
height: 38px;
|
|
|
|
|
flex-shrink: 0;
|
2021-02-25 18:26:28 +08:00
|
|
|
width: 100%;
|
|
|
|
|
font-size: ${theme.typography.size.md};
|
|
|
|
|
font-weight: ${theme.typography.weight.semibold};
|
2021-02-26 19:29:28 +08:00
|
|
|
padding-left: ${theme.spacing.sm};
|
2020-04-21 19:40:49 +08:00
|
|
|
transition: background-color 0.1s ease-in-out;
|
2021-02-25 18:26:28 +08:00
|
|
|
cursor: move;
|
2021-02-26 19:29:28 +08:00
|
|
|
|
2020-04-21 19:40:49 +08:00
|
|
|
&:hover {
|
|
|
|
|
background: ${theme.colors.bg2};
|
|
|
|
|
}
|
|
|
|
|
`,
|
2021-02-25 18:26:28 +08:00
|
|
|
backButton: css`
|
2020-04-21 19:40:49 +08:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2021-02-25 18:26:28 +08:00
|
|
|
cursor: pointer;
|
|
|
|
|
padding-left: ${theme.spacing.xs};
|
|
|
|
|
width: ${theme.spacing.xl};
|
2020-04-21 19:40:49 +08:00
|
|
|
`,
|
2021-02-25 18:26:28 +08:00
|
|
|
noMargin: css`
|
|
|
|
|
margin: 0;
|
2020-04-21 19:40:49 +08:00
|
|
|
`,
|
|
|
|
|
};
|
2021-02-26 19:29:28 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type AddPanelStyles = ReturnType<typeof getStyles>;
|