From acbea3aa9c41ca77f715c7d006a3acab9e7a7788 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Thu, 23 May 2024 18:59:43 +0530 Subject: [PATCH] feat: add the ability for creating/deleting PATs from the UI --- packages/hoppscotch-common/locales/en.json | 27 ++- .../hoppscotch-common/src/components.d.ts | 10 +- .../components/accessTokens/GenerateModal.vue | 221 ++++++++++++++++++ .../src/components/accessTokens/List.vue | 82 +++++++ .../src/components/accessTokens/Overview.vue | 30 +++ .../src/components/accessTokens/index.vue | 187 +++++++++++++++ .../src/components/teams/Edit.vue | 2 +- .../src/helpers/utils/date.ts | 15 +- .../hoppscotch-common/src/pages/profile.vue | 34 ++- 9 files changed, 589 insertions(+), 19 deletions(-) create mode 100644 packages/hoppscotch-common/src/components/accessTokens/GenerateModal.vue create mode 100644 packages/hoppscotch-common/src/components/accessTokens/List.vue create mode 100644 packages/hoppscotch-common/src/components/accessTokens/Overview.vue create mode 100644 packages/hoppscotch-common/src/components/accessTokens/index.vue diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.json index 2ab5f041c0..e274c4aec9 100644 --- a/packages/hoppscotch-common/locales/en.json +++ b/packages/hoppscotch-common/locales/en.json @@ -208,7 +208,8 @@ "remove_telemetry": "Are you sure you want to opt-out of Telemetry?", "request_change": "Are you sure you want to discard current request, unsaved changes will be lost.", "save_unsaved_tab": "Do you want to save changes made in this tab?", - "sync": "Would you like to restore your workspace from cloud? This will discard your local progress." + "sync": "Would you like to restore your workspace from cloud? This will discard your local progress.", + "delete_access_token": "Are you sure you want to delete the access token {tokenLabel}?" }, "context_menu": { "add_parameters": "Add to parameters", @@ -342,7 +343,10 @@ "script_fail": "Could not execute pre-request script", "something_went_wrong": "Something went wrong", "test_script_fail": "Could not execute post-request script", - "reading_files": "Error while reading one or more files." + "reading_files": "Error while reading one or more files.", + "fetching_access_tokens_list": "Something went wrong while fetching the list of tokens", + "generate_access_token": "Something went wrong while generating the access token", + "delete_access_token": "Something went wrong while deleting the access token" }, "export": { "as_json": "Export as JSON", @@ -1033,5 +1037,24 @@ "login_to_continue": "Login to continue", "login_to_continue_description": "You need to be logged in to access this Hoppscotch Enterprise Instance.", "error_fetching_site_protection_status": "Something Went Wrong While Fetching Site Protection Status" + }, + "access_tokens": { + "tab_title": "Tokens", + "section_title": "Personal Access Tokens", + "section_description": "Personal access tokens currently helps you connect the CLI to your Hoppscotch account", + "last_used_on": "Last used on", + "expires_on": "Expires on", + "no_expiration": "No expiration", + "copy_token_warning": "Make sure to copy your personal access token now. You won't be able to see it again!", + "token_purpose": "What's this token for?", + "expiration_label": "Expiration", + "scope_label": "Scope", + "workspace_read_only_access": "Read-only access to workspace data.", + "personal_workspace_access_limitation": "Personal Access Tokens can't access your personal workspace.", + "generate_token": "Generate Token", + "invalid_label": "Please provide a label for the token", + "no_expiration_verbose": "This token will never expire!", + "token_expires_on": "This token will expire on", + "generate_new_token": "Generate new token" } } diff --git a/packages/hoppscotch-common/src/components.d.ts b/packages/hoppscotch-common/src/components.d.ts index b1ab7c3334..e45bef1919 100644 --- a/packages/hoppscotch-common/src/components.d.ts +++ b/packages/hoppscotch-common/src/components.d.ts @@ -7,6 +7,11 @@ export {} declare module 'vue' { export interface GlobalComponents { + AccessTokens: typeof import('./components/accessTokens/index.vue')['default'] + AccessTokensGenerate: typeof import('./components/accessTokens/Generate.vue')['default'] + AccessTokensGenerateModal: typeof import('./components/accessTokens/GenerateModal.vue')['default'] + AccessTokensList: typeof import('./components/accessTokens/List.vue')['default'] + AccessTokensOverview: typeof import('./components/accessTokens/Overview.vue')['default'] AppActionHandler: typeof import('./components/app/ActionHandler.vue')['default'] AppBanner: typeof import('./components/app/Banner.vue')['default'] AppContextMenu: typeof import('./components/app/ContextMenu.vue')['default'] @@ -148,7 +153,7 @@ declare module 'vue' { IconLucideAlertTriangle: typeof import('~icons/lucide/alert-triangle')['default'] IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default'] IconLucideArrowUpRight: typeof import('~icons/lucide/arrow-up-right')['default'] - IconLucideBrush: (typeof import("~icons/lucide/brush"))["default"] + IconLucideBrush: typeof import('~icons/lucide/brush')['default'] IconLucideCheckCircle: typeof import('~icons/lucide/check-circle')['default'] IconLucideChevronRight: typeof import('~icons/lucide/chevron-right')['default'] IconLucideGlobe: typeof import('~icons/lucide/globe')['default'] @@ -158,9 +163,10 @@ declare module 'vue' { IconLucideLayers: typeof import('~icons/lucide/layers')['default'] IconLucideListEnd: typeof import('~icons/lucide/list-end')['default'] IconLucideMinus: typeof import('~icons/lucide/minus')['default'] - IconLucideRss: (typeof import("~icons/lucide/rss"))["default"] + IconLucideRss: typeof import('~icons/lucide/rss')['default'] IconLucideSearch: typeof import('~icons/lucide/search')['default'] IconLucideUsers: typeof import('~icons/lucide/users')['default'] + IconLucideVerified: typeof import('~icons/lucide/verified')['default'] IconLucideX: typeof import('~icons/lucide/x')['default'] ImportExportBase: typeof import('./components/importExport/Base.vue')['default'] ImportExportImportExportList: typeof import('./components/importExport/ImportExportList.vue')['default'] diff --git a/packages/hoppscotch-common/src/components/accessTokens/GenerateModal.vue b/packages/hoppscotch-common/src/components/accessTokens/GenerateModal.vue new file mode 100644 index 0000000000..faffea2dd8 --- /dev/null +++ b/packages/hoppscotch-common/src/components/accessTokens/GenerateModal.vue @@ -0,0 +1,221 @@ + + + diff --git a/packages/hoppscotch-common/src/components/accessTokens/List.vue b/packages/hoppscotch-common/src/components/accessTokens/List.vue new file mode 100644 index 0000000000..1739f6e3c4 --- /dev/null +++ b/packages/hoppscotch-common/src/components/accessTokens/List.vue @@ -0,0 +1,82 @@ + + + diff --git a/packages/hoppscotch-common/src/components/accessTokens/Overview.vue b/packages/hoppscotch-common/src/components/accessTokens/Overview.vue new file mode 100644 index 0000000000..0b60e5dff3 --- /dev/null +++ b/packages/hoppscotch-common/src/components/accessTokens/Overview.vue @@ -0,0 +1,30 @@ + + + diff --git a/packages/hoppscotch-common/src/components/accessTokens/index.vue b/packages/hoppscotch-common/src/components/accessTokens/index.vue new file mode 100644 index 0000000000..e9e627e37d --- /dev/null +++ b/packages/hoppscotch-common/src/components/accessTokens/index.vue @@ -0,0 +1,187 @@ + + + diff --git a/packages/hoppscotch-common/src/components/teams/Edit.vue b/packages/hoppscotch-common/src/components/teams/Edit.vue index c2b8b4746c..a8ed8b341b 100644 --- a/packages/hoppscotch-common/src/components/teams/Edit.vue +++ b/packages/hoppscotch-common/src/components/teams/Edit.vue @@ -61,7 +61,7 @@
- -
+ + + + + @@ -193,27 +200,34 @@