From 7ec136f7ddc8b41117840c05da86f623f4da73bd Mon Sep 17 00:00:00 2001 From: TianTan Date: Fri, 10 Jan 2025 14:53:54 +0800 Subject: [PATCH] feat(pluginform): cancel of plugin edit redirects to plugin select (#362) --- src/pages/plugins/Form.vue | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pages/plugins/Form.vue b/src/pages/plugins/Form.vue index 3358ce6..5f7f09d 100644 --- a/src/pages/plugins/Form.vue +++ b/src/pages/plugins/Form.vue @@ -14,6 +14,7 @@ :disable-scope-selection="disableScopeSelection" @error:fetch-schema="onFetchSchemaError" @update="onSave" + @cancel="onFormCancel" /> @@ -77,13 +78,22 @@ const cancelRoute = computed(() => { const config = reactive({ ...toRefs(useFormGeneralConfig()), - cancelRoute, entityId: computed(() => entityScope.value?.id ?? ''), entityType: computed(() => entityScope.value?.typeLiteral), disableConsumerGroupScope: true, isNewOtelSchema: true, }) +// return to previous page on cancel +const onFormCancel = (): void => { + if (history.state?.back) { + router.back() + return + } else { + router.push(cancelRoute.value) + } +} + const onFetchSchemaError = (err: AxiosError) => { if (err.response?.status === 404) { router.replace({ name: 'not-found' })