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

[EPM] Remove unnecessary await if we can return the promise. #50329

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
12 changes: 3 additions & 9 deletions x-pack/legacy/plugins/integrations_manager/public/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ export function setClient(client: HttpHandler): void {

export async function getCategories(): Promise<CategorySummaryList> {
const path = getCategoriesPath();
const list: CategorySummaryList = await _fetch(path);

return list;
return _fetch(path);
}

export async function getPackages(params?: ListParams): Promise<PackageList> {
const path = getListPath();
const options = params ? { query: { ...params } } : undefined;
const list: PackageList = await _fetch(path, options);

return list;
return _fetch(path, options);
}

export async function getPackagesGroupedByStatus() {
Expand All @@ -66,9 +62,7 @@ export async function getPackagesGroupedByStatus() {

export async function getPackageInfoByKey(pkgkey: string): Promise<PackageInfo> {
const path = getInfoPath(pkgkey);
const info: PackageInfo = await _fetch(path);

return info;
return _fetch(path);
}

export async function installPackage(pkgkey: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,16 @@ export async function handleGetCategories(req: Request, extra: Extra) {

export async function handleGetList(req: ListPackagesRequest, extra: Extra) {
const savedObjectsClient = getClient(req);
const packageList = await getPackages({
return getPackages({
savedObjectsClient,
category: req.query.category,
});

return packageList;
}

export async function handleGetInfo(req: PackageInfoRequest, extra: Extra) {
const { pkgkey } = req.params;
const savedObjectsClient = getClient(req);
const packageInfo = await getPackageInfo({ savedObjectsClient, pkgkey });

return packageInfo;
return getPackageInfo({ savedObjectsClient, pkgkey });
}

export const handleGetFile = async (req: Request, extra: Extra) => {
Expand All @@ -79,7 +75,7 @@ export const handleGetFile = async (req: Request, extra: Extra) => {
export async function handleRequestInstall(req: InstallDeletePackageRequest, extra: Extra) {
const { pkgkey } = req.params;
const savedObjectsClient = getClient(req);
return await installPackage({
return installPackage({
savedObjectsClient,
pkgkey,
});
Expand All @@ -89,7 +85,5 @@ export async function handleRequestDelete(req: InstallDeletePackageRequest, extr
const { pkgkey } = req.params;
const savedObjectsClient = getClient(req);
const callCluster = getClusterAccessor(extra.context.esClient, req);
const deleted = await removeInstallation({ savedObjectsClient, pkgkey, callCluster });

return deleted;
return removeInstallation({ savedObjectsClient, pkgkey, callCluster });
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@ export async function saveInstallationReferences(options: {
};

const toInstall = toSave.reduce(mergeRefsReducer, savedRefs || []);
const results = await savedObjectsClient.create<InstallationAttributes>(

return savedObjectsClient.create<InstallationAttributes>(
SAVED_OBJECT_TYPE,
{ installed: toInstall },
{ id: pkgkey, overwrite: true }
);

return results;
}

async function installKibanaSavedObjects({
Expand Down