Skip to content

Commit

Permalink
Merge pull request opensearch-project#3 from wanglam/feat-remove-all-…
Browse files Browse the repository at this point in the history
…data-source-modal

Remove all tab and sort connections by name alphabetical
  • Loading branch information
yubonluo authored Aug 28, 2024
2 parents 49377ce + f1a54af commit 724170e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,11 @@ const convertConnectionsToOptions = (
};

enum AssociationDataSourceModalTab {
All = 'all',
OpenSearchConnections = 'opensearch-connections',
DirectQueryConnections = 'direction-query-connections',
}

const tabOptions: EuiButtonGroupOptionProps[] = [
{
id: AssociationDataSourceModalTab.All,
label: i18n.translate('workspace.form.selectDataSource.subTitle', {
defaultMessage: 'All',
}),
},
{
id: AssociationDataSourceModalTab.OpenSearchConnections,
label: i18n.translate('workspace.form.selectDataSource.subTitle', {
Expand Down Expand Up @@ -100,7 +93,7 @@ export const AssociationDataSourceModal = ({
handleAssignDataSourceConnections,
}: AssociationDataSourceModalProps) => {
const [allConnections, setAllConnections] = useState<DataSourceConnection[]>([]);
const [currentTab, setCurrentTab] = useState('all');
const [currentTab, setCurrentTab] = useState(tabOptions[0].id);
const [allOptions, setAllOptions] = useState<DataSourceModalOption[]>([]);
const [isLoading, setIsLoading] = useState(false);

Expand Down
5 changes: 4 additions & 1 deletion src/plugins/workspace/public/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,10 @@ export const fetchDataSourceConnections = async (
);
const directQueryConnectionsResult = await Promise.all(directQueryConnectionsPromises);
const directQueryConnections = directQueryConnectionsResult.flat();
return mergeDataSourcesWithConnections(assignedDataSources, directQueryConnections);
return mergeDataSourcesWithConnections(
assignedDataSources,
directQueryConnections
).sort((a, b) => a.name.localeCompare(b.name));
} catch (error) {
notifications?.toasts.addDanger(
i18n.translate('workspace.detail.dataSources.error.message', {
Expand Down

0 comments on commit 724170e

Please sign in to comment.