Skip to content

Commit

Permalink
Fix edge case and test
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho committed Apr 10, 2024
1 parent 5cd84aa commit 6ab449b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions public/apps/configuration/test/top-nav-menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('SecurityPluginTopNavMenu', () => {
depsStart={securityPluginStartDepsMock}
dataSourcePickerReadOnly={false}
dataSourceManagement={dataSourceManagementMock}
selectedDataSource={{}}
params={{}}
/>
);
Expand Down
5 changes: 4 additions & 1 deletion public/apps/configuration/top-nav-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ export const SecurityPluginTopNavMenu = React.memo(
const dataSourceEnabled = !!depsStart.dataSource?.dataSourceEnabled;

const wrapSetDataSourceWithUpdateUrl = (dataSources: DataSourceOption[]) => {
console.log(dataSources);
setDataSourceInUrl(dataSources[0]);
setDataSource(dataSources[0]);
};
console.log(selectedDataSource);

return dataSourceEnabled ? (
<DataSourceMenu
Expand All @@ -53,7 +55,8 @@ export const SecurityPluginTopNavMenu = React.memo(
componentConfig={{
savedObjects: coreStart.savedObjects.client,
notifications: coreStart.notifications,
activeOption: [selectedDataSource],
activeOption:
selectedDataSource.id || selectedDataSource.label ? [selectedDataSource] : undefined,
onSelectedDataSources: wrapSetDataSourceWithUpdateUrl,
fullWidth: true,
}}
Expand Down

0 comments on commit 6ab449b

Please sign in to comment.