mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-08 05:57:02 +09:00
method names refactoring
This commit is contained in:
parent
b276cb7f86
commit
148ad72ea6
28 changed files with 36 additions and 36 deletions
|
@ -103,7 +103,7 @@ const Create = observer(class Create extends React.Component<I.PageComponent, St
|
|||
|
||||
init () {
|
||||
const spaces = UtilSpace.getList()
|
||||
.filter(it => it && UtilSpace.canParticipantWrite(it.targetSpaceId))
|
||||
.filter(it => it && UtilSpace.canMyParticipantWrite(it.targetSpaceId))
|
||||
.map(it => ({ ...it, id: it.targetSpaceId, object: it, iconSize: 16 }));
|
||||
|
||||
if (this.refSpace && spaces.length) {
|
||||
|
|
|
@ -242,7 +242,7 @@ const Create = observer(class Create extends React.Component<I.PageComponent, St
|
|||
|
||||
getSpaces () {
|
||||
return UtilSpace.getList()
|
||||
.filter(it => it && UtilSpace.canParticipantWrite(it.targetSpaceId))
|
||||
.filter(it => it && UtilSpace.canMyParticipantWrite(it.targetSpaceId))
|
||||
.map(it => ({ ...it, id: it.targetSpaceId, object: it }));
|
||||
};
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ const HeaderMainHistory = observer(class HeaderMainHistory extends React.Compone
|
|||
|
||||
render () {
|
||||
const { version } = this.state;
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
|
|
@ -47,7 +47,7 @@ const ListWidget = observer(class ListWidget extends React.Component<Props, Stat
|
|||
const { isEditing, previewId } = this.state;
|
||||
const { widgets } = blockStore;
|
||||
const cn = [ 'listWidget' ];
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
|
||||
let content = null;
|
||||
|
||||
|
@ -325,7 +325,7 @@ const ListWidget = observer(class ListWidget extends React.Component<Props, Stat
|
|||
|
||||
onContextMenu () {
|
||||
const { previewId } = this.state;
|
||||
if (previewId || !UtilSpace.canParticipantWrite()) {
|
||||
if (previewId || !UtilSpace.canMyParticipantWrite()) {
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ class MenuBlockMore extends React.Component<I.Menu> {
|
|||
const turn = { id: 'turnObject', icon: 'object', name: translate('commonTurnIntoObject'), arrow: true };
|
||||
const pageExport = { id: 'pageExport', icon: 'export', name: translate('menuBlockMoreExport') };
|
||||
const blockRemove = { id: 'blockRemove', icon: 'remove', name: translate('commonDelete') };
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
const canDelete = blockStore.checkFlags(rootId, rootId, [ I.RestrictionObject.Delete ]);
|
||||
|
||||
let archive = null;
|
||||
|
|
|
@ -84,7 +84,7 @@ class MenuContext extends React.Component<I.Menu> {
|
|||
const { data } = param;
|
||||
const { subId, objectIds, getObject, isCollection } = data;
|
||||
const length = objectIds.length;
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
|
||||
let pageCopy = { id: 'copy', icon: 'copy', name: translate('commonDuplicate') };
|
||||
let open = { id: 'open', icon: 'expand', name: translate('commonOpenObject') };
|
||||
|
|
|
@ -273,7 +273,7 @@ const MenuRelationSuggest = observer(class MenuRelationSuggest extends React.Com
|
|||
const library = items.filter(it => it.isInstalled && !systemKeys.includes(it.relationKey));
|
||||
const system = items.filter(it => it.isInstalled && systemKeys.includes(it.relationKey));
|
||||
const librarySources = library.map(it => it.sourceObject);
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
|
||||
let sections: any[] = [
|
||||
{ id: 'library', name: translate('menuRelationSuggestMyRelations'), children: library },
|
||||
|
|
|
@ -240,7 +240,7 @@ const MenuSearchObject = observer(class MenuSearchObject extends React.Component
|
|||
const { filter, label, canAdd, addParam } = data;
|
||||
const length = this.items.length;
|
||||
const items = [].concat(this.items);
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
|
||||
if (label && length) {
|
||||
items.unshift({ isSection: true, name: label });
|
||||
|
|
|
@ -283,7 +283,7 @@ const MenuTypeSuggest = observer(class MenuTypeSuggest extends React.Component<I
|
|||
const items = UtilCommon.objectCopy(this.items || []).map(it => ({ ...it, object: it }));
|
||||
const library = items.filter(it => (it.spaceId == space));
|
||||
const librarySources = library.map(it => it.sourceObject);
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
|
||||
let sections: any[] = [
|
||||
{ id: 'library', name: translate('menuTypeSuggestMyTypes'), children: library },
|
||||
|
|
|
@ -42,7 +42,7 @@ const HeadSimple = observer(class Controls extends React.Component<Props> {
|
|||
const object = detailStore.get(rootId, rootId, [ 'featuredRelations' ]);
|
||||
const featuredRelations = Relation.getArrayValue(object.featuredRelations);
|
||||
const allowDetails = blockStore.checkFlags(rootId, rootId, [ I.RestrictionObject.Details ]);
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
|
||||
const blockFeatured: any = new M.Block({ id: 'featuredRelations', type: I.BlockType.Featured, childrenIds: [], fields: {}, content: {} });
|
||||
const isTypeOrRelation = UtilObject.isTypeOrRelationLayout(object.layout);
|
||||
|
|
|
@ -266,7 +266,7 @@ const PageMainSet = observer(class PageMainSet extends React.Component<I.PageCom
|
|||
};
|
||||
|
||||
isReadonly () {
|
||||
return !UtilSpace.canParticipantWrite();
|
||||
return !UtilSpace.canMyParticipantWrite();
|
||||
};
|
||||
|
||||
resize () {
|
||||
|
|
|
@ -58,7 +58,7 @@ const PageMainStore = observer(class PageMainStore extends React.Component<I.Pag
|
|||
return null;
|
||||
};
|
||||
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
const { isPopup } = this.props;
|
||||
const views = this.getViews();
|
||||
const items = this.getItems();
|
||||
|
@ -562,7 +562,7 @@ const PageMainStore = observer(class PageMainStore extends React.Component<I.Pag
|
|||
|
||||
getViews (): any[] {
|
||||
const views: any[] = [];
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
|
||||
switch (this.tab) {
|
||||
case I.StoreTab.Type:
|
||||
|
|
|
@ -54,7 +54,7 @@ const PageMainType = observer(class PageMainType extends React.Component<I.PageC
|
|||
const object = detailStore.get(rootId, rootId);
|
||||
const subIdTemplate = this.getSubIdTemplate();
|
||||
const templates = dbStore.getRecordIds(subIdTemplate, '');
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
|
||||
const layout: any = UtilMenu.getLayouts().find(it => it.id == object.recommendedLayout) || {};
|
||||
const showTemplates = !UtilObject.getLayoutsWithoutTemplates().includes(object.recommendedLayout);
|
||||
|
|
|
@ -59,8 +59,8 @@ const PopupSettingsSpaceIndex = observer(class PopupSettingsSpaceIndex extends R
|
|||
const sharedCnt = this.getSharedCnt();
|
||||
|
||||
const hasLink = cid && key;
|
||||
const isOwner = UtilSpace.isOwner();
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const isOwner = UtilSpace.isMyOwner();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
const canDelete = space.targetSpaceId != accountSpaceId;
|
||||
const isShareActive = UtilSpace.isShareActive();
|
||||
|
||||
|
@ -73,7 +73,7 @@ const PopupSettingsSpaceIndex = observer(class PopupSettingsSpaceIndex extends R
|
|||
const progressSegments = (spaces || []).map(space => {
|
||||
const object: any = commonStore.spaceStorage.spaces.find(it => it.spaceId == space.targetSpaceId) || {};
|
||||
const usage = Number(object.bytesUsage) || 0;
|
||||
const isOwner = UtilSpace.isOwner(space.targetSpaceId);
|
||||
const isOwner = UtilSpace.isMyOwner(space.targetSpaceId);
|
||||
|
||||
if (!isOwner) {
|
||||
return null;
|
||||
|
@ -563,7 +563,7 @@ const PopupSettingsSpaceIndex = observer(class PopupSettingsSpaceIndex extends R
|
|||
};
|
||||
|
||||
getSharedCnt (): number {
|
||||
return UtilSpace.getList().filter(it => it.isShared && UtilSpace.isOwner(it.targetSpaceId)).length;
|
||||
return UtilSpace.getList().filter(it => it.isShared && UtilSpace.isMyOwner(it.targetSpaceId)).length;
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -195,7 +195,7 @@ class PopupUsecasePageItem extends React.Component<I.PopupUsecase, State> {
|
|||
};
|
||||
|
||||
list = list.concat(UtilSpace.getList()
|
||||
.filter(it => UtilSpace.canParticipantWrite(it.targetSpaceId))
|
||||
.filter(it => UtilSpace.canMyParticipantWrite(it.targetSpaceId))
|
||||
.map(it => ({ ...it, iconSize: 48, object: it })));
|
||||
|
||||
return list;
|
||||
|
|
|
@ -413,7 +413,7 @@ const PopupSearch = observer(class PopupSearch extends React.Component<I.Popup,
|
|||
const hasRelations = keyboard.isMainEditor() || keyboard.isMainSet();
|
||||
const filter = this.getFilter();
|
||||
const lang = Constant.default.interfaceLang;
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
|
||||
let name = '';
|
||||
if (filter) {
|
||||
|
|
|
@ -451,7 +451,7 @@ const Graph = observer(class Graph extends React.Component<Props> {
|
|||
};
|
||||
|
||||
onContextSpaceClick (param: any, data: any) {
|
||||
if (!UtilSpace.canParticipantWrite()) {
|
||||
if (!UtilSpace.canMyParticipantWrite()) {
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ const Navigation = observer(class Navigation extends React.Component {
|
|||
const isLinux = UtilCommon.isPlatformLinux();
|
||||
const cb = isWin || isLinux ? `${alt} + ←` : `${cmd} + [`;
|
||||
const cf = isWin || isLinux ? `${alt} + →` : `${cmd} + ]`;
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
|
||||
let buttonPlus: any = null;
|
||||
if (canWrite) {
|
||||
|
|
|
@ -410,7 +410,7 @@ const WidgetIndex = observer(class WidgetIndex extends React.Component<Props> {
|
|||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
if (!UtilSpace.canParticipantWrite()) {
|
||||
if (!UtilSpace.canMyParticipantWrite()) {
|
||||
return;
|
||||
};
|
||||
|
||||
|
@ -651,7 +651,7 @@ const WidgetIndex = observer(class WidgetIndex extends React.Component<Props> {
|
|||
const object = this.getObject();
|
||||
const { block, isEditing } = this.props;
|
||||
|
||||
if (!object || isEditing || !UtilSpace.canParticipantWrite()) {
|
||||
if (!object || isEditing || !UtilSpace.canMyParticipantWrite()) {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ const WidgetListItem = observer(class WidgetListItem extends React.Component<Pro
|
|||
const iconKey = `widget-icon-${block.id}-${id}`;
|
||||
const canDrop = !isEditing && blockStore.isAllowed(restrictions, [ I.RestrictionObject.Block ]);
|
||||
const canDrag = isPreview && (block.content.targetBlockId == Constant.widgetId.favorite);
|
||||
const hasMore = UtilSpace.canParticipantWrite();
|
||||
const hasMore = UtilSpace.canMyParticipantWrite();
|
||||
|
||||
if (isSection) {
|
||||
return (
|
||||
|
|
|
@ -17,11 +17,11 @@ const WidgetSpace = observer(class WidgetSpace extends React.Component<I.WidgetC
|
|||
|
||||
render (): React.ReactNode {
|
||||
const space = UtilSpace.getSpaceview();
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
const participants = UtilSpace.getParticipantsList([ I.ParticipantStatus.Active, I.ParticipantStatus.Joining, I.ParticipantStatus.Removing ]);
|
||||
const memberCnt = participants.filter(it => it.isActive).length;
|
||||
const requestCnt = participants.filter(it => it.isJoining || it.isRemoving).length;
|
||||
const isSpaceOwner = UtilSpace.isOwner();
|
||||
const isSpaceOwner = UtilSpace.isMyOwner();
|
||||
const showCnt = isSpaceOwner && requestCnt;
|
||||
|
||||
let status = '';
|
||||
|
|
|
@ -44,7 +44,7 @@ const TreeItem = observer(class Node extends React.Component<Props> {
|
|||
const canDrop = !isEditing && blockStore.isAllowed(restrictions, [ I.RestrictionObject.Block ]);
|
||||
const allowedDetails = blockStore.isAllowed(restrictions, [ I.RestrictionObject.Details ]);
|
||||
const paddingLeft = depth > 1 ? (depth - 1) * 12 : 6;
|
||||
const hasMore = UtilSpace.canParticipantWrite();
|
||||
const hasMore = UtilSpace.canMyParticipantWrite();
|
||||
|
||||
let arrow = null;
|
||||
let onArrowClick = null;
|
||||
|
|
|
@ -176,7 +176,7 @@ export default {
|
|||
}),
|
||||
|
||||
dashboard: () => {
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
const commonParam = {
|
||||
element: '#page.isFull #footer #button-help',
|
||||
classNameWrap: 'fixed',
|
||||
|
|
|
@ -566,7 +566,7 @@ class Action {
|
|||
|
||||
const { accountSpaceId } = authStore;
|
||||
const { space } = commonStore;
|
||||
const isOwner = UtilSpace.isOwner(id);
|
||||
const isOwner = UtilSpace.isMyOwner(id);
|
||||
const name = UtilCommon.shorten(deleted.name, 32);
|
||||
const suffix = isOwner ? 'Delete' : 'Leave';
|
||||
const title = UtilCommon.sprintf(translate(`space${suffix}WarningTitle`), name);
|
||||
|
|
|
@ -135,7 +135,7 @@ class Keyboard {
|
|||
const key = e.key.toLowerCase();
|
||||
const cmd = this.cmdKey();
|
||||
const isMain = this.isMain();
|
||||
const canWrite = UtilSpace.canParticipantWrite();
|
||||
const canWrite = UtilSpace.canMyParticipantWrite();
|
||||
|
||||
this.pressed.push(key);
|
||||
|
||||
|
|
|
@ -627,7 +627,7 @@ class UtilMenu {
|
|||
return;
|
||||
};
|
||||
|
||||
const isOwner = UtilSpace.isOwner(targetSpaceId);
|
||||
const isOwner = UtilSpace.isMyOwner(targetSpaceId);
|
||||
|
||||
let options: any[] = [];
|
||||
|
||||
|
|
|
@ -133,12 +133,12 @@ class UtilSpace {
|
|||
return object._empty_ ? null : object;
|
||||
};
|
||||
|
||||
canParticipantWrite (spaceId?: string): boolean {
|
||||
canMyParticipantWrite (spaceId?: string): boolean {
|
||||
const participant = this.getMyParticipant(spaceId);
|
||||
return participant ? (participant.isWriter || participant.isOwner) : true;
|
||||
};
|
||||
|
||||
isOwner (spaceId?: string): boolean {
|
||||
isMyOwner (spaceId?: string): boolean {
|
||||
const participant = this.getMyParticipant(spaceId || commonStore.space);
|
||||
return participant ? participant.isOwner : false;
|
||||
};
|
||||
|
|
|
@ -411,7 +411,7 @@ class BlockStore {
|
|||
};
|
||||
|
||||
isAllowed (restrictions: any[], flags: any[]): boolean {
|
||||
if (!UtilSpace.canParticipantWrite()) {
|
||||
if (!UtilSpace.canMyParticipantWrite()) {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue