Skip to content

Commit

Permalink
Simplify explicit input to only include what is **absolutely necessary**
Browse files Browse the repository at this point in the history
  • Loading branch information
Heenawter committed Jun 22, 2023
1 parent 6982698 commit bc9c863
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const NavigationEmbeddableComponent = () => {
setDashboardListGroupItems(
(selectedDashboards ?? []).map((dashboard) => {
return {
label: dashboard.label ?? dashboard.attributes.title,
label: dashboard.label || dashboard.title,
iconType: 'dashboardApp',
color: dashboard.id === currentDashboardId ? 'text' : 'primary',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export const NavigationEmbeddableDashboardList = ({ onDashboardSelected, ...othe
(state) => state.componentState.currentDashboardId
);

const [dashboardListOptions, setDashboardListOptions] = useState<
Array<EuiSelectableOption<DashboardItem>>
>([]);
const [dashboardListOptions, setDashboardListOptions] = useState<EuiSelectableOption[]>([]);

const { loading: loadingDashboardList, value: dashboardList } = useAsync(async () => {
return await navEmbeddable.fetchDashboardList();
Expand All @@ -47,9 +45,9 @@ export const NavigationEmbeddableDashboardList = ({ onDashboardSelected, ...othe
}),
checked: isCurrentDashboard ? 'on' : undefined,
label: dashboard.attributes.title,
};
} as EuiSelectableOption;
}) ?? [];
setDashboardListOptions(dashboardOptions as Array<EuiSelectableOption<DashboardItem>>);
setDashboardListOptions(dashboardOptions);
}, [dashboardList, currentDashboardId, onDashboardSelected]);

return loadingDashboardList ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ export const NavigationEmbeddableDashboardPicker = () => {
onClick={() => {
if (selectedDashboard) {
navEmbeddable.dispatch.addLink({
...selectedDashboard,
label: dashboardLabel === '' ? selectedDashboard.attributes.title : dashboardLabel,
label: dashboardLabel,
id: selectedDashboard.id,
title: selectedDashboard.attributes.title,
description: selectedDashboard.attributes.description,
});
}
setDashboardLabel('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
* Side Public License, v 1.
*/

import { EmbeddableInput, EmbeddableOutput } from '@kbn/embeddable-plugin/public';
import { DashboardItem } from '@kbn/dashboard-plugin/common/content_management';
import { ReduxEmbeddableState } from '@kbn/presentation-util-plugin/public';
import { DashboardItem } from '@kbn/dashboard-plugin/common/content_management';
import { EmbeddableInput, EmbeddableOutput } from '@kbn/embeddable-plugin/public';

export type DashboardLink = DashboardItem & { label?: string };
export interface DashboardLink {
id: string;
title: string;
label?: string;
description?: string;
}

export interface NavigationEmbeddableInput extends EmbeddableInput {
dashboardLinks?: DashboardLink[]; // probably want to simplify this so we are only storing what is absolutely necessary
dashboardLinks?: DashboardLink[];
}

export interface NavigationEmbeddableComponentState {
Expand Down

0 comments on commit bc9c863

Please sign in to comment.