Skip to content

Commit 9ab2769

Browse files
committed
JS-8822: fix
1 parent 8056500 commit 9ab2769

File tree

6 files changed

+104
-115
lines changed

6 files changed

+104
-115
lines changed

src/json/text.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,6 +1899,7 @@
18991899
"menuObjectAdvanced": "Advanced",
19001900
"menuObjectOpenInNewTab": "Open in New Tab",
19011901
"menuObjectOpenInNewWindow": "Open in New Window",
1902+
"menuObjectRelations": "Open Properties",
19021903

19031904
"menuItemFilterTimeAgo": "%d %s ago",
19041905
"menuItemFilterTimeFromNow": "%d %s from now",

src/scss/component/header.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
.icon.unpin { background-image: url('~img/icon/header/unpin.svg'); }
8080
.icon.invite { background-image: url('~img/icon/header/invite.svg'); }
8181
.icon.oneToOne { background-image: url('~img/icon/header/oneToOne.svg'); }
82+
.icon.search { background-image: url('~img/icon/header/search.svg'); }
8283

8384
.label.btn {
8485
-webkit-app-region: no-drag; @include text-common; font-weight: 500; padding: 3px 8px; border-radius: 6px;

src/ts/component/header/main/chat.tsx

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const HeaderMainChat = observer(forwardRef<{}, I.HeaderComponent>((props, ref) =
1111
const canWrite = U.Space.canMyParticipantWrite();
1212
const rightSidebar = S.Common.getRightSidebarState(isPopup);
1313
const hasWidget = !!S.Block.getWidgetsForTarget(rootId).length;
14-
const showInvite = !spaceview.isOneToOne;
1514
const isSearchMenuOpen = S.Menu.isOpenList([ 'searchText', 'searchChat' ]);
1615
const cnc = [ 'side', 'center' ];
1716

@@ -27,8 +26,6 @@ const HeaderMainChat = observer(forwardRef<{}, I.HeaderComponent>((props, ref) =
2726
};
2827

2928
const isDeleted = object._empty_ || object.isDeleted;
30-
const readonly = object.isArchived;
31-
const showRelations = !isDeleted && !spaceview.isChat && !spaceview.isOneToOne;
3229
const showPin = canWrite && !spaceview.isChat && !spaceview.isOneToOne;
3330
const bannerProps = { type: I.BannerType.None, isPopup, object };
3431

@@ -40,10 +37,6 @@ const HeaderMainChat = observer(forwardRef<{}, I.HeaderComponent>((props, ref) =
4037
Action.toggleWidgetsForObject(rootId, analytics.route.header);
4138
};
4239

43-
const onRelation = () => {
44-
sidebar.rightPanelToggle(isPopup, { page: 'object/relation', rootId, readonly });
45-
};
46-
4740
const onOpen = () => {
4841
const object = S.Detail.get(rootId, rootId, []);
4942

@@ -110,25 +103,13 @@ const HeaderMainChat = observer(forwardRef<{}, I.HeaderComponent>((props, ref) =
110103
</div>
111104

112105
<div className="side right">
113-
{showInvite ? (
114-
<Icon
115-
id="button-header-invite"
116-
tooltipParam={{ text: translate('pageSettingsSpaceIndexAddMembers'), typeY: I.MenuDirection.Bottom }}
117-
className="invite withBackground"
118-
onClick={() => Action.openSpaceShare(analytics.route.chat)}
119-
onDoubleClick={e => e.stopPropagation()}
120-
/>
121-
) : ''}
122-
123-
{showRelations ? (
124-
<Icon
125-
id="button-header-relation"
126-
tooltipParam={{ text: translate('commonRelations'), caption: keyboard.getCaption('relation'), typeY: I.MenuDirection.Bottom }}
127-
className={[ 'relation', 'withBackground', (rightSidebar.page == 'object/relation' ? 'active' : '') ].join(' ')}
128-
onClick={onRelation}
129-
onDoubleClick={e => e.stopPropagation()}
130-
/>
131-
) : ''}
106+
<Icon
107+
id="button-header-search"
108+
tooltipParam={{ text: translate('commonSearch'), caption: keyboard.getCaption('searchText'), typeY: I.MenuDirection.Bottom }}
109+
className="search withBackground"
110+
onClick={() => keyboard.onSearchText('', analytics.route.header)}
111+
onDoubleClick={e => e.stopPropagation()}
112+
/>
132113

133114
{showPin ? (
134115
<Icon

src/ts/component/header/main/object.tsx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,21 @@ const HeaderMainObject = observer(forwardRef<{}, I.HeaderComponent>((props, ref)
88
const { rootId, isPopup, onSearch, onTooltipShow, onTooltipHide, renderLeftIcons, menuOpen } = props;
99
const [ templatesCnt, setTemplateCnt ] = useState(0);
1010
const [ dummy, setDummy ] = useState(0);
11-
const rightSidebar = S.Common.getRightSidebarState(isPopup);
1211
const canWrite = U.Space.canMyParticipantWrite();
1312
const root = S.Block.getLeaf(rootId, rootId);
1413
const object = S.Detail.get(rootId, rootId, J.Relation.template);
1514
const isDeleted = object._empty_ || object.isDeleted;
1615
const isLocked = root ? root.isLocked() : false;
17-
const isTypeOrRelation = U.Object.isTypeOrRelationLayout(object.layout);
1816
const isRelation = U.Object.isRelationLayout(object.layout);
1917
const isDate = U.Object.isDateLayout(object.layout);
2018
const isTemplate = U.Object.isTemplateType(object.type);
2119
const showShare = S.Block.isAllowed(object.restrictions, [ I.RestrictionObject.Publish ], true) && !isDeleted && !object.isArchived;
22-
const showRelations = !isTypeOrRelation && !isDate && !isDeleted;
2320
const showMenu = !isDeleted;
2421
const showPin = canWrite && !isRelation && !isTemplate;
2522
const allowedTemplateSelect = (object.internalFlags || []).includes(I.ObjectFlag.SelectTemplate);
2623
const bannerProps = { type: I.BannerType.None, isPopup, object, count: 0 };
2724
const readonly = object.isArchived || isLocked;
2825
const hasWidget = !!S.Block.getWidgetsForTarget(rootId).length;
29-
const isRelationOpen = (rightSidebar.page == 'object/relation');
3026
const isSearchMenuOpen = S.Menu.isOpenList([ 'searchText', 'searchChat' ]);
3127
const cnc = [ 'side', 'center' ];
3228

@@ -112,10 +108,6 @@ const HeaderMainObject = observer(forwardRef<{}, I.HeaderComponent>((props, ref)
112108
Action.toggleWidgetsForObject(rootId, analytics.route.header);
113109
};
114110

115-
const onRelation = () => {
116-
sidebar.rightPanelToggle(isPopup, { page: 'object/relation', rootId, readonly });
117-
};
118-
119111
const updateTemplatesCnt = () => {
120112
if (!allowedTemplateSelect) {
121113
return;
@@ -160,16 +152,6 @@ const HeaderMainObject = observer(forwardRef<{}, I.HeaderComponent>((props, ref)
160152
/>
161153
) : ''}
162154

163-
{showRelations ? (
164-
<Icon
165-
id="button-header-relation"
166-
tooltipParam={{ text: translate('commonRelations'), caption: keyboard.getCaption('relation'), typeY: I.MenuDirection.Bottom }}
167-
className={[ 'relation', 'withBackground', (isRelationOpen ? 'active' : '') ].join(' ')}
168-
onClick={onRelation}
169-
onDoubleClick={e => e.stopPropagation()}
170-
/>
171-
) : ''}
172-
173155
{showPin ? (
174156
<Icon
175157
id="button-header-pin"

src/ts/component/menu/object.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)