🚸(app-impress) warning when resource not editable
When a resource is public, the users can see it but not edit it. This commit adds a warning message to the user to tell them that the resource is not editable.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { BlockNoteView, useCreateBlockNote } from '@blocknote/react';
|
||||
import '@blocknote/react/style.css';
|
||||
import { Alert, VariantType } from '@openfun/cunningham-react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { WebrtcProvider } from 'y-webrtc';
|
||||
|
||||
@@ -57,6 +58,8 @@ export const BlockNoteContent = ({ pad, provider }: BlockNoteContentProps) => {
|
||||
},
|
||||
});
|
||||
|
||||
editor.isEditable = pad.abilities.partial_update;
|
||||
|
||||
useEffect(() => {
|
||||
setEditor(pad.id, editor);
|
||||
}, [setEditor, pad.id, editor]);
|
||||
@@ -69,6 +72,13 @@ export const BlockNoteContent = ({ pad, provider }: BlockNoteContentProps) => {
|
||||
};
|
||||
`}
|
||||
>
|
||||
{!pad.abilities.partial_update && (
|
||||
<Box className="m-b" $css="margin-top:0;">
|
||||
<Alert
|
||||
type={VariantType.WARNING}
|
||||
>{`Read only, you don't have the right to update this pad.`}</Alert>
|
||||
</Box>
|
||||
)}
|
||||
<BlockNoteView editor={editor} formattingToolbar={false}>
|
||||
<BlockNoteToolbar />
|
||||
</BlockNoteView>
|
||||
|
||||
@@ -28,5 +28,6 @@ export interface Pad {
|
||||
retrieve: boolean;
|
||||
manage_accesses: boolean;
|
||||
update: boolean;
|
||||
partial_update: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export const TemplateEditor = ({ template }: TemplateEditorProps) => {
|
||||
? template.code_editor
|
||||
: editor.getProjectData();
|
||||
|
||||
editor.loadProjectData(projectData);
|
||||
editor?.loadProjectData(projectData);
|
||||
|
||||
editor.Storage.add('remote', {
|
||||
load() {
|
||||
@@ -118,6 +118,14 @@ export const TemplateEditor = ({ template }: TemplateEditorProps) => {
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{!template.abilities.partial_update && (
|
||||
<Box className="m-b" $css="margin-top:0;">
|
||||
<Alert
|
||||
type={VariantType.WARNING}
|
||||
>{`Read only, you don't have the right to update this template.`}</Alert>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
<Box className="m-b" $css="margin-top:0;flex:1;" $overflow="auto">
|
||||
<GjsEditor
|
||||
grapesjs={grapesjs}
|
||||
|
||||
@@ -27,6 +27,7 @@ export interface Template {
|
||||
manage_accesses: boolean;
|
||||
retrieve: boolean;
|
||||
update: boolean;
|
||||
partial_update: boolean;
|
||||
};
|
||||
accesses: Access[];
|
||||
code_editor: ProjectData;
|
||||
|
||||
Reference in New Issue
Block a user