From c357f17882a682eca315384194c457eefc911997 Mon Sep 17 00:00:00 2001 From: liyasthomas Date: Sat, 19 Feb 2022 20:23:50 +0530 Subject: [PATCH] feat: alert when no environment selected --- .../components/http/TestResult.vue | 61 +++++++++++++------ .../components/http/TestResultEnv.vue | 28 +++++++-- packages/hoppscotch-app/locales/en.json | 7 ++- 3 files changed, 71 insertions(+), 25 deletions(-) diff --git a/packages/hoppscotch-app/components/http/TestResult.vue b/packages/hoppscotch-app/components/http/TestResult.vue index 4e907285c..10519b565 100644 --- a/packages/hoppscotch-app/components/http/TestResult.vue +++ b/packages/hoppscotch-app/components/http/TestResult.vue @@ -34,36 +34,41 @@
+
+ warning +
+

+ {{ t("environment.no_environment_description") }} +

+

+ + +

+
+
- - - import { computed } from "@nuxtjs/composition-api" -import { useReadonlyStream, useI18n } from "~/helpers/utils/composables" +import { + useReadonlyStream, + useI18n, + useStream, +} from "~/helpers/utils/composables" +import { + selectedEnvIndex$, + setCurrentEnvironment, +} from "~/newstore/environments" import { restTestResults$, setRESTTestResults } from "~/newstore/RESTSession" const t = useI18n() @@ -185,4 +198,12 @@ const haveEnvVariables = computed(() => { testResults.value.envDiff.selected.deletions.length ) }) + +const selectedEnvironmentIndex = useStream( + selectedEnvIndex$, + -1, + setCurrentEnvironment +) + +const noEnvSelected = computed(() => selectedEnvironmentIndex.value === -1) diff --git a/packages/hoppscotch-app/components/http/TestResultEnv.vue b/packages/hoppscotch-app/components/http/TestResultEnv.vue index 261022f79..2b3069c0a 100644 --- a/packages/hoppscotch-app/components/http/TestResultEnv.vue +++ b/packages/hoppscotch-app/components/http/TestResultEnv.vue @@ -1,6 +1,11 @@ diff --git a/packages/hoppscotch-app/locales/en.json b/packages/hoppscotch-app/locales/en.json index c4ab67360..c6dce1f75 100644 --- a/packages/hoppscotch-app/locales/en.json +++ b/packages/hoppscotch-app/locales/en.json @@ -159,14 +159,19 @@ "tests": "There are no tests for this request" }, "environment": { + "added": "Environment addition", + "add_to_global": "Add to Global", "create_new": "Create new environment", + "deleted": "Environment deletion", "edit": "Edit Environment", "invalid_name": "Please provide a name for the environment", "nested_overflow": "nested environment variables are limited to 10 levels", "new": "New Environment", "no_environment": "No environment", + "no_environment_description": "No environments were selected. Choose what to do with the following variables.", "select": "Select environment", "title": "Environments", + "updated": "Environment updation", "variable_list": "Variable List" }, "error": { @@ -468,7 +473,7 @@ }, "state": { "bulk_mode": "Bulk edit", - "bulk_mode_placeholder": "Entries are separated by newline\nKeys and values are separated by :\nPrepend # to any row you want to add but keep disabled", + "bulk_mode_placeholder": "Entries are separated by newline Keys and values are separated by : Prepend # to any row you want to add but keep disabled", "cleared": "Cleared", "connected": "Connected", "connected_to": "Connected to {name}",