From 9d3f9e812048888c0a99ecc483cfb8119a949a32 Mon Sep 17 00:00:00 2001 From: GnsP Date: Tue, 15 Oct 2024 18:29:49 +0530 Subject: [PATCH] use getApp instead of list api --- .../services/create/stores/config-store.js | 49 ++++++++++--------- .../java/io/cdap/cdap/ui/utils/Commands.java | 5 +- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/app/hydrator/services/create/stores/config-store.js b/app/hydrator/services/create/stores/config-store.js index 4bb078215d6..caf1ccdda59 100644 --- a/app/hydrator/services/create/stores/config-store.js +++ b/app/hydrator/services/create/stores/config-store.js @@ -1355,29 +1355,34 @@ class HydratorPlusPlusConfigStore { var config = this.getConfigForExport(); config['app.deploy.update.schedules'] = false; + if (isEdit) { + publish(config.name); + return; + } + + let displayPipelineNameExistsError = () => { + this.HydratorPlusPlusConsoleActions.addMessage([{ + type: 'error', + content: this.GLOBALS.en.hydrator.studio.error['NAME-ALREADY-EXISTS'] + }]); + this.EventPipe.emit('hideLoadingIcon.immediate'); + }; + // Checking if Pipeline name already exist - this.myAppsApi - .list({ namespace: this.$state.params.namespace }) - .$promise - .then( (apps) => { - if (isEdit) { - publish(config.name); - } else { - var appNames = apps.map( (app) => { return app.name; } ); - if (appNames.indexOf(config.name) !== -1) { - this.HydratorPlusPlusConsoleActions.addMessage([{ - type: 'error', - content: this.GLOBALS.en.hydrator.studio.error['NAME-ALREADY-EXISTS'] - }]); - this.EventPipe.emit('hideLoadingIcon.immediate'); - } else { - // normal deployment does not need these fields - delete config.change; - delete config.parentVersion; - publish(config.name); - } - } - }); + this.myAppsApi.get({ + namespace: this.$state.params.namespace, + appId: config.name, + }).$promise.then((app) => { + displayPipelineNameExistsError(); + }).catch((err) => { + if (err.status !== 404) { + displayPipelineNameExistsError(); + } else { + delete config.change; + delete config.parentVersion; + publish(config.name); + } + }); } } diff --git a/src/e2e-test/java/io/cdap/cdap/ui/utils/Commands.java b/src/e2e-test/java/io/cdap/cdap/ui/utils/Commands.java index 2affb74f64e..ff7cae534ee 100644 --- a/src/e2e-test/java/io/cdap/cdap/ui/utils/Commands.java +++ b/src/e2e-test/java/io/cdap/cdap/ui/utils/Commands.java @@ -30,6 +30,7 @@ import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.openqa.selenium.By; +import org.openqa.selenium.ElementClickInterceptedException; import org.openqa.selenium.NoAlertPresentException; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.OutputType; @@ -363,8 +364,8 @@ public static void dismissTopBanner() { "//div[@data-testid='valium-banner-hydrator']//button[@class='close ng-scope']"); WaitHelper.waitForElementToBeClickable(bannerCloseButton, 180L); ElementHelper.clickOnElement(bannerCloseButton); - } catch (NoSuchElementException e) { - // pass + } catch (NoSuchElementException | ElementClickInterceptedException e) { + // pass and just wait for the banner to disappear } WaitHelper.waitForElementToBeHidden(Helper.locateElementByTestId("valium-banner-hydrator")); }