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