feat: refine configurable header and branding
This commit is contained in:
1 parent
803d590a16
commit
f8d3d5893a
47 files changed
+234
-8634
No files matched your search
@@ -19,7 +19,6 @@ import {
|
||||
items,
|
||||
users,
|
||||
} from "@homarr/db/schema";
|
||||
import { getServerSettingByKeyAsync } from "@homarr/db/queries";
|
||||
import {
|
||||
assistantProviderCanUseOpenRouterServerTools,
|
||||
assistantProviderIds,
|
||||
@@ -38,13 +37,6 @@ import { createTRPCRouter, isDemoMode, permissionRequiredProcedure, protectedPro
|
||||
import { boardRouter, getHomeIdBoardAsync } from "./board";
|
||||
|
||||
const adminProcedure = permissionRequiredProcedure.requiresPermission("admin");
|
||||
const assistantEnabledProcedure = protectedProcedure.use(async ({ ctx, next }) => {
|
||||
const featureControls = await getServerSettingByKeyAsync(ctx.db, "featureControls");
|
||||
if (!featureControls.assistantEnabled) {
|
||||
throw new TRPCError({ code: "NOT_FOUND", message: "Assistant is disabled." });
|
||||
}
|
||||
return next({ ctx });
|
||||
});
|
||||
const configurationId = "default";
|
||||
const providerSchema = z.enum(assistantProviderIds);
|
||||
|
||||
@@ -461,8 +453,6 @@ const addFeedbackToMessageContent = (serializedContent: string, type: "positive"
|
||||
|
||||
export const assistantRouter = createTRPCRouter({
|
||||
getAvailability: protectedProcedure.query(async ({ ctx }) => {
|
||||
const featureControls = await getServerSettingByKeyAsync(ctx.db, "featureControls");
|
||||
if (!featureControls.assistantEnabled) return { enabled: false };
|
||||
if (isDemoMode) {
|
||||
return { enabled: true };
|
||||
}
|
||||
@@ -475,11 +465,11 @@ export const assistantRouter = createTRPCRouter({
|
||||
};
|
||||
}),
|
||||
|
||||
getContextEntities: assistantEnabledProcedure.query(async ({ ctx }) => {
|
||||
getContextEntities: protectedProcedure.query(async ({ ctx }) => {
|
||||
return await getAssistantContextEntitiesAsync(ctx);
|
||||
}),
|
||||
|
||||
getModelCapabilities: assistantEnabledProcedure
|
||||
getModelCapabilities: protectedProcedure
|
||||
.input(z.object({ modelId: z.string().trim().min(1).max(256).optional() }).optional())
|
||||
.query(async ({ ctx, input }) => {
|
||||
const configuration = await getConfigurationAsync(ctx.db);
|
||||
@@ -496,7 +486,7 @@ export const assistantRouter = createTRPCRouter({
|
||||
};
|
||||
}),
|
||||
|
||||
getRuntimeOptions: assistantEnabledProcedure.query(async ({ ctx }) => {
|
||||
getRuntimeOptions: protectedProcedure.query(async ({ ctx }) => {
|
||||
const configuration = await getConfigurationAsync(ctx.db);
|
||||
if (isDemoMode) {
|
||||
return {
|
||||
@@ -694,7 +684,7 @@ export const assistantRouter = createTRPCRouter({
|
||||
});
|
||||
}),
|
||||
|
||||
createThread: assistantEnabledProcedure
|
||||
createThread: protectedProcedure
|
||||
.input(z.object({ localId: z.string().max(128).optional() }).optional())
|
||||
.mutation(async ({ ctx }) => {
|
||||
const configuration = await getConfigurationAsync(ctx.db);
|
||||
@@ -710,7 +700,7 @@ export const assistantRouter = createTRPCRouter({
|
||||
return { id };
|
||||
}),
|
||||
|
||||
updateThreadModel: assistantEnabledProcedure
|
||||
updateThreadModel: protectedProcedure
|
||||
.input(z.object({ threadId: z.string().max(64), modelId: z.string().trim().min(1).max(256) }))
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
const [thread, configuration] = await Promise.all([
|
||||
@@ -755,7 +745,7 @@ export const assistantRouter = createTRPCRouter({
|
||||
};
|
||||
}),
|
||||
|
||||
getGenerationTelemetry: assistantEnabledProcedure
|
||||
getGenerationTelemetry: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
threadId: z.string().max(64),
|
||||
@@ -801,7 +791,7 @@ export const assistantRouter = createTRPCRouter({
|
||||
};
|
||||
}),
|
||||
|
||||
renameThread: assistantEnabledProcedure
|
||||
renameThread: protectedProcedure
|
||||
.input(z.object({ threadId: z.string().max(64), title: z.string().trim().min(1).max(120) }))
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
await ownedThreadAsync(ctx.db, input.threadId, ctx.session.user.id);
|
||||
@@ -818,7 +808,7 @@ export const assistantRouter = createTRPCRouter({
|
||||
await ctx.db.delete(assistantThreads).where(eq(assistantThreads.id, input.threadId));
|
||||
}),
|
||||
|
||||
appendMessage: assistantEnabledProcedure
|
||||
appendMessage: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
threadId: z.string().max(64),
|
||||
@@ -879,7 +869,7 @@ export const assistantRouter = createTRPCRouter({
|
||||
.where(eq(assistantThreads.id, thread.id));
|
||||
}),
|
||||
|
||||
submitFeedback: assistantEnabledProcedure
|
||||
submitFeedback: protectedProcedure
|
||||
.input(
|
||||
z.object({
|
||||
threadId: z.string().max(64),
|
||||
|
||||
@@ -14,9 +14,7 @@ import {
|
||||
authBrandingSchema,
|
||||
brandingServerSettingsSchema,
|
||||
defaultServerSettingsKeys,
|
||||
featureControlsServerSettingsSchema,
|
||||
parseBrandingSettings,
|
||||
parseFeatureControls,
|
||||
} from "@homarr/server-settings";
|
||||
|
||||
import { createTRPCRouter, permissionRequiredProcedure, publicProcedure } from "../trpc";
|
||||
@@ -37,8 +35,6 @@ const legacyAuthBrandingUpdateSchema = z.object({
|
||||
showCustomLogoOnLogin: z.boolean().optional(),
|
||||
showCustomGreetingOnLogin: z.boolean().optional(),
|
||||
});
|
||||
const featureControlsServerSettingsUpdateSchema = featureControlsServerSettingsSchema.partial();
|
||||
|
||||
export const serverSettingsRouter = createTRPCRouter({
|
||||
getCulture: publicProcedure.query(async ({ ctx }) => {
|
||||
return await getServerSettingByKeyAsync(ctx.db, "culture");
|
||||
@@ -137,14 +133,6 @@ export const serverSettingsRouter = createTRPCRouter({
|
||||
await updateServerSettingByKeyAsync(ctx.db, "branding", value);
|
||||
return;
|
||||
}
|
||||
if (input.settingsKey === "featureControls") {
|
||||
const current = await getServerSettingByKeyAsync(ctx.db, "featureControls");
|
||||
const parsedInput = featureControlsServerSettingsUpdateSchema.parse(input.value);
|
||||
const value = parseFeatureControls({ ...current, ...parsedInput });
|
||||
await updateServerSettingByKeyAsync(ctx.db, "featureControls", value);
|
||||
return;
|
||||
}
|
||||
|
||||
const current = await getServerSettingByKeyAsync(ctx.db, input.settingsKey);
|
||||
await updateServerSettingByKeyAsync(ctx.db, input.settingsKey, {
|
||||
...current,
|
||||
|
||||
Reference in new issue
Block a user