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

Deangularize Dashboard #82909

Merged
merged 22 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
068c9fa
squashed all previous dashboard deangularization commits
ThomThomson Dec 3, 2020
0b52c48
add help menu link, fix export csv action types, move loadbytitle int…
ThomThomson Dec 3, 2020
2ce9302
Dashboard external dependencies moved into services folder. All files…
ThomThomson Dec 4, 2020
3e3e968
updated strings file to use only methods
ThomThomson Dec 4, 2020
d416037
Merge branch 'master' of github.com:elastic/kibana into deangularize/…
ThomThomson Dec 4, 2020
1a45187
Changed import in plugin.tsx
ThomThomson Dec 4, 2020
26b35b0
Removed unused translations, standardized hideWriteControls permissions
ThomThomson Dec 7, 2020
0c81703
Merge branch 'master' of github.com:elastic/kibana into deangularize/…
ThomThomson Dec 7, 2020
bfc3de3
removed isEditable code from dashboard container factory
ThomThomson Dec 7, 2020
efa435e
Better attempt to use custom hooks from #84913. Used EmbeddableRender…
ThomThomson Dec 8, 2020
4c87f64
fixed typo affecting create new use case, fixed cleanup dashboard con…
ThomThomson Dec 8, 2020
5789956
added dashboard viewport class
ThomThomson Dec 8, 2020
79c3b2c
Merge branch 'master' of github.com:elastic/kibana into deangularize/…
ThomThomson Dec 8, 2020
4e6bafe
moved switchViewMode out of dashboard input
ThomThomson Dec 8, 2020
b7d90f6
Merge branch 'master' of github.com:elastic/kibana into deangularize/…
ThomThomson Dec 8, 2020
07f33ad
updated imports in hooks, fixed types
ThomThomson Dec 9, 2020
534210d
moved incomingEmbeddable fetch outside of the router to avoid the Has…
ThomThomson Dec 9, 2020
26329de
Merge branch 'master' of github.com:elastic/kibana into deangularize/…
ThomThomson Dec 9, 2020
880e29a
undid moving incomingEmbeddable outside of router. It caused a duplic…
ThomThomson Dec 9, 2020
f4bcfcc
Merge branch 'master' of github.com:elastic/kibana into deangularize/…
ThomThomson Dec 10, 2020
7fda631
worked in changes from #84261
ThomThomson Dec 10, 2020
0b8de95
Merge branch 'master' of github.com:elastic/kibana into deangularize/…
ThomThomson Dec 10, 2020
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
6 changes: 6 additions & 0 deletions src/plugins/dashboard/public/application/_dashboard_app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
flex: 1;
}

.dashboardViewport {
flex: 1;
display: flex;
flex-direction: column;
}

.dshStartScreen {
text-align: center;
}
Expand Down
13 changes: 0 additions & 13 deletions src/plugins/dashboard/public/application/_hacks.scss

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,31 @@
* specific language governing permissions and limitations
* under the License.
*/

import { AddToLibraryAction } from '.';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput } from '../test_helpers';

import { CoreStart } from 'kibana/public';

import { coreMock, uiSettingsServiceMock } from '../../../../../core/public/mocks';
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';

import {
isErrorEmbeddable,
EmbeddableInput,
ErrorEmbeddable,
IContainer,
isErrorEmbeddable,
ReferenceOrValueEmbeddable,
EmbeddableInput,
} from '../../embeddable_plugin';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput } from '../test_helpers';
ViewMode,
} from '../../services/embeddable';
import {
CONTACT_CARD_EMBEDDABLE,
ContactCardEmbeddableFactory,
ContactCardEmbeddable,
ContactCardEmbeddableFactory,
ContactCardEmbeddableInput,
ContactCardEmbeddableOutput,
} from '../../embeddable_plugin_test_samples';
import { coreMock } from '../../../../../core/public/mocks';
import { CoreStart } from 'kibana/public';
import { AddToLibraryAction } from '.';
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
import { ErrorEmbeddable, ViewMode } from '../../../../embeddable/public';
CONTACT_CARD_EMBEDDABLE,
} from '../../services/embeddable_test_samples';

const { setup, doStart } = embeddablePluginMock.createInstance();
setup.registerEmbeddableFactory(
Expand All @@ -60,6 +65,8 @@ beforeEach(async () => {
overlays: coreStart.overlays,
savedObjectMetaData: {} as any,
uiActions: {} as any,
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreStart.http,
};

container = new DashboardContainer(getSampleDashboardInput(), containerOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import _ from 'lodash';
import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin';
import { ViewMode, PanelState, IEmbeddable } from '../../embeddable_plugin';

import { ActionByType, IncompatibleActionError } from '../../services/ui_actions';
import {
ViewMode,
PanelState,
IEmbeddable,
PanelNotFoundError,
EmbeddableInput,
isReferenceOrValueEmbeddable,
isErrorEmbeddable,
} from '../../../../embeddable/public';
import { NotificationsStart } from '../../../../../core/public';
} from '../../services/embeddable';
import { NotificationsStart } from '../../services/core';
import { dashboardAddToLibraryAction } from '../../dashboard_strings';
import { DashboardPanelState, DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '..';

export const ACTION_ADD_TO_LIBRARY = 'addToFromLibrary';
Expand All @@ -47,9 +50,7 @@ export class AddToLibraryAction implements ActionByType<typeof ACTION_ADD_TO_LIB
if (!embeddable.getRoot() || !embeddable.getRoot().isContainer) {
throw new IncompatibleActionError();
}
return i18n.translate('dashboard.panel.AddToLibrary', {
defaultMessage: 'Add to library',
});
return dashboardAddToLibraryAction.getDisplayName();
}

public getIconType({ embeddable }: AddToLibraryActionContext) {
Expand Down Expand Up @@ -92,13 +93,12 @@ export class AddToLibraryAction implements ActionByType<typeof ACTION_ADD_TO_LIB
};
dashboard.replacePanel(panelToReplace, newPanel, true);

const title = i18n.translate('dashboard.panel.addToLibrary.successMessage', {
defaultMessage: `Panel '{panelTitle}' was added to the visualize library`,
values: { panelTitle: embeddable.getTitle() },
});
const title = dashboardAddToLibraryAction.getSuccessMessage(
embeddable.getTitle() ? `'${embeddable.getTitle()}'` : ''
);
this.deps.toasts.addSuccess({
title,
'data-test-subj': 'unlinkPanelSuccess',
'data-test-subj': 'addPanelToLibrarySuccess',
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
import { isErrorEmbeddable, IContainer, ErrorEmbeddable } from '../../embeddable_plugin';

import { DashboardContainer, DashboardPanelState } from '../embeddable';
import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers';

import { coreMock, uiSettingsServiceMock } from '../../../../../core/public/mocks';
import { CoreStart } from 'kibana/public';
import { ClonePanelAction } from '.';
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
import {
CONTACT_CARD_EMBEDDABLE,
ContactCardEmbeddableFactory,
ContactCardEmbeddable,
ContactCardEmbeddableFactory,
ContactCardEmbeddableInput,
ContactCardEmbeddableOutput,
} from '../../embeddable_plugin_test_samples';
import { coreMock } from '../../../../../core/public/mocks';
import { CoreStart } from 'kibana/public';
import { ClonePanelAction } from '.';
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
CONTACT_CARD_EMBEDDABLE,
} from '../../services/embeddable_test_samples';
import { ErrorEmbeddable, IContainer, isErrorEmbeddable } from '../../services/embeddable';

const { setup, doStart } = embeddablePluginMock.createInstance();
setup.registerEmbeddableFactory(
Expand Down Expand Up @@ -60,6 +62,8 @@ beforeEach(async () => {
overlays: coreStart.overlays,
savedObjectMetaData: {} as any,
uiActions: {} as any,
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreStart.http,
};
const input = getSampleDashboardInput({
panels: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,26 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { CoreStart } from 'src/core/public';
import uuid from 'uuid';
import _ from 'lodash';
import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin';
import { ViewMode, PanelState, IEmbeddable } from '../../embeddable_plugin';
import { SavedObject } from '../../../../saved_objects/public';
import uuid from 'uuid';

import { CoreStart } from 'src/core/public';
import { ActionByType, IncompatibleActionError } from '../../services/ui_actions';
import { SavedObject } from '../../services/saved_objects';
import {
ViewMode,
PanelState,
IEmbeddable,
PanelNotFoundError,
EmbeddableInput,
SavedObjectEmbeddableInput,
isErrorEmbeddable,
} from '../../../../embeddable/public';
} from '../../services/embeddable';
import {
placePanelBeside,
IPanelPlacementBesideArgs,
} from '../embeddable/panel/dashboard_panel_placement';
import { dashboardClonePanelAction } from '../../dashboard_strings';
import { DashboardPanelState, DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '..';

export const ACTION_CLONE_PANEL = 'clonePanel';
Expand All @@ -53,9 +56,7 @@ export class ClonePanelAction implements ActionByType<typeof ACTION_CLONE_PANEL>
if (!embeddable.getRoot() || !embeddable.getRoot().isContainer) {
throw new IncompatibleActionError();
}
return i18n.translate('dashboard.panel.clonePanel', {
defaultMessage: 'Clone panel',
});
return dashboardClonePanelAction.getDisplayName();
}

public getIconType({ embeddable }: ClonePanelActionContext) {
Expand Down Expand Up @@ -99,9 +100,7 @@ export class ClonePanelAction implements ActionByType<typeof ACTION_CLONE_PANEL>
}

private async getUniqueTitle(rawTitle: string, embeddableType: string): Promise<string> {
const clonedTag = i18n.translate('dashboard.panel.title.clonedTag', {
defaultMessage: 'copy',
});
const clonedTag = dashboardClonePanelAction.getClonedTag();
const cloneRegex = new RegExp(`\\(${clonedTag}\\)`, 'g');
const cloneNumberRegex = new RegExp(`\\(${clonedTag} [0-9]+\\)`, 'g');
const baseTitle = rawTitle.replace(cloneNumberRegex, '').replace(cloneRegex, '').trim();
Expand Down Expand Up @@ -152,9 +151,7 @@ export class ClonePanelAction implements ActionByType<typeof ACTION_CLONE_PANEL>
(panelState.explicitInput as SavedObjectEmbeddableInput).savedObjectId = clonedSavedObject.id;
}
this.core.notifications.toasts.addSuccess({
title: i18n.translate('dashboard.panel.clonedToast', {
defaultMessage: 'Cloned panel',
}),
title: dashboardClonePanelAction.getSuccessMessage(),
'data-test-subj': 'addObjectToContainerSuccess',
});
return panelState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@
* under the License.
*/

import { isErrorEmbeddable } from '../../embeddable_plugin';
import { ExpandPanelAction } from './expand_panel_action';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers';

import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
import { isErrorEmbeddable } from '../../services/embeddable';
import {
CONTACT_CARD_EMBEDDABLE,
ContactCardEmbeddableFactory,
ContactCardEmbeddable,
ContactCardEmbeddableInput,
ContactCardEmbeddableOutput,
} from '../../embeddable_plugin_test_samples';
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
} from '../../services/embeddable_test_samples';
import { coreMock, uiSettingsServiceMock } from '../../../../../core/public/mocks';

const { setup, doStart } = embeddablePluginMock.createInstance();

Expand All @@ -52,6 +54,8 @@ beforeEach(async () => {
overlays: {} as any,
savedObjectMetaData: {} as any,
uiActions: {} as any,
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreMock.createStart().http,
};
const input = getSampleDashboardInput({
panels: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { IEmbeddable } from '../../embeddable_plugin';
import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin';
import { dashboardExpandPanelAction } from '../../dashboard_strings';
import { IEmbeddable } from '../../services/embeddable';
import { ActionByType, IncompatibleActionError } from '../../services/ui_actions';
import {
DASHBOARD_CONTAINER_TYPE,
DashboardContainer,
Expand Down Expand Up @@ -59,12 +59,8 @@ export class ExpandPanelAction implements ActionByType<typeof ACTION_EXPAND_PANE
}

return isExpanded(embeddable)
? i18n.translate('dashboard.actions.toggleExpandPanelMenuItem.expandedDisplayName', {
defaultMessage: 'Minimize',
})
: i18n.translate('dashboard.actions.toggleExpandPanelMenuItem.notExpandedDisplayName', {
defaultMessage: 'Maximize panel',
});
? dashboardExpandPanelAction.getMinimizeTitle()
: dashboardExpandPanelAction.getMaximizeTitle();
}

public getIconType({ embeddable }: ExpandPanelActionContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { CoreStart } from 'kibana/public';

import { isErrorEmbeddable, IContainer, ErrorEmbeddable } from '../../embeddable_plugin';
import { isErrorEmbeddable, IContainer, ErrorEmbeddable } from '../../services/embeddable';
import { DashboardContainer } from '../../application/embeddable';
import { getSampleDashboardInput, getSampleDashboardPanel } from '../../application/test_helpers';
import {
Expand All @@ -28,8 +28,8 @@ import {
ContactCardEmbeddableOutput,
ContactCardExportableEmbeddableFactory,
CONTACT_CARD_EXPORTABLE_EMBEDDABLE,
} from '../../embeddable_plugin_test_samples';
import { coreMock } from '../../../../../core/public/mocks';
} from '../../services/embeddable_test_samples';
import { coreMock, uiSettingsServiceMock } from '../../../../../core/public/mocks';
import { ExportCSVAction } from './export_csv_action';
import { embeddablePluginMock } from '../../../../embeddable/public/mocks';
import { DataPublicPluginStart } from '../../../../data/public/types';
Expand Down Expand Up @@ -68,6 +68,8 @@ describe('Export CSV action', () => {
overlays: coreStart.overlays,
savedObjectMetaData: {} as any,
uiActions: {} as any,
uiSettings: uiSettingsServiceMock.createStartContract(),
http: coreStart.http,
};
const input = getSampleDashboardInput({
panels: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { Datatable } from 'src/plugins/expressions/public';
import { FormatFactory } from '../../../../data/common/field_formats/utils';
import { DataPublicPluginStart, exporters } from '../../../../data/public';
import { downloadMultipleAs } from '../../../../share/public';
import { Adapters, IEmbeddable } from '../../../../embeddable/public';
import { ActionByType } from '../../../../ui_actions/public';
import { CoreStart } from '../../../../../core/public';
import { FormatFactory } from '../../../../data/common/field_formats/utils';

import { DataPublicPluginStart, exporters } from '../../services/data';
import { downloadMultipleAs } from '../../services/share';
import { Adapters, IEmbeddable } from '../../services/embeddable';
import { ActionByType } from '../../services/ui_actions';
import { dashboardExportCsvAction } from '../../dashboard_strings';

export const ACTION_EXPORT_CSV = 'ACTION_EXPORT_CSV';

Expand Down Expand Up @@ -57,9 +58,7 @@ export class ExportCSVAction implements ActionByType<typeof ACTION_EXPORT_CSV> {
}

public readonly getDisplayName = (context: ExportContext): string =>
i18n.translate('dashboard.actions.DownloadCreateDrilldownAction.displayName', {
defaultMessage: 'Download as CSV',
});
dashboardExportCsvAction.getDisplayName();

public async isCompatible(context: ExportContext): Promise<boolean> {
return !!this.hasDatatableContent(context.embeddable?.getInspectorAdapters?.());
Expand Down Expand Up @@ -99,12 +98,7 @@ export class ExportCSVAction implements ActionByType<typeof ACTION_EXPORT_CSV> {
// skip empty datatables
if (datatable) {
const postFix = datatables.length > 1 ? `-${i + 1}` : '';
const untitledFilename = i18n.translate(
'dashboard.actions.downloadOptionsUnsavedFilename',
{
defaultMessage: 'unsaved',
}
);
const untitledFilename = dashboardExportCsvAction.getUntitledFilename();

memo[`${context!.embeddable!.getTitle() || untitledFilename}${postFix}.csv`] = {
content: exporters.datatableToCSV(datatable, {
Expand Down
Loading