From 8b7e7f792ffb320c8c08a0a8f9bc0503ae39127b Mon Sep 17 00:00:00 2001 From: Mike Tasset Date: Mon, 18 Nov 2024 23:18:02 +0100 Subject: [PATCH 1/6] Abstracted table components --- .../workspaces/billing/PricingTable.vue | 156 ------------------ .../billing/PricingTable/Desktop.vue | 78 +++++++++ .../billing/PricingTable/Header.vue | 74 +++++++++ .../billing/PricingTable/PricingTable.vue | 46 ++++++ .../lib/billing/helpers/constants.ts | 20 +-- .../frontend-2/lib/billing/helpers/types.ts | 24 +++ .../lib/common/generated/gql/gql.ts | 1 + 7 files changed, 231 insertions(+), 168 deletions(-) delete mode 100644 packages/frontend-2/components/settings/workspaces/billing/PricingTable.vue create mode 100644 packages/frontend-2/components/settings/workspaces/billing/PricingTable/Desktop.vue create mode 100644 packages/frontend-2/components/settings/workspaces/billing/PricingTable/Header.vue create mode 100644 packages/frontend-2/components/settings/workspaces/billing/PricingTable/PricingTable.vue create mode 100644 packages/frontend-2/lib/billing/helpers/types.ts diff --git a/packages/frontend-2/components/settings/workspaces/billing/PricingTable.vue b/packages/frontend-2/components/settings/workspaces/billing/PricingTable.vue deleted file mode 100644 index 7470619f7d..0000000000 --- a/packages/frontend-2/components/settings/workspaces/billing/PricingTable.vue +++ /dev/null @@ -1,156 +0,0 @@ - - - diff --git a/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Desktop.vue b/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Desktop.vue new file mode 100644 index 0000000000..cce8ba9220 --- /dev/null +++ b/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Desktop.vue @@ -0,0 +1,78 @@ + + + diff --git a/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Header.vue b/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Header.vue new file mode 100644 index 0000000000..1087c53f1c --- /dev/null +++ b/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Header.vue @@ -0,0 +1,74 @@ + + + diff --git a/packages/frontend-2/components/settings/workspaces/billing/PricingTable/PricingTable.vue b/packages/frontend-2/components/settings/workspaces/billing/PricingTable/PricingTable.vue new file mode 100644 index 0000000000..4c3444d693 --- /dev/null +++ b/packages/frontend-2/components/settings/workspaces/billing/PricingTable/PricingTable.vue @@ -0,0 +1,46 @@ + + + diff --git a/packages/frontend-2/lib/billing/helpers/constants.ts b/packages/frontend-2/lib/billing/helpers/constants.ts index 01a0d51c38..756959ab2c 100644 --- a/packages/frontend-2/lib/billing/helpers/constants.ts +++ b/packages/frontend-2/lib/billing/helpers/constants.ts @@ -1,16 +1,6 @@ import { WorkspacePlans, BillingInterval } from '~/lib/common/generated/gql/graphql' import { Roles } from '@speckle/shared' - -enum PlanFeaturesList { - Workspaces = 'Workspaces', - RoleManagement = 'Role management', - GuestUsers = 'Guest users', - PrivateAutomateFunctions = 'Private automate functions', - DomainSecurity = 'Domain security', - SSO = 'Single Sign-On (SSO)', - CustomerDataRegion = 'Customer data region', - PrioritySupport = 'Priority support' -} +import { PlanFeaturesList, type PricingPlan } from '@/lib/billing/helpers/types' const baseFeatures = [ PlanFeaturesList.Workspaces, @@ -20,7 +10,13 @@ const baseFeatures = [ PlanFeaturesList.DomainSecurity ] -export const pricingPlansConfig = { +export const pricingPlansConfig: { + features: Record + plans: Record< + WorkspacePlans.Team | WorkspacePlans.Pro | WorkspacePlans.Business, + PricingPlan + > +} = { features: { [PlanFeaturesList.Workspaces]: { name: PlanFeaturesList.Workspaces, diff --git a/packages/frontend-2/lib/billing/helpers/types.ts b/packages/frontend-2/lib/billing/helpers/types.ts new file mode 100644 index 0000000000..a91c262991 --- /dev/null +++ b/packages/frontend-2/lib/billing/helpers/types.ts @@ -0,0 +1,24 @@ +import type { + BillingInterval, + WorkspacePlans +} from '~/lib/common/generated/gql/graphql' +import type { WorkspaceRoles } from '@speckle/shared' + +export enum PlanFeaturesList { + Workspaces = 'Workspaces', + RoleManagement = 'Role management', + GuestUsers = 'Guest users', + PrivateAutomateFunctions = 'Private automate functions', + DomainSecurity = 'Domain security', + SSO = 'Single Sign-On (SSO)', + CustomerDataRegion = 'Customer data region', + PrioritySupport = 'Priority support' +} + +export type PricingPlan = { + name: WorkspacePlans + features: PlanFeaturesList[] + cost: { + [I in BillingInterval]: Record + } +} diff --git a/packages/frontend-2/lib/common/generated/gql/gql.ts b/packages/frontend-2/lib/common/generated/gql/gql.ts index 99ab3c500f..e401606533 100644 --- a/packages/frontend-2/lib/common/generated/gql/gql.ts +++ b/packages/frontend-2/lib/common/generated/gql/gql.ts @@ -11,6 +11,7 @@ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document- * 3. It does not support dead code elimination, so it will add unused operations. * * Therefore it is highly recommended to use the babel or swc plugin for production. + * Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size */ const documents = { "\n fragment AuthLoginWithEmailBlock_PendingWorkspaceCollaborator on PendingWorkspaceCollaborator {\n id\n email\n user {\n id\n }\n }\n": types.AuthLoginWithEmailBlock_PendingWorkspaceCollaboratorFragmentDoc, From 8ee8c147e1edb59e6c1f0686bfe4566a5cbf2b12 Mon Sep 17 00:00:00 2001 From: Mike Tasset Date: Mon, 18 Nov 2024 23:44:12 +0100 Subject: [PATCH 2/6] Added mobile price plan --- .../settings/workspaces/Billing.vue | 1 + .../billing/PricingTable/Desktop.vue | 6 ++- .../billing/PricingTable/Header.vue | 7 +-- .../billing/PricingTable/Mobile.vue | 46 +++++++++++++++++++ .../billing/PricingTable/PricingTable.vue | 24 +++++++--- 5 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 packages/frontend-2/components/settings/workspaces/billing/PricingTable/Mobile.vue diff --git a/packages/frontend-2/components/settings/workspaces/Billing.vue b/packages/frontend-2/components/settings/workspaces/Billing.vue index 3c08e7e44e..82b5cb5717 100644 --- a/packages/frontend-2/components/settings/workspaces/Billing.vue +++ b/packages/frontend-2/components/settings/workspaces/Billing.vue @@ -99,6 +99,7 @@ import { import { useBillingActions } from '~/lib/billing/composables/actions' import { pricingPlansConfig } from '~/lib/billing/helpers/constants' import { Roles } from '@speckle/shared' + graphql(` fragment SettingsWorkspacesBilling_Workspace on Workspace { ...BillingAlert_Workspace diff --git a/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Desktop.vue b/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Desktop.vue index cce8ba9220..31e905c945 100644 --- a/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Desktop.vue +++ b/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Desktop.vue @@ -7,7 +7,7 @@ @@ -66,10 +67,11 @@ import { WorkspacePlans } from '~/lib/common/generated/gql/graphql' import { pricingPlansConfig } from '~/lib/billing/helpers/constants' import type { PlanFeaturesList } from '~/lib/billing/helpers/types' import { CheckIcon } from '@heroicons/vue/24/outline' +import type { MaybeNullOrUndefined } from '@speckle/shared' defineProps<{ isYearlyPlan: boolean - currentPlan: WorkspacePlan + currentPlan: MaybeNullOrUndefined workspaceId: string }>() diff --git a/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Header.vue b/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Header.vue index 1087c53f1c..7f14eb7855 100644 --- a/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Header.vue +++ b/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Header.vue @@ -19,9 +19,10 @@ :color="plan.name === WorkspacePlans.Team ? 'primary' : 'outline'" :disabled="!hasTrialPlan && !canUpgradeToPlan" class="mt-3" + full-width @click="onUpgradePlanClick(plan.name)" > - {{ hasTrialPlan ? 'Subscribe' : 'Upgrade' }} to + {{ hasTrialPlan ? 'Subscribe' : 'Upgrade' }} to  {{ plan.name }} @@ -37,11 +38,11 @@ import { BillingInterval } from '~/lib/common/generated/gql/graphql' import { useBillingActions } from '~/lib/billing/composables/actions' - +import type { MaybeNullOrUndefined } from '@speckle/shared' const props = defineProps<{ plan: PricingPlan isYearlyPlan: boolean - currentPlan: WorkspacePlan + currentPlan: MaybeNullOrUndefined workspaceId: string }>() diff --git a/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Mobile.vue b/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Mobile.vue new file mode 100644 index 0000000000..7d419b7966 --- /dev/null +++ b/packages/frontend-2/components/settings/workspaces/billing/PricingTable/Mobile.vue @@ -0,0 +1,46 @@ + + + diff --git a/packages/frontend-2/components/settings/workspaces/billing/PricingTable/PricingTable.vue b/packages/frontend-2/components/settings/workspaces/billing/PricingTable/PricingTable.vue index 4c3444d693..8c31ee3f26 100644 --- a/packages/frontend-2/components/settings/workspaces/billing/PricingTable/PricingTable.vue +++ b/packages/frontend-2/components/settings/workspaces/billing/PricingTable/PricingTable.vue @@ -1,6 +1,6 @@