From d36ab337d78dee62b84f756bb2e421f48562a55a Mon Sep 17 00:00:00 2001 From: Anwarul Islam Date: Sat, 17 Dec 2022 10:01:39 +0600 Subject: [PATCH] feat: ability to delete user account and data (#2863) * feat: add gql mutation * feat: added delete account section in profile page * feat: separate shortcodes section to a component * feat: delete user modal * feat: delete user account * feat: navigate to homepage after delete * chore: improve ui * fix: delete user mutation * chore: minor ui improvements * chore: correct grammar in certain i18n strings * feat: delection section separated to component * feat: separate user delete section into component * feat: defer fetch my teams * feat: disable delete account button on loading state * Update Shortcodes.vue Co-authored-by: Liyas Thomas Co-authored-by: Andrew Bastin --- packages/hoppscotch-common/locales/en.json | 6 + .../hoppscotch-common/src/components.d.ts | 9 +- .../src/components/profile/Shortcodes.vue | 170 ++++++++++++++++ .../src/components/profile/UserDelete.vue | 187 ++++++++++++++++++ .../backend/gql/mutations/DeleteUser.graphql | 3 + .../src/helpers/backend/mutations/Profile.ts | 15 ++ .../hoppscotch-common/src/pages/profile.vue | 158 +-------------- 7 files changed, 390 insertions(+), 158 deletions(-) create mode 100644 packages/hoppscotch-common/src/components/profile/Shortcodes.vue create mode 100644 packages/hoppscotch-common/src/components/profile/UserDelete.vue create mode 100644 packages/hoppscotch-common/src/helpers/backend/gql/mutations/DeleteUser.graphql create mode 100644 packages/hoppscotch-common/src/helpers/backend/mutations/Profile.ts diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.json index 8dbd78357..a8b48ca9e 100644 --- a/packages/hoppscotch-common/locales/en.json +++ b/packages/hoppscotch-common/locales/en.json @@ -203,6 +203,9 @@ "browser_support_sse": "This browser doesn't seems to have Server Sent Events support.", "check_console_details": "Check console log for details.", "curl_invalid_format": "cURL is not formatted properly", + "danger_zone": "Danger zone", + "delete_account": "Your account is currently an owner in these teams:", + "delete_account_description": "You must either remove yourself, transfer ownership, or delete these teams before you can delete your account.", "empty_req_name": "Empty Request Name", "f12_details": "(F12 for details)", "gql_prettify_invalid_query": "Couldn't prettify an invalid query, solve query syntax errors and try again", @@ -437,6 +440,7 @@ "settings": { "accent_color": "Accent color", "account": "Account", + "account_deleted": "Your account has been deleted", "account_description": "Customize your account settings.", "account_email_description": "Your primary email address.", "account_name_description": "This is your display name.", @@ -445,6 +449,8 @@ "change_font_size": "Change font size", "choose_language": "Choose language", "dark_mode": "Dark", + "delete_account": "Delete account", + "delete_account_description": "Once you delete your account, all your data will be permanently deleted. This action cannot be undone.", "expand_navigation": "Expand navigation", "experiments": "Experiments", "experiments_notice": "This is a collection of experiments we're working on that might turn out to be useful, fun, both, or neither. They're not final and may not be stable, so if something overly weird happens, don't panic. Just turn the dang thing off. Jokes aside, ", diff --git a/packages/hoppscotch-common/src/components.d.ts b/packages/hoppscotch-common/src/components.d.ts index d90e016fa..48229a088 100644 --- a/packages/hoppscotch-common/src/components.d.ts +++ b/packages/hoppscotch-common/src/components.d.ts @@ -98,20 +98,14 @@ declare module '@vue/runtime-core' { HttpTestResultReport: typeof import('./components/http/TestResultReport.vue')['default'] HttpTests: typeof import('./components/http/Tests.vue')['default'] HttpURLEncodedParams: typeof import('./components/http/URLEncodedParams.vue')['default'] - IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['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'] IconLucideInbox: typeof import('~icons/lucide/inbox')['default'] IconLucideInfo: typeof import('~icons/lucide/info')['default'] - IconLucideLayers: typeof import('~icons/lucide/layers')['default'] IconLucideLoader: typeof import('~icons/lucide/loader')['default'] - IconLucideMinus: typeof import('~icons/lucide/minus')['default'] - IconLucideRss: typeof import('~icons/lucide/rss')['default'] IconLucideSearch: typeof import('~icons/lucide/search')['default'] IconLucideUser: typeof import('~icons/lucide/user')['default'] IconLucideUsers: typeof import('~icons/lucide/users')['default'] + IconLucideVerified: typeof import('~icons/lucide/verified')['default'] LensesHeadersRenderer: typeof import('./components/lenses/HeadersRenderer.vue')['default'] LensesHeadersRendererEntry: typeof import('./components/lenses/HeadersRendererEntry.vue')['default'] LensesRenderersHTMLLensRenderer: typeof import('./components/lenses/renderers/HTMLLensRenderer.vue')['default'] @@ -123,6 +117,7 @@ declare module '@vue/runtime-core' { LensesResponseBodyRenderer: typeof import('./components/lenses/ResponseBodyRenderer.vue')['default'] ProfilePicture: typeof import('./components/profile/Picture.vue')['default'] ProfileShortcode: typeof import('./components/profile/Shortcode.vue')['default'] + ProfileShortcodes: typeof import('./components/profile/Shortcodes.vue')['default'] RealtimeCommunication: typeof import('./components/realtime/Communication.vue')['default'] RealtimeConnectionConfig: typeof import('./components/realtime/ConnectionConfig.vue')['default'] RealtimeLog: typeof import('./components/realtime/Log.vue')['default'] diff --git a/packages/hoppscotch-common/src/components/profile/Shortcodes.vue b/packages/hoppscotch-common/src/components/profile/Shortcodes.vue new file mode 100644 index 000000000..159a003b9 --- /dev/null +++ b/packages/hoppscotch-common/src/components/profile/Shortcodes.vue @@ -0,0 +1,170 @@ + + + + + diff --git a/packages/hoppscotch-common/src/components/profile/UserDelete.vue b/packages/hoppscotch-common/src/components/profile/UserDelete.vue new file mode 100644 index 000000000..eb73efd06 --- /dev/null +++ b/packages/hoppscotch-common/src/components/profile/UserDelete.vue @@ -0,0 +1,187 @@ + + + diff --git a/packages/hoppscotch-common/src/helpers/backend/gql/mutations/DeleteUser.graphql b/packages/hoppscotch-common/src/helpers/backend/gql/mutations/DeleteUser.graphql new file mode 100644 index 000000000..8e529696b --- /dev/null +++ b/packages/hoppscotch-common/src/helpers/backend/gql/mutations/DeleteUser.graphql @@ -0,0 +1,3 @@ +mutation DeleteUser { + deleteUser +} diff --git a/packages/hoppscotch-common/src/helpers/backend/mutations/Profile.ts b/packages/hoppscotch-common/src/helpers/backend/mutations/Profile.ts new file mode 100644 index 000000000..82a4ddfd6 --- /dev/null +++ b/packages/hoppscotch-common/src/helpers/backend/mutations/Profile.ts @@ -0,0 +1,15 @@ +import { runMutation } from "../GQLClient" +import { + DeleteUserDocument, + DeleteUserMutation, + DeleteUserMutationVariables, +} from "../graphql" + +type DeleteUserErrors = "user/not_found" + +export const deleteUser = () => + runMutation< + DeleteUserMutation, + DeleteUserMutationVariables, + DeleteUserErrors + >(DeleteUserDocument, {}) diff --git a/packages/hoppscotch-common/src/pages/profile.vue b/packages/hoppscotch-common/src/pages/profile.vue index 07475c782..5ec484ba8 100644 --- a/packages/hoppscotch-common/src/pages/profile.vue +++ b/packages/hoppscotch-common/src/pages/profile.vue @@ -64,7 +64,7 @@ v-if="currentUser.emailVerified" v-tippy="{ theme: 'tooltip' }" :title="t('settings.verified_email')" - class="ml-2 text-green-500 svg-icons cursor-help" + class="ml-2 text-green-500 svg-icons focus:outline-none cursor-help" /> + + +

{{ t("settings.sync") }} @@ -192,90 +195,8 @@

-
-

- {{ t("settings.short_codes") }} -

-
- {{ t("settings.short_codes_description") }} -
-
-
- - {{ - t("state.loading") - }} -
-
- - - {{ t("empty.shortcodes") }} - -
-
- -
- - -
- -
-
-
-
-
- - {{ getErrorMessage(adapterError) }} -
-
-
+ + @@ -284,15 +205,13 @@ + - -