mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 15:35:55 +01:00
fix: allow note only in edit mode
This commit is contained in:
@@ -12,13 +12,20 @@ export const notebookRouter = createTRPCRouter({
|
||||
update: publicProcedure
|
||||
.input(z.object({ widgetId: z.string(), content: z.string(), configName: z.string() }))
|
||||
.mutation(async ({ input }) => {
|
||||
if (!process.env.DISABLE_EDIT_MODE) {
|
||||
throw new TRPCError({
|
||||
code: 'METHOD_NOT_SUPPORTED',
|
||||
message: 'Edit is not allowed, because edit mode is disabled'
|
||||
});
|
||||
}
|
||||
|
||||
const config = getConfig(input.configName);
|
||||
const widget = config.widgets.find((widget) => widget.id === input.widgetId) as
|
||||
| INotebookWidget
|
||||
| undefined;
|
||||
|
||||
if (!widget) {
|
||||
return new TRPCError({
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
message: 'Specified widget was not found',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user