1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-08 05:57:02 +09:00

Remove allowDataview flag

This commit is contained in:
Andrew Simachev 2021-09-02 14:11:20 +03:00
parent 95ecfb06d1
commit 0135cf7bbb
17 changed files with 68 additions and 205 deletions

View file

@ -581,13 +581,6 @@ function menuInit () {
menuParam.push({
label: 'Sudo',
submenu: [
{
label: 'Dataview', type: 'checkbox', checked: config.allowDataview,
click: () => {
setConfig({ allowDataview: !config.allowDataview });
win.reload();
}
},
{
label: 'Graph',
click: () => { send('popup', 'graph', {}); }

View file

@ -53,8 +53,4 @@
.editorWrapper.noSystemBlocks {
.blocks .block.blockFeatured { display: none; }
}
html.withDataview {
.blocks .block.blockFeatured { display: flex; }
}

View file

@ -118,12 +118,10 @@ const BlockCover = observer(class BlockCover extends React.Component<Props, Stat
</div>
) : ''}
{config.allowDataview ? (
<div id="button-relation" className="btn white withIcon" onClick={this.onRelation}>
<Icon className="relation" />
<div className="txt">{translate('editorControlRelation')}</div>
</div>
) : ''}
<div id="button-relation" className="btn white withIcon" onClick={this.onRelation}>
<Icon className="relation" />
<div className="txt">{translate('editorControlRelation')}</div>
</div>
</div>
</React.Fragment>
);

View file

@ -71,12 +71,10 @@ const Controls = observer(class Controls extends React.Component<Props, {}> {
</div>
) : ''}
{config.allowDataview ? (
<div id="button-relation" className="btn" onClick={this.onRelation}>
<Icon className="relation" />
<div className="txt">{translate('editorControlRelation')}</div>
</div>
) : ''}
<div id="button-relation" className="btn" onClick={this.onRelation}>
<Icon className="relation" />
<div className="txt">{translate('editorControlRelation')}</div>
</div>
</div>
</div>
);

View file

@ -332,13 +332,8 @@ class MenuBlockAction extends React.Component<Props, State> {
const { content, align } = block;
const { color, bgColor } = content;
let types = [ Constant.typeId.page ];
const types = dbStore.getObjectTypesForSBType(I.SmartBlockType.Page).map((it: I.ObjectType) => { return it.id; });
if (config.allowDataview) {
types = dbStore.getObjectTypesForSBType(I.SmartBlockType.Page).map((it: I.ObjectType) => { return it.id; });
};
setActive(item, false);
if (!item.arrow) {
@ -396,13 +391,10 @@ class MenuBlockAction extends React.Component<Props, State> {
menuParam.className = 'single';
filters = [
{ operator: I.FilterOperator.And, relationKey: 'id', condition: I.FilterCondition.In, value: types }
{ operator: I.FilterOperator.And, relationKey: 'id', condition: I.FilterCondition.In, value: types },
{ operator: I.FilterOperator.And, relationKey: 'id', condition: I.FilterCondition.NotIn, value: [ Constant.typeId.page ] }
];
if (config.allowDataview) {
filters.push({ operator: I.FilterOperator.And, relationKey: 'id', condition: I.FilterCondition.NotIn, value: [ Constant.typeId.page ] });
};
menuParam.data = Object.assign(menuParam.data, {
placeholder: 'Find a type of object...',
label: 'Your object type library',

View file

@ -332,11 +332,9 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<Props,
return s;
});
if (config.allowDataview) {
sections = sections.concat([
{ id: 'relation', name: 'Relations', children: this.relations },
]);
};
sections = sections.concat([
{ id: 'relation', name: 'Relations', children: this.relations },
]);
if (filter && filter.text) {
const actions = DataUtil.menuGetActions(false);
@ -403,10 +401,6 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<Props,
{ operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.In, value: types },
];
if (!config.allowDataview) {
filters.push({ operator: I.FilterOperator.And, relationKey: 'id', condition: I.FilterCondition.In, value: [ Constant.typeId.page ] });
};
const text = Util.stringCut(data.text, filter.from - 1, filter.from + filter.text.length);
const length = text.length;
const position = length ? I.BlockPosition.Bottom : I.BlockPosition.Replace;
@ -462,10 +456,6 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component<Props,
menuId = 'searchObject';
menuParam.className = 'single';
if (!config.allowDataview) {
filters.push({ operator: I.FilterOperator.And, relationKey: 'id', condition: I.FilterCondition.In, value: [ Constant.typeId.page ] });
};
menuParam.data = Object.assign(menuParam.data, {
placeholder: 'Find a type of object...',
label: 'Your object type library',

View file

@ -155,8 +155,8 @@ const MenuBlockMention = observer(class MenuBlockMention extends React.Component
load (clear: boolean, callBack?: (message: any) => void) {
const { filter } = commonStore;
const { config } = commonStore;
const filterMapper = (it: any) => { return this.filterMapper(it, config); };
const filters: any[] = [
{ operator: I.FilterOperator.And, relationKey: 'isArchived', condition: I.FilterCondition.Equal, value: false },
{
operator: I.FilterOperator.And, relationKey: 'id', condition: I.FilterCondition.NotIn, value: [
blockStore.storeType,
@ -172,10 +172,6 @@ const MenuBlockMention = observer(class MenuBlockMention extends React.Component
if (!config.debug.ho) {
filters.push({ operator: I.FilterOperator.And, relationKey: 'isHidden', condition: I.FilterCondition.NotEqual, value: true });
};
if (!config.allowDataview) {
filters.push({ operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.Equal, value: I.ObjectLayout.Page });
filters.push({ operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.NotIn, value: [ Constant.typeId.template ] });
};
this.setState({ loading: true });
@ -194,23 +190,12 @@ const MenuBlockMention = observer(class MenuBlockMention extends React.Component
name: String(it.name || DataUtil.defaultName('page')),
};
}));
this.items = this.items.filter(filterMapper);
this.items.sort(DataUtil.sortByName);
this.setState({ loading: false });
});
};
filterMapper (it: any, config: any) {
if (it.isArchived) {
return false;
};
if (!config.allowDataview && (it.layout != I.ObjectLayout.Page)) {
return false;
};
return true;
};
onOver (e: any, item: any) {
if (!keyboard.isMouseDisabled) {
this.props.setActive(item, false);

View file

@ -56,19 +56,17 @@ class MenuBlockMore extends React.Component<Props, {}> {
);
let sectionPage = null;
if (block && block.isPage() && config.allowDataview) {
if (block && block.isPage() && config.sudo && restr.length) {
sectionPage = (
<React.Fragment>
{config.sudo && restr.length ? (
<div className="section">
<div className="name">Restrictions</div>
<div className="items">
{restr.map((item: any, i: number) => (
<div className="item" key={i}>{item || 'Empty'}</div>
))}
</div>
<div className="section">
<div className="name">Restrictions</div>
<div className="items">
{restr.map((item: any, i: number) => (
<div className="item" key={i}>{item || 'Empty'}</div>
))}
</div>
) : ''}
</div>
</React.Fragment>
);
};
@ -184,7 +182,7 @@ class MenuBlockMore extends React.Component<Props, {}> {
redo = null;
};
if (!config.allowDataview || (object.type == Constant.typeId.page)) {
if (object.type == Constant.typeId.page) {
template = null;
};
@ -271,9 +269,7 @@ class MenuBlockMore extends React.Component<Props, {}> {
};
let types = dbStore.getObjectTypesForSBType(I.SmartBlockType.Page).map((it: I.ObjectType) => { return it.id; });
if (config.allowDataview) {
types = types.filter((it: string) => { return it != Constant.typeId.page; });
};
types = types.filter((it: string) => { return it != Constant.typeId.page; });
switch (item.id) {
case 'turnObject':
@ -284,10 +280,6 @@ class MenuBlockMore extends React.Component<Props, {}> {
{ operator: I.FilterOperator.And, relationKey: 'id', condition: I.FilterCondition.In, value: types },
];
if (!config.allowDataview) {
filters.push({ operator: I.FilterOperator.And, relationKey: 'id', condition: I.FilterCondition.In, value: [ Constant.typeId.page ] });
};
menuParam.data = Object.assign(menuParam.data, {
placeholder: 'Find a type of object...',
label: 'Your object type library',
@ -310,10 +302,6 @@ class MenuBlockMore extends React.Component<Props, {}> {
{ operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.In, value: types }
];
if (!config.allowDataview) {
filters.push({ operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.In, value: [ Constant.typeId.page ] });
};
menuParam.data = Object.assign(menuParam.data, {
filters: filters,
type: I.NavigationType.Move,
@ -336,10 +324,6 @@ class MenuBlockMore extends React.Component<Props, {}> {
{ operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.In, value: types }
];
if (!config.allowDataview) {
filters.push({ operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.In, value: [ Constant.typeId.page ] });
};
menuParam.data = Object.assign(menuParam.data, {
filters: filters,
type: I.NavigationType.LinkTo,

View file

@ -253,9 +253,6 @@ const MenuSearchObject = observer(class MenuSearchObject extends React.Component
if (!config.debug.ho) {
filters.push({ operator: I.FilterOperator.And, relationKey: 'isHidden', condition: I.FilterCondition.Equal, value: false });
};
if (!config.allowDataview) {
filters.push({ operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.NotIn, value: [ Constant.typeId.template ] });
};
if (type == I.NavigationType.Move) {
filters.push({ operator: I.FilterOperator.And, relationKey: 'isReadonly', condition: I.FilterCondition.Equal, value: false });
};
@ -302,19 +299,6 @@ const MenuSearchObject = observer(class MenuSearchObject extends React.Component
if (it.id == skipId) {
return false;
};
if (!config.allowDataview) {
if (it.type == Constant.typeId.template) {
return false;
};
if ((it.layout != I.ObjectLayout.Page) && (it.id != Constant.typeId.page)) {
return false;
};
if ((type == I.NavigationType.Link) && ([ I.ObjectLayout.Page, I.ObjectLayout.Human, I.ObjectLayout.Task ].indexOf(it.layout) < 0)) {
return false;
};
};
if ((type == I.NavigationType.Move) && ([ I.ObjectLayout.Page, I.ObjectLayout.Human, I.ObjectLayout.Task, I.ObjectLayout.Dashboard ].indexOf(it.layout) < 0)) {
return false;
};

View file

@ -240,9 +240,6 @@ class Page extends React.Component<Props, {}> {
if (config.debug.dm) {
cn.push('dark');
};
if (config.allowDataview) {
cn.push('withDataview');
};
obj.attr({ class: cn.join(' ') });
};

View file

@ -98,9 +98,7 @@ const PageMainIndex = observer(class PageMainIndex extends React.Component<Props
<div className="rightMenu">
<Icon id="button-account" className="account" tooltip="Accounts" onClick={this.onAccount} />
<Icon id="button-add" className="add" tooltip="Add new object" onClick={this.onAdd} />
{config.allowDataview ? (
<Icon id="button-store" className="store" tooltip="Store" onClick={this.onStore} />
) : ''}
<Icon id="button-store" className="store" tooltip="Store" onClick={this.onStore} />
<IconObject getObject={() => { return { ...object, layout: I.ObjectLayout.Human } }} size={56} tooltip="Your profile" onClick={this.onProfile} />
</div>
</div>
@ -108,13 +106,9 @@ const PageMainIndex = observer(class PageMainIndex extends React.Component<Props
<div id="documents">
<div className="tabWrap">
<div className="tabs">
{Tabs.map((item: any, i: number) => {
if (!config.allowDataview && ([ Tab.Draft, Tab.Set ].indexOf(item.id) >= 0)) {
return null;
};
return <TabItem key={i} {...item} />
})}
{Tabs.map((item: any, i: number) => (
<TabItem key={i} {...item} />
))}
</div>
<div id="searchWrap" className="searchWrap" onClick={this.onSearch}>
<Icon className="search" />
@ -339,10 +333,7 @@ const PageMainIndex = observer(class PageMainIndex extends React.Component<Props
let link = null;
let move = { id: 'move', icon: 'move', name: 'Move to', arrow: true };
let types = dbStore.getObjectTypesForSBType(I.SmartBlockType.Page).map((it: I.ObjectType) => { return it.id; });
if (config.allowDataview) {
types = types.filter((it: string) => { return it != Constant.typeId.page; });
};
types = types.filter((it: string) => { return it != Constant.typeId.page; });
if (item.isBlock) {
favorites = blockStore.getChildren(blockStore.root, blockStore.root, (it: I.Block) => {
@ -411,10 +402,6 @@ const PageMainIndex = observer(class PageMainIndex extends React.Component<Props
{ operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.In, value: types }
];
if (!config.allowDataview) {
filters.push({ operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.In, value: [ Constant.typeId.page ] });
};
menuStore.open('searchObject', {
element: `#menuSelect #item-${el.id}`,
offsetX: menuContext.getSize().width,
@ -578,11 +565,8 @@ const PageMainIndex = observer(class PageMainIndex extends React.Component<Props
};
const object = detailStore.get(rootId, it.content.targetBlockId, []);
const { layout, name, _empty_, isArchived } = object;
const { name, isArchived } = object;
if (!config.allowDataview && ([ I.ObjectLayout.Page, I.ObjectLayout.Human, I.ObjectLayout.Task ].indexOf(layout) < 0) && !_empty_) {
return false;
};
if (reg && name && !name.match(reg)) {
return false;
};

View file

@ -484,8 +484,7 @@ const PopupNavigation = observer(class PopupNavigation extends React.Component<P
};
loadPage (id: string) {
const { config } = commonStore;
const filter = (it: I.PageInfo) => { return this.filterMapper(it, config); };
const filter = (it: I.PageInfo) => { return this.filterMapper(it); };
this.setState({ loading: true });
crumbs.addPage(id);
@ -514,21 +513,8 @@ const PopupNavigation = observer(class PopupNavigation extends React.Component<P
});
};
filterMapper (it: I.PageInfo, config: any) {
const object = it.details;
if (object.isArchived) {
return false;
};
if (!config.allowDataview) {
if (object.type == Constant.typeId.template) {
return false;
};
if ([ I.ObjectLayout.Page, I.ObjectLayout.Dashboard ].indexOf(object.layout) < 0) {
return false;
};
};
return true;
filterMapper (it: I.PageInfo) {
return !it.details.isArchived;
};
onClick (e: any, item: I.PageInfo) {

View file

@ -384,9 +384,6 @@ const PopupSearch = observer(class PopupSearch extends React.Component<Props, St
const { filter } = this.state;
let skipLayouts = [ I.ObjectLayout.File, I.ObjectLayout.Image, I.ObjectLayout.Video ];
if (!config.allowDataview) {
skipLayouts = skipLayouts.concat(I.ObjectLayout.Human, I.ObjectLayout.Set, I.ObjectLayout.Type, I.ObjectLayout.Relation);
};
const filters: any[] = [
{ operator: I.FilterOperator.And, relationKey: 'isArchived', condition: I.FilterCondition.Equal, value: false },
@ -399,9 +396,6 @@ const PopupSearch = observer(class PopupSearch extends React.Component<Props, St
if (!config.debug.ho) {
filters.push({ operator: I.FilterOperator.And, relationKey: 'isHidden', condition: I.FilterCondition.Equal, value: false });
};
if (!config.allowDataview) {
filters.push({ operator: I.FilterOperator.And, relationKey: 'type', condition: I.FilterCondition.NotIn, value: [ Constant.typeId.template ] });
};
this.setState({ loading: true, n: -1 });
@ -469,9 +463,6 @@ const PopupSearch = observer(class PopupSearch extends React.Component<Props, St
if (!config.debug.ho && it.isHidden) {
return false;
};
if (!config.allowDataview && (it.layout != I.ObjectLayout.Page)) {
return false;
};
return true;
};

View file

@ -3,7 +3,6 @@ export interface Account {
};
export interface AccountConfig {
allowDataview: boolean;
};
export enum Platform {

View file

@ -619,27 +619,23 @@ class DataUtil {
];
let i = 0;
if (config.allowDataview) {
let objectTypes = Util.objectCopy(dbStore.getObjectTypesForSBType(I.SmartBlockType.Page));
if (!config.debug.ho) {
objectTypes = objectTypes.filter((it: I.ObjectType) => { return !it.isHidden; })
};
objectTypes.sort(this.sortByName);
let objectTypes = Util.objectCopy(dbStore.getObjectTypesForSBType(I.SmartBlockType.Page));
if (!config.debug.ho) {
objectTypes = objectTypes.filter((it: I.ObjectType) => { return !it.isHidden; })
};
objectTypes.sort(this.sortByName);
for (let type of objectTypes) {
ret.push({
type: I.BlockType.Page,
id: 'object' + i++,
objectTypeId: type.id,
iconEmoji: type.iconEmoji,
name: type.name || this.defaultName('page'),
description: type.description,
isObject: true,
isHidden: type.isHidden,
});
};
} else {
ret.push({ type: I.BlockType.Page, id: 'page', icon: 'page', lang: 'Page' });
for (let type of objectTypes) {
ret.push({
type: I.BlockType.Page,
id: 'object' + i++,
objectTypeId: type.id,
iconEmoji: type.iconEmoji,
name: type.name || this.defaultName('page'),
description: type.description,
isObject: true,
isHidden: type.isHidden,
});
};
return ret.map(this.menuMapperBlock);
@ -656,26 +652,24 @@ class DataUtil {
const { config } = commonStore;
const ret = [];
if (config.allowDataview) {
let objectTypes = dbStore.objectTypes;
if (!config.debug.ho) {
objectTypes = objectTypes.filter((it: I.ObjectType) => { return !it.isHidden; });
};
objectTypes.sort(this.sortByName);
let objectTypes = dbStore.objectTypes;
if (!config.debug.ho) {
objectTypes = objectTypes.filter((it: I.ObjectType) => { return !it.isHidden; });
};
objectTypes.sort(this.sortByName);
let i = 0;
for (let type of objectTypes) {
ret.push({
type: I.BlockType.Page,
id: 'object' + i++,
objectTypeId: type.id,
iconEmoji: type.iconEmoji,
name: type.name || this.defaultName('page'),
description: type.description,
isObject: true,
isHidden: type.isHidden,
});
};
let i = 0;
for (let type of objectTypes) {
ret.push({
type: I.BlockType.Page,
id: 'object' + i++,
objectTypeId: type.id,
iconEmoji: type.iconEmoji,
name: type.name || this.defaultName('page'),
description: type.description,
isObject: true,
isHidden: type.isHidden,
});
};
return ret.map(this.menuMapperBlock);

View file

@ -645,12 +645,6 @@ class Dispatcher {
};
blockTypeCheck (rootId: string) {
const { config } = commonStore;
if (!config.allowDataview) {
return;
};
const object = detailStore.get(rootId, rootId, []);
let childrenIds = Util.objectCopy(blockStore.getChildrenIds(rootId, rootId));

View file

@ -15,9 +15,7 @@ const Mapper = {
},
AccountConfig: (obj: any): I.AccountConfig => {
return {
allowDataview: obj.getEnabledataview(),
};
return {};
},
ObjectInfo: (obj: any): I.PageInfo => {