Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const fromUid = context.params.from;
const toUid = context.params.to;

const newNameQuery = (
await unigraph.getQueries([
`(func: uid(${toUid})) {
uid
unigraph.indexes {
name {
uid
expand(_userpredicate_) {uid
expand(_userpredicate_) {uid
expand(_userpredicate_) {uid
expand(_userpredicate_) {uid
expand(_userpredicate_) {uid
expand(_userpredicate_) { } } } } } }
}
}
}`,
])
)[0][0];
const newName = new UnigraphObject(newNameQuery['unigraph.indexes'].name).as('primitive');
await unigraph.runExecutable('$/executable/rename-entity', {
uid: fromUid,
newName,
});

const refs = await unigraph.getQueries([
`(func: uid(${fromUid})) {
<~_value> {
uid
}
<unigraph.origin> {
uid
}
}`,
]);

const valUids = refs?.[0]?.[0]?.['~_value'].map((el) => el.uid);
const originUids = refs?.[0]?.[0]?.['unigraph.origin'].map((el) => el.uid);

const updateTriplets = [
...valUids.map((uid) => `<${uid}> <_value> <${toUid}> .`),
...originUids.map((uid) => `<${toUid}> <unigraph.origin> <${uid}> .`),
];

await unigraph.updateTriplets(updateTriplets);
await unigraph.deleteObject(fromUid, true);
7 changes: 7 additions & 0 deletions packages/default-packages/unigraph.semantic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@
"src": "executables/renameEntity.js",
"editable": true,
"name": "Renames an entity and update all its references"
},
{
"id": "merge-entities",
"env": "routine/js",
"src": "executables/mergeEntities.js",
"editable": true,
"name": "Merges an entity to another"
}
]
}
Expand Down
2 changes: 2 additions & 0 deletions packages/unigraph-dev-explorer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const providedTheme = createTheme(globalTheme);

const dndOpts = {
enableMouseEvents: true,
delayTouchStart: 500,
ignoreContextMenu: true,
};

function AppToWrap() {
Expand Down
27 changes: 20 additions & 7 deletions packages/unigraph-dev-explorer/src/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ import { MobileBar } from './components/UnigraphCore/MobileBar';
import { CustomDragLayer } from './CustomDragLayer';

export function WorkspacePageComponent({ children, maximize, paddingTop, id, tabCtx }: any) {
const [_maximize, setMaximize] = React.useState(maximize);
tabCtx.setMaximize = (val: boolean) => {
setMaximize(val);
};
// const [_maximize, setMaximize] = React.useState(maximize);
// tabCtx.setMaximize = (val: boolean) => {
// setMaximize(val);
// };
const memoTabCtx = React.useMemo(() => tabCtx, [id]);

return (
Expand All @@ -49,15 +49,15 @@ export function WorkspacePageComponent({ children, maximize, paddingTop, id, tab
width: '100%',
height: '100%',
overflow: 'auto',
paddingTop: _maximize || !paddingTop ? '0px' : '12px',
paddingTop: maximize || !paddingTop ? '0px' : '12px',
}}
>
<Container
maxWidth={_maximize ? false : 'lg'}
maxWidth={maximize ? false : 'lg'}
id={`workspaceContainer${id}`}
disableGutters
style={{
paddingTop: _maximize || !paddingTop ? '0px' : '12px',
paddingTop: maximize || !paddingTop ? '0px' : '12px',
height: '100%',
display: 'flex',
flexDirection: 'column',
Expand Down Expand Up @@ -282,6 +282,8 @@ const providedTheme = createTheme(globalTheme);

const dndOpts = {
enableMouseEvents: true,
delayTouchStart: 500,
ignoreContextMenu: true,
};

export function WorkSpace(this: any) {
Expand Down Expand Up @@ -519,6 +521,17 @@ export function WorkSpace(this: any) {
component: (window.layoutModel.getNodeById(action.data.tabNode) as any)
?._attributes?.component,
});
} else if (
action.type === 'FlexLayout_DeleteTab' &&
action.data.animationShown !== true
) {
console.log('Closing');
const tabEl = document.getElementById(`tabId${action.data.node}`)?.parentElement;
tabEl?.classList.remove('rendered_tab_button');
setTimeout(() => {
model.doAction({ ...action, data: { ...action.data, animationShown: true } });
}, 200);
return undefined;
}
return action;
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ import { ErrorBoundary } from 'react-error-boundary';
import { useSwipeable } from 'react-swipeable';
import { UnigraphObject, getRandomInt, getRandomId } from 'unigraph-dev-common/lib/utils/utils';
import { AutoDynamicViewProps } from '../../types/ObjectView.d';
import { DataContext, DataContextWrapper, isMobile, isMultiSelectKeyPressed, selectUid, TabContext } from '../../utils';
import {
DataContext,
DataContextWrapper,
isMobile,
isMultiSelectKeyPressed,
selectUid,
TabContext,
trivialTypes,
} from '../../utils';
import { onUnigraphContextMenu } from './DefaultObjectContextMenu';
import { StringObjectViewer } from './BasicObjectViews';
import { excludableTypes } from './GraphView';
import { getSubentities, isStub, SubentityDropAcceptor } from './utils';
import { registerKeyboardShortcut, removeKeyboardShortcut } from '../../keyboardShortcuts';
import { useFocusDelegate, useSelectionDelegate } from './AutoDynamicView/FocusSelectionDelegate';
Expand Down Expand Up @@ -56,7 +63,7 @@ export function AutoDynamicView({

const shouldGetBacklinks =
!finalOptions.ignoreBacklinks &&
(finalOptions.shouldGetBacklinks || (!excludableTypes.includes(object?.type?.['unigraph.id']) && !inline));
(finalOptions.shouldGetBacklinks || (!trivialTypes.includes(object?.type?.['unigraph.id']) && !inline));

const dataContext = React.useContext(DataContext);
const tabContext = React.useContext(TabContext);
Expand Down Expand Up @@ -309,6 +316,7 @@ export function AutoDynamicView({
parents={finalOptions.ignoreBacklinks ? dataContext.parents : totalParents}
viewType="$/schema/dynamic_view"
expandedChildren={expandedChildren || false}
subsId={subsId}
>
<div
style={{
Expand All @@ -330,7 +338,7 @@ export function AutoDynamicView({
window.wsnavigator(
`/library/object?uid=${object?.uid}&viewer=${'dynamic-view-detailed'}&type=${
object?.type?.['unigraph.id']
}&name=${object?.get('name')?.as('primitive')}`,
}&name=${getObject_()?.get?.('name')?.as('primitive') || ''}`,
);
})();
}
Expand All @@ -355,10 +363,12 @@ export function AutoDynamicView({
noContextMenu
? () => false
: (event) =>
onUnigraphContextMenu(event, getObjectRef.current(), contextEntity, {
...callbacks,
componentId,
})
isDragging
? event.preventDefault()
: onUnigraphContextMenu(event, getObjectRef.current(), contextEntity, {
...callbacks,
componentId,
})
}
{...(attributes || {})}
ref={attach}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const AutoDynamicViewDetailed: DynamicViewRenderer = ({
parents={totalParents}
viewType="$/schema/dynamic_view_detailed"
expandedChildren
subsId={subsId}
>
<div style={{ display: 'contents' }} id={`object-view-${object.uid}`}>
<TabContext.Consumer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { byElementIndex } from 'unigraph-dev-common/lib/utils/entityUtils';
import { TransitionGroup } from 'react-transition-group';
import { getDynamicViews } from '../../unigraph-react';
import { AutoDynamicView } from './AutoDynamicView';
import { DataContext, DataContextWrapper, hoverSx, isMobile, TabContext } from '../../utils';
import { DataContext, DataContextWrapper, hoverSx, isMobile, TabContext, trivialTypes } from '../../utils';
import { setupInfiniteScrolling } from './infiniteScrolling';
import { DragandDrop } from './DragandDrop';

Expand Down Expand Up @@ -509,8 +509,7 @@ export const DynamicObjectListView: React.FC<DynamicObjectListViewProps> = ({
},
{
id: 'no-trivial',
fn: (obj) =>
['$/schema/markdown', '$/schema/subentity'].includes(obj?.type?.['unigraph.id']) ? null : obj,
fn: (obj) => (trivialTypes.includes(obj?.type?.['unigraph.id']) ? null : obj),
},
{ id: 'no-hidden', fn: (obj) => obj._hide !== true },
...filters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ForceGraph2D from 'react-force-graph-2d';
import ReactResizeDetector from 'react-resize-detector';
import _ from 'lodash';
import { Checkbox, List, ListItem, Typography } from '@mui/material';
import { TabContext } from '../../utils';
import { TabContext, trivialTypes as excludableTypes } from '../../utils';

const queryNameIndex = `@filter(type(Entity) AND (NOT eq(<_propertyType>, "inheritance"))) {
uid
Expand All @@ -20,7 +20,6 @@ const queryNameIndex = `@filter(type(Entity) AND (NOT eq(<_propertyType>, "inher
<type> { <unigraph.id> }
}`;

export const excludableTypes = ['$/schema/subentity', '$/schema/interface/textual', '$/schema/markdown'];
const getExcluded = (id: number) =>
excludableTypes.reduce((prev, curr, idx) => ((id >> idx) % 2 ? [...prev, curr] : prev), [] as string[]);

Expand Down
Loading