From 33db658d9b47423240d4849916037fed2bc5afb3 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Thu, 19 Dec 2019 08:29:34 +0530 Subject: [PATCH] src: cleanup unused utility This cleans up and uses the global `$pollJob()`. Signed-off-by: Rohit Yadav --- ui/src/utils/methods.js | 60 -------------------------- ui/src/views/compute/MigrateWizard.vue | 3 +- 2 files changed, 1 insertion(+), 62 deletions(-) delete mode 100644 ui/src/utils/methods.js diff --git a/ui/src/utils/methods.js b/ui/src/utils/methods.js deleted file mode 100644 index 460efb0be78..00000000000 --- a/ui/src/utils/methods.js +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -import { api } from '@/api' -import { message, notification } from 'ant-design-vue' - -/** - * Reusable queryAsyncJobResult method - * @param {String} jobId - * @param {String} successMessage - * @param {Function} successMethod - * @param {String} errorMessage - * @param {Function} errorMethod - * @param {String} loadingMessage - * @param {String} catchMessage - * @param {Function} catchMethod - * @param {Number} loadingDuration - */ -export const pollActionCompletion = ({ - jobId, successMessage, successMethod, errorMessage, errorMethod, loadingMessage, catchMessage, catchMethod, loadingDuration = 3 -}) => { - function runApi () { - api('queryAsyncJobResult', { jobId }).then(json => { - const result = json.queryasyncjobresultresponse - - if (result.jobstatus === 1) { - message.success(successMessage || 'Success') - successMethod && successMethod() - } else if (result.jobstatus === 2) { - notification.error({ - message: errorMessage || 'Error', - description: result.jobresult.errortext || 'Error' - }) - errorMethod && errorMethod() - } else if (result.jobstatus === 0) { - message - .loading(loadingMessage, loadingDuration) - .then(() => runApi()) - } - }).catch(e => { - console.error(`${catchMessage} - ${e}`) - catchMethod && catchMethod() - }) - } - runApi() -} diff --git a/ui/src/views/compute/MigrateWizard.vue b/ui/src/views/compute/MigrateWizard.vue index 80417e94277..27f0c13df11 100644 --- a/ui/src/views/compute/MigrateWizard.vue +++ b/ui/src/views/compute/MigrateWizard.vue @@ -74,7 +74,6 @@