refine app management and source repository displays
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -40,8 +40,9 @@ export class AppsService {
|
||||
private readonly launcherService: LauncherService,
|
||||
) {}
|
||||
|
||||
listApps() {
|
||||
return this.prisma.app.findMany({
|
||||
async listApps() {
|
||||
const [apps, launcherAppKeys] = await Promise.all([
|
||||
this.prisma.app.findMany({
|
||||
orderBy: { name: 'asc' },
|
||||
include: {
|
||||
components: {
|
||||
@@ -58,7 +59,15 @@ export class AppsService {
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}),
|
||||
this.launcherService.listEnabledAppKeys().catch(() => []),
|
||||
]);
|
||||
const launcherLinkedKeys = new Set(launcherAppKeys);
|
||||
|
||||
return apps.map((app) => ({
|
||||
...app,
|
||||
launcherLinked: launcherLinkedKeys.has(app.key),
|
||||
}));
|
||||
}
|
||||
|
||||
async createApp(body: CreateAppDto) {
|
||||
|
||||
@@ -454,6 +454,13 @@ export class LauncherService {
|
||||
};
|
||||
}
|
||||
|
||||
async listEnabledAppKeys() {
|
||||
const rows = await this.launcherPrisma.$queryRawUnsafe<Array<{ app_key: string }>>(
|
||||
`SELECT app_key FROM launcher_apps WHERE is_enabled = true`,
|
||||
);
|
||||
return rows.map((row) => row.app_key);
|
||||
}
|
||||
|
||||
async listUserAppPermissions(userId: string) {
|
||||
const rows = await this.launcherPrisma.$queryRawUnsafe<LauncherUserAppPermissionRow[]>(
|
||||
`SELECT app.id AS app_id, app.app_key, app.display_name, app.description, app.sort_order, app.is_enabled,
|
||||
|
||||
Reference in New Issue
Block a user