Skip to content

Commit 8ab7ee0

Browse files
[Doom - Downgrade] Cancel banner shows when user canceled subscription (#2599)
* wip * wip2 * All pages updated * typo
1 parent 3755911 commit 8ab7ee0

File tree

35 files changed

+271
-41
lines changed

35 files changed

+271
-41
lines changed

front/components/assistant_builder/AssistantBuilder.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import { PostOrPatchAgentConfigurationRequestBodySchema } from "@app/pages/api/w
5858
import { AppType } from "@app/types/app";
5959
import { TimeframeUnit } from "@app/types/assistant/actions/retrieval";
6060
import { DataSourceType } from "@app/types/data_source";
61-
import { PlanType } from "@app/types/plan";
61+
import { PlanType, SubscriptionType } from "@app/types/plan";
6262
import { UserType, WorkspaceType } from "@app/types/user";
6363

6464
import DataSourceResourceSelectorTree from "../DataSourceResourceSelectorTree";
@@ -164,6 +164,7 @@ export type AssistantBuilderInitialState = {
164164
type AssistantBuilderProps = {
165165
user: UserType;
166166
owner: WorkspaceType;
167+
subscription: SubscriptionType;
167168
plan: PlanType;
168169
gaTrackingId: string;
169170
dataSources: DataSourceType[];
@@ -209,6 +210,7 @@ const getCreativityLevelFromTemperature = (temperature: number) => {
209210
export default function AssistantBuilder({
210211
user,
211212
owner,
213+
subscription,
212214
plan,
213215
gaTrackingId,
214216
dataSources,
@@ -698,6 +700,7 @@ export default function AssistantBuilder({
698700
avatarUrls={avatarUrls}
699701
/>
700702
<AppLayout
703+
subscription={subscription}
701704
hideSidebar
702705
user={user}
703706
owner={owner}

front/components/sparkle/AppLayout.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import React from "react";
1818

1919
import WorkspacePicker from "@app/components/WorkspacePicker";
2020
import { classNames } from "@app/lib/utils";
21+
import { SubscriptionType } from "@app/types/plan";
2122
import { UserType, WorkspaceType } from "@app/types/user";
2223

2324
import {
@@ -29,12 +30,14 @@ import {
2930
function NavigationBar({
3031
user,
3132
owner,
33+
subscription,
3234
topNavigationCurrent,
3335
subNavigation,
3436
children,
3537
}: {
3638
user: UserType | null;
3739
owner: WorkspaceType;
40+
subscription: SubscriptionType;
3841
topNavigationCurrent: TopNavigationId;
3942
subNavigation?: SidebarNavigation[] | null;
4043
children: React.ReactNode;
@@ -104,6 +107,10 @@ function NavigationBar({
104107
</DropdownMenu>
105108
)}
106109
</div>
110+
111+
{subscription.endDate && (
112+
<SubscriptionEndBanner endDate={subscription.endDate} />
113+
)}
107114
<div>
108115
<Tab tabs={topNavigation({ owner, current: topNavigationCurrent })} />
109116
</div>
@@ -168,6 +175,7 @@ function NavigationBar({
168175
export default function AppLayout({
169176
user,
170177
owner,
178+
subscription,
171179
isWideMode = false,
172180
hideSidebar = false,
173181
topNavigationCurrent,
@@ -180,6 +188,7 @@ export default function AppLayout({
180188
}: {
181189
user: UserType | null;
182190
owner: WorkspaceType;
191+
subscription: SubscriptionType;
183192
isWideMode?: boolean;
184193
hideSidebar?: boolean;
185194
topNavigationCurrent: TopNavigationId;
@@ -300,6 +309,7 @@ export default function AppLayout({
300309
</div>
301310
</Transition.Child>
302311
<NavigationBar
312+
subscription={subscription}
303313
user={user}
304314
owner={owner}
305315
subNavigation={subNavigation}
@@ -319,6 +329,7 @@ export default function AppLayout({
319329
<NavigationBar
320330
user={user}
321331
owner={owner}
332+
subscription={subscription}
322333
subNavigation={subNavigation}
323334
topNavigationCurrent={topNavigationCurrent}
324335
>
@@ -417,3 +428,28 @@ export default function AppLayout({
417428
</>
418429
);
419430
}
431+
432+
function SubscriptionEndBanner({ endDate }: { endDate: number }) {
433+
const formattedEndDate = new Date(endDate).toLocaleDateString("en-US", {
434+
year: "numeric",
435+
month: "long",
436+
day: "numeric",
437+
});
438+
439+
return (
440+
<div className="border-y border-pink-200 bg-pink-100 px-3 py-3 text-xs text-pink-900">
441+
<div className="font-bold">Subscription ending on {formattedEndDate}</div>
442+
<div className="font-normal">
443+
Connections will be deleted and members will be revoked. Details{" "}
444+
<Link
445+
href="https://dust-tt.notion.site/What-happens-when-we-cancel-our-Dust-subscription-59aad3866dcc4bbdb26a54e1ce0d848a?pvs=4"
446+
target="_blank"
447+
className="underline"
448+
>
449+
here
450+
</Link>
451+
.
452+
</div>
453+
</div>
454+
);
455+
}

front/pages/w/[wId]/a/[aId]/clone.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ import { Authenticator, getSession, getUserFromSession } from "@app/lib/auth";
1717
import { APIError } from "@app/lib/error";
1818
import { classNames } from "@app/lib/utils";
1919
import { AppType, AppVisibility } from "@app/types/app";
20+
import { SubscriptionType } from "@app/types/plan";
2021
import { UserType, WorkspaceType } from "@app/types/user";
2122

2223
const { GA_TRACKING_ID = "" } = process.env;
2324

2425
export const getServerSideProps: GetServerSideProps<{
2526
user: UserType;
2627
owner: WorkspaceType;
28+
subscription: SubscriptionType;
2729
app: AppType;
2830
gaTrackingId: string;
2931
}> = async (context) => {
@@ -42,7 +44,9 @@ export const getServerSideProps: GetServerSideProps<{
4244
);
4345

4446
const owner = auth.workspace();
45-
if (!owner) {
47+
const subscription = auth.subscription();
48+
49+
if (!owner || !subscription) {
4650
return {
4751
notFound: true,
4852
};
@@ -60,6 +64,7 @@ export const getServerSideProps: GetServerSideProps<{
6064
props: {
6165
user,
6266
owner,
67+
subscription,
6368
app,
6469
gaTrackingId: GA_TRACKING_ID,
6570
},
@@ -69,6 +74,7 @@ export const getServerSideProps: GetServerSideProps<{
6974
export default function CloneView({
7075
user,
7176
owner,
77+
subscription,
7278
app,
7379
gaTrackingId,
7480
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
@@ -130,6 +136,7 @@ export default function CloneView({
130136

131137
return (
132138
<AppLayout
139+
subscription={subscription}
133140
user={user}
134141
owner={owner}
135142
gaTrackingId={gaTrackingId}

front/pages/w/[wId]/a/[aId]/datasets/[name]/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ import { Authenticator, getSession, getUserFromSession } from "@app/lib/auth";
1818
import { useRegisterUnloadHandlers } from "@app/lib/front";
1919
import { AppType } from "@app/types/app";
2020
import { DatasetSchema, DatasetType } from "@app/types/dataset";
21+
import { SubscriptionType } from "@app/types/plan";
2122
import { UserType, WorkspaceType } from "@app/types/user";
2223

2324
const { GA_TRACKING_ID = "" } = process.env;
2425

2526
export const getServerSideProps: GetServerSideProps<{
2627
user: UserType | null;
2728
owner: WorkspaceType;
29+
subscription: SubscriptionType;
2830
readOnly: boolean;
2931
app: AppType;
3032
dataset: DatasetType;
@@ -39,7 +41,9 @@ export const getServerSideProps: GetServerSideProps<{
3941
);
4042

4143
const owner = auth.workspace();
42-
if (!owner) {
44+
const subscription = auth.subscription();
45+
46+
if (!owner || !subscription) {
4347
return {
4448
notFound: true,
4549
};
@@ -74,6 +78,7 @@ export const getServerSideProps: GetServerSideProps<{
7478
props: {
7579
user,
7680
owner,
81+
subscription,
7782
readOnly,
7883
app,
7984
dataset,
@@ -86,6 +91,7 @@ export const getServerSideProps: GetServerSideProps<{
8691
export default function ViewDatasetView({
8792
user,
8893
owner,
94+
subscription,
8995
readOnly,
9096
app,
9197
dataset,
@@ -166,6 +172,7 @@ export default function ViewDatasetView({
166172

167173
return (
168174
<AppLayout
175+
subscription={subscription}
169176
user={user}
170177
owner={owner}
171178
gaTrackingId={gaTrackingId}

front/pages/w/[wId]/a/[aId]/datasets/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ import { Authenticator, getSession, getUserFromSession } from "@app/lib/auth";
1515
import { classNames } from "@app/lib/utils";
1616
import { AppType } from "@app/types/app";
1717
import { DatasetType } from "@app/types/dataset";
18+
import { SubscriptionType } from "@app/types/plan";
1819
import { UserType, WorkspaceType } from "@app/types/user";
1920

2021
const { GA_TRACKING_ID = "" } = process.env;
2122

2223
export const getServerSideProps: GetServerSideProps<{
2324
user: UserType | null;
2425
owner: WorkspaceType;
26+
subscription: SubscriptionType;
2527
readOnly: boolean;
2628
app: AppType;
2729
datasets: DatasetType[];
@@ -35,7 +37,8 @@ export const getServerSideProps: GetServerSideProps<{
3537
);
3638

3739
const owner = auth.workspace();
38-
if (!owner) {
40+
const subscription = auth.subscription();
41+
if (!owner || !subscription) {
3942
return {
4043
notFound: true,
4144
};
@@ -57,6 +60,7 @@ export const getServerSideProps: GetServerSideProps<{
5760
props: {
5861
user,
5962
owner,
63+
subscription,
6064
readOnly,
6165
app,
6266
datasets,
@@ -68,6 +72,7 @@ export const getServerSideProps: GetServerSideProps<{
6872
export default function DatasetsView({
6973
user,
7074
owner,
75+
subscription,
7176
readOnly,
7277
app,
7378
datasets,
@@ -92,6 +97,7 @@ export default function DatasetsView({
9297

9398
return (
9499
<AppLayout
100+
subscription={subscription}
95101
user={user}
96102
owner={owner}
97103
gaTrackingId={gaTrackingId}

front/pages/w/[wId]/a/[aId]/datasets/new.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ import { Authenticator, getSession, getUserFromSession } from "@app/lib/auth";
1818
import { useRegisterUnloadHandlers } from "@app/lib/front";
1919
import { AppType } from "@app/types/app";
2020
import { DatasetSchema, DatasetType } from "@app/types/dataset";
21+
import { SubscriptionType } from "@app/types/plan";
2122
import { UserType, WorkspaceType } from "@app/types/user";
2223

2324
const { GA_TRACKING_ID = "" } = process.env;
2425

2526
export const getServerSideProps: GetServerSideProps<{
2627
user: UserType | null;
2728
owner: WorkspaceType;
29+
subscription: SubscriptionType;
2830
app: AppType;
2931
datasets: DatasetType[];
3032
gaTrackingId: string;
@@ -37,7 +39,8 @@ export const getServerSideProps: GetServerSideProps<{
3739
);
3840

3941
const owner = auth.workspace();
40-
if (!owner || !auth.isBuilder()) {
42+
const subscription = auth.subscription();
43+
if (!owner || !auth.isBuilder() || !subscription) {
4144
return {
4245
notFound: true,
4346
};
@@ -57,6 +60,7 @@ export const getServerSideProps: GetServerSideProps<{
5760
props: {
5861
user,
5962
owner,
63+
subscription,
6064
app,
6165
datasets,
6266
gaTrackingId: GA_TRACKING_ID,
@@ -67,6 +71,7 @@ export const getServerSideProps: GetServerSideProps<{
6771
export default function NewDatasetView({
6872
user,
6973
owner,
74+
subscription,
7075
app,
7176
datasets,
7277
gaTrackingId,
@@ -129,6 +134,7 @@ export default function NewDatasetView({
129134

130135
return (
131136
<AppLayout
137+
subscription={subscription}
132138
user={user}
133139
owner={owner}
134140
gaTrackingId={gaTrackingId}

front/pages/w/[wId]/a/[aId]/execute/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { useSavedRunStatus } from "@app/lib/swr";
3535
import { classNames } from "@app/lib/utils";
3636
import { AppType, BlockRunConfig, SpecificationType } from "@app/types/app";
3737
import { DatasetType } from "@app/types/dataset";
38+
import { SubscriptionType } from "@app/types/plan";
3839
import { TraceType } from "@app/types/run";
3940
import { UserType, WorkspaceType } from "@app/types/user";
4041

@@ -54,6 +55,7 @@ type Event = {
5455
export const getServerSideProps: GetServerSideProps<{
5556
user: UserType | null;
5657
owner: WorkspaceType;
58+
subscription: SubscriptionType;
5759
app: AppType;
5860
config: BlockRunConfig;
5961
inputDataset: DatasetType | null;
@@ -68,7 +70,8 @@ export const getServerSideProps: GetServerSideProps<{
6870
);
6971

7072
const owner = auth.workspace();
71-
if (!owner) {
73+
const subscription = auth.subscription();
74+
if (!owner || !subscription) {
7275
return {
7376
notFound: true,
7477
};
@@ -107,6 +110,7 @@ export const getServerSideProps: GetServerSideProps<{
107110
props: {
108111
user,
109112
owner,
113+
subscription,
110114
app,
111115
config,
112116
inputDataset,
@@ -359,6 +363,7 @@ function ExecuteInput({
359363
export default function ExecuteView({
360364
user,
361365
owner,
366+
subscription,
362367
app,
363368
config,
364369
inputDataset,
@@ -566,6 +571,7 @@ export default function ExecuteView({
566571

567572
return (
568573
<AppLayout
574+
subscription={subscription}
569575
user={user}
570576
owner={owner}
571577
gaTrackingId={gaTrackingId}

0 commit comments

Comments
 (0)