Skip to content
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
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'],
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than trying hard coding the option, I've removed it instead.

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) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removes handling the 'fields' option in the query since we don't want to explicitly expose attributes in the response

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')
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adapts tests

.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