Skip to content

Commit 5b48dbc

Browse files
committed
Deangularize Dashboard (elastic#82909)
Deangularized dashboard application
1 parent 4ac0a47 commit 5b48dbc

File tree

109 files changed

+4083
-3227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+4083
-3227
lines changed

src/plugins/dashboard/public/application/_dashboard_app.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
flex: 1;
55
}
66

7+
.dashboardViewport {
8+
flex: 1;
9+
display: flex;
10+
flex-direction: column;
11+
}
12+
713
.dshStartScreen {
814
text-align: center;
915
}

src/plugins/dashboard/public/application/_hacks.scss

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/plugins/dashboard/public/application/actions/add_to_library_action.test.tsx

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,31 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
20+
import { AddToLibraryAction } from '.';
21+
import { DashboardContainer } from '../embeddable';
22+
import { getSampleDashboardInput } from '../test_helpers';
23+
24+
import { CoreStart } from 'kibana/public';
25+
26+
import { coreMock, uiSettingsServiceMock } from '../../../../../core/public/mocks';
27+
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
28+
1929
import {
20-
isErrorEmbeddable,
30+
EmbeddableInput,
31+
ErrorEmbeddable,
2132
IContainer,
33+
isErrorEmbeddable,
2234
ReferenceOrValueEmbeddable,
23-
EmbeddableInput,
24-
} from '../../embeddable_plugin';
25-
import { DashboardContainer } from '../embeddable';
26-
import { getSampleDashboardInput } from '../test_helpers';
35+
ViewMode,
36+
} from '../../services/embeddable';
2737
import {
28-
CONTACT_CARD_EMBEDDABLE,
29-
ContactCardEmbeddableFactory,
3038
ContactCardEmbeddable,
39+
ContactCardEmbeddableFactory,
3140
ContactCardEmbeddableInput,
3241
ContactCardEmbeddableOutput,
33-
} from '../../embeddable_plugin_test_samples';
34-
import { coreMock } from '../../../../../core/public/mocks';
35-
import { CoreStart } from 'kibana/public';
36-
import { AddToLibraryAction } from '.';
37-
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
38-
import { ErrorEmbeddable, ViewMode } from '../../../../embeddable/public';
42+
CONTACT_CARD_EMBEDDABLE,
43+
} from '../../services/embeddable_test_samples';
3944

4045
const { setup, doStart } = embeddablePluginMock.createInstance();
4146
setup.registerEmbeddableFactory(
@@ -60,6 +65,8 @@ beforeEach(async () => {
6065
overlays: coreStart.overlays,
6166
savedObjectMetaData: {} as any,
6267
uiActions: {} as any,
68+
uiSettings: uiSettingsServiceMock.createStartContract(),
69+
http: coreStart.http,
6370
};
6471

6572
container = new DashboardContainer(getSampleDashboardInput(), containerOptions);

src/plugins/dashboard/public/application/actions/add_to_library_action.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,20 @@
1717
* under the License.
1818
*/
1919

20-
import { i18n } from '@kbn/i18n';
2120
import _ from 'lodash';
22-
import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin';
23-
import { ViewMode, PanelState, IEmbeddable } from '../../embeddable_plugin';
21+
22+
import { ActionByType, IncompatibleActionError } from '../../services/ui_actions';
2423
import {
24+
ViewMode,
25+
PanelState,
26+
IEmbeddable,
2527
PanelNotFoundError,
2628
EmbeddableInput,
2729
isReferenceOrValueEmbeddable,
2830
isErrorEmbeddable,
29-
} from '../../../../embeddable/public';
30-
import { NotificationsStart } from '../../../../../core/public';
31+
} from '../../services/embeddable';
32+
import { NotificationsStart } from '../../services/core';
33+
import { dashboardAddToLibraryAction } from '../../dashboard_strings';
3134
import { DashboardPanelState, DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '..';
3235

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

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

95-
const title = i18n.translate('dashboard.panel.addToLibrary.successMessage', {
96-
defaultMessage: `Panel '{panelTitle}' was added to the visualize library`,
97-
values: { panelTitle: embeddable.getTitle() },
98-
});
96+
const title = dashboardAddToLibraryAction.getSuccessMessage(
97+
embeddable.getTitle() ? `'${embeddable.getTitle()}'` : ''
98+
);
9999
this.deps.toasts.addSuccess({
100100
title,
101-
'data-test-subj': 'unlinkPanelSuccess',
101+
'data-test-subj': 'addPanelToLibrarySuccess',
102102
});
103103
}
104104
}

src/plugins/dashboard/public/application/actions/clone_panel_action.test.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
import { isErrorEmbeddable, IContainer, ErrorEmbeddable } from '../../embeddable_plugin';
19+
2020
import { DashboardContainer, DashboardPanelState } from '../embeddable';
2121
import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers';
22+
23+
import { coreMock, uiSettingsServiceMock } from '../../../../../core/public/mocks';
24+
import { CoreStart } from 'kibana/public';
25+
import { ClonePanelAction } from '.';
26+
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
2227
import {
23-
CONTACT_CARD_EMBEDDABLE,
24-
ContactCardEmbeddableFactory,
2528
ContactCardEmbeddable,
29+
ContactCardEmbeddableFactory,
2630
ContactCardEmbeddableInput,
2731
ContactCardEmbeddableOutput,
28-
} from '../../embeddable_plugin_test_samples';
29-
import { coreMock } from '../../../../../core/public/mocks';
30-
import { CoreStart } from 'kibana/public';
31-
import { ClonePanelAction } from '.';
32-
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
32+
CONTACT_CARD_EMBEDDABLE,
33+
} from '../../services/embeddable_test_samples';
34+
import { ErrorEmbeddable, IContainer, isErrorEmbeddable } from '../../services/embeddable';
3335

3436
const { setup, doStart } = embeddablePluginMock.createInstance();
3537
setup.registerEmbeddableFactory(
@@ -60,6 +62,8 @@ beforeEach(async () => {
6062
overlays: coreStart.overlays,
6163
savedObjectMetaData: {} as any,
6264
uiActions: {} as any,
65+
uiSettings: uiSettingsServiceMock.createStartContract(),
66+
http: coreStart.http,
6367
};
6468
const input = getSampleDashboardInput({
6569
panels: {

src/plugins/dashboard/public/application/actions/clone_panel_action.tsx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,26 @@
1717
* under the License.
1818
*/
1919

20-
import { i18n } from '@kbn/i18n';
21-
import { CoreStart } from 'src/core/public';
22-
import uuid from 'uuid';
2320
import _ from 'lodash';
24-
import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin';
25-
import { ViewMode, PanelState, IEmbeddable } from '../../embeddable_plugin';
26-
import { SavedObject } from '../../../../saved_objects/public';
21+
import uuid from 'uuid';
22+
23+
import { CoreStart } from 'src/core/public';
24+
import { ActionByType, IncompatibleActionError } from '../../services/ui_actions';
25+
import { SavedObject } from '../../services/saved_objects';
2726
import {
27+
ViewMode,
28+
PanelState,
29+
IEmbeddable,
2830
PanelNotFoundError,
2931
EmbeddableInput,
3032
SavedObjectEmbeddableInput,
3133
isErrorEmbeddable,
32-
} from '../../../../embeddable/public';
34+
} from '../../services/embeddable';
3335
import {
3436
placePanelBeside,
3537
IPanelPlacementBesideArgs,
3638
} from '../embeddable/panel/dashboard_panel_placement';
39+
import { dashboardClonePanelAction } from '../../dashboard_strings';
3740
import { DashboardPanelState, DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '..';
3841

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

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

101102
private async getUniqueTitle(rawTitle: string, embeddableType: string): Promise<string> {
102-
const clonedTag = i18n.translate('dashboard.panel.title.clonedTag', {
103-
defaultMessage: 'copy',
104-
});
103+
const clonedTag = dashboardClonePanelAction.getClonedTag();
105104
const cloneRegex = new RegExp(`\\(${clonedTag}\\)`, 'g');
106105
const cloneNumberRegex = new RegExp(`\\(${clonedTag} [0-9]+\\)`, 'g');
107106
const baseTitle = rawTitle.replace(cloneNumberRegex, '').replace(cloneRegex, '').trim();
@@ -152,9 +151,7 @@ export class ClonePanelAction implements ActionByType<typeof ACTION_CLONE_PANEL>
152151
(panelState.explicitInput as SavedObjectEmbeddableInput).savedObjectId = clonedSavedObject.id;
153152
}
154153
this.core.notifications.toasts.addSuccess({
155-
title: i18n.translate('dashboard.panel.clonedToast', {
156-
defaultMessage: 'Cloned panel',
157-
}),
154+
title: dashboardClonePanelAction.getSuccessMessage(),
158155
'data-test-subj': 'addObjectToContainerSuccess',
159156
});
160157
return panelState;

src/plugins/dashboard/public/application/actions/expand_panel_action.test.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@
1717
* under the License.
1818
*/
1919

20-
import { isErrorEmbeddable } from '../../embeddable_plugin';
2120
import { ExpandPanelAction } from './expand_panel_action';
2221
import { DashboardContainer } from '../embeddable';
2322
import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers';
23+
24+
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
25+
import { isErrorEmbeddable } from '../../services/embeddable';
2426
import {
2527
CONTACT_CARD_EMBEDDABLE,
2628
ContactCardEmbeddableFactory,
2729
ContactCardEmbeddable,
2830
ContactCardEmbeddableInput,
2931
ContactCardEmbeddableOutput,
30-
} from '../../embeddable_plugin_test_samples';
31-
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
32+
} from '../../services/embeddable_test_samples';
33+
import { coreMock, uiSettingsServiceMock } from '../../../../../core/public/mocks';
3234

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

@@ -52,6 +54,8 @@ beforeEach(async () => {
5254
overlays: {} as any,
5355
savedObjectMetaData: {} as any,
5456
uiActions: {} as any,
57+
uiSettings: uiSettingsServiceMock.createStartContract(),
58+
http: coreMock.createStart().http,
5559
};
5660
const input = getSampleDashboardInput({
5761
panels: {

src/plugins/dashboard/public/application/actions/expand_panel_action.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
* under the License.
1818
*/
1919

20-
import { i18n } from '@kbn/i18n';
21-
import { IEmbeddable } from '../../embeddable_plugin';
22-
import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin';
20+
import { dashboardExpandPanelAction } from '../../dashboard_strings';
21+
import { IEmbeddable } from '../../services/embeddable';
22+
import { ActionByType, IncompatibleActionError } from '../../services/ui_actions';
2323
import {
2424
DASHBOARD_CONTAINER_TYPE,
2525
DashboardContainer,
@@ -59,12 +59,8 @@ export class ExpandPanelAction implements ActionByType<typeof ACTION_EXPAND_PANE
5959
}
6060

6161
return isExpanded(embeddable)
62-
? i18n.translate('dashboard.actions.toggleExpandPanelMenuItem.expandedDisplayName', {
63-
defaultMessage: 'Minimize',
64-
})
65-
: i18n.translate('dashboard.actions.toggleExpandPanelMenuItem.notExpandedDisplayName', {
66-
defaultMessage: 'Maximize panel',
67-
});
62+
? dashboardExpandPanelAction.getMinimizeTitle()
63+
: dashboardExpandPanelAction.getMaximizeTitle();
6864
}
6965

7066
public getIconType({ embeddable }: ExpandPanelActionContext) {

src/plugins/dashboard/public/application/actions/export_csv_action.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import { CoreStart } from 'kibana/public';
2121

22-
import { isErrorEmbeddable, IContainer, ErrorEmbeddable } from '../../embeddable_plugin';
22+
import { isErrorEmbeddable, IContainer, ErrorEmbeddable } from '../../services/embeddable';
2323
import { DashboardContainer } from '../../application/embeddable';
2424
import { getSampleDashboardInput, getSampleDashboardPanel } from '../../application/test_helpers';
2525
import {
@@ -28,8 +28,8 @@ import {
2828
ContactCardEmbeddableOutput,
2929
ContactCardExportableEmbeddableFactory,
3030
CONTACT_CARD_EXPORTABLE_EMBEDDABLE,
31-
} from '../../embeddable_plugin_test_samples';
32-
import { coreMock } from '../../../../../core/public/mocks';
31+
} from '../../services/embeddable_test_samples';
32+
import { coreMock, uiSettingsServiceMock } from '../../../../../core/public/mocks';
3333
import { ExportCSVAction } from './export_csv_action';
3434
import { embeddablePluginMock } from '../../../../embeddable/public/mocks';
3535
import { DataPublicPluginStart } from '../../../../data/public/types';
@@ -68,6 +68,8 @@ describe('Export CSV action', () => {
6868
overlays: coreStart.overlays,
6969
savedObjectMetaData: {} as any,
7070
uiActions: {} as any,
71+
uiSettings: uiSettingsServiceMock.createStartContract(),
72+
http: coreStart.http,
7173
};
7274
const input = getSampleDashboardInput({
7375
panels: {

src/plugins/dashboard/public/application/actions/export_csv_action.tsx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
* under the License.
1818
*/
1919

20-
import { i18n } from '@kbn/i18n';
2120
import { Datatable } from 'src/plugins/expressions/public';
22-
import { FormatFactory } from '../../../../data/common/field_formats/utils';
23-
import { DataPublicPluginStart, exporters } from '../../../../data/public';
24-
import { downloadMultipleAs } from '../../../../share/public';
25-
import { Adapters, IEmbeddable } from '../../../../embeddable/public';
26-
import { ActionByType } from '../../../../ui_actions/public';
2721
import { CoreStart } from '../../../../../core/public';
22+
import { FormatFactory } from '../../../../data/common/field_formats/utils';
23+
24+
import { DataPublicPluginStart, exporters } from '../../services/data';
25+
import { downloadMultipleAs } from '../../services/share';
26+
import { Adapters, IEmbeddable } from '../../services/embeddable';
27+
import { ActionByType } from '../../services/ui_actions';
28+
import { dashboardExportCsvAction } from '../../dashboard_strings';
2829

2930
export const ACTION_EXPORT_CSV = 'ACTION_EXPORT_CSV';
3031

@@ -57,9 +58,7 @@ export class ExportCSVAction implements ActionByType<typeof ACTION_EXPORT_CSV> {
5758
}
5859

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

6463
public async isCompatible(context: ExportContext): Promise<boolean> {
6564
return !!this.hasDatatableContent(context.embeddable?.getInspectorAdapters?.());
@@ -99,12 +98,7 @@ export class ExportCSVAction implements ActionByType<typeof ACTION_EXPORT_CSV> {
9998
// skip empty datatables
10099
if (datatable) {
101100
const postFix = datatables.length > 1 ? `-${i + 1}` : '';
102-
const untitledFilename = i18n.translate(
103-
'dashboard.actions.downloadOptionsUnsavedFilename',
104-
{
105-
defaultMessage: 'unsaved',
106-
}
107-
);
101+
const untitledFilename = dashboardExportCsvAction.getUntitledFilename();
108102

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

0 commit comments

Comments
 (0)