Fix default app in main appstore list (#7141)
This commit is contained in:
1 parent
7c749299bb
commit
00ebda2fc6
3 files changed
+15
-2
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
|
import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
|
||||||
import prisma, { safeAppSelect, safeCredentialSelect } from "@calcom/prisma";
|
import prisma, { safeAppSelect, safeCredentialSelect } from "@calcom/prisma";
|
||||||
|
import { userMetadata } from "@calcom/prisma/zod-utils";
|
||||||
import type { AppFrontendPayload as App } from "@calcom/types/App";
|
import type { AppFrontendPayload as App } from "@calcom/types/App";
|
||||||
import type { CredentialFrontendPayload as Credential } from "@calcom/types/Credential";
|
import type { CredentialFrontendPayload as Credential } from "@calcom/types/Credential";
|
||||||
|
|
||||||
@@ -61,8 +62,19 @@ export async function getAppRegistryWithCredentials(userId: number) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const user = await prisma.user.findUnique({
|
||||||
|
where: {
|
||||||
|
id: userId,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
metadata: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const usersDefaultApp = userMetadata.parse(user?.metadata)?.defaultConferencingApp?.appSlug;
|
||||||
const apps = [] as (App & {
|
const apps = [] as (App & {
|
||||||
credentials: Credential[];
|
credentials: Credential[];
|
||||||
|
isDefault?: boolean;
|
||||||
})[];
|
})[];
|
||||||
for await (const dbapp of dbApps) {
|
for await (const dbapp of dbApps) {
|
||||||
const app = await getAppWithMetadata(dbapp);
|
const app = await getAppWithMetadata(dbapp);
|
||||||
@@ -70,7 +82,6 @@ export async function getAppRegistryWithCredentials(userId: number) {
|
|||||||
// Skip if app isn't installed
|
// Skip if app isn't installed
|
||||||
/* This is now handled from the DB */
|
/* This is now handled from the DB */
|
||||||
// if (!app.installed) return apps;
|
// if (!app.installed) return apps;
|
||||||
|
|
||||||
const { rating, reviews, trending, verified, ...remainingAppProps } = app;
|
const { rating, reviews, trending, verified, ...remainingAppProps } = app;
|
||||||
apps.push({
|
apps.push({
|
||||||
rating: rating || 0,
|
rating: rating || 0,
|
||||||
@@ -81,6 +92,7 @@ export async function getAppRegistryWithCredentials(userId: number) {
|
|||||||
categories: dbapp.categories,
|
categories: dbapp.categories,
|
||||||
credentials: dbapp.credentials,
|
credentials: dbapp.credentials,
|
||||||
installed: true,
|
installed: true,
|
||||||
|
isDefault: usersDefaultApp === dbapp.slug,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return apps;
|
return apps;
|
||||||
|
|||||||
Vendored
+1
@@ -142,6 +142,7 @@ export interface App {
|
|||||||
|
|
||||||
export type AppFrontendPayload = Omit<App, "key"> & {
|
export type AppFrontendPayload = Omit<App, "key"> & {
|
||||||
/** We should type error if keys are leaked to the frontend */
|
/** We should type error if keys are leaked to the frontend */
|
||||||
|
isDefault?: boolean;
|
||||||
key?: never;
|
key?: never;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ export function AppCard({ app, credentials, searchText }: AppCardProps) {
|
|||||||
<span className="rounded-md bg-red-100 px-2 py-1 text-sm font-normal text-red-800">Template</span>
|
<span className="rounded-md bg-red-100 px-2 py-1 text-sm font-normal text-red-800">Template</span>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{app.isGlobal && (
|
{(app.isDefault || (!app.isDefault && app.isGlobal)) && (
|
||||||
<span className="flex items-center rounded-md bg-gray-100 px-2 py-1 text-sm font-normal text-gray-800">
|
<span className="flex items-center rounded-md bg-gray-100 px-2 py-1 text-sm font-normal text-gray-800">
|
||||||
{t("default")}
|
{t("default")}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in new issue
Block a user