mirror of
https://github.com/pockethost/pockethost.git
synced 2025-03-30 15:08:30 +00:00
chore: remove hard-coded max instance counts and prefer subscription_quantity
This commit is contained in:
parent
a1d7f65aa6
commit
ad64887ba0
@ -1,8 +1,4 @@
|
||||
import {
|
||||
type InstanceFields,
|
||||
parseBoolean,
|
||||
SubscriptionType,
|
||||
} from 'pockethost/common'
|
||||
import { type InstanceFields, parseBoolean } from 'pockethost/common'
|
||||
|
||||
/**
|
||||
* These environment variables default to pointing to the production build so
|
||||
@ -33,15 +29,6 @@ const mkPath = (...paths: string[]) => {
|
||||
return paths.filter((v) => !!v).join('/')
|
||||
}
|
||||
|
||||
export const MAX_INSTANCE_COUNTS = {
|
||||
[SubscriptionType.Free]: 25,
|
||||
[SubscriptionType.Legacy]: 25,
|
||||
[SubscriptionType.Founder]: 2147483647, // https://discord.com/channels/1128192380500193370/1128192380500193373/1296340516044017718
|
||||
[SubscriptionType.Premium]: 250,
|
||||
[SubscriptionType.Flounder]: 250, // Added to get the error away
|
||||
}
|
||||
export const FREE_MAX_INSTANCE_COUNT = 25
|
||||
|
||||
export const APP_URL = (...paths: string[]) => {
|
||||
return `${PUBLIC_APP_URL}/${mkPath(...paths)}`
|
||||
}
|
||||
|
@ -1,12 +1,16 @@
|
||||
<script lang="ts">
|
||||
import { MAX_INSTANCE_COUNTS } from '$src/env'
|
||||
import { globalInstancesStore, userSubscriptionType } from '$util/stores'
|
||||
import {
|
||||
globalInstancesStore,
|
||||
userSubscriptionType,
|
||||
userStore,
|
||||
} from '$util/stores'
|
||||
import { values } from '@s-libs/micro-dash'
|
||||
import InstanceList from './InstanceList.svelte'
|
||||
import { SubscriptionType } from 'pockethost/common'
|
||||
import { faPlus } from '@fortawesome/free-solid-svg-icons'
|
||||
import Fa from 'svelte-fa'
|
||||
|
||||
$: maxInstances = $userStore?.subscription_quantity || 0
|
||||
$: instanceCount = values($globalInstancesStore).length
|
||||
</script>
|
||||
|
||||
@ -29,17 +33,17 @@
|
||||
<progress
|
||||
class="progress progress-primary w-48 md:w-80"
|
||||
value={instanceCount}
|
||||
max={MAX_INSTANCE_COUNTS[$userSubscriptionType]}
|
||||
max={maxInstances}
|
||||
></progress>
|
||||
<div>
|
||||
{#if $userSubscriptionType === SubscriptionType.Founder}
|
||||
{instanceCount}/<a
|
||||
href="https://discord.com/channels/1128192380500193370/1128192380500193373/1296340516044017718"
|
||||
class="link"
|
||||
target="_blank">{MAX_INSTANCE_COUNTS[$userSubscriptionType]}</a
|
||||
target="_blank">{maxInstances}</a
|
||||
>
|
||||
{:else}
|
||||
{instanceCount}/{MAX_INSTANCE_COUNTS[$userSubscriptionType]}
|
||||
{instanceCount}/{maxInstances}
|
||||
{/if}
|
||||
{#if $userSubscriptionType === SubscriptionType.Free}
|
||||
<a href="/pricing" class="link text-xs text-success">Upgrade</a>
|
||||
|
@ -3,19 +3,18 @@
|
||||
globalInstancesStore,
|
||||
userSubscriptionType,
|
||||
versions,
|
||||
userStore,
|
||||
} from '$util/stores'
|
||||
import { values } from '@s-libs/micro-dash'
|
||||
import Creator from './Creator.svelte'
|
||||
import Paywall from './Paywall.svelte'
|
||||
import { MAX_INSTANCE_COUNTS } from '$src/env'
|
||||
|
||||
$: maxInstances = $userStore?.subscription_quantity || 0
|
||||
let instanceCount = 0
|
||||
let canCreate = false
|
||||
$: {
|
||||
instanceCount = values($globalInstancesStore).length
|
||||
canCreate =
|
||||
instanceCount < MAX_INSTANCE_COUNTS[$userSubscriptionType] &&
|
||||
$versions.length > 0
|
||||
canCreate = instanceCount < maxInstances && $versions.length > 0
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { MAX_INSTANCE_COUNTS } from '$src/env'
|
||||
import { userSubscriptionType } from '$util/stores'
|
||||
import { PLAN_NAMES, SubscriptionType } from 'pockethost/common'
|
||||
import { userSubscriptionType, userStore } from '$util/stores'
|
||||
import { PLAN_NAMES } from 'pockethost/common'
|
||||
|
||||
$: maxInstances = $userStore?.subscription_quantity || 0
|
||||
</script>
|
||||
|
||||
<div class="card max-w-sm bg-base-100 shadow-xl">
|
||||
@ -9,8 +10,9 @@
|
||||
<h2 class="card-title">Paywall!</h2>
|
||||
<p>Oof. You hit a paywall.</p>
|
||||
<p class="text-error">
|
||||
You're only allowed {MAX_INSTANCE_COUNTS[$userSubscriptionType]} projects on
|
||||
the {PLAN_NAMES[$userSubscriptionType]} plan.
|
||||
You're only allowed {maxInstances} projects on the {PLAN_NAMES[
|
||||
$userSubscriptionType
|
||||
]} plan.
|
||||
</p>
|
||||
<p>
|
||||
But that's okay, we know you want to support PocketHost if you love it
|
||||
|
Loading…
x
Reference in New Issue
Block a user