Merge pull request #18187 from mvdbeek/fix_on_success_redirect

[24.0] Fix on success redirect
This commit is contained in:
Marius van den Beek
2024-05-21 13:22:48 +02:00
committed by GitHub
+8 -11
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { BAlert } from "bootstrap-vue";
import { computed, onMounted } from "vue";
import { computed } from "vue";
import { useRouter } from "vue-router/composables";
import { useConfig } from "@/composables/config";
@@ -22,27 +22,24 @@ const responseVal = computed(() => jobStore.getLatestResponse);
const showRecommendation = computed(() => config.value.enable_tool_recommendations);
const toolName = computed(() => responseVal.value.toolName);
/* lifecyle */
onMounted(() => {
// no response means that no tool was run in this session i.e. no data in the store
if (Object.keys(responseVal.value).length === 0) {
router.push(`/`);
}
});
// no data means that no tool was run in this session i.e. no data in the store
if (Object.keys(responseVal.value).length === 0) {
router.push(`/`);
}
</script>
<template>
<section>
<BAlert v-if="!jobResponse" variant="info" show>
<LoadingSpan message="Waiting on a job response" />
<LoadingSpan message="Waiting on data" />
</BAlert>
<div v-else>
<div v-if="jobResponse?.produces_entry_points">
<ToolEntryPoints v-for="job in jobResponse.jobs" :key="job.id" :job-id="job.id" />
</div>
<ToolSuccessMessage :job-response="jobResponse" :tool-name="toolName" />
<Webhook type="tool" :tool-id="jobDef.tool_id" />
<ToolRecommendation v-if="showRecommendation" :tool-id="jobDef.tool_id" />
</div>
<Webhook type="tool" :tool-id="jobDef.tool_id" />
<ToolRecommendation v-if="showRecommendation" :tool-id="jobDef.tool_id" />
</section>
</template>