From d7cdeb796ae472874dabe7946c0996f20dd7b2ac Mon Sep 17 00:00:00 2001 From: James George Date: Fri, 2 Feb 2024 15:32:06 +0530 Subject: [PATCH 01/25] chore(common): analytics on spotlight (#3727) Co-authored-by: amk-dev --- .../src/components/app/Header.vue | 2 +- .../src/components/app/spotlight/index.vue | 46 +++++--- .../src/components/history/index.vue | 3 +- .../src/components/http/Request.vue | 25 +---- .../hoppscotch-common/src/helpers/actions.ts | 66 +++++++---- .../src/helpers/keybindings.ts | 6 +- .../hoppscotch-common/src/layouts/default.vue | 22 +++- .../src/platform/analytics.ts | 12 ++ .../spotlight/__tests__/index.spec.ts | 106 ++++++++++++++++-- .../src/services/spotlight/index.ts | 55 ++++++++- 10 files changed, 267 insertions(+), 76 deletions(-) diff --git a/packages/hoppscotch-common/src/components/app/Header.vue b/packages/hoppscotch-common/src/components/app/Header.vue index 58301f18d..280ae805e 100644 --- a/packages/hoppscotch-common/src/components/app/Header.vue +++ b/packages/hoppscotch-common/src/components/app/Header.vue @@ -23,7 +23,7 @@
+ + > + +
import IconHelpCircle from "~icons/lucide/help-circle" +import IconPlus from "~icons/lucide/plus" import { useI18n } from "~/composables/i18n" import ShortcodeListAdapter from "~/helpers/shortcode/ShortcodeListAdapter" import { useReadonlyStream } from "~/composables/stream" @@ -270,6 +284,17 @@ onAuthEvent((ev) => { } }) +const shareRequest = () => { + if (currentUser.value) { + const tab = restTab.currentActiveTab + invokeAction("share.request", { + request: tab.value.document.request, + }) + } else { + invokeAction("modals.login.toggle") + } +} + const deleteSharedRequest = (codeID: string) => { if (currentUser.value) { sharedRequestID.value = codeID @@ -434,13 +459,6 @@ const copySharedRequest = (payload: { } } -const openInNewTab = (request: HoppRESTRequest) => { - restTab.createNewTab({ - isDirty: false, - request, - }) -} - const resolveConfirmModal = (title: string | null) => { if (title === `${t("confirm.remove_shared_request")}`) onDeleteSharedRequest() else { diff --git a/packages/hoppscotch-common/src/pages/index.vue b/packages/hoppscotch-common/src/pages/index.vue index 5c9078862..ecd169105 100644 --- a/packages/hoppscotch-common/src/pages/index.vue +++ b/packages/hoppscotch-common/src/pages/index.vue @@ -26,6 +26,7 @@ @close-tab="removeTab(tab.id)" @close-other-tabs="closeOtherTabsAction(tab.id)" @duplicate-tab="duplicateTab(tab.id)" + @share-tab-request="shareTabRequest(tab.id)" /> diff --git a/packages/hoppscotch-common/src/components/environments/my/Environment.vue b/packages/hoppscotch-common/src/components/environments/my/Environment.vue index 04a272442..e5f8a80ea 100644 --- a/packages/hoppscotch-common/src/components/environments/my/Environment.vue +++ b/packages/hoppscotch-common/src/components/environments/my/Environment.vue @@ -135,6 +135,8 @@ import { useToast } from "@composables/toast" import { TippyComponent } from "vue-tippy" import { HoppSmartItem } from "@hoppscotch/ui" import { exportAsJSON } from "~/helpers/import-export/export/environment" +import { useService } from "dioc/vue" +import { SecretEnvironmentService } from "~/services/secret-environment.service" const t = useI18n() const toast = useToast() @@ -150,6 +152,8 @@ const emit = defineEmits<{ const confirmRemove = ref(false) +const secretEnvironmentService = useService(SecretEnvironmentService) + const exportEnvironmentAsJSON = () => { const { environment, environmentIndex } = props exportAsJSON(environment, environmentIndex) @@ -168,6 +172,7 @@ const removeEnvironment = () => { if (props.environmentIndex === null) return if (props.environmentIndex !== "Global") { deleteEnvironment(props.environmentIndex, props.environment.id) + secretEnvironmentService.deleteSecretEnvironment(props.environment.id) } toast.success(`${t("state.deleted")}`) } diff --git a/packages/hoppscotch-common/src/components/environments/my/index.vue b/packages/hoppscotch-common/src/components/environments/my/index.vue index f066df1e4..9eaa2f00c 100644 --- a/packages/hoppscotch-common/src/components/environments/my/index.vue +++ b/packages/hoppscotch-common/src/components/environments/my/index.vue @@ -67,6 +67,7 @@ :action="action" :editing-environment-index="editingEnvironmentIndex" :editing-variable-name="editingVariableName" + :is-secret-option-selected="secretOptionSelected" @hide-modal="displayModalEdit(false)" /> ("edit") const editingEnvironmentIndex = ref(null) const editingVariableName = ref("") +const secretOptionSelected = ref(false) const displayModalAdd = (shouldDisplay: boolean) => { action.value = "new" @@ -120,18 +122,23 @@ const editEnvironment = (environmentIndex: number) => { } const resetSelectedData = () => { editingEnvironmentIndex.value = null + editingVariableName.value = "" + secretOptionSelected.value = false } defineActionHandler( "modals.my.environment.edit", - ({ envName, variableName }) => { + ({ envName, variableName, isSecret }) => { if (variableName) editingVariableName.value = variableName const envIndex: number = environments.value.findIndex( (environment: Environment) => { return environment.name === envName } ) - if (envName !== "Global") editEnvironment(envIndex) + if (envName !== "Global") { + editEnvironment(envIndex) + secretOptionSelected.value = isSecret ?? false + } } ) diff --git a/packages/hoppscotch-common/src/components/environments/teams/Details.vue b/packages/hoppscotch-common/src/components/environments/teams/Details.vue index d54d18034..906a7a608 100644 --- a/packages/hoppscotch-common/src/components/environments/teams/Details.vue +++ b/packages/hoppscotch-common/src/components/environments/teams/Details.vue @@ -16,90 +16,112 @@ @submit="saveEnvironment" /> -
- -
- - -
-
-
- {{ t("environment.nested_overflow") }} -
-
+
- - -
- -
+ {{ t("environment.nested_overflow") }}
- - -