Removed delete flow button for non managers

This commit is contained in:
Viswamedha Nalabotu 2026-03-11 14:10:38 +00:00
parent d20f8ab70c
commit 927f406fa7

View file

@ -20,6 +20,7 @@ import {
import { CheckCircleOutlined, CloseCircleOutlined } from '@ant-design/icons-vue' import { CheckCircleOutlined, CloseCircleOutlined } from '@ant-design/icons-vue'
import { apiClient, API, isAxiosError } from '../router/api' import { apiClient, API, isAxiosError } from '../router/api'
import { useOnboardingAgentStore } from '../stores/onboardingAgentStore' import { useOnboardingAgentStore } from '../stores/onboardingAgentStore'
import { useUserStore } from '../stores/userStore'
import type { import type {
OnboardingFlow, OnboardingFlow,
OnboardingPage, OnboardingPage,
@ -34,6 +35,7 @@ const marked = new Marked()
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
const agentStore = useOnboardingAgentStore() const agentStore = useOnboardingAgentStore()
const userStore = useUserStore()
const roleId = computed(() => route.params.roleId as string) const roleId = computed(() => route.params.roleId as string)
const flowDetails = ref<OnboardingFlow | null>(null) const flowDetails = ref<OnboardingFlow | null>(null)
@ -73,6 +75,7 @@ const currentPage = computed<OnboardingPage | null>(
const hasNext = computed(() => currentPageIndex.value < pages.value.length - 1) const hasNext = computed(() => currentPageIndex.value < pages.value.length - 1)
const hasPrev = computed(() => currentPageIndex.value > 0) const hasPrev = computed(() => currentPageIndex.value > 0)
const isError = computed(() => agentStore.executionStatus === 'failed') const isError = computed(() => agentStore.executionStatus === 'failed')
const canDeleteFlow = computed(() => Boolean(userStore.isGeneralManager))
const completedModules = computed<string[]>(() => { const completedModules = computed<string[]>(() => {
const state = (session.value as unknown as { state?: Record<string, unknown> } | null)?.state const state = (session.value as unknown as { state?: Record<string, unknown> } | null)?.state
@ -240,6 +243,10 @@ const retryGeneration = async () => {
const resetCurrentFlow = async () => { const resetCurrentFlow = async () => {
if (!flowDetails.value || deletingFlow.value) return if (!flowDetails.value || deletingFlow.value) return
if (!canDeleteFlow.value) {
message.error('Only managers can delete onboarding flows.')
return
}
deletingFlow.value = true deletingFlow.value = true
try { try {
@ -641,7 +648,7 @@ watch(
</Typography.Title> </Typography.Title>
<Typography.Paragraph class="white-text" style="opacity: 0.8"> <Typography.Paragraph class="white-text" style="opacity: 0.8">
You have already completed this onboarding flow. You can return to your You have already completed this onboarding flow. You can return to your
organization page, or delete this flow to regenerate a new one. organization page and wait for your manager to review your onboarding results.
</Typography.Paragraph> </Typography.Paragraph>
<div class="completed-actions"> <div class="completed-actions">
@ -649,12 +656,15 @@ watch(
Return to Organization Return to Organization
</Button> </Button>
<Popconfirm <Popconfirm
v-if="canDeleteFlow"
title="Delete this onboarding flow and regenerate it?" title="Delete this onboarding flow and regenerate it?"
ok-text="Delete" ok-text="Delete"
cancel-text="Cancel" cancel-text="Cancel"
@confirm="resetCurrentFlow" @confirm="resetCurrentFlow"
> >
<Button danger :loading="deletingFlow">Delete Flow</Button> <Button danger :loading="deletingFlow">
Delete Flow
</Button>
</Popconfirm> </Popconfirm>
</div> </div>
</div> </div>
@ -694,12 +704,15 @@ watch(
{{ flowDetails.title }} {{ flowDetails.title }}
</Typography.Title> </Typography.Title>
<Popconfirm <Popconfirm
v-if="canDeleteFlow"
title="Delete this onboarding flow and regenerate it?" title="Delete this onboarding flow and regenerate it?"
ok-text="Delete" ok-text="Delete"
cancel-text="Cancel" cancel-text="Cancel"
@confirm="resetCurrentFlow" @confirm="resetCurrentFlow"
> >
<Button danger :loading="deletingFlow">Delete Flow</Button> <Button danger :loading="deletingFlow">
Delete Flow
</Button>
</Popconfirm> </Popconfirm>
</div> </div>
<Typography.Paragraph class="white-text" style="opacity: 0.8"> <Typography.Paragraph class="white-text" style="opacity: 0.8">