Skip to content

Commit

Permalink
reafctor based on PR 2334 comments to merge to main (opensearch-proje…
Browse files Browse the repository at this point in the history
…ct#2375)

Signed-off-by: mpabba3003 <[email protected]>

Signed-off-by: mpabba3003 <[email protected]>
Signed-off-by: Kristen Tian <[email protected]>
  • Loading branch information
mpabba3003 authored and kristenTian committed Sep 15, 2022
1 parent bd8cf04 commit 98fa63e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 deletions.
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 @@ -162,7 +162,7 @@ export const DataSourceTable = ({ history }: RouteComponentProps) => {
</>
),
dataType: 'string' as const,
sortable: ({ sort }: { sort: string }) => sort,
sortable: ({ title }: { title: string }) => title,
},
{
field: 'description',
Expand All @@ -172,7 +172,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

0 comments on commit 98fa63e

Please sign in to comment.