diff --git a/packages/frontend-2/components/automate/function/CreateDialog.vue b/packages/frontend-2/components/automate/function/CreateDialog.vue index ce1d2fba2..8837e1112 100644 --- a/packages/frontend-2/components/automate/function/CreateDialog.vue +++ b/packages/frontend-2/components/automate/function/CreateDialog.vue @@ -61,8 +61,12 @@ import { useUpdateAutomateFunction } from '~/lib/automate/composables/management' import { useMutationLoading } from '@vue/apollo-composable' -import type { AutomateFunctionCreateDialogDoneStep_AutomateFunctionFragment } from '~~/lib/common/generated/gql/graphql' +import type { + AutomateFunctionCreateDialogDoneStep_AutomateFunctionFragment, + AutomateFunctionCreateDialog_WorkspaceFragment +} from '~~/lib/common/generated/gql/graphql' import { useMixpanel } from '~/lib/core/composables/mp' +import { graphql } from '~/lib/common/generated/gql' enum FunctionCreateSteps { Authorize, @@ -73,11 +77,19 @@ enum FunctionCreateSteps { type DetailsFormValues = FunctionDetailsFormValues +graphql(` + fragment AutomateFunctionCreateDialog_Workspace on Workspace { + id + name + slug + } +`) + const props = defineProps<{ isAuthorized: boolean templates: CreatableFunctionTemplate[] githubOrgs: string[] - workspaceId?: string + workspace?: AutomateFunctionCreateDialog_WorkspaceFragment }>() const open = defineModel('open', { required: true }) @@ -114,19 +126,19 @@ const onDetailsSubmit = handleDetailsSubmit(async (values) => { templateId: selectedTemplate.value.id, name: values.name, /* eslint-disable-next-line camelcase */ - workspace_id: props.workspaceId + workspace_id: props.workspace?.id }) createdFunction.value = res step.value++ - if (!props.workspaceId) { + if (!props.workspace?.id) { return } await updateFunction({ input: { id: res.id, - workspaceIds: [props.workspaceId] + workspaceIds: [props.workspace.id] } }) }) @@ -184,7 +196,10 @@ const title = computed(() => { }) const authorizeGithubUrl = computed(() => { - const redirectUrl = new URL(automateGithubAppAuthorizationRoute, apiBaseUrl) + const redirectUrl = new URL( + automateGithubAppAuthorizationRoute(props.workspace?.slug), + apiBaseUrl + ) return redirectUrl.toString() }) diff --git a/packages/frontend-2/components/automate/function/EditDialog.vue b/packages/frontend-2/components/automate/function/EditDialog.vue index d4faaf47f..794b1c241 100644 --- a/packages/frontend-2/components/automate/function/EditDialog.vue +++ b/packages/frontend-2/components/automate/function/EditDialog.vue @@ -18,12 +18,20 @@ import { difference, differenceBy } from 'lodash-es' import { useForm } from 'vee-validate' import { useUpdateAutomateFunction } from '~/lib/automate/composables/management' import type { FunctionDetailsFormValues } from '~/lib/automate/helpers/functions' -import type { Workspace } from '~/lib/common/generated/gql/graphql' +import { graphql } from '~/lib/common/generated/gql' +import type { AutomateFunctionEditDialog_WorkspaceFragment } from '~/lib/common/generated/gql/graphql' + +graphql(` + fragment AutomateFunctionEditDialog_Workspace on Workspace { + id + name + } +`) const props = defineProps<{ model: FunctionDetailsFormValues fnId: string - workspaces?: Pick[] + workspaces?: AutomateFunctionEditDialog_WorkspaceFragment[] }>() const open = defineModel('open', { required: true }) const { handleSubmit, setValues } = useForm() diff --git a/packages/frontend-2/components/automate/function/create-dialog/DetailsStep.vue b/packages/frontend-2/components/automate/function/create-dialog/DetailsStep.vue index bf0aa467e..27945da5c 100644 --- a/packages/frontend-2/components/automate/function/create-dialog/DetailsStep.vue +++ b/packages/frontend-2/components/automate/function/create-dialog/DetailsStep.vue @@ -109,19 +109,11 @@