Merge remote-tracking branch 'origin/main' into poc-invoice-cycle-ref

This commit is contained in:
Damodar Lohani committed 2025-02-11 05:01:51 +00:00
commit b5d723003e
10 files changed
+83 -16

No files matched your search

+2 -1
View File
@@ -5,6 +5,7 @@ WORKDIR /app
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
RUN corepack prepare pnpm@10.0.0 --activate
ADD ./package.json /app/package.json
ADD ./pnpm-lock.yaml /app/pnpm-lock.yaml
@@ -38,4 +39,4 @@ FROM nginx:1.25-alpine
EXPOSE 80
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/build /usr/share/nginx/html/console
COPY --from=build /app/build /usr/share/nginx/html/console
@@ -0,0 +1,25 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/stores';
import { Button } from '$lib/elements/forms';
import { HeaderAlert } from '$lib/layout';
import { failedInvoice } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
$: isOnProjects = $page.route.id.includes('project-[project]');
</script>
{#if $failedInvoice && $failedInvoice.teamId === $organization.$id && isOnProjects}
<HeaderAlert type="error" title="A scheduled payment for {$organization.name} failed">
To avoid service disruptions in your projects, please verify your payment details and try
again.
<svelte:fragment slot="buttons">
<Button
href={`${base}/organization-${$organization?.$id}/billing`}
secondary
fullWidthMobile>
<span class="text">Go to billing</span>
</Button>
</svelte:fragment>
</HeaderAlert>
{/if}
@@ -77,9 +77,16 @@
</LabelCard>
</li>
<li>
<LabelCard name="plan" bind:group={billingPlan} value={BillingPlan.SCALE} padding={1.5}>
<svelte:fragment slot="custom">
<div class="u-flex u-flex-vertical u-gap-4 u-width-full-line">
<LabelCard
name="plan"
bind:group={billingPlan}
value={BillingPlan.SCALE}
padding={1.5}
disabled={!selfService}>
<svelte:fragment slot="custom" let:disabled>
<div
class="u-flex u-flex-vertical u-gap-4 u-width-full-line"
class:u-opacity-50={disabled}>
<h4 class="body-text-2 u-bold">
{tierScale.name}
{#if $organization?.billingPlan === BillingPlan.SCALE && !isNewOrg}
+12
View File
@@ -1,9 +1,12 @@
<script lang="ts">
import { onMount } from 'svelte';
export let name: string;
export let group: string;
export let value: string | number | boolean;
export let disabled = false;
export let padding = 1;
export let autofocus = false;
export let fullHeight = true;
export let borderRadius: 'xsmall' | 'small' | 'medium' | 'large' = 'small';
@@ -13,9 +16,18 @@
medium = '--border-radius-medium',
large = '--border-radius-large'
}
let labelReference: HTMLLabelElement | null = null;
onMount(() => {
if (autofocus) {
labelReference?.focus();
}
});
</script>
<label
bind:this={labelReference}
class="box u-cursor-pointer u-flex u-flex-vertical u-gap-16"
class:is-allow-focus={!disabled}
class:is-disabled={disabled}
+2 -1
View File
@@ -470,7 +470,8 @@ export enum BillingPlan {
PRO = 'tier-1',
SCALE = 'tier-2',
GITHUB_EDUCATION = 'auto-1',
CUSTOM = 'cont-1'
CUSTOM = 'cont-1',
ENTERPRISE = 'ent-1'
}
export const feedbackDowngradeOptions = [
+2 -2
View File
@@ -69,7 +69,7 @@
? checkForUsageFees($organization?.billingPlan, serviceId)
: false;
$: isLimited = limit !== 0 && limit < Infinity;
$: overflowingServices = limitedServices.filter((service) => service.value >= 0);
$: overflowingServices = limitedServices.filter((service) => service.value > 0);
$: isButtonDisabled =
buttonDisabled ||
($readOnly && !GRACE_PERIOD_OVERRIDE) ||
@@ -102,7 +102,7 @@
>.
</span>
</Alert>
{:else}
{:else if services.length}
<Alert type={alertType} isStandalone>
<span class="text">
You've reached the {services} limit for the {tier} plan. <Button
+13 -5
View File
@@ -33,7 +33,7 @@ import { user } from './user';
import { browser } from '$app/environment';
import { canSeeBilling } from './roles';
export type Tier = 'tier-0' | 'tier-1' | 'tier-2' | 'auto-1' | 'cont-1';
export type Tier = 'tier-0' | 'tier-1' | 'tier-2' | 'auto-1' | 'cont-1' | 'ent-1';
export const roles = [
{
@@ -80,6 +80,8 @@ export function tierToPlan(tier: Tier) {
return tierGitHubEducation;
case BillingPlan.CUSTOM:
return tierCustom;
case BillingPlan.ENTERPRISE:
return tierEnterprise;
default:
return tierFree;
}
@@ -149,11 +151,12 @@ export const failedInvoice = cachedStore<
load: async (orgId) => {
if (!isCloud) set(null);
if (!get(canSeeBilling)) set(null);
const invoices = await sdk.forConsole.billing.listInvoices(orgId);
const failedInvoices = invoices.invoices.filter((i) => i.status === 'failed');
const failedInvoices = await sdk.forConsole.billing.listInvoices(orgId, [
Query.equal('status', 'failed')
]);
// const failedInvoices = invoices.invoices;
if (failedInvoices?.length > 0) {
const firstFailed = failedInvoices[0];
if (failedInvoices?.invoices?.length > 0) {
const firstFailed = failedInvoices.invoices[0];
const today = new Date();
const thirtyDaysAgo = new Date(today.setDate(today.getDate() - 30));
const failedDate = new Date(firstFailed.$createdAt);
@@ -198,6 +201,11 @@ export const tierCustom: TierData = {
description: 'Team on a custom contract'
};
export const tierEnterprise: TierData = {
name: 'Enterprise',
description: 'For enterprises that need more power and premium support.'
};
export const showUsageRatesModal = writable<boolean>(false);
export function checkForUsageFees(plan: Tier, id: PlanServices) {
@@ -3,7 +3,7 @@
import { Card, CardGrid, Collapsible, CollapsibleItem, Heading } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { toLocaleDate } from '$lib/helpers/date';
import { plansInfo, tierToPlan, upgradeURL } from '$lib/stores/billing';
import { plansInfo, upgradeURL } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import type { Aggregation, CreditList, Invoice, Plan } from '$lib/sdk/billing';
import { abbreviateNumber, formatCurrency, formatNumberWithCommas } from '$lib/helpers/numbers';
@@ -46,7 +46,7 @@
<Collapsible>
<div class="u-flex-vertical u-gap-8">
<div class="u-flex">
<span class="body-text-2"> {currentPlan.name} plan</span>
<span class="body-text-2">{currentPlan.name} plan</span>
<div class="body-text-2 u-margin-inline-start-auto">
{isTrial ||
$organization?.billingPlan === BillingPlan.GITHUB_EDUCATION
@@ -77,13 +77,15 @@
return 1;
}
return -1;
}) as region}
}) as region, index}
<li>
<RegionCard
name="region"
bind:group={$createProject.region}
value={region.$id}
disabled={region.disabled}>
disabled={region.disabled}
autofocus={index === 0}>
<!-- focus first item so enter key works! -->
<div
class="u-flex u-flex-vertical u-gap-8 u-justify-main-center u-cross-center u-margin-inline-auto">
{#if region.disabled}
@@ -8,6 +8,9 @@ import { isCloud } from '$lib/system';
import type { Organization } from '$lib/stores/organization';
import { defaultRoles, defaultScopes } from '$lib/constants';
import type { Plan } from '$lib/sdk/billing';
import { get } from 'svelte/store';
import { headerAlert } from '$lib/stores/headerAlert';
import PaymentFailed from '$lib/components/billing/alerts/paymentFailed.svelte';
export const load: LayoutLoad = async ({ params, depends }) => {
depends(Dependencies.PROJECT);
@@ -35,6 +38,14 @@ export const load: LayoutLoad = async ({ params, depends }) => {
scopes = res.scopes;
if (scopes.includes('billing.read')) {
await failedInvoice.load(project.teamId);
if (get(failedInvoice)) {
headerAlert.add({
show: true,
component: PaymentFailed,
id: 'paymentFailed',
importance: 1
});
}
}
}