Skip to content

Commit

Permalink
Removes FindQueryHTTP['fields'] option in Saved Objects Management (#…
Browse files Browse the repository at this point in the history
…152306)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
TinaHeiligers and kibanamachine committed Feb 28, 2023
1 parent 124b5be commit 5274175
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 24 deletions.
7 changes: 0 additions & 7 deletions src/plugins/saved_objects_management/common/types/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,6 @@ export interface FindQueryHTTP {
sortOrder?: FindSortOrderHTTP;
hasReference?: ReferenceHTTP | ReferenceHTTP[];
hasReferenceOperator?: FindSearchOperatorHTTP;
/**
* It is not clear who might be using this API option, the SOM UI only ever passes in "id" here.
*
* TODO: Determine use. If not in use we should remove this option. If in use we must deprecate and eventually
* remove.
*/
fields?: string | string[];
}

export interface FindResponseHTTP {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb
search: queryText ? `${queryText}*` : undefined,
perPage,
page: page + 1,
fields: ['id'],
type: searchTypes,
sortField: sort?.field,
sortOrder: sort?.direction,
Expand Down
7 changes: 0 additions & 7 deletions src/plugins/saved_objects_management/server/routes/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ export const registerFindRoute = (
schema.oneOf([referenceSchema, schema.arrayOf(referenceSchema)])
),
hasReferenceOperator: searchOperatorSchema,
fields: schema.oneOf([schema.string(), schema.arrayOf(schema.string())], {
defaultValue: [],
}),
}),
},
},
Expand All @@ -58,7 +55,6 @@ export const registerFindRoute = (
const { getClient, typeRegistry } = (await context.core).savedObjects;

const searchTypes = Array.isArray(query.type) ? query.type : [query.type];
const includedFields = Array.isArray(query.fields) ? query.fields : [query.fields];

const importAndExportableTypes = searchTypes.filter((type) =>
typeRegistry.isImportableAndExportable(type)
Expand Down Expand Up @@ -90,9 +86,6 @@ export const registerFindRoute = (
saved_objects: savedObjects.map((so) => {
const obj = injectMetaAttributes(so, managementService);
const result = { ...obj, attributes: {} as Record<string, unknown> };
for (const field of includedFields) {
result.attributes[field] = (obj.attributes as Record<string, unknown>)[field];
}
return result;
}),
total: findResponse.total,
Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/saved_objects_management/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function ({ getService }: FtrProviderContext) {

it('should return 200 with individual responses', async () =>
await supertest
.get('/api/kibana/management/saved_objects/_find?type=visualization&fields=title')
.get('/api/kibana/management/saved_objects/_find?type=visualization')
.expect(200)
.then((resp: Response) => {
expect(resp.body.saved_objects.map((so: { id: string }) => so.id)).to.eql([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {

it('returns empty response for importableAndExportable types', async () =>
await supertest
.get('/api/saved_objects/_find?type=test-hidden-importable-exportable&fields=title')
.get('/api/saved_objects/_find?type=test-hidden-importable-exportable')
.set('kbn-xsrf', 'true')
.expect(200)
.then((resp) => {
Expand All @@ -41,7 +41,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {

it('returns empty response for non importableAndExportable types', async () =>
await supertest
.get('/api/saved_objects/_find?type=test-hidden-non-importable-exportable&fields=title')
.get('/api/saved_objects/_find?type=test-hidden-non-importable-exportable')
.set('kbn-xsrf', 'true')
.expect(200)
.then((resp) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
);
it('returns saved objects with importableAndExportable types', async () =>
await supertest
.get(
'/api/kibana/management/saved_objects/_find?type=test-hidden-importable-exportable&fields=title'
)
.get('/api/kibana/management/saved_objects/_find?type=test-hidden-importable-exportable')
.set('kbn-xsrf', 'true')
.expect(200)
.then((resp) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
describe('find', () => {
it('returns saved objects registered as hidden from the http Apis', async () => {
await supertest
.get(
`/api/kibana/management/saved_objects/_find?type=${hiddenFromHttpApisType.type}&fields=title`
)
.get(`/api/kibana/management/saved_objects/_find?type=${hiddenFromHttpApisType.type}`)
.set('kbn-xsrf', 'true')
.expect(200)
.then((resp) => {
Expand Down

0 comments on commit 5274175

Please sign in to comment.