Skip to content

Commit

Permalink
fix syntax
Browse files Browse the repository at this point in the history
Signed-off-by: Yuanqi(Ella) Zhu <[email protected]>
  • Loading branch information
zhyuanqi committed Apr 3, 2024
1 parent 2746d0f commit 3bf9adf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -568,15 +568,15 @@ describe('DataSourceManagement: Utils.ts', () => {
});

it('should return the default datasource if hideLocalCluster is false', () => {
mockUiSettingsCalls(uiSettings, 'get', '1');
mockUiSettingsCalls(uiSettings, 'get', '2');
const result = getDefaultDataSource(getDataSource, LocalCluster, uiSettings, true);
expect(result).toEqual([{ id: '1', label: 'DataSource 1' }]);
expect(result).toEqual([{ id: '2', label: 'DataSource 2' }]);
});

it('should return an empty default data source if no default option, hideLocalCluster is ture and no default datasource', () => {
it('should return the first data source if no default option, hideLocalCluster is ture and no default datasource', () => {
mockUiSettingsCalls(uiSettings, 'get', null);
const result = getDefaultDataSource(getDataSource, LocalCluster, uiSettings, true);
expect(result).toEqual([]);
expect(result).toEqual([{ id: '1', label: 'DataSource 1' }]);
});
});
});
17 changes: 12 additions & 5 deletions src/plugins/data_source_management/public/components/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ export function getDefaultDataSource(
label: defaultOption?.[0]?.label || defaultOptionDataSource.attributes?.title,
},
];
}
if (defaultDataSourceAfterCheck) {
}
if (defaultDataSourceAfterCheck) {
return [
{
id: defaultDataSourceAfterCheck.id,
Expand All @@ -121,9 +121,16 @@ if (defaultDataSourceAfterCheck) {
}
if (!hideLocalCluster) {
return [LocalCluster];
}
return [];

}
if (dataSources.length > 0) {
return [
{
id: dataSources[0].id,
label: dataSources[0].attributes.title,
},
];
}
return [];
}

export async function getDataSourceById(
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data_source_management/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const getDataSource = [
type: '',
references: [],
attributes: {
title: 'DataSource 1',
title: 'DataSource 2',
endpoint: '',
auth: { type: AuthType.NoAuth, credentials: undefined },
name: AuthType.NoAuth,
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/dev_tools/public/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function DevToolsWrapper({
uiSettings,
}: DevToolsWrapperProps) {
const mountedTool = useRef<MountedDevToolDescriptor | null>(null);
const [isLoading, setIsLoading] = React.useState(false);
const [isLoading, setIsLoading] = React.useState<boolean>(true);

useEffect(
() => () => {
Expand Down Expand Up @@ -114,7 +114,7 @@ function DevToolsWrapper({
mountpoint: mountPoint,
unmountHandler,
};
setIsLoading(true);
setIsLoading(false);
};

return (
Expand All @@ -135,7 +135,7 @@ function DevToolsWrapper({
</EuiTab>
</EuiToolTip>
))}
{dataSourceEnabled && isLoading ? (
{dataSourceEnabled && !isLoading ? (
<div className="devAppDataSourceSelector">
<DataSourceSelector
savedObjectsClient={savedObjects.client}
Expand Down

0 comments on commit 3bf9adf

Please sign in to comment.