From efbd165c5c36618dd78a7266234c9425b57aaf58 Mon Sep 17 00:00:00 2001 From: Nivedin <53208152+nivedin@users.noreply.github.com> Date: Wed, 13 Apr 2022 20:52:44 +0530 Subject: [PATCH] feat: unsaved change popup (#2239) Co-authored-by: Andrew Bastin Co-authored-by: liyasthomas --- packages/hoppscotch-app/.gitignore | 2 +- .../components/collections/my/Request.vue | 412 +++++++++++++----- .../components/collections/teams/Request.vue | 370 +++++++++++----- .../components/history/index.vue | 160 ++++++- .../components/http/ReqChangeConfirmModal.vue | 59 +++ .../helpers/types/HoppRequestSaveContext.ts | 10 + packages/hoppscotch-app/locales/en.json | 2 + 7 files changed, 772 insertions(+), 243 deletions(-) create mode 100644 packages/hoppscotch-app/components/http/ReqChangeConfirmModal.vue diff --git a/packages/hoppscotch-app/.gitignore b/packages/hoppscotch-app/.gitignore index a3ab74b17..7c831b208 100644 --- a/packages/hoppscotch-app/.gitignore +++ b/packages/hoppscotch-app/.gitignore @@ -115,4 +115,4 @@ shims-volar.d.ts helpers/backend/backend-schema.json # GraphQL Type Generation -helpers/backend/graphql.ts \ No newline at end of file +helpers/backend/graphql.ts diff --git a/packages/hoppscotch-app/components/collections/my/Request.vue b/packages/hoppscotch-app/components/collections/my/Request.vue index 41ee80cd1..abeb983e3 100644 --- a/packages/hoppscotch-app/components/collections/my/Request.vue +++ b/packages/hoppscotch-app/components/collections/my/Request.vue @@ -32,15 +32,10 @@ {{ request.name }} @@ -72,7 +67,7 @@ @@ -89,11 +84,11 @@ + + - diff --git a/packages/hoppscotch-app/components/collections/teams/Request.vue b/packages/hoppscotch-app/components/collections/teams/Request.vue index 5ac37e6e1..477e61e23 100644 --- a/packages/hoppscotch-app/components/collections/teams/Request.vue +++ b/packages/hoppscotch-app/components/collections/teams/Request.vue @@ -32,11 +32,7 @@ {{ request.name }} + + - diff --git a/packages/hoppscotch-app/components/history/index.vue b/packages/hoppscotch-app/components/history/index.vue index ce5480533..f757d4c79 100644 --- a/packages/hoppscotch-app/components/history/index.vue +++ b/packages/hoppscotch-app/components/history/index.vue @@ -36,7 +36,7 @@ open > + + diff --git a/packages/hoppscotch-app/components/http/ReqChangeConfirmModal.vue b/packages/hoppscotch-app/components/http/ReqChangeConfirmModal.vue new file mode 100644 index 000000000..3e0376aaa --- /dev/null +++ b/packages/hoppscotch-app/components/http/ReqChangeConfirmModal.vue @@ -0,0 +1,59 @@ + + + diff --git a/packages/hoppscotch-app/helpers/types/HoppRequestSaveContext.ts b/packages/hoppscotch-app/helpers/types/HoppRequestSaveContext.ts index f80def03b..014b76b39 100644 --- a/packages/hoppscotch-app/helpers/types/HoppRequestSaveContext.ts +++ b/packages/hoppscotch-app/helpers/types/HoppRequestSaveContext.ts @@ -1,3 +1,5 @@ +import { HoppRESTRequest } from "@hoppscotch/data" + /** * We use the save context to figure out * how a loaded request is to be saved. @@ -18,6 +20,10 @@ export type HoppRequestSaveContext = * Index to the request */ requestIndex: number + /** + * Current request + */ + req?: HoppRESTRequest } | { /** @@ -36,4 +42,8 @@ export type HoppRequestSaveContext = * ID of the collection loaded */ collectionID?: string + /** + * Current request + */ + req?: HoppRESTRequest } diff --git a/packages/hoppscotch-app/locales/en.json b/packages/hoppscotch-app/locales/en.json index 7c8c31e37..e911675f2 100644 --- a/packages/hoppscotch-app/locales/en.json +++ b/packages/hoppscotch-app/locales/en.json @@ -10,6 +10,7 @@ "disconnect": "Disconnect", "dismiss": "Dismiss", "download_file": "Download file", + "dont_save": "Don't save", "duplicate": "Duplicate", "edit": "Edit", "go_back": "Go back", @@ -121,6 +122,7 @@ "team_collections": "Team Collections" }, "confirm": { + "request_change": "Are you sure you want to discard current request, unsaved changes will be lost.", "exit_team": "Are you sure you want to leave this team?", "logout": "Are you sure you want to logout?", "remove_collection": "Are you sure you want to permanently delete this collection?",