[Dashboard] Fast Navigation Between Dashboards (#157437)

## Summary
Makes all navigation from one Dashboard to another feel snappier.
This commit is contained in:
Devon Thomson 2023-05-25 14:40:48 -04:00 committed by GitHub
parent 83b7939e03
commit 5342563a22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 299 additions and 230 deletions

View file

@ -14,7 +14,11 @@ import { EuiPanel, EuiSpacer, EuiText, EuiTitle } from '@elastic/eui';
import { controlGroupInputBuilder } from '@kbn/controls-plugin/public';
import { getDefaultControlGroupInput } from '@kbn/controls-plugin/common';
import { FILTER_DEBUGGER_EMBEDDABLE } from '@kbn/embeddable-examples-plugin/public';
import { AwaitingDashboardAPI, DashboardRenderer } from '@kbn/dashboard-plugin/public';
import {
AwaitingDashboardAPI,
DashboardRenderer,
DashboardCreationOptions,
} from '@kbn/dashboard-plugin/public';
export const DashboardWithControlsExample = ({ dataView }: { dataView: DataView }) => {
const [dashboard, setDashboard] = useState<AwaitingDashboardAPI>();
@ -48,7 +52,7 @@ export const DashboardWithControlsExample = ({ dataView }: { dataView: DataView
<EuiSpacer size="m" />
<EuiPanel hasBorder={true}>
<DashboardRenderer
getCreationOptions={async () => {
getCreationOptions={async (): Promise<DashboardCreationOptions> => {
const builder = controlGroupInputBuilder;
const controlGroupInput = getDefaultControlGroupInput();
await builder.addDataControlFromField(controlGroupInput, {
@ -68,11 +72,11 @@ export const DashboardWithControlsExample = ({ dataView }: { dataView: DataView
return {
useControlGroupIntegration: true,
initialInput: {
getInitialInput: () => ({
timeRange: { from: 'now-30d', to: 'now' },
viewMode: ViewMode.VIEW,
controlGroupInput,
},
}),
};
}}
ref={setDashboard}

View file

@ -136,10 +136,10 @@ export const DynamicByReferenceExample = () => {
getCreationOptions={async () => {
const persistedInput = getPersistableInput();
return {
initialInput: {
getInitialInput: () => ({
...persistedInput,
timeRange: { from: 'now-30d', to: 'now' }, // need to set the time range for the by value vis
},
}),
};
}}
ref={setdashboard}

View file

@ -50,12 +50,15 @@ export const StaticByReferenceExample = ({
const field = dataView.getFieldByName('machine.os.keyword');
let filter: Filter;
let creationOptions: DashboardCreationOptions = {
initialInput: { viewMode: ViewMode.VIEW },
getInitialInput: () => ({ viewMode: ViewMode.VIEW }),
};
if (field) {
filter = buildPhraseFilter(field, 'win xp', dataView);
filter.meta.negate = true;
creationOptions = { ...creationOptions, initialInput: { filters: [filter] } };
creationOptions = {
...creationOptions,
getInitialInput: () => ({ filters: [filter] }),
};
}
return creationOptions; // if can't find the field, then just return no special creation options
}}

View file

@ -29,11 +29,11 @@ export const StaticByValueExample = () => {
<DashboardRenderer
getCreationOptions={async () => {
return {
initialInput: {
getInitialInput: () => ({
timeRange: { from: 'now-30d', to: 'now' },
viewMode: ViewMode.VIEW,
panels: panelsJson as DashboardPanelMap,
},
}),
};
}}
/>