chore: add save option to modify sahred request
This commit is contained in:
@@ -432,6 +432,7 @@
|
|||||||
"close_unsaved_tab": "You have unsaved changes",
|
"close_unsaved_tab": "You have unsaved changes",
|
||||||
"collections": "Collections",
|
"collections": "Collections",
|
||||||
"confirm": "Confirm",
|
"confirm": "Confirm",
|
||||||
|
"customize_request": "Customize Request",
|
||||||
"edit_request": "Edit Request",
|
"edit_request": "Edit Request",
|
||||||
"share_request":"Share Request",
|
"share_request":"Share Request",
|
||||||
"import_export": "Import / Export"
|
"import_export": "Import / Export"
|
||||||
@@ -636,6 +637,7 @@
|
|||||||
"embed_info": "Add a mini 'Hoppscotch API Playground' to your website, blog or documentation.",
|
"embed_info": "Add a mini 'Hoppscotch API Playground' to your website, blog or documentation.",
|
||||||
"link":"Link",
|
"link":"Link",
|
||||||
"link_info": "Create a shareable link to share with anyone on the internet with view access.",
|
"link_info": "Create a shareable link to share with anyone on the internet with view access.",
|
||||||
|
"modified": "Shared request modified",
|
||||||
"not_found":"Shared request not found",
|
"not_found":"Shared request not found",
|
||||||
"open_new_tab": "Open in new tab",
|
"open_new_tab": "Open in new tab",
|
||||||
"preview":"Preview",
|
"preview":"Preview",
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
<HoppSmartModal
|
<HoppSmartModal
|
||||||
v-if="show"
|
v-if="show"
|
||||||
dialog
|
dialog
|
||||||
:title="t('modal.share_request')"
|
:title="
|
||||||
|
step === 1 ? t('modal.share_request') : t('modal.customize_request')
|
||||||
|
"
|
||||||
styles="sm:max-w-md"
|
styles="sm:max-w-md"
|
||||||
@close="hideModal"
|
@close="hideModal"
|
||||||
>
|
>
|
||||||
@@ -29,19 +31,25 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div v-if="step === 1" class="flex justify-end">
|
<div class="flex justify-start flex-1">
|
||||||
<HoppButtonPrimary
|
<HoppButtonPrimary
|
||||||
|
v-if="step === 1"
|
||||||
:label="t('action.create')"
|
:label="t('action.create')"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
@click="createSharedRequest"
|
@click="createSharedRequest"
|
||||||
/>
|
/>
|
||||||
|
<HoppButtonPrimary
|
||||||
|
v-else
|
||||||
|
:label="t('action.save')"
|
||||||
|
:loading="loading"
|
||||||
|
@click="saveSharedRequest"
|
||||||
|
/>
|
||||||
<HoppButtonSecondary
|
<HoppButtonSecondary
|
||||||
:label="t('action.cancel')"
|
:label="t('action.cancel')"
|
||||||
class="mr-2"
|
class="ml-2"
|
||||||
@click="hideModal"
|
@click="hideModal"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<HoppButtonPrimary v-else :label="t('action.close')" @click="hideModal" />
|
|
||||||
</template>
|
</template>
|
||||||
</HoppSmartModal>
|
</HoppSmartModal>
|
||||||
</template>
|
</template>
|
||||||
@@ -137,24 +145,29 @@ const emit = defineEmits<{
|
|||||||
(e: "update:step", value: number): void
|
(e: "update:step", value: number): void
|
||||||
(
|
(
|
||||||
e: "copy-shared-request",
|
e: "copy-shared-request",
|
||||||
request: {
|
payload: {
|
||||||
sharedRequestID: string | undefined
|
sharedRequestID: string | undefined
|
||||||
content: string | undefined
|
content: string | undefined
|
||||||
type: string | undefined
|
type: string | undefined
|
||||||
}
|
}
|
||||||
): void
|
): void
|
||||||
|
(e: "save-shared-request"): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const createSharedRequest = () => {
|
const createSharedRequest = () => {
|
||||||
emit("create-shared-request", props.request as HoppRESTRequest)
|
emit("create-shared-request", props.request as HoppRESTRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
const copySharedRequest = (request: {
|
const copySharedRequest = (payload: {
|
||||||
sharedRequestID: string | undefined
|
sharedRequestID: string | undefined
|
||||||
content: string | undefined
|
content: string | undefined
|
||||||
type: string | undefined
|
type: string | undefined
|
||||||
}) => {
|
}) => {
|
||||||
emit("copy-shared-request", request)
|
emit("copy-shared-request", payload)
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveSharedRequest = () => {
|
||||||
|
emit("save-shared-request")
|
||||||
}
|
}
|
||||||
|
|
||||||
const hideModal = () => {
|
const hideModal = () => {
|
||||||
|
|||||||
@@ -88,6 +88,7 @@
|
|||||||
@hide-modal="displayCustomizeRequestModal(false, null)"
|
@hide-modal="displayCustomizeRequestModal(false, null)"
|
||||||
@copy-shared-request="copySharedRequest"
|
@copy-shared-request="copySharedRequest"
|
||||||
@create-shared-request="createSharedRequest"
|
@create-shared-request="createSharedRequest"
|
||||||
|
@save-shared-request="saveSharedRequest"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -161,7 +162,7 @@ const embedOptions = ref<EmbedOption>({
|
|||||||
|
|
||||||
const updateEmbedProperty = async (
|
const updateEmbedProperty = async (
|
||||||
shareRequestID: string,
|
shareRequestID: string,
|
||||||
properties: string
|
properties: string | null
|
||||||
) => {
|
) => {
|
||||||
const customizeEmbedResult = await updateEmbedProperties(
|
const customizeEmbedResult = await updateEmbedProperties(
|
||||||
shareRequestID,
|
shareRequestID,
|
||||||
@@ -383,19 +384,20 @@ const customizeSharedRequest = (
|
|||||||
displayCustomizeRequestModal(true, embedProperties)
|
displayCustomizeRequestModal(true, embedProperties)
|
||||||
}
|
}
|
||||||
|
|
||||||
const copySharedRequest = (request: {
|
const copySharedRequest = (payload: {
|
||||||
sharedRequestID: string | undefined
|
sharedRequestID: string | undefined
|
||||||
content: string | undefined
|
content: string | undefined
|
||||||
type: string | undefined
|
type: string | undefined
|
||||||
}) => {
|
}) => {
|
||||||
if (request.content) {
|
if (payload.content) {
|
||||||
copyToClipboard(request.content)
|
copyToClipboard(payload.content)
|
||||||
toast.success(t("state.copied_to_clipboard"))
|
toast.success(t("state.copied_to_clipboard"))
|
||||||
if (
|
}
|
||||||
requestToShare.value &&
|
}
|
||||||
requestToShare.value.id &&
|
|
||||||
request.type === "embed"
|
const saveSharedRequest = () => {
|
||||||
) {
|
if (requestToShare.value && requestToShare.value.id) {
|
||||||
|
if (selectedWidget.value.value === "embed") {
|
||||||
const properties = {
|
const properties = {
|
||||||
options: embedOptions.value.tabs
|
options: embedOptions.value.tabs
|
||||||
.filter((tab) => tab.enabled)
|
.filter((tab) => tab.enabled)
|
||||||
@@ -403,7 +405,12 @@ const copySharedRequest = (request: {
|
|||||||
theme: embedOptions.value.theme,
|
theme: embedOptions.value.theme,
|
||||||
}
|
}
|
||||||
updateEmbedProperty(requestToShare.value.id, JSON.stringify(properties))
|
updateEmbedProperty(requestToShare.value.id, JSON.stringify(properties))
|
||||||
|
} else {
|
||||||
|
updateEmbedProperty(requestToShare.value.id, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toast.success(t("shared_requests.modified"))
|
||||||
|
displayShareRequestModal(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,10 @@ export const deleteShortcode = (code: string) =>
|
|||||||
code,
|
code,
|
||||||
})
|
})
|
||||||
|
|
||||||
export const updateEmbedProperties = (code: string, properties: string) =>
|
export const updateEmbedProperties = (
|
||||||
|
code: string,
|
||||||
|
properties: string | null
|
||||||
|
) =>
|
||||||
runMutation<
|
runMutation<
|
||||||
UpdateEmbedPropertiesMutation,
|
UpdateEmbedPropertiesMutation,
|
||||||
UpdateEmbedPropertiesMutationVariables,
|
UpdateEmbedPropertiesMutationVariables,
|
||||||
|
|||||||
Reference in New Issue
Block a user