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

[Lens] Show underlying data editor navigation #125983

Merged
merged 43 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8805136
:alembic: First steps
dej611 Feb 15, 2022
873ff6d
Merge remote-tracking branch 'upstream/main' into feature/show-underl…
dej611 Feb 15, 2022
fa64071
:tada: Initial implementation for button insider editor
dej611 Feb 17, 2022
32baaa0
:white_check_mark: fix types and tests
dej611 Feb 17, 2022
f659b6b
:white_check_mark: Add some tests and some test placeholders
dej611 Feb 17, 2022
7495712
Merge remote-tracking branch 'upstream/main' into feature/show-underl…
dej611 Feb 21, 2022
54bdbd2
:bug: Fix issues on mount
dej611 Feb 21, 2022
5b7dbe4
:fire: Remove unused attr
dej611 Feb 21, 2022
c938b01
:white_check_mark: Add more tests for edge cases
dej611 Feb 21, 2022
05163c8
:recycle: First code refactor
dej611 Feb 21, 2022
6206d27
:bug: Fix discover capabilities check
dej611 Feb 21, 2022
675b4db
:bug: Fix various issues
dej611 Feb 22, 2022
9dfc9d2
:white_check_mark: Add functional tests
dej611 Feb 22, 2022
6ddbee4
Merge remote-tracking branch 'upstream/main' into feature/show-underl…
dej611 Feb 22, 2022
aec1234
:white_check_mark: Add more tests
dej611 Feb 22, 2022
b214e75
Merge branch 'main' into feature/show-underlying-data
kibanamachine Feb 23, 2022
0f10e7c
Merge branch 'main' into feature/show-underlying-data
kibanamachine Feb 23, 2022
63440f3
Merge branch 'main' into feature/show-underlying-data
kibanamachine Feb 23, 2022
795f9b6
Merge branch 'main' into feature/show-underlying-data
kibanamachine Feb 23, 2022
71369da
:sparkles: Add support for terms + multiterms
dej611 Feb 23, 2022
83a08d3
:sparkles: Make link open a new window with discover
dej611 Feb 24, 2022
655a35e
:white_check_make: Update functional tests to deal with new tab
dej611 Feb 24, 2022
f9f95fd
:bug: Fix transposed table case: make it use fallback
dej611 Feb 24, 2022
c72219f
:bug: Fix unit tests
dej611 Feb 24, 2022
4eda950
Merge branch 'main' into feature/show-underlying-data
kibanamachine Feb 28, 2022
44d1088
Merge remote-tracking branch 'upstream/main' into feature/show-underl…
dej611 Mar 1, 2022
6124dbc
:ok_hand: Address review feedback
dej611 Mar 1, 2022
b30862e
:bug: Skip filtered metrics if there's at least an unfiltered one
dej611 Mar 2, 2022
1a8153f
:bug: Improve string escaping strategy
dej611 Mar 2, 2022
d0297fa
Merge branch 'main' into feature/show-underlying-data
kibanamachine Mar 2, 2022
0111cca
:bug: Fix functional tests and improved filters dedup checks
dej611 Mar 2, 2022
f0f7df5
Merge branch 'feature/show-underlying-data' of github.com:dej611/kiba…
dej611 Mar 2, 2022
1f6682a
:white_check_mark: Fix functional tests for formula case
dej611 Mar 3, 2022
972b432
:wrench: Make close editor panel more robust
dej611 Mar 3, 2022
6eec900
:wrench: Try focus approach
dej611 Mar 3, 2022
7be3ec7
:ok_hand: Rename variable
dej611 Mar 3, 2022
dbf8de9
:white_check_mark: Try to click outside
dej611 Mar 4, 2022
5f727c7
:white_check_mark: Use the keyboard arrow approach
dej611 Mar 4, 2022
0ad4bc3
Merge branch 'main' into feature/show-underlying-data
kibanamachine Mar 4, 2022
51da4b9
Merge branch 'main' into feature/show-underlying-data
kibanamachine Mar 7, 2022
bda6a9d
:ok_hand: Address some issues raised by review
dej611 Mar 7, 2022
b464915
:white_check_mark: Fix tests and add one more for unsupported datasource
dej611 Mar 7, 2022
6f36675
Merge branch 'main' into feature/show-underlying-data
kibanamachine Mar 8, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export interface TopNavMenuData {
isLoading?: boolean;
iconType?: string;
iconSide?: EuiButtonProps['iconSide'];
target?: string;
href?: string;
}

export interface RegisteredTopNavMenuData extends TopNavMenuData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,19 @@ export function TopNavMenuItem(props: TopNavMenuData) {
className: props.className,
};

// If the item specified a href, then override the suppress the onClick
// and make it become a regular link
const overrideProps =
props.target && props.href
? { onClick: undefined, href: props.href, target: props.target }
: {};

const btn = props.emphasize ? (
<EuiButton size="s" {...commonButtonProps} fill>
{getButtonContainer()}
</EuiButton>
) : (
<EuiHeaderLink size="s" color="primary" {...commonButtonProps}>
<EuiHeaderLink size="s" color="primary" {...commonButtonProps} {...overrideProps}>
{getButtonContainer()}
</EuiHeaderLink>
);
Expand Down
5 changes: 5 additions & 0 deletions test/functional/services/filter_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ export class FilterBarService extends FtrService {
return filters.length;
}

public async getFiltersLabel(): Promise<string[]> {
const filters = await this.testSubjects.findAll('~filter');
return Promise.all(filters.map((filter) => filter.getVisibleText()));
}

/**
* Adds a filter to the filter bar.
*
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/lens/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"taskManager",
"globalSearch",
"savedObjectsTagging",
"spaces"
"spaces",
"discover"
],
"configPath": [
"xpack",
Expand Down
78 changes: 78 additions & 0 deletions x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ import {
DispatchSetState,
} from '../state_management';
import { getIndexPatternsObjects, getIndexPatternsIds, getResolvedDateRange } from '../utils';
import {
combineQueryAndFilters,
getLayerMetaInfo,
getShowUnderlyingDataLabel,
} from './show_underlying_data';

function getLensTopNavConfig(options: {
showSaveAndReturn: boolean;
enableExportToCSV: boolean;
showOpenInDiscover?: boolean;
showCancel: boolean;
isByValueMode: boolean;
allowByValue: boolean;
Expand All @@ -46,6 +52,7 @@ function getLensTopNavConfig(options: {
showCancel,
allowByValue,
enableExportToCSV,
showOpenInDiscover,
showSaveAndReturn,
savingToLibraryPermitted,
savingToDashboardPermitted,
Expand Down Expand Up @@ -90,6 +97,21 @@ function getLensTopNavConfig(options: {
});
}

if (showOpenInDiscover) {
topNavMenu.push({
label: getShowUnderlyingDataLabel(),
run: () => {},
testId: 'lnsApp_openInDiscover',
description: i18n.translate('xpack.lens.app.openInDiscoverAriaLabel', {
defaultMessage: 'Open underlying data in Discover',
}),
disableButton: Boolean(tooltips.showUnderlyingDataWarning()),
tooltip: tooltips.showUnderlyingDataWarning,
target: '_blank',
href: actions.getUnderlyingDataUrl(),
});
}

topNavMenu.push({
label: i18n.translate('xpack.lens.app.inspect', {
defaultMessage: 'Inspect',
Expand Down Expand Up @@ -183,6 +205,7 @@ export const LensTopNavMenu = ({
uiSettings,
application,
attributeService,
discover,
dashboardFeatureFlag,
} = useKibana<LensAppServices>().services;

Expand Down Expand Up @@ -290,6 +313,26 @@ export const LensTopNavMenu = ({
filters,
initialContext,
]);

const layerMetaInfo = useMemo(() => {
if (!activeDatasourceId || !discover) {
return;
}
return getLayerMetaInfo(
datasourceMap[activeDatasourceId],
datasourceStates[activeDatasourceId].state,
activeData,
application.capabilities
);
}, [
activeData,
activeDatasourceId,
datasourceMap,
datasourceStates,
discover,
application.capabilities,
]);

const topNavConfig = useMemo(() => {
const baseMenuEntries = getLensTopNavConfig({
showSaveAndReturn:
Expand All @@ -299,6 +342,7 @@ export const LensTopNavMenu = ({
(dashboardFeatureFlag.allowByValueEmbeddables || Boolean(initialInput))
) || Boolean(initialContextIsEmbedded),
enableExportToCSV: Boolean(isSaveable && activeData && Object.keys(activeData).length),
showOpenInDiscover: Boolean(layerMetaInfo?.isVisible),
isByValueMode: getIsByValueMode(),
allowByValue: dashboardFeatureFlag.allowByValueEmbeddables,
showCancel: Boolean(isLinkedToOriginatingApp),
Expand All @@ -321,6 +365,9 @@ export const LensTopNavMenu = ({
}
return undefined;
},
showUnderlyingDataWarning: () => {
return layerMetaInfo?.error;
},
},
actions: {
inspect: () => lensInspector.inspect({ title }),
Expand Down Expand Up @@ -388,6 +435,31 @@ export const LensTopNavMenu = ({
redirectToOrigin();
}
},
getUnderlyingDataUrl: () => {
if (!layerMetaInfo) {
return;
}
const { error, meta } = layerMetaInfo;
// If Discover is not available, return
// If there's no data, return
if (error || !discover || !meta) {
return;
}
const { filters: newFilters, query: newQuery } = combineQueryAndFilters(
query,
filters,
meta,
indexPatterns
);

return discover.locator!.getRedirectUrl({
indexPatternId: meta.id,
timeRange: data.query.timefilter.timefilter.getTime(),
filters: newFilters,
query: newQuery,
columns: meta.columns,
});
},
},
});
return [...(additionalMenuEntries || []), ...baseMenuEntries];
Expand All @@ -398,6 +470,7 @@ export const LensTopNavMenu = ({
initialContextIsEmbedded,
isSaveable,
activeData,
layerMetaInfo,
getIsByValueMode,
savingToLibraryPermitted,
savingToDashboardPermitted,
Expand All @@ -414,6 +487,11 @@ export const LensTopNavMenu = ({
setIsSaveModalVisible,
goBackToOriginatingApp,
redirectToOrigin,
discover,
query,
filters,
indexPatterns,
data.query.timefilter.timefilter,
]);

const onQuerySubmitWrapped = useCallback(
Expand Down
8 changes: 6 additions & 2 deletions x-pack/plugins/lens/public/app_plugin/mounter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export async function getLensServices(
usageCollection,
fieldFormats,
spaces,
discover,
} = startDependencies;

const storage = new Storage(localStorage);
Expand Down Expand Up @@ -95,6 +96,7 @@ export async function getLensServices(
// Temporarily required until the 'by value' paradigm is default.
dashboardFeatureFlag: startDependencies.dashboard.dashboardFeatureFlagConfig,
spaces,
discover,
};
}

Expand All @@ -114,8 +116,10 @@ export async function mountApp(
getPresentationUtilContext,
topNavMenuEntryGenerators,
} = mountProps;
const [coreStart, startDependencies] = await core.getStartServices();
const instance = await createEditorFrame();
const [[coreStart, startDependencies], instance] = await Promise.all([
core.getStartServices(),
createEditorFrame(),
]);
const historyLocationState = params.history.location.state as HistoryLocationState;

const lensServices = await getLensServices(coreStart, startDependencies, attributeService);
Expand Down
Loading