7474<script >
7575import Vue , { ref , set , watch } from ' vue'
7676import { getCurrentUser } from ' @nextcloud/auth'
77+ import { showWarning } from ' @nextcloud/dialogs'
7778import { loadState } from ' @nextcloud/initial-state'
7879import { isPublicShare } from ' @nextcloud/sharing/public'
7980import { emit , subscribe , unsubscribe } from ' @nextcloud/event-bus'
@@ -471,6 +472,7 @@ export default {
471472 bus .on (' stateChange' , this .onStateChange )
472473 bus .on (' idle' , this .onIdle )
473474 bus .on (' save' , this .onSave )
475+ bus .on (' permissionChange' , this .onPermissionChange )
474476 },
475477
476478 unlistenSyncServiceEvents () {
@@ -483,6 +485,7 @@ export default {
483485 bus .off (' stateChange' , this .onStateChange )
484486 bus .off (' idle' , this .onIdle )
485487 bus .off (' save' , this .onSave )
488+ bus .off (' permissionChange' , this .onPermissionChange )
486489 },
487490
488491 reconnect () {
@@ -669,7 +672,17 @@ export default {
669672 }
670673
671674 if (type === ERROR_TYPE .PUSH_FORBIDDEN ) {
672- this .hasConnectionIssue = true
675+ this .readOnly = true
676+ this .editMode = false
677+ if (this .$editor ) {
678+ this .$editor .setEditable (this .editMode )
679+ }
680+ showWarning (
681+ t (
682+ ' text' ,
683+ ' Your editing permissions have been revoked. The document is now read-only.' ,
684+ ),
685+ )
673686 this .emit (' push:forbidden' )
674687 return
675688 }
@@ -722,6 +735,26 @@ export default {
722735 })
723736 },
724737
738+ onPermissionChange ({ readOnly }) {
739+ this .readOnly = readOnly
740+ this .editMode = ! readOnly && ! this .openReadOnlyEnabled
741+ if (this .$editor ) {
742+ this .$editor .setEditable (this .editMode )
743+ }
744+ if (readOnly) {
745+ showWarning (
746+ t (
747+ ' text' ,
748+ ' Your editing permissions have been revoked. The document is now read-only.' ,
749+ ),
750+ )
751+ } else {
752+ showWarning (
753+ t (' text' , ' You now have edit permissions for this document.' ),
754+ )
755+ }
756+ },
757+
725758 onFocus () {
726759 this .emit (' focus' )
727760 },
0 commit comments