Skip to content

Commit b44bb6d

Browse files
authored
feat: trigger setting guide with instance createdTime (#1871)
1 parent cd0099f commit b44bb6d

5 files changed

Lines changed: 25 additions & 3 deletions

File tree

apps/nestjs-backend/src/features/setting/setting.service.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import { Injectable } from '@nestjs/common';
1818
import type { Prisma } from '@teable/db-main-prisma';
1919
import { PrismaService } from '@teable/db-main-prisma';
20-
import type { ISettingVo } from '@teable/openapi';
20+
import { SettingKey, type ISettingVo } from '@teable/openapi';
2121
import { isArray } from 'lodash';
2222
import { ClsService } from 'nestjs-cls';
2323
import type { IClsStore } from '../../types/cls';
@@ -60,6 +60,14 @@ export class SettingService {
6060
}
6161
}
6262

63+
const instanceData = await this.prismaService.setting.findFirst({
64+
where: { name: SettingKey.INSTANCE_ID },
65+
select: {
66+
createdTime: true,
67+
},
68+
});
69+
res.createdTime = instanceData?.createdTime;
70+
6371
return res as ISettingVo;
6472
}
6573

apps/nextjs-app/src/features/app/blocks/space/FreshSettingGuideDialog.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
import { useSession } from '@teable/sdk/hooks';
22
import { Button, Dialog, DialogContent } from '@teable/ui-lib/shadcn';
3+
import dayjs from 'dayjs';
34
import Image from 'next/image';
45
import { useRouter } from 'next/router';
56
import { useTranslation } from 'next-i18next';
67
import { useState } from 'react';
78
import { useLocalStorage } from 'react-use';
89
import { useBrand } from '../../hooks/useBrand';
910
import { useIsCloud } from '../../hooks/useIsCloud';
11+
import { useSetting } from '../../hooks/useSetting';
1012

1113
export const FreshSettingGuideDialog = () => {
1214
const isCloud = useIsCloud();
1315
const {
1416
user: { isAdmin },
1517
} = useSession();
18+
19+
const { createdTime } = useSetting();
20+
1621
const [freshAdmin, setFreshAdmin] = useLocalStorage('freshAdmin', true);
17-
const showGuideModal = Boolean(freshAdmin && isAdmin && !isCloud);
22+
const showGuideModal = Boolean(
23+
freshAdmin && isAdmin && !isCloud && dayjs().isAfter(dayjs(createdTime).add(4, 'hour'))
24+
);
1825
const [isModalOpen, setIsModalOpen] = useState(showGuideModal);
1926
const { t } = useTranslation('common');
2027
const router = useRouter();
@@ -54,7 +61,10 @@ export const FreshSettingGuideDialog = () => {
5461
</p>
5562
</div>
5663
<Button
57-
onClick={() => router.push('/admin/setting')}
64+
onClick={() => {
65+
router.push('/admin/setting');
66+
setFreshAdmin(false);
67+
}}
5868
className="h-[44px] w-[194px] self-center"
5969
>
6070
{t('admin.action.goToConfiguration')}

apps/nextjs-app/src/features/app/hooks/useSetting.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const useSetting = () => {
1616
disallowSpaceInvitation = false,
1717
webSearchEnabled = false,
1818
appGenerationEnabled = false,
19+
createdTime,
1920
} = setting ?? {};
2021

2122
return {
@@ -24,5 +25,6 @@ export const useSetting = () => {
2425
disallowSpaceInvitation: !user.isAdmin && (isLoading || disallowSpaceInvitation),
2526
webSearchEnabled,
2627
appGenerationEnabled,
28+
createdTime,
2729
};
2830
};

packages/openapi/src/admin/setting/get-public.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const publicSettingVoSchema = settingVoSchema
3030
disallowSpaceInvitation: true,
3131
enableEmailVerification: true,
3232
enableWaitlist: true,
33+
createdTime: true,
3334
})
3435
.merge(
3536
z.object({

packages/openapi/src/admin/setting/get.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const settingVoSchema = z.object({
1919
automationMailTransportConfig: mailTransportConfigSchema.nullable().optional(),
2020
appConfig: appConfigSchema.nullable().optional(),
2121
webSearchConfig: webSearchConfigSchema.nullable().optional(),
22+
createdTime: z.string().optional(),
2223
});
2324

2425
export type ISettingVo = z.infer<typeof settingVoSchema>;

0 commit comments

Comments
 (0)