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

JS-4425: add files setting to the graph

This commit is contained in:
Andrew Simachev 2024-05-05 09:46:51 +02:00
parent af3730f463
commit e24cbbc29e
No known key found for this signature in database
GPG key ID: 49A163D0D14E6FD8
5 changed files with 21 additions and 6 deletions

21
dist/workers/graph.js vendored
View file

@ -18,11 +18,16 @@ const transformThreshold = 1;
const transformThresholdHalf = transformThreshold / 2;
const delayFocus = 1000;
const ObjectLayout = {
const Layout = {
Human: 1,
Task: 2,
File: 6,
Image: 8,
Audio: 15,
Video: 16,
Bookmark: 11,
Participant: 19,
Pdf: 20,
};
const EdgeType = {
@ -187,6 +192,12 @@ updateForces = () => {
updateOrphans();
// Filter files
if (!settings.files) {
const layouts = [ Layout.File, Layout.Image, Layout.Audio, Layout.Video, Layout.Pdf ];
nodes = nodes.filter(d => !layouts.includes(d.layout) || d.forceShow);
};
// Filter links
if (!settings.link) {
edges = edges.filter(d => d.type != EdgeType.Link);
@ -251,7 +262,7 @@ updateForces = () => {
};
updateSettings = (param) => {
const updateKeys = [ 'link', 'relation', 'orphan', 'local' ];
const updateKeys = [ 'link', 'relation', 'orphan', 'local', 'files' ];
let needUpdate = false;
let needFocus = false;
@ -749,15 +760,15 @@ const checkNodeInViewport = (d) => {
};
const isLayoutHuman = (d) => {
return d.layout == ObjectLayout.Human;
return d.layout == Layout.Human;
};
const isLayoutParticipant = (d) => {
return d.layout == ObjectLayout.Participant;
return d.layout == Layout.Participant;
};
const isLayoutBookmark = (d) => {
return d.layout == ObjectLayout.Bookmark;
return d.layout == Layout.Bookmark;
};
const getNodeById = (id) => {

View file

@ -1431,6 +1431,7 @@
"menuGraphSettingsLinks": "Links",
"menuGraphSettingsRelations": "Relations",
"menuGraphSettingsUnlinkedObjects": "Unlinked Objects",
"menuGraphSettingsFiles": "Files",
"menuGraphSettingsLocal": "Local graph",
"menuHelpWhatsNew": "What's New",

View file

@ -110,6 +110,7 @@ const MenuGraphSettings = observer(class MenuGraphSettings extends React.Compone
{ id: 'link', name: translate('menuGraphSettingsLinks') },
{ id: 'relation', name: translate('menuGraphSettingsRelations') },
{ id: 'orphan', name: translate('menuGraphSettingsUnlinkedObjects') },
{ id: 'files', name: translate('menuGraphSettingsFiles') },
]
},
];

View file

@ -871,7 +871,7 @@ class UtilData {
{ operator: I.FilterOperator.And, relationKey: 'isHiddenDiscovery', condition: I.FilterCondition.NotEqual, value: true },
{ operator: I.FilterOperator.And, relationKey: 'isArchived', condition: I.FilterCondition.NotEqual, value: true },
{ operator: I.FilterOperator.And, relationKey: 'isDeleted', condition: I.FilterCondition.NotEqual, value: true },
{ operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.NotIn, value: UtilObject.getFileAndSystemLayouts() },
{ operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.NotIn, value: UtilObject.getSystemLayouts() },
{ operator: I.FilterOperator.And, relationKey: 'id', condition: I.FilterCondition.NotIn, value: [ '_anytype_profile' ] },
{ operator: I.FilterOperator.And, relationKey: 'spaceId', condition: I.FilterCondition.In, value: [ space ] },
];

View file

@ -16,6 +16,7 @@ interface Graph {
label: boolean;
relation: boolean;
link: boolean;
files: boolean;
local: boolean;
filter: string;
};
@ -74,6 +75,7 @@ class CommonStore {
marker: true,
label: true,
relation: true,
files: false,
link: true,
local: false,
filter: '',