Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reafctor based on PR 2334 comments to merge to main #2375

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugins/data_source_management/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dataSourceManagement

A OpenSearch Dashboards plugin
An OpenSearch Dashboards plugin

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export const DataSourceTable = ({ history }: RouteComponentProps) => {
</>
),
dataType: 'string' as const,
sortable: ({ sort }: { sort: string }) => sort,
sortable: ({ title }: { title: string }) => title,
},
{
field: 'description',
Expand All @@ -180,7 +180,7 @@ export const DataSourceTable = ({ history }: RouteComponentProps) => {
show: false,
},
dataType: 'string' as const,
sortable: ({ sort }: { sort: string }) => sort,
sortable: ({ description }: { description: string }) => description,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('DataSourceManagement: Utils.ts', () => {
mockResponseForSavedObjectsCalls(savedObjects.client, 'find', getDataSourcesResponse);
const fetchDataSources = await getDataSources(savedObjects.client);
expect(fetchDataSources.length).toBe(getDataSourcesResponse.savedObjects.length);
expect(fetchDataSources[0].title).toBe('alpha-test');
});
test('Success but no data sources found: getting data sources', async () => {
mockResponseForSavedObjectsCalls(savedObjects.client, 'find', {});
Expand Down
32 changes: 11 additions & 21 deletions src/plugins/data_source_management/public/components/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,18 @@ export async function getDataSources(savedObjectsClient: SavedObjectsClientContr
})
.then(
(response) =>
response?.savedObjects
?.map((source) => {
const id = source.id;
const title = source.get('title');
const description = source.get('description');
response?.savedObjects?.map((source) => {
const id = source.id;
const title = source.get('title');
const description = source.get('description');

return {
id,
title,
description,
sort: `${title}`,
};
})
.sort((a, b) => {
if (a.sort < b.sort) {
return -1;
} else if (a.sort > b.sort) {
return 1;
} else {
return 0;
}
}) || []
return {
id,
title,
description,
sort: `${title}`,
};
}) || []
);
}

Expand Down