@@ -13,6 +13,7 @@ const MenuObject = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
1313 const spaceview = U . Space . getSpaceview ( ) ;
1414 const block = S . Block . getLeaf ( rootId , blockId ) ;
1515 const object = data . object || S . Detail . get ( rootId , blockId ) ;
16+ const type = S . Record . getTypeById ( object . type ) ;
1617 const restrictions = S . Block . getRestrictions ( rootId , rootId ) . map ( it => I . RestrictionObject [ it ] ) ;
1718 const isTemplate = U . Object . isTemplateType ( object . type ) ;
1819 const isDate = U . Object . isDateLayout ( object . layout ) ;
@@ -22,6 +23,7 @@ const MenuObject = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
2223 const isInSet = U . Object . isInSetLayouts ( object . layout ) ;
2324 const isInFile = U . Object . isInFileLayouts ( object . layout ) ;
2425 const isInFileOrSystem = U . Object . isInFileOrSystemLayouts ( object . layout ) ;
26+ const isInSystem = U . Object . isInSystemLayouts ( object . layout ) ;
2527 const isTypeOrRelation = U . Object . isTypeOrRelationLayout ( object . layout ) ;
2628 const isRelation = U . Object . isRelationLayout ( object . layout ) ;
2729 const isType = U . Object . isTypeLayout ( object . layout ) ;
@@ -61,7 +63,6 @@ const MenuObject = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
6163 let linkTo = { id : 'linkTo' , icon : 'linkTo' , name : translate ( 'commonLinkTo' ) , arrow : true } ;
6264 let addCollection = { id : 'addCollection' , icon : 'collection' , name : translate ( 'commonAddToCollection' ) , arrow : true } ;
6365 let searchText = { id : 'searchText' , icon : 'search' , name : translate ( 'menuObjectSearchOnPage' ) , caption : keyboard . getCaption ( 'searchText' ) } ;
64- let searchChat = { id : 'searchChat' , icon : 'search' , name : translate ( 'menuObjectSearchInChat' ) , caption : keyboard . getCaption ( 'searchText' ) } ;
6566 let history = { id : 'history' , name : translate ( 'commonVersionHistory' ) , caption : keyboard . getCaption ( 'history' ) } ;
6667 let pageCopy = { id : 'pageCopy' , icon : 'copy' , name : translate ( 'commonDuplicate' ) } ;
6768 let pageLink = { id : 'pageLink' , icon : 'linkTo' , name : translate ( 'commonCopyLink' ) } ;
@@ -72,6 +73,7 @@ const MenuObject = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
7273 let openFile = { id : 'openFile' , icon : 'expand' , name : translate ( 'menuObjectDownloadOpen' ) } ;
7374 let openObject = { id : 'openAsObject' , icon : 'expand' , name : translate ( 'commonOpenObject' ) } ;
7475 let advanced = { id : 'advanced' , icon : 'advanced' , name : translate ( 'menuObjectAdvanced' ) , children :[ ] , arrow : true } ;
76+ let editRelation = { id : 'editRelation' , name : translate ( 'menuObjectRelations' ) , icon : 'editRelation' } ;
7577 let editType = { id : 'editType' , name : translate ( 'commonEditType' ) , icon : 'editType' } ;
7678 let editChat = { id : 'editChat' , name : translate ( 'commonEditChat' ) , icon : 'editChat' } ;
7779 let notification = { id : 'notification' , name : translate ( 'commonNotifications' ) , icon : 'notification' , arrow : true } ;
@@ -111,10 +113,8 @@ const MenuObject = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
111113 isChat
112114 ) ;
113115
114- const allowedDetails = S . Block . isAllowed ( object . restrictions , [ I . RestrictionObject . Details ] ) ;
115116 const allowedArchive = canWrite && canDelete ;
116117 const allowedSearchText = ! isFilePreview && ! isInSet && ! isChat ;
117- const allowedSearchChat = isChat ;
118118 const allowedHistory = ! object . isArchived && ! isInFileOrSystem && ! isParticipant && ! isDate && ! isChat && ! object . templateIsBundled ;
119119 const allowedLock = canWrite && ! object . isArchived && S . Block . checkFlags ( rootId , rootId , [ I . RestrictionObject . Details ] ) && ! isInFileOrSystem ;
120120 const allowedLinkTo = canWrite && ! isRelation && ! object . isArchived ;
@@ -128,10 +128,19 @@ const MenuObject = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
128128 const allowedDownloadFile = isInFile ;
129129 const allowedOpenFile = isInFile ;
130130 const allowedOpenObject = isFilePreview ;
131- const allowedEditType = isType && allowedDetails && ! U . Object . isParticipantLayout ( object . recommendedLayout ) && ! U . Object . isTemplateType ( object . id ) ;
131+ const allowedEditType = (
132+ isType &&
133+ S . Block . isAllowed ( object . restrictions , [ I . RestrictionObject . Details ] ) &&
134+ ! U . Object . isParticipantLayout ( object . recommendedLayout ) &&
135+ ! U . Object . isTemplateType ( object . id )
136+ ) || (
137+ ! isInSystem &&
138+ S . Block . isAllowed ( type ?. restrictions , [ I . RestrictionObject . Details ] )
139+ ) ;
132140 const allowedEditChat = canWrite && isChat ;
133141 const allowedNotification = isChat ;
134142 const allowedCopyMedia = U . Object . isImageLayout ( object . layout ) ;
143+ const allowedEditRelation = ! isInSystem ;
135144
136145 if ( ! allowedPageLink ) {
137146 pageLink = null ;
@@ -143,7 +152,6 @@ const MenuObject = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
143152 if ( ! allowedCopy ) pageCopy = null ;
144153 if ( ! allowedReload ) pageReload = null ;
145154 if ( ! allowedSearchText ) searchText = null ;
146- if ( ! allowedSearchChat ) searchChat = null ;
147155 if ( ! allowedHistory ) history = null ;
148156 if ( ! isTemplate && ! allowedTemplate ) template = null ;
149157 if ( ! allowedLinkTo ) linkTo = null ;
@@ -157,6 +165,7 @@ const MenuObject = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
157165 if ( ! allowedEditChat ) editChat = null ;
158166 if ( ! allowedNotification ) notification = null ;
159167 if ( ! allowedCopyMedia ) copyMedia = null ;
168+ if ( ! allowedEditRelation ) relation = null ;
160169
161170 if ( ! canWrite ) {
162171 template = null ;
@@ -179,7 +188,6 @@ const MenuObject = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
179188 } ;
180189
181190 sections = sections . concat ( [
182- { children : [ searchChat ] } ,
183191 { children : [ openObject ] } ,
184192 { children : [ pageLock , history ] } ,
185193 { children : [ linkTo , addCollection , template , pageLink ] } ,
@@ -197,14 +205,12 @@ const MenuObject = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
197205 } else
198206 if ( object . isArchived ) {
199207 sections = sections . concat ( [
200- { children : [ searchChat ] } ,
201208 { children : [ openObject ] } ,
202209 { children : [ searchText , pageExport , remove , archive ] } ,
203210 { children : [ print ] } ,
204211 ] ) ;
205212 } else {
206213 sections = sections . concat ( [
207- { children : [ searchChat ] } ,
208214 { children : [ openObject ] } ,
209215 { children : [ pageLock ] } ,
210216 { children : [ linkTo , addCollection , template , pageLink ] } ,
@@ -217,8 +223,8 @@ const MenuObject = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
217223 sections = sections . map ( ( it : any , i : number ) => ( { ...it , id : `page${ i } ` } ) ) ;
218224 } ;
219225
226+ sections . unshift ( { children : [ editRelation , editType , editChat , notification ] } ) ;
220227 sections . push ( { children : [ advanced ] } ) ;
221- sections . unshift ( { children : [ editType , editChat , notification ] } ) ;
222228
223229 sections = sections . filter ( ( section : any ) => {
224230 section . children = section . children . filter ( it => it ) ;
@@ -394,7 +400,6 @@ const MenuObject = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
394400 break ;
395401 } ;
396402
397- case 'searchChat' :
398403 case 'searchText' : {
399404 keyboard . onSearchText ( '' , route ) ;
400405 shouldClose = false ;
@@ -498,8 +503,13 @@ const MenuObject = observer(forwardRef<I.MenuRef, I.Menu>((props, ref) => {
498503 break ;
499504 } ;
500505
506+ case 'editRelation' : {
507+ sidebar . rightPanelToggle ( isPopup , { page : 'object/relation' , rootId, readonly : object . isArchived } ) ;
508+ break ;
509+ } ;
510+
501511 case 'editType' : {
502- U . Object . editType ( rootId , isPopup ) ;
512+ U . Object . editType ( isType ? rootId : object . type , isPopup ) ;
503513 break ;
504514 } ;
505515
0 commit comments