Skip to content

Commit

Permalink
update plugin setup
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Apr 5, 2021
1 parent 9c86621 commit 7e5cf29
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 33 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/observability/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "8.0.0",
"kibanaVersion": "kibana",
"configPath": ["xpack", "observability"],
"optionalPlugins": ["licensing", "home", "usageCollection"],
"requiredPlugins": ["data", "lens"],
"optionalPlugins": ["licensing", "home", "usageCollection","lens"],
"requiredPlugins": ["data"],
"ui": true,
"server": true,
"requiredBundles": ["data", "kibanaReact", "kibanaUtils"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { i18n } from '@kbn/i18n';
import React, { useEffect, useState } from 'react';
import styled from 'styled-components';
import { EuiLoadingSpinner, EuiPanel } from '@elastic/eui';
import { EuiLoadingSpinner, EuiPanel, EuiTitle } from '@elastic/eui';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
import { ObservabilityPublicPluginsStart } from '../../../plugin';
import { ExploratoryViewHeader } from './header/header';
Expand All @@ -29,7 +29,7 @@ export function ExploratoryView() {

const { indexPattern } = useIndexPatternContext();

const LensComponent = lens.EmbeddableComponent;
const LensComponent = lens?.EmbeddableComponent;

const { firstSeriesId: seriesId, firstSeries: series } = useUrlStorage();

Expand All @@ -45,24 +45,36 @@ export function ExploratoryView() {

return (
<EuiPanel style={{ maxWidth: 1800, minWidth: 1200, margin: '0 auto' }}>
<ExploratoryViewHeader lensAttributes={lensAttributes} seriesId={seriesId} />
{!indexPattern && (
<SpinnerWrap>
<EuiLoadingSpinner size="xl" />
</SpinnerWrap>
)}

{lensAttributes && seriesId && series?.reportType && series?.time ? (
<LensComponent
id="exploratoryView"
style={{ height: 550 }}
timeRange={series?.time}
attributes={lensAttributes}
/>
{lens ? (
<>
<ExploratoryViewHeader lensAttributes={lensAttributes} seriesId={seriesId} />
{!indexPattern && (
<SpinnerWrap>
<EuiLoadingSpinner size="xl" />
</SpinnerWrap>
)}
{lensAttributes && seriesId && series?.reportType && series?.time ? (
<LensComponent
id="exploratoryView"
style={{ height: 550 }}
timeRange={series?.time}
attributes={lensAttributes}
/>
) : (
<EmptyView />
)}
<SeriesEditor />
</>
) : (
<EmptyView />
<EuiTitle>
<h2>
{i18n.translate('xpack.observability.overview.exploratoryView.lensDisabled', {
defaultMessage:
'Lens app is not available, please enable Lens to use exploratory view.',
})}
</h2>
</EuiTitle>
)}
<SeriesEditor />
</EuiPanel>
);
}
Expand Down
27 changes: 15 additions & 12 deletions x-pack/plugins/uptime/public/apps/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,21 @@ export class UptimePlugin

return UptimeDataHelper(coreStart);
};
plugins.observability.dashboard.register({
appName: 'uptime',
hasData: async () => {
const dataHelper = await getUptimeDataHelper();
const status = await dataHelper.indexStatus();
return status.docCount > 0;
},
fetchData: async (params: FetchDataParams) => {
const dataHelper = await getUptimeDataHelper();
return await dataHelper.overviewData(params);
},
});

if (plugins.observability) {
plugins.observability.dashboard.register({
appName: 'uptime',
hasData: async () => {
const dataHelper = await getUptimeDataHelper();
const status = await dataHelper.indexStatus();
return status.docCount > 0;
},
fetchData: async (params: FetchDataParams) => {
const dataHelper = await getUptimeDataHelper();
return await dataHelper.overviewData(params);
},
});
}

core.application.register({
id: PLUGIN.ID,
Expand Down

0 comments on commit 7e5cf29

Please sign in to comment.