Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.7] Support duplicate visualization in dashboard #405

Merged
merged 1 commit into from
Apr 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 22 additions & 46 deletions public/components/custom_panels/custom_panel_view_so.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/* // eslint-disable no-console */
/* eslint-disable react-hooks/exhaustive-deps */

import { useCallback } from 'react';
import {
EuiBreadcrumb,
EuiButton,
Expand All @@ -27,60 +26,34 @@ import {
OnTimeChangeProps,
ShortDate,
} from '@elastic/eui';
import { last } from 'lodash';
import React, { useEffect, useState } from 'react';
import { DurationRange } from '@elastic/eui/src/components/date_picker/types';
import { last } from 'lodash';
import moment from 'moment';
import _ from 'lodash';
import React, { useCallback, useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useRef } from 'react';
import DSLService from '../../services/requests/dsl';
import { CoreStart, SimpleSavedObject } from '../../../../../src/core/public';
import { EmptyPanelView } from './panel_modules/empty_panel';
import {
CREATE_PANEL_MESSAGE,
CUSTOM_PANELS_API_PREFIX,
CUSTOM_PANELS_SAVED_OBJECT_TYPE,
} from '../../../common/constants/custom_panels';
import { CustomPanelType, PanelType } from '../../../common/types/custom_panels';
import { PanelGridSO } from './panel_modules/panel_grid/panel_grid_so';

import { CoreStart } from '../../../../../src/core/public';
import { CREATE_PANEL_MESSAGE } from '../../../common/constants/custom_panels';
import { UI_DATE_FORMAT } from '../../../common/constants/shared';
import { CustomPanelType } from '../../../common/types/custom_panels';
import { uiSettingsService } from '../../../common/utils';
import { coreRefs } from '../../framework/core_refs';
import { PPLReferenceFlyout } from '../common/helpers';
import { DeleteModal } from '../common/helpers/delete_modal';
import { Autocomplete } from '../common/search/autocomplete';
import { onItemSelect, parseGetSuggestions } from '../common/search/autocomplete_logic';
import { addVisualizationPanel } from './helpers/add_visualization_helper';
import { AddVisualizationPopover } from './helpers/add_visualization_popover';
import { getCustomModal } from './helpers/modal_containers';
import PPLService from '../../services/requests/ppl';
import {
isDateValid,
convertDateTime,
isDateValid,
isPPLFilterValid,
isNameValid,
prependRecentlyUsedRange,
} from './helpers/utils';
import { UI_DATE_FORMAT } from '../../../common/constants/shared';
import { VisaulizationFlyout } from './panel_modules/visualization_flyout';
import { uiSettingsService } from '../../../common/utils';
import { PPLReferenceFlyout } from '../common/helpers';
import { Autocomplete } from '../common/search/autocomplete';
import {
parseGetSuggestions,
onItemSelect,
parseForIndices,
} from '../common/search/autocomplete_logic';
import { AddVisualizationPopover } from './helpers/add_visualization_popover';
import { DeleteModal } from '../common/helpers/delete_modal';
import { EmptyPanelView } from './panel_modules/empty_panel';
import { PanelGridSO } from './panel_modules/panel_grid/panel_grid_so';
import { VisaulizationFlyoutSO } from './panel_modules/visualization_flyout/visualization_flyout_so';
import { addVisualizationPanel } from './helpers/add_visualization_helper';
import {
clonePanel,
createPanel,
fetchPanel,
newPanelTemplate,
selectPanel,
setPanel,
setPanelEt,
setPanelId,
setPanelSt,
updatePanel,
} from './redux/panel_slice';
import { coreRefs } from '../../framework/core_refs';
import { clonePanel, fetchPanel, selectPanel, setPanel, updatePanel } from './redux/panel_slice';

/*
* "CustomPanelsView" module used to render an Observability Dashboard
Expand Down Expand Up @@ -375,6 +348,7 @@ export const CustomPanelViewSO = (props: CustomPanelViewProps) => {
};

const cloneVisualization = (visualzationTitle: string, savedVisualizationId: string) => {
addVisualizationToCurrentPanel({ savedVisualizationId });
// http
// .post(`${CUSTOM_PANELS_API_PREFIX}/visualizations`, {
// body: JSON.stringify({
Expand Down Expand Up @@ -548,7 +522,9 @@ export const CustomPanelViewSO = (props: CustomPanelViewProps) => {
// Toggle input type (disabled or not disabled)
// Disabled when there no visualizations in panels or when the panel is in edit mode
useEffect(() => {
!loading && checkDisabledInputs();
if (!loading) {
checkDisabledInputs();
}
}, [isEditing, loading]);

// Build base query with all of the indices included in the current visualizations
Expand Down