mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Clean up over-selectoring dashboard (#14765)
This commit is contained in:
parent
cfaf09df07
commit
ff7b383cee
7 changed files with 45 additions and 158 deletions
|
@ -1,22 +0,0 @@
|
|||
/**
|
||||
* @typedef {Object} EmbeddableState
|
||||
* @property {string} title
|
||||
* @property {string} editUrl
|
||||
* @property {string|object} error
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param embeddable {Embeddable}
|
||||
* @return {string}
|
||||
*/
|
||||
export const getTitle = embeddable => embeddable.title;
|
||||
/**
|
||||
* @param embeddable {Embeddable}
|
||||
* @return {string}
|
||||
*/
|
||||
export const getEditUrl = embeddable => embeddable.editUrl;
|
||||
/**
|
||||
* @param embeddable {Embeddable}
|
||||
* @return {string}
|
||||
*/
|
||||
export const getError = embeddable => embeddable.error;
|
|
@ -1,34 +0,0 @@
|
|||
import {
|
||||
getTitle,
|
||||
getEditUrl,
|
||||
getError,
|
||||
} from './embeddable';
|
||||
|
||||
/**
|
||||
* @typedef {Object.<string, EmbeddableState>} EmbeddablesState
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param embeddables {EmbeddablesState}
|
||||
* @param panelId {string}
|
||||
* @return {Embeddable}
|
||||
*/
|
||||
export const getEmbeddable = (embeddables, panelId) => embeddables[panelId];
|
||||
/**
|
||||
* @param embeddables {EmbeddablesState}
|
||||
* @param panelId {string}
|
||||
* @return {string}
|
||||
*/
|
||||
export const getEmbeddableTitle = (embeddables, panelId) => getTitle(getEmbeddable(embeddables, panelId));
|
||||
/**
|
||||
* @param embeddables {EmbeddablesState}
|
||||
* @param panelId {string}
|
||||
* @return {string}
|
||||
*/
|
||||
export const getEmbeddableEditUrl = (embeddables, panelId) => getEditUrl(getEmbeddable(embeddables, panelId));
|
||||
/**
|
||||
* @param embeddables {EmbeddablesState}
|
||||
* @param panelId {string}
|
||||
* @return {string}
|
||||
*/
|
||||
export const getEmbeddableError = (embeddables, panelId) => getError(getEmbeddable(embeddables, panelId));
|
|
@ -1,98 +1,87 @@
|
|||
import {
|
||||
getEmbeddableTitle as getEmbeddableTitleFromEmbeddables,
|
||||
getEmbeddableEditUrl as getEmbeddableEditUrlFromEmbeddables,
|
||||
getEmbeddableError as getEmbeddableErrorFromEmbeddables,
|
||||
getEmbeddable as getEmbeddableFromEmbeddables,
|
||||
} from './embeddables';
|
||||
/**
|
||||
* @typedef {Object} ViewState
|
||||
* @property {DashboardViewMode} viewMode
|
||||
* @property {boolean} isFullScreenMode
|
||||
* @property {string|undefined} maximizedPanelId
|
||||
*/
|
||||
|
||||
import {
|
||||
getPanel as getPanelFromPanels,
|
||||
getPanelType as getPanelTypeFromPanels
|
||||
} from './panels';
|
||||
|
||||
import {
|
||||
getViewMode as getViewModeFromView,
|
||||
getFullScreenMode as getFullScreenModeFromView,
|
||||
getMaximizedPanelId as getMaximizedPanelIdFromView
|
||||
} from './view';
|
||||
/**
|
||||
* @typedef {Object} EmbeddableState
|
||||
* @property {string} title
|
||||
* @property {string} editUrl
|
||||
* @property {string|object} error
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} DashboardState
|
||||
* @property {Object} PanelsState
|
||||
* @property {Object} EmbeddablesState
|
||||
* @property {Object} ViewState
|
||||
* @property {Object.<string, PanelState>} panels
|
||||
* @property {Object.<string, EmbeddableState>} embeddables
|
||||
* @property {ViewState} view
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param dashboard {DashboardState}
|
||||
* @return {PanelsState}
|
||||
* @return {Object.<string, PanelState>}
|
||||
*/
|
||||
export const getPanels = dashboard => dashboard.panels;
|
||||
|
||||
/**
|
||||
* @param dashboard {DashboardState}
|
||||
* @param panelId {string}
|
||||
* @return {PanelState}
|
||||
*/
|
||||
export const getPanel = (dashboard, panelId) => getPanelFromPanels(getPanels(dashboard), panelId);
|
||||
export const getPanel = (dashboard, panelId) => getPanels(dashboard)[panelId];
|
||||
/**
|
||||
* @param dashboard {DashboardState}
|
||||
* @param panelId {string}
|
||||
* @return {string}
|
||||
*/
|
||||
export const getPanelType = (dashboard, panelId) => getPanelTypeFromPanels(getPanels(dashboard), panelId);
|
||||
export const getPanelType = (dashboard, panelId) => getPanel(dashboard, panelId).type;
|
||||
|
||||
/**
|
||||
* @param dashboard {DashboardState}
|
||||
* @return {EmbeddablesState}
|
||||
*/
|
||||
export const getEmbeddables = dashboard => dashboard.embeddables;
|
||||
/**
|
||||
* @param dashboard {DashboardState}
|
||||
* @param panelId {string}
|
||||
* @return {EmbeddableState}
|
||||
*/
|
||||
export const getEmbeddable = (dashboard, panelId) => getEmbeddableFromEmbeddables(getEmbeddables(dashboard), panelId);
|
||||
export const getEmbeddable = (dashboard, panelId) => dashboard.embeddables[panelId];
|
||||
|
||||
/**
|
||||
* @param dashboard {DashboardState}
|
||||
* @param panelId {string}
|
||||
* @return {string|Object}
|
||||
*/
|
||||
export const getEmbeddableError =
|
||||
(dashboard, panelId) => getEmbeddableErrorFromEmbeddables(getEmbeddables(dashboard), panelId);
|
||||
export const getEmbeddableError = (dashboard, panelId) => getEmbeddable(dashboard, panelId).error;
|
||||
/**
|
||||
* @param dashboard {DashboardState}
|
||||
* @param panelId {string}
|
||||
* @return {string}
|
||||
*/
|
||||
export const getEmbeddableTitle =
|
||||
(dashboard, panelId) => getEmbeddableTitleFromEmbeddables(getEmbeddables(dashboard), panelId);
|
||||
export const getEmbeddableTitle = (dashboard, panelId) => getEmbeddable(dashboard, panelId).title;
|
||||
/**
|
||||
* @param dashboard {DashboardState}
|
||||
* @param panelId {string}
|
||||
* @return {string}
|
||||
*/
|
||||
export const getEmbeddableEditUrl =
|
||||
(dashboard, panelId) => getEmbeddableEditUrlFromEmbeddables(getEmbeddables(dashboard), panelId);
|
||||
export const getEmbeddableEditUrl = (dashboard, panelId) => getEmbeddable(dashboard, panelId).editUrl;
|
||||
|
||||
/**
|
||||
* @param dashboard {DashboardState}
|
||||
* @return {ViewState}
|
||||
*/
|
||||
export const getView = dashboard => dashboard.view;
|
||||
/**
|
||||
* @param dashboard {DashboardState}
|
||||
* @return {DashboardViewMode}
|
||||
*/
|
||||
export const getViewMode = dashboard => getViewModeFromView(getView(dashboard));
|
||||
/**
|
||||
* @param dashboard {DashboardState}
|
||||
* @return {boolean}
|
||||
*/
|
||||
export const getFullScreenMode = dashboard => getFullScreenModeFromView(getView(dashboard));
|
||||
export const getUseMargins = dashboard => dashboard.view.useMargins;
|
||||
/**
|
||||
* @param dashboard {DashboardState}
|
||||
* @return {DashboardViewMode}
|
||||
*/
|
||||
export const getViewMode = dashboard => dashboard.view.viewMode;
|
||||
/**
|
||||
* @param dashboard {DashboardState}
|
||||
* @return {boolean}
|
||||
*/
|
||||
export const getFullScreenMode = dashboard => dashboard.view.isFullScreenMode;
|
||||
/**
|
||||
* @param dashboard {DashboardState}
|
||||
* @return {string|undefined}
|
||||
*/
|
||||
export const getMaximizedPanelId = dashboard => getMaximizedPanelIdFromView(getView(dashboard));
|
||||
export const getMaximizedPanelId = dashboard => dashboard.view.maximizedPanelId;
|
||||
|
||||
export const getUseMargins = dashboard => getView(dashboard).useMargins;
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
/**
|
||||
* NOTE: The PanelState jsdoc is defined in ../panel/panel_state. Right now whatever is stored on this tree is
|
||||
* saved both to appstate and with the dashboard object. This coupling is subtle, fragile, and should be removed.
|
||||
* TODO: make a function to translate the redux panel state into an object to be used for storage and/or appstate.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param panel {PanelState}
|
||||
* @return {string}
|
||||
*/
|
||||
export const getPanelType = panel => panel.type;
|
|
@ -1,19 +0,0 @@
|
|||
import { getPanelType as getPanelTypeFromPanel } from './panel';
|
||||
|
||||
/**
|
||||
* @typedef {Object.<string, PanelState>} PanelsState
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param panels {PanelsState}
|
||||
* @param panelId {string}
|
||||
* @return {PanelState}
|
||||
*/
|
||||
export const getPanel = (panels, panelId) => panels[panelId];
|
||||
|
||||
/**
|
||||
* @param panels {PanelsState}
|
||||
* @param panelId {string}
|
||||
* @return {string}
|
||||
*/
|
||||
export const getPanelType = (panels, panelId) => getPanelTypeFromPanel(getPanel(panels, panelId));
|
|
@ -1,22 +0,0 @@
|
|||
/**
|
||||
* @typedef {Object} ViewState
|
||||
* @property {DashboardViewMode} viewMode
|
||||
* @property {boolean} isFullScreenMode
|
||||
* @property {string|undefined} maximizedPanelId
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param view {ViewState}
|
||||
* @return {DashboardViewMode}
|
||||
*/
|
||||
export const getViewMode = view => view.viewMode;
|
||||
/**
|
||||
* @param view {ViewState}
|
||||
* @return {boolean}
|
||||
*/
|
||||
export const getFullScreenMode = view => view.isFullScreenMode;
|
||||
/**
|
||||
* @param view {ViewState}
|
||||
* @return {string|undefined}
|
||||
*/
|
||||
export const getMaximizedPanelId = view => view.maximizedPanelId;
|
|
@ -1,19 +1,25 @@
|
|||
import * as DashboardSelectors from '../dashboard/selectors';
|
||||
|
||||
/**
|
||||
* @typedef {Object} KibanaCoreAppState
|
||||
* @property {Object} DashboardState
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {KibanaCoreAppState} state
|
||||
* @return {DashboardState}
|
||||
*/
|
||||
export const getDashboard = state => state.dashboard;
|
||||
|
||||
export const getPanels = state => DashboardSelectors.getPanels(getDashboard(state));
|
||||
export const getPanel = (state, panelId) => DashboardSelectors.getPanel(getDashboard(state), panelId);
|
||||
export const getPanelType = (state, panelId) => DashboardSelectors.getPanelType(getDashboard(state), panelId);
|
||||
|
||||
export const getEmbeddables = state => DashboardSelectors.getEmbeddables(getDashboard(state));
|
||||
export const getEmbeddable = (state, panelId) => DashboardSelectors.getEmbeddable(getDashboard(state), panelId);
|
||||
export const getEmbeddableError = (state, panelId) =>
|
||||
DashboardSelectors.getEmbeddableError((getDashboard(state)), panelId);
|
||||
export const getEmbeddableTitle = (state, panelId) => DashboardSelectors.getEmbeddableTitle(getDashboard(state), panelId);
|
||||
export const getEmbeddableEditUrl = (state, panelId) => DashboardSelectors.getEmbeddableEditUrl(getDashboard(state), panelId);
|
||||
|
||||
export const getView = state => DashboardSelectors.getView(state);
|
||||
export const getViewMode = state => DashboardSelectors.getViewMode(getDashboard(state));
|
||||
export const getFullScreenMode = state => DashboardSelectors.getFullScreenMode(getDashboard(state));
|
||||
export const getMaximizedPanelId = state => DashboardSelectors.getMaximizedPanelId(getDashboard(state));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue