Skip to content

Commit

Permalink
[Dashboard] EUI-fication of the empty dashboard screen (elastic#51151)
Browse files Browse the repository at this point in the history
* [Dashboard][POC] De-angularize empty screen

* EUI-fication of the empty dashboard screen

* Adding tests for empty dashboard screen

* Removing unused imports

* Reorganizing directive so that it works with local Angular

* Adding string constants

* Adding missing snapshot
  • Loading branch information
Maja Grubic authored Nov 21, 2019
1 parent 46e0f9f commit a6f7b18
Show file tree
Hide file tree
Showing 10 changed files with 780 additions and 70 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { DashboardEmptyScreen, Props } from '../dashboard_empty_screen';

describe('DashboardEmptyScreen', () => {
const defaultProps = {
showLinkToVisualize: true,
onLinkClick: jest.fn(),
};

function mountComponent(props?: Props) {
const compProps = props || defaultProps;
const comp = mountWithIntl(<DashboardEmptyScreen {...compProps} />);
return comp;
}

test('renders correctly with visualize paragraph', () => {
const component = mountComponent();
expect(component).toMatchSnapshot();
const paragraph = component.find('.linkToVisualizeParagraph');
expect(paragraph.length).toBe(1);
});

test('renders correctly without visualize paragraph', () => {
const component = mountComponent({ ...defaultProps, ...{ showLinkToVisualize: false } });
expect(component).toMatchSnapshot();
const paragraph = component.find('.linkToVisualizeParagraph');
expect(paragraph.length).toBe(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ function createLocalAngularModule(core: AppMountContext['core'], navigation: Nav
'app/dashboard/State',
'app/dashboard/ConfirmModal',
'app/dashboard/icon',
'app/dashboard/emptyScreen',
]);
return dashboardAngularModule;
}
Expand Down
66 changes: 6 additions & 60 deletions src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,71 +51,17 @@

<div ng-show="getShouldShowEditHelp() || getShouldShowViewHelp()" class="dshStartScreen">
<div class="euiPanel euiPanel--paddingLarge euiPageContent euiPageContent--horizontalCenter">
<icon type="'dashboardApp'" size="'xxl'" color="'subdued'"></icon>

<br><br>

<div ng-show="getShouldShowEditHelp()" class="euiText">
<h2
i18n-id="kbn.dashboard.fillDashboardTitle"
i18n-default-message="This dashboard is empty. Let&rsquo;s fill it up!"
>
</h2>

<p>
<span
i18n-id="kbn.dashboard.addVisualizationDescription1"
i18n-default-message="Click the "
i18n-context="Part of composite label kbn.dashboard.addVisualizationDescription1 + kbn.dashboard.addVisualizationLinkText + kbn.dashboard.addVisualizationDescription2"
></span>
<a
kbn-accessible-click
class="euiLink"
ng-click="showAddPanel()"
aria-label="{{::'kbn.dashboard.addVisualizationLinkAriaLabel' | i18n: { defaultMessage: 'Add visualization' } }}"
data-test-subj="emptyDashboardAddPanelButton"
i18n-id="kbn.dashboard.addVisualizationLinkText"
i18n-default-message="Add"
></a>
<span
i18n-id="kbn.dashboard.addVisualizationDescription2"
i18n-default-message=" button in the menu bar above to add a visualization to the dashboard."
></span>
</p>
<p
i18n-id="kbn.dashboard.addVisualizationDescription3"
i18n-default-message="If you haven't set up any visualizations yet, {visitVisualizeAppLink} to create your first visualization."
i18n-values="{
html_visitVisualizeAppLink: '<a class=\'euiLink\' href=\'#/visualize\'>' + visitVisualizeAppLinkText + '</a>'
}"
></p>
<dashboard-empty-screen on-link-click="showAddPanel"
show-link-to-visualize="true"
/>
</div>

<div ng-show="getShouldShowViewHelp()" class="euiText">
<h2
i18n-id="kbn.dashboard.fillDashboardTitle"
i18n-default-message="This dashboard is empty. Let&rsquo;s fill it up!"
>
</h2>

<p>
<span
i18n-id="kbn.dashboard.howToStartWorkingOnNewDashboardDescription1"
i18n-default-message="Click the "
i18n-context="Part of composite label kbn.dashboard.howToStartWorkingOnNewDashboardDescription1 + kbn.dashboard.howToStartWorkingOnNewDashboardEditLinkText + kbn.dashboard.howToStartWorkingOnNewDashboardDescription2"
></span>
<a
kbn-accessible-click
class="euiLink"
ng-click="enterEditMode()"
i18n-id="kbn.dashboard.howToStartWorkingOnNewDashboardEditLinkText"
i18n-default-message="Edit"
></a>
<span
i18n-id="kbn.dashboard.howToStartWorkingOnNewDashboardDescription2"
i18n-default-message=" button in the menu bar above to start working on your new dashboard."
></span>
</p>
<dashboard-empty-screen show-link-to-visualize="false"
on-link-click="enterEditMode"
/>
</div>

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import {
import { FilterStateManager, IndexPattern, SavedQuery } from '../../../data/public';
import { Query } from '../../../../../plugins/data/public';

import './dashboard_empty_screen_directive';

import {
DashboardContainer,
DASHBOARD_CONTAINER_TYPE,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react';
import { I18nProvider, FormattedMessage } from '@kbn/i18n/react';
import { EuiIcon, EuiLink } from '@elastic/eui';
import * as constants from './dashboard_empty_screen_constants';

export interface Props {
showLinkToVisualize: boolean;
onLinkClick: () => void;
}

export function DashboardEmptyScreen({ showLinkToVisualize, onLinkClick }: Props) {
const linkToVisualizeParagraph = (
<p className="linkToVisualizeParagraph">
<FormattedMessage
id="kbn.dashboard.addVisualizationDescription3"
defaultMessage="If you haven't set up any visualizations yet, {visualizeAppLink} to create your first visualization"
values={{
visualizeAppLink: (
<a className="euiLink" href="#/visualize">
{constants.visualizeAppLinkTest}
</a>
),
}}
/>
</p>
);
const paragraph = (
description1: string,
description2: string,
linkText: string,
ariaLabel: string,
dataTestSubj?: string
) => {
return (
<p>
<span>
{description1}
<EuiLink onClick={onLinkClick} aria-label={ariaLabel} data-test-subj={dataTestSubj || ''}>
{linkText}
</EuiLink>
{description2}
</span>
</p>
);
};
const addVisualizationParagraph = (
<React.Fragment>
{paragraph(
constants.addVisualizationDescription1,
constants.addVisualizationDescription2,
constants.addVisualizationLinkText,
constants.addVisualizationLinkAriaLabel,
'emptyDashboardAddPanelButton'
)}
{linkToVisualizeParagraph}
</React.Fragment>
);
const enterEditModeParagraph = paragraph(
constants.howToStartWorkingOnNewDashboardDescription1,
constants.howToStartWorkingOnNewDashboardDescription2,
constants.howToStartWorkingOnNewDashboardEditLinkText,
constants.howToStartWorkingOnNewDashboardEditLinkAriaLabel
);
return (
<I18nProvider>
<React.Fragment>
<EuiIcon type="dashboardApp" size="xxl" color="subdued" />
<h2>{constants.fillDashboardTitle}</h2>
{showLinkToVisualize ? addVisualizationParagraph : enterEditModeParagraph}
</React.Fragment>
</I18nProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { i18n } from '@kbn/i18n';

export const addVisualizationDescription1: string = i18n.translate(
'kbn.dashboard.addVisualizationDescription1',
{
defaultMessage: 'Click the ',
}
);
export const addVisualizationDescription2: string = i18n.translate(
'kbn.dashboard.addVisualizationDescription2',
{
defaultMessage: ' button in the menu bar above to add a visualization to the dashboard.',
}
);
export const addVisualizationLinkText: string = i18n.translate(
'kbn.dashboard.addVisualizationLinkText',
{
defaultMessage: 'Add',
}
);
export const addVisualizationLinkAriaLabel: string = i18n.translate(
'kbn.dashboard.addVisualizationLinkAriaLabel',
{
defaultMessage: 'Add visualization',
}
);
export const howToStartWorkingOnNewDashboardDescription1: string = i18n.translate(
'kbn.dashboard.howToStartWorkingOnNewDashboardDescription1',
{
defaultMessage: 'Click the ',
}
);
export const howToStartWorkingOnNewDashboardDescription2: string = i18n.translate(
'kbn.dashboard.howToStartWorkingOnNewDashboardDescription2',
{
defaultMessage: ' button in the menu bar above to start working on your new dashboard.',
}
);
export const howToStartWorkingOnNewDashboardEditLinkText: string = i18n.translate(
'kbn.dashboard.howToStartWorkingOnNewDashboardEditLinkText',
{
defaultMessage: 'Edit',
}
);
export const howToStartWorkingOnNewDashboardEditLinkAriaLabel: string = i18n.translate(
'kbn.dashboard.howToStartWorkingOnNewDashboardEditLinkAriaLabel',
{
defaultMessage: 'Edit dashboard',
}
);
export const fillDashboardTitle: string = i18n.translate('kbn.dashboard.fillDashboardTitle', {
defaultMessage: 'This dashboard is empty. Let\u2019s fill it up!',
});
export const visualizeAppLinkTest: string = i18n.translate(
'kbn.dashboard.visitVisualizeAppLinkText',
{
defaultMessage: 'visit the Visualize app',
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// @ts-ignore
import angular from 'angular';
import { DashboardEmptyScreen } from './dashboard_empty_screen';

angular
.module('app/dashboard/emptyScreen', ['react'])
.directive('dashboardEmptyScreen', function(reactDirective: any) {
return reactDirective(DashboardEmptyScreen, [
['showLinkToVisualize', { watchDepth: 'value' }],
['onLinkClick', { watchDepth: 'reference' }],
]);
});
9 changes: 4 additions & 5 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,9 @@
"data.search.searchBar.savedQueryForm.titleMissingText": "名前が必要です",
"data.query.queryBar.searchInputAriaLabel": "{pageType} ページの検索とフィルタリングを行うには入力を開始してください",
"data.search.searchBar.savedQueryPopoverSaveAsNewButtonAriaLabel": "新規保存クエリを保存",
"data.functions.esaggs.help": "AggConfig 集約を実行します",
"data.functions.esaggs.inspector.dataRequest.description": "このリクエストは Elasticsearch にクエリし、ビジュアライゼーション用のデータを取得します。",
"data.functions.esaggs.inspector.dataRequest.title": "データ",
"embeddableApi.actions.applyFilterActionTitle": "現在のビューにフィルターを適用",
"embeddableApi.addPanel.createNewDefaultOption": "新規作成...",
"embeddableApi.addPanel.displayName": "パネルの追加",
Expand Down Expand Up @@ -954,9 +957,6 @@
"visualizations.function.visDimension.accessor.help": "使用するデータセット内の列 (列インデックスまたは列名)",
"visualizations.function.visDimension.error.accessor": "入力された列名は無効です。",
"visualizations.function.visDimension.help": "visConfig ディメンションオブジェクトを生成します",
"data.functions.esaggs.help": "AggConfig 集約を実行します",
"data.functions.esaggs.inspector.dataRequest.description": "このリクエストは Elasticsearch にクエリし、ビジュアライゼーション用のデータを取得します。",
"data.functions.esaggs.inspector.dataRequest.title": "データ",
"expressions.functions.kibana_context.help": "Kibana グローバルコンテキストを更新します",
"expressions.functions.kibana.help": "Kibana グローバルコンテキストを取得します",
"expressions.functions.font.args.alignHelpText": "水平テキスト配置",
Expand Down Expand Up @@ -1440,7 +1440,6 @@
"kbn.context.unableToLoadDocumentDescription": "ドキュメントが読み込めません",
"kbn.dashboard.addVisualizationDescription1": "上のメニューバーの ",
"kbn.dashboard.addVisualizationDescription2": " ボタンをクリックして、ダッシュボードにビジュアライゼーションを追加します。",
"kbn.dashboard.addVisualizationDescription3": "まだビジュアライゼーションをセットアップしていない場合は、{visitVisualizeAppLink} して初めのビジュアライゼーションを作成します。",
"kbn.dashboard.addVisualizationLinkAriaLabel": "ビジュアライゼーションを追加",
"kbn.dashboard.addVisualizationLinkText": "追加",
"kbn.dashboard.badge.readOnly.text": "読み込み専用",
Expand Down Expand Up @@ -12761,4 +12760,4 @@
"xpack.licensing.check.errorUnavailableMessage": "現在ライセンス情報が利用できないため {pluginName} を使用できません。",
"xpack.licensing.check.errorUnsupportedMessage": "ご使用の {licenseType} ライセンスは {pluginName} をサポートしていません。ライセンスをアップグレードしてください。"
}
}
}
Loading

0 comments on commit a6f7b18

Please sign in to comment.