Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Enable workspace wizard #3634

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions packages/frontend-2/components/dashboard/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,6 @@
</template>

<FeedbackDialog v-model:open="showFeedbackDialog" />

<WorkspaceCreateDialog
v-model:open="showWorkspaceCreateDialog"
navigate-on-success
event-source="sidebar"
/>
</div>
</template>
<script setup lang="ts">
Expand All @@ -187,7 +181,8 @@ import {
projectsRoute,
workspaceRoute,
workspacesRoute,
downloadManagerUrl
downloadManagerUrl,
workspaceCreateRoute
} from '~/lib/common/helpers/route'
import { useRoute } from 'vue-router'
import { useActiveUser } from '~~/lib/auth/composables/activeUser'
Expand Down Expand Up @@ -220,7 +215,6 @@ const mixpanel = useMixpanel()

const isOpenMobile = ref(false)
const showFeedbackDialog = ref(false)
const showWorkspaceCreateDialog = ref(false)

const { result: workspaceResult, onResult: onWorkspaceResult } = useQuery(
settingsSidebarQuery,
Expand Down Expand Up @@ -274,7 +268,7 @@ const openFeedbackDialog = () => {
}

const openWorkspaceCreateDialog = () => {
showWorkspaceCreateDialog.value = true
navigateTo(workspaceCreateRoute())
mixpanel.track('Create Workspace Button Clicked', {
source: 'sidebar'
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const isMatchingInterval = computed(
(props.yearlyIntervalSelected ? BillingInterval.Yearly : BillingInterval.Monthly)
)
const isSelectable = computed(() => {
if (!props.isAdmin) return false
// Always enable buttons during trial
if (statusIsTrial.value) return true

Expand Down
25 changes: 18 additions & 7 deletions packages/frontend-2/components/workspace/CreatePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
<nav
class="fixed top-0 h-14 bg-foundation w-full shadow flex items-center justify-between px-2 cursor-pointer"
>
<HeaderLogoBlock
:active="false"
class="mr-0"
no-link
@click="isCancelDialogOpen = true"
/>
<FormButton color="outline" @click="isCancelDialogOpen = true">Cancel</FormButton>
<HeaderLogoBlock :active="false" class="mr-0" no-link @click="onCancelClick" />
<FormButton color="outline" @click="onCancelClick">Cancel</FormButton>
</nav>
<div class="h-dvh w-dvh overflow-hidden flex flex-col">
<!-- Static Spacer to allow for absolutely positioned HeaderNavBar -->
Expand All @@ -29,9 +24,25 @@
</template>

<script setup lang="ts">
import { workspacesRoute } from '~~/lib/common/helpers/route'
import { WizardSteps } from '~/lib/workspaces/helpers/types'
import { useWorkspacesWizard } from '~/lib/workspaces/composables/wizard'

defineProps<{
workspaceId?: string
}>()

const { currentStep } = useWorkspacesWizard()

const isCancelDialogOpen = ref(false)

const isFirstStep = computed(() => currentStep.value === WizardSteps.Details)

const onCancelClick = () => {
if (isFirstStep.value) {
navigateTo(workspacesRoute)
} else {
isCancelDialogOpen.value = true
}
}
</script>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>
<LayoutDialog
v-model:open="isOpen"
title="Confirm cancellation"
title="Discard new workspace?"
:buttons="dialogButtons"
max-width="xs"
>
<div class="flex flex-col gap-2">
<p class="text-body-xs text-foreground font-medium">
You have unsaved changes. Are you sure you want to leave?
You'll loose all the information entered for this workspace.
</p>
</div>
</LayoutDialog>
Expand Down Expand Up @@ -49,7 +49,7 @@ const dialogButtons = computed((): LayoutDialogButton[] => [
}
},
{
text: 'Continue',
text: 'Discard',
props: { color: 'primary' },
onClick: onConfirm
}
Expand Down
5 changes: 1 addition & 4 deletions packages/frontend-2/components/workspace/wizard/Wizard.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<template>
<div class="py-3 md:py-6">
<CommonLoadingIcon
v-if="loading || !isClientReady"
class="my-10 justify-self-center"
/>
<CommonLoadingIcon v-if="loading || !isClientReady" class="my-10 mx-auto" />
<template v-else>
<CommonAlert
v-if="showPaymentError"
Expand Down
11 changes: 2 additions & 9 deletions packages/frontend-2/components/workspaces/Promo/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@
<h4 class="text-foreground text-heading mb-6">Pricing</h4>
<SettingsWorkspacesBillingPricingTable />
</section>

<WorkspaceCreateDialog
v-model:open="showWorkspaceCreateDialog"
navigate-on-success
event-source="promo-page"
/>
</div>
</template>
<script setup lang="ts">
Expand All @@ -76,13 +70,12 @@ import {
GlobeAltIcon,
PlusIcon
} from '@heroicons/vue/24/outline'
import { workspaceCreateRoute } from '~~/lib/common/helpers/route'

const mixpanel = useMixpanel()

const showWorkspaceCreateDialog = ref(false)

const openWorkspaceCreateDialog = () => {
showWorkspaceCreateDialog.value = true
navigateTo(workspaceCreateRoute())
mixpanel.track('Create Workspace Button Clicked', {
source: 'promo-page'
})
Expand Down
34 changes: 27 additions & 7 deletions packages/frontend-2/lib/workspaces/composables/wizard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import type { WorkspaceInviteCreateInput } from '~/lib/common/generated/gql/graphql'
import type {
WorkspaceInviteCreateInput,
Workspace
} from '~/lib/common/generated/gql/graphql'
import { BillingInterval, PaidWorkspacePlans } from '~/lib/common/generated/gql/graphql'
import { type WorkspaceWizardState, WizardSteps } from '~/lib/workspaces/helpers/types'
import {
Expand Down Expand Up @@ -193,13 +196,30 @@ export const useWorkspacesWizard = () => {
})
}

const result = await updateWorkspaceCreationState({
input: {
state: {},
workspaceId,
completed: true
const result = await updateWorkspaceCreationState(
{
input: {
state: {},
workspaceId,
completed: true
}
},
{
update: (cache, res) => {
if (!res.data?.workspaceMutations) return

cache.modify<Workspace>({
id: getCacheId('Workspace', workspaceId),
fields: {
creationState: () => ({
completed: true,
state: {}
})
}
})
}
}
}).catch(convertThrowIntoFetchResult)
).catch(convertThrowIntoFetchResult)

if (result?.data?.workspaceMutations.updateCreationState) {
mixpanel.track('Workspace Created', {
Expand Down