2021-04-01 14:15:23 +02:00
|
|
|
import { css, cx, keyframes } from '@emotion/css';
|
2021-04-21 08:38:00 +01:00
|
|
|
import { chain, cloneDeep, defaults, find, sortBy } from 'lodash';
|
2022-04-22 14:33:13 +01:00
|
|
|
import React, { useMemo, useState } from 'react';
|
|
|
|
|
import { connect, MapDispatchToProps } from 'react-redux';
|
2021-02-25 10:26:28 +00:00
|
|
|
import tinycolor from 'tinycolor2';
|
2022-04-22 14:33:13 +01:00
|
|
|
|
|
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
2021-07-09 11:45:25 +02:00
|
|
|
import { locationService, reportInteraction } from '@grafana/runtime';
|
2021-11-25 09:41:03 +01:00
|
|
|
import { Icon, IconButton, useStyles2 } from '@grafana/ui';
|
2022-04-22 14:33:13 +01:00
|
|
|
import { CardButton } from 'app/core/components/CardButton';
|
2017-10-16 09:55:55 +02:00
|
|
|
import config from 'app/core/config';
|
2022-04-22 14:33:13 +01:00
|
|
|
import { LS_PANEL_COPY_KEY } from 'app/core/constants';
|
2019-02-05 17:15:21 +01:00
|
|
|
import store from 'app/core/store';
|
2020-02-22 21:08:42 +01:00
|
|
|
import { addPanel } from 'app/features/dashboard/state/reducers';
|
2022-04-22 14:33:13 +01:00
|
|
|
|
2021-04-28 17:34:18 +02:00
|
|
|
import {
|
|
|
|
|
LibraryPanelsSearch,
|
|
|
|
|
LibraryPanelsSearchVariant,
|
|
|
|
|
} from '../../../library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch';
|
2022-04-22 14:33:13 +01:00
|
|
|
import { LibraryElementDTO } from '../../../library-panels/types';
|
|
|
|
|
import { DashboardModel, PanelModel } from '../../state';
|
2017-10-16 09:55:55 +02:00
|
|
|
|
2023-03-14 09:51:44 +00:00
|
|
|
export type PanelPluginInfo = { id: number; defaults: { gridPos: { w: number; h: number }; title: string } };
|
2019-08-01 14:38:34 +02:00
|
|
|
|
2020-02-10 14:23:54 +01:00
|
|
|
export interface OwnProps {
|
2017-10-16 09:55:55 +02:00
|
|
|
panel: PanelModel;
|
2018-01-03 13:33:54 +01:00
|
|
|
dashboard: DashboardModel;
|
2017-10-16 09:55:55 +02:00
|
|
|
}
|
|
|
|
|
|
2020-02-10 14:23:54 +01:00
|
|
|
export interface DispatchProps {
|
2020-02-22 21:08:42 +01:00
|
|
|
addPanel: typeof addPanel;
|
2020-02-10 14:23:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type Props = OwnProps & DispatchProps;
|
|
|
|
|
|
2020-04-21 13:40:49 +02:00
|
|
|
const getCopiedPanelPlugins = () => {
|
2021-04-21 08:38:00 +01:00
|
|
|
const panels = chain(config.panels)
|
2020-04-21 13:40:49 +02:00
|
|
|
.filter({ hideFromList: false })
|
2021-01-20 07:59:48 +01:00
|
|
|
.map((item) => item)
|
2020-04-21 13:40:49 +02:00
|
|
|
.value();
|
|
|
|
|
const copiedPanels = [];
|
|
|
|
|
|
|
|
|
|
const copiedPanelJson = store.get(LS_PANEL_COPY_KEY);
|
|
|
|
|
if (copiedPanelJson) {
|
|
|
|
|
const copiedPanel = JSON.parse(copiedPanelJson);
|
2021-04-21 08:38:00 +01:00
|
|
|
const pluginInfo: any = find(panels, { id: copiedPanel.type });
|
2020-04-21 13:40:49 +02:00
|
|
|
if (pluginInfo) {
|
2021-04-21 08:38:00 +01:00
|
|
|
const pluginCopy = cloneDeep(pluginInfo);
|
2020-04-21 13:40:49 +02:00
|
|
|
pluginCopy.name = copiedPanel.title;
|
|
|
|
|
pluginCopy.sort = -1;
|
|
|
|
|
pluginCopy.defaults = copiedPanel;
|
|
|
|
|
copiedPanels.push(pluginCopy);
|
|
|
|
|
}
|
2017-10-16 09:55:55 +02:00
|
|
|
}
|
|
|
|
|
|
2021-04-21 08:38:00 +01:00
|
|
|
return sortBy(copiedPanels, 'sort');
|
2020-04-21 13:40:49 +02:00
|
|
|
};
|
2019-02-05 12:47:42 +01:00
|
|
|
|
2022-08-24 13:54:34 -07:00
|
|
|
export const AddPanelWidgetUnconnected = ({ panel, dashboard }: Props) => {
|
2021-02-25 10:26:28 +00:00
|
|
|
const [addPanelView, setAddPanelView] = useState(false);
|
2018-12-14 14:33:49 +01:00
|
|
|
|
2021-02-25 10:26:28 +00:00
|
|
|
const onCancelAddPanel = (evt: React.MouseEvent<HTMLButtonElement>) => {
|
2018-12-14 14:33:49 +01:00
|
|
|
evt.preventDefault();
|
2020-04-21 13:40:49 +02:00
|
|
|
dashboard.removePanel(panel);
|
|
|
|
|
};
|
2017-12-26 13:20:45 +01:00
|
|
|
|
2021-02-25 10:26:28 +00:00
|
|
|
const onBack = () => {
|
|
|
|
|
setAddPanelView(false);
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-21 13:40:49 +02:00
|
|
|
const onCreateNewPanel = () => {
|
|
|
|
|
const { gridPos } = panel;
|
2017-10-16 09:55:55 +02:00
|
|
|
|
2021-02-25 10:26:28 +00:00
|
|
|
const newPanel: Partial<PanelModel> = {
|
2021-05-05 13:19:14 +02:00
|
|
|
type: 'timeseries',
|
2017-10-16 09:55:55 +02:00
|
|
|
title: 'Panel Title',
|
2023-01-06 15:21:40 +01:00
|
|
|
datasource: panel.datasource,
|
2017-12-21 18:10:24 +01:00
|
|
|
gridPos: { x: gridPos.x, y: gridPos.y, w: gridPos.w, h: gridPos.h },
|
2023-04-25 17:18:58 +03:00
|
|
|
isNew: true,
|
2017-10-16 10:39:50 +02:00
|
|
|
};
|
|
|
|
|
|
2017-12-26 13:20:45 +01:00
|
|
|
dashboard.addPanel(newPanel);
|
2020-04-21 13:40:49 +02:00
|
|
|
dashboard.removePanel(panel);
|
2018-12-14 20:53:42 +01: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-10 18:03:36 +01:00
|
|
|
locationService.partial({ editPanel: newPanel.id });
|
2017-12-26 13:20:45 +01:00
|
|
|
};
|
2017-12-21 18:10:24 +01:00
|
|
|
|
2020-04-21 13:40:49 +02:00
|
|
|
const onPasteCopiedPanel = (panelPluginInfo: PanelPluginInfo) => {
|
|
|
|
|
const { gridPos } = panel;
|
2018-02-21 15:39:15 +01:00
|
|
|
|
2023-03-14 09:51:44 +00:00
|
|
|
const newPanel = {
|
2018-12-14 14:33:49 +01:00
|
|
|
type: panelPluginInfo.id,
|
|
|
|
|
title: 'Panel Title',
|
2019-03-06 15:19:58 +01:00
|
|
|
gridPos: {
|
|
|
|
|
x: gridPos.x,
|
|
|
|
|
y: gridPos.y,
|
|
|
|
|
w: panelPluginInfo.defaults.gridPos.w,
|
|
|
|
|
h: panelPluginInfo.defaults.gridPos.h,
|
|
|
|
|
},
|
2018-12-14 14:33:49 +01:00
|
|
|
};
|
2017-10-16 09:55:55 +02:00
|
|
|
|
2018-12-14 14:33:49 +01:00
|
|
|
// apply panel template / defaults
|
|
|
|
|
if (panelPluginInfo.defaults) {
|
2021-04-21 08:38:00 +01:00
|
|
|
defaults(newPanel, panelPluginInfo.defaults);
|
2018-12-14 14:33:49 +01:00
|
|
|
newPanel.title = panelPluginInfo.defaults.title;
|
|
|
|
|
store.delete(LS_PANEL_COPY_KEY);
|
|
|
|
|
}
|
2018-02-22 09:58:52 +01:00
|
|
|
|
2018-12-14 14:33:49 +01:00
|
|
|
dashboard.addPanel(newPanel);
|
2020-04-21 13:40:49 +02:00
|
|
|
dashboard.removePanel(panel);
|
2018-12-14 14:33:49 +01:00
|
|
|
};
|
2018-06-07 03:08:39 +02:00
|
|
|
|
2021-05-11 07:10:19 +02:00
|
|
|
const onAddLibraryPanel = (panelInfo: LibraryElementDTO) => {
|
2021-02-25 10:26:28 +00:00
|
|
|
const { gridPos } = panel;
|
|
|
|
|
|
2023-01-29 20:14:12 -08:00
|
|
|
const newPanel = {
|
2021-02-25 10:26:28 +00:00
|
|
|
...panelInfo.model,
|
|
|
|
|
gridPos,
|
2022-10-26 15:38:20 -07:00
|
|
|
libraryPanel: panelInfo,
|
2021-02-25 10:26:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
dashboard.addPanel(newPanel);
|
|
|
|
|
dashboard.removePanel(panel);
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-21 13:40:49 +02:00
|
|
|
const onCreateNewRow = () => {
|
2023-03-14 09:51:44 +00:00
|
|
|
const newRow = {
|
2018-12-14 20:53:42 +01:00
|
|
|
type: 'row',
|
2018-12-14 14:33:49 +01:00
|
|
|
title: 'Row title',
|
|
|
|
|
gridPos: { x: 0, y: 0 },
|
|
|
|
|
};
|
2018-02-21 14:51:28 +01:00
|
|
|
|
2018-12-14 14:33:49 +01:00
|
|
|
dashboard.addPanel(newRow);
|
2020-04-21 13:40:49 +02:00
|
|
|
dashboard.removePanel(panel);
|
2018-12-14 14:33:49 +01:00
|
|
|
};
|
2018-02-21 14:51:28 +01:00
|
|
|
|
2021-08-20 14:53:03 +02:00
|
|
|
const styles = useStyles2(getStyles);
|
2021-02-25 10:26:28 +00:00
|
|
|
const copiedPanelPlugins = useMemo(() => getCopiedPanelPlugins(), []);
|
|
|
|
|
|
2020-04-21 13:40:49 +02:00
|
|
|
return (
|
2021-05-27 15:28:09 +02:00
|
|
|
<div className={styles.wrapper}>
|
|
|
|
|
<div className={cx('panel-container', styles.callToAction)}>
|
|
|
|
|
<AddPanelWidgetHandle onCancel={onCancelAddPanel} onBack={addPanelView ? onBack : undefined} styles={styles}>
|
|
|
|
|
{addPanelView ? 'Add panel from panel library' : 'Add panel'}
|
|
|
|
|
</AddPanelWidgetHandle>
|
|
|
|
|
{addPanelView ? (
|
|
|
|
|
<LibraryPanelsSearch onClick={onAddLibraryPanel} variant={LibraryPanelsSearchVariant.Tight} showPanelFilter />
|
|
|
|
|
) : (
|
|
|
|
|
<div className={styles.actionsWrapper}>
|
2021-11-25 09:41:03 +01:00
|
|
|
<CardButton
|
|
|
|
|
icon="file-blank"
|
|
|
|
|
aria-label={selectors.pages.AddDashboard.addNewPanel}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
reportInteraction('Create new panel');
|
|
|
|
|
onCreateNewPanel();
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Add a new panel
|
|
|
|
|
</CardButton>
|
|
|
|
|
<CardButton
|
|
|
|
|
icon="wrap-text"
|
|
|
|
|
aria-label={selectors.pages.AddDashboard.addNewRow}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
reportInteraction('Create new row');
|
|
|
|
|
onCreateNewRow();
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Add a new row
|
|
|
|
|
</CardButton>
|
|
|
|
|
<CardButton
|
|
|
|
|
icon="book-open"
|
|
|
|
|
aria-label={selectors.pages.AddDashboard.addNewPanelLibrary}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
reportInteraction('Add a panel from the panel library');
|
|
|
|
|
setAddPanelView(true);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Add a panel from the panel library
|
|
|
|
|
</CardButton>
|
|
|
|
|
{copiedPanelPlugins.length === 1 && (
|
|
|
|
|
<CardButton
|
|
|
|
|
icon="clipboard-alt"
|
|
|
|
|
aria-label={selectors.pages.AddDashboard.addNewPanelLibrary}
|
2021-07-09 11:45:25 +02:00
|
|
|
onClick={() => {
|
2021-11-25 09:41:03 +01:00
|
|
|
reportInteraction('Paste panel from clipboard');
|
|
|
|
|
onPasteCopiedPanel(copiedPanelPlugins[0]);
|
2021-07-09 11:45:25 +02:00
|
|
|
}}
|
|
|
|
|
>
|
2021-11-25 09:41:03 +01:00
|
|
|
Paste panel from clipboard
|
|
|
|
|
</CardButton>
|
|
|
|
|
)}
|
2021-05-12 08:48:17 +02:00
|
|
|
</div>
|
2021-05-27 15:28:09 +02:00
|
|
|
)}
|
|
|
|
|
</div>
|
2020-04-21 13:40:49 +02:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
2020-02-10 14:23:54 +01: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-10 18:03:36 +01:00
|
|
|
const mapDispatchToProps: MapDispatchToProps<DispatchProps, OwnProps> = { addPanel };
|
2020-02-10 14:23:54 +01:00
|
|
|
|
2021-02-25 10:26:28 +00:00
|
|
|
export const AddPanelWidget = connect(undefined, mapDispatchToProps)(AddPanelWidgetUnconnected);
|
2020-04-21 13:40:49 +02:00
|
|
|
|
|
|
|
|
interface AddPanelWidgetHandleProps {
|
|
|
|
|
onCancel: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
2021-02-25 10:26:28 +00:00
|
|
|
onBack?: () => void;
|
|
|
|
|
children?: string;
|
2021-02-26 12:29:28 +01:00
|
|
|
styles: AddPanelStyles;
|
2020-04-21 13:40:49 +02:00
|
|
|
}
|
2021-02-25 10:26:28 +00:00
|
|
|
|
2023-03-15 07:56:09 -07:00
|
|
|
const AddPanelWidgetHandle = ({ children, onBack, onCancel, styles }: AddPanelWidgetHandleProps) => {
|
2020-04-21 13:40:49 +02:00
|
|
|
return (
|
2021-02-26 12:29:28 +01:00
|
|
|
<div className={cx(styles.headerRow, 'grid-drag-handle')}>
|
|
|
|
|
{onBack && (
|
|
|
|
|
<div className={styles.backButton}>
|
2023-06-08 10:23:28 +02:00
|
|
|
<IconButton name="arrow-left" onClick={onBack} size="xl" tooltip="Go back" />
|
2021-02-26 12:29:28 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{!onBack && (
|
|
|
|
|
<div className={styles.backButton}>
|
2023-03-30 13:50:35 +03:00
|
|
|
<Icon name="panel-add" size="xl" />
|
2021-02-26 12:29:28 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|
2021-02-25 10:26:28 +00:00
|
|
|
{children && <span>{children}</span>}
|
2021-02-26 12:29:28 +01:00
|
|
|
<div className="flex-grow-1" />
|
2023-06-08 10:23:28 +02:00
|
|
|
<IconButton aria-label="Close 'Add Panel' widget" name="times" onClick={onCancel} tooltip="Close widget" />
|
2020-04-21 13:40:49 +02:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2021-08-20 14:53:03 +02:00
|
|
|
const getStyles = (theme: GrafanaTheme2) => {
|
2020-04-21 13:40:49 +02:00
|
|
|
const pulsate = keyframes`
|
2021-08-20 14:53:03 +02:00
|
|
|
0% {box-shadow: 0 0 0 2px ${theme.colors.background.canvas}, 0 0 0px 4px ${theme.colors.primary.main};}
|
|
|
|
|
50% {box-shadow: 0 0 0 2px ${theme.components.dashboard.background}, 0 0 0px 4px ${tinycolor(
|
|
|
|
|
theme.colors.primary.main
|
|
|
|
|
)
|
2020-04-21 13:40:49 +02:00
|
|
|
.darken(20)
|
|
|
|
|
.toHexString()};}
|
2021-08-20 14:53:03 +02:00
|
|
|
100% {box-shadow: 0 0 0 2px ${theme.components.dashboard.background}, 0 0 0px 4px ${theme.colors.primary.main};}
|
2020-04-21 13:40:49 +02:00
|
|
|
`;
|
2021-02-26 12:29:28 +01:00
|
|
|
|
2020-04-21 13:40:49 +02:00
|
|
|
return {
|
2021-05-27 15:28:09 +02:00
|
|
|
// wrapper is used to make sure box-shadow animation isn't cut off in dashboard page
|
2020-04-21 13:40:49 +02:00
|
|
|
wrapper: css`
|
2021-05-27 15:28:09 +02:00
|
|
|
height: 100%;
|
2021-08-20 14:53:03 +02:00
|
|
|
padding-top: ${theme.spacing(0.5)};
|
2021-05-27 15:28:09 +02:00
|
|
|
`,
|
|
|
|
|
callToAction: css`
|
2020-04-21 13:40:49 +02:00
|
|
|
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-11-25 09:41:03 +01:00
|
|
|
actionsWrapper: css`
|
2021-02-25 10:26:28 +00:00
|
|
|
height: 100%;
|
2021-11-25 09:41:03 +01:00
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
|
column-gap: ${theme.spacing(1)};
|
|
|
|
|
row-gap: ${theme.spacing(1)};
|
|
|
|
|
padding: ${theme.spacing(0, 1, 1, 1)};
|
2021-02-25 10:26:28 +00:00
|
|
|
|
2021-11-25 09:41:03 +01:00
|
|
|
// This is to make the last action full width (if by itself)
|
|
|
|
|
& > div:nth-child(2n-1):nth-last-of-type(1) {
|
|
|
|
|
grid-column: span 2;
|
2021-02-25 10:26:28 +00:00
|
|
|
}
|
|
|
|
|
`,
|
2021-02-26 12:29:28 +01:00
|
|
|
headerRow: css`
|
2020-04-21 13:40:49 +02:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2021-02-26 12:29:28 +01:00
|
|
|
height: 38px;
|
|
|
|
|
flex-shrink: 0;
|
2021-02-25 10:26:28 +00:00
|
|
|
width: 100%;
|
2021-08-20 14:53:03 +02:00
|
|
|
font-size: ${theme.typography.fontSize};
|
|
|
|
|
font-weight: ${theme.typography.fontWeightMedium};
|
|
|
|
|
padding-left: ${theme.spacing(1)};
|
2020-04-21 13:40:49 +02:00
|
|
|
transition: background-color 0.1s ease-in-out;
|
2021-02-25 10:26:28 +00:00
|
|
|
cursor: move;
|
2021-02-26 12:29:28 +01:00
|
|
|
|
2020-04-21 13:40:49 +02:00
|
|
|
&:hover {
|
2021-08-20 14:53:03 +02:00
|
|
|
background: ${theme.colors.background.secondary};
|
2020-04-21 13:40:49 +02:00
|
|
|
}
|
|
|
|
|
`,
|
2021-02-25 10:26:28 +00:00
|
|
|
backButton: css`
|
2020-04-21 13:40:49 +02:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2021-02-25 10:26:28 +00:00
|
|
|
cursor: pointer;
|
2021-08-20 14:53:03 +02:00
|
|
|
padding-left: ${theme.spacing(0.5)};
|
|
|
|
|
width: ${theme.spacing(4)};
|
2020-04-21 13:40:49 +02:00
|
|
|
`,
|
2021-02-25 10:26:28 +00:00
|
|
|
noMargin: css`
|
|
|
|
|
margin: 0;
|
2020-04-21 13:40:49 +02:00
|
|
|
`,
|
|
|
|
|
};
|
2021-02-26 12:29:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type AddPanelStyles = ReturnType<typeof getStyles>;
|