-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Dataset Quality] Added Dataset Quality Locator #177000
Changes from 3 commits
8e5d847
24ef352
ac505ed
7d6f5c8
e5467a4
7e6190e
8e3ed81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { SerializableRecord } from '@kbn/utility-types'; | ||
|
||
export const DATASET_QUALITY_LOCATOR_ID = 'DATASET_QUALITY_LOCATOR'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
type RefreshInterval = { | ||
isPaused: boolean; | ||
interval: number; | ||
}; | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
type TimeRangeConfig = { | ||
from: string; | ||
to: string; | ||
refresh: RefreshInterval; | ||
}; | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
type Filters = { | ||
timeRange: TimeRangeConfig; | ||
}; | ||
|
||
export interface DatasetQualityLocatorParams extends SerializableRecord { | ||
filters?: Filters; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,10 @@ import { mapPercentagesToQualityCounts } from '../../quality_indicator'; | |
import { InfoIndicators } from '../../common'; | ||
|
||
export function DatasetsQualityIndicators() { | ||
const { datasetsQuality, isDatasetsQualityLoading } = useSummaryPanelContext(); | ||
const { datasetsQuality, isDatasetsQualityLoading, datasetsActivity } = useSummaryPanelContext(); | ||
const qualityCounts = mapPercentagesToQualityCounts(datasetsQuality.percentages); | ||
const datasetsWithoutIgnoredField = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not part of the PR scope but a bug that is found and decided to fix it here |
||
datasetsActivity.total > 0 ? datasetsActivity.total - datasetsQuality.percentages.length : 0; | ||
|
||
return ( | ||
<EuiPanel hasBorder> | ||
|
@@ -61,7 +63,7 @@ export function DatasetsQualityIndicators() { | |
/> | ||
<span css={verticalRule} /> | ||
<QualityIndicator | ||
value={qualityCounts.good} | ||
value={qualityCounts.good + datasetsWithoutIgnoredField} | ||
quality="success" | ||
description={summaryPanelQualityGoodText} | ||
isLoading={isDatasetsQualityLoading} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { LocatorDefinition, LocatorPublic } from '@kbn/share-plugin/public'; | ||
import { | ||
DatasetQualityLocatorParams, | ||
DATASET_QUALITY_LOCATOR_ID, | ||
} from '@kbn/deeplinks-observability/locators'; | ||
import { DatasetQualityLocatorDependencies } from './types'; | ||
import { constructDatasetQualityLocatorPath } from './utils'; | ||
|
||
export type DatasetQualityLocator = LocatorPublic<DatasetQualityLocatorParams>; | ||
|
||
export class DatasetQualityLocatorDefinition | ||
implements LocatorDefinition<DatasetQualityLocatorParams> | ||
{ | ||
public readonly id = DATASET_QUALITY_LOCATOR_ID; | ||
|
||
constructor(protected readonly deps: DatasetQualityLocatorDependencies) {} | ||
|
||
public readonly getLocation = async (params: DatasetQualityLocatorParams) => { | ||
return constructDatasetQualityLocatorPath(params); | ||
}; | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this file will later on be moved to the dataset quality plugin as we are planning to create our own app |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { DatasetQualityLocatorParams } from '@kbn/deeplinks-observability/locators'; | ||
import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/common'; | ||
import { OBSERVABILITY_LOGS_EXPLORER_APP_ID } from '@kbn/deeplinks-observability'; | ||
import { | ||
OBSERVABILITY_DATASET_QUALITY_URL_STATE_KEY, | ||
datasetQualityUrlSchemaV1, | ||
} from '../../url_schema'; | ||
import { deepCompactObject } from '../../utils/deep_compact_object'; | ||
|
||
export const constructDatasetQualityLocatorPath = async (params: DatasetQualityLocatorParams) => { | ||
const { filters } = params; | ||
|
||
const pageState = datasetQualityUrlSchemaV1.urlSchemaRT.encode( | ||
deepCompactObject({ | ||
v: 1, | ||
filters, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we will be not only taking into account timeRange or the other filters as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. at the moment I am only passing the timerange, its the only filter added to the locator params. |
||
}) | ||
); | ||
|
||
const path = setStateToKbnUrl( | ||
OBSERVABILITY_DATASET_QUALITY_URL_STATE_KEY, | ||
pageState, | ||
{ useHash: false, storeInHashQuery: false }, | ||
'/dataset-quality' | ||
); | ||
|
||
return { | ||
app: OBSERVABILITY_LOGS_EXPLORER_APP_ID, | ||
path, | ||
state: {}, | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
*/ | ||
|
||
export * from './construct_locator_path'; | ||
export * from './construct_dataset_quality_locator_path'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { EuiHeaderLink } from '@elastic/eui'; | ||
import { | ||
DatasetQualityLocatorParams, | ||
DATASET_QUALITY_LOCATOR_ID, | ||
} from '@kbn/deeplinks-observability/locators'; | ||
import { LogsExplorerPublicState } from '@kbn/logs-explorer-plugin/public'; | ||
import { getRouterLinkProps } from '@kbn/router-utils'; | ||
import { BrowserUrlService } from '@kbn/share-plugin/public'; | ||
import { MatchedStateFromActor } from '@kbn/xstate-utils'; | ||
import { useActor } from '@xstate/react'; | ||
import React from 'react'; | ||
import { datasetQualityLinkTitle } from '../../common/translations'; | ||
import { | ||
ObservabilityLogsExplorerService, | ||
useObservabilityLogsExplorerPageStateContext, | ||
} from '../state_machines/observability_logs_explorer/src'; | ||
import { useKibanaContextForPlugin } from '../utils/use_kibana'; | ||
|
||
export const ConnectedDatasetQualityLink = React.memo(() => { | ||
const { | ||
services: { | ||
share: { url }, | ||
}, | ||
} = useKibanaContextForPlugin(); | ||
const [pageState] = useActor(useObservabilityLogsExplorerPageStateContext()); | ||
|
||
if (pageState.matches({ initialized: 'validLogsExplorerState' })) { | ||
return <DatasetQualityLink urlService={url} pageState={pageState} />; | ||
} else { | ||
return <DatasetQualityLink urlService={url} />; | ||
} | ||
}); | ||
|
||
type InitializedPageState = MatchedStateFromActor< | ||
ObservabilityLogsExplorerService, | ||
{ initialized: 'validLogsExplorerState' } | ||
>; | ||
|
||
const constructLocatorParams = ( | ||
logsExplorerState: LogsExplorerPublicState | ||
): DatasetQualityLocatorParams => { | ||
const { time, refreshInterval } = logsExplorerState; | ||
const locatorParams: DatasetQualityLocatorParams = { | ||
filters: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this construction will be refactored when we use the types from the data plugin |
||
timeRange: { | ||
from: time?.from || 'now-24h', | ||
to: time?.to || 'now', | ||
refresh: { | ||
isPaused: refreshInterval ? refreshInterval.pause : false, | ||
interval: refreshInterval ? refreshInterval.value : 60000, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
return locatorParams; | ||
}; | ||
|
||
export const DatasetQualityLink = React.memo( | ||
({ | ||
urlService, | ||
pageState, | ||
}: { | ||
urlService: BrowserUrlService; | ||
pageState?: InitializedPageState; | ||
}) => { | ||
const locator = urlService.locators.get<DatasetQualityLocatorParams>( | ||
DATASET_QUALITY_LOCATOR_ID | ||
); | ||
const locatorParams: DatasetQualityLocatorParams = pageState | ||
? constructLocatorParams(pageState.context.logsExplorerState) | ||
: {}; | ||
|
||
const datasetQualityUrl = locator?.useUrl(locatorParams); | ||
|
||
const navigateToDatasetQuality = () => { | ||
locator?.navigate(locatorParams); | ||
}; | ||
|
||
const datasetQualityLinkProps = getRouterLinkProps({ | ||
href: datasetQualityUrl, | ||
onClick: navigateToDatasetQuality, | ||
}); | ||
|
||
return ( | ||
<EuiHeaderLink | ||
{...datasetQualityLinkProps} | ||
color="primary" | ||
data-test-subj="logsExplorerDatasetQualityLink" | ||
> | ||
{datasetQualityLinkTitle} | ||
</EuiHeaderLink> | ||
); | ||
} | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import { | |
import { OBSERVABILITY_LOGS_EXPLORER_APP_ID } from '@kbn/deeplinks-observability'; | ||
import { | ||
AllDatasetsLocatorDefinition, | ||
DatasetQualityLocatorDefinition, | ||
ObservabilityLogsExplorerLocators, | ||
SingleDatasetLocatorDefinition, | ||
} from '../common/locators'; | ||
|
@@ -95,6 +96,10 @@ export class ObservabilityLogsExplorerPlugin | |
useHash, | ||
}) | ||
); | ||
const datasetQualityLocator = share.url.locators.create( | ||
new DatasetQualityLocatorDefinition({}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we not using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes correct will add it here we should read it from |
||
); | ||
|
||
const dataViewLocator = share.url.locators.create( | ||
new DataViewLocatorDefinition({ | ||
useHash, | ||
|
@@ -108,6 +113,7 @@ export class ObservabilityLogsExplorerPlugin | |
|
||
this.locators = { | ||
allDatasetsLocator, | ||
datasetQualityLocator, | ||
dataViewLocator, | ||
singleDatasetLocator, | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the types here will be removed as part of another ticket to make use of the types from the data plugin
https://github.com/elastic/kibana/blob/9e04d2c5c7b2139b7e23743b133ea79bf93f5ba3/src/plugins/data/common/query/timefilter/types.ts