Skip to content

Commit

Permalink
* Removed code referencing the now-unneeded "Node.multiPremiseArgumen…
Browse files Browse the repository at this point in the history
…t" field. (well, almost all; the server-commands on it are left in place, for now)

* Improved node-sizing logic for argument nodes a bit.
  • Loading branch information
Venryx committed Apr 7, 2023
1 parent 357a312 commit 1b7277e
Show file tree
Hide file tree
Showing 38 changed files with 128 additions and 573 deletions.
1 change: 1 addition & 0 deletions Packages/app-server/src/db/commands/delete_argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub struct DeleteArgumentResult {

}

// todo: eventually remove (or rework) this command, since unused
pub async fn delete_argument(ctx: &AccessorContext<'_>, actor: &User, is_root: bool, input: DeleteArgumentInput, _extras: NoExtras) -> Result<DeleteArgumentResult, Error> {
let DeleteArgumentInput { mapID, argumentID, claimID, deleteClaim } = input;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub struct SetNodeIsMultiPremiseArgumentResult {

}

// todo: eventually remove this command, since unused
pub async fn set_node_is_multi_premise_argument(ctx: &AccessorContext<'_>, actor: &User, _is_root: bool, input: SetNodeIsMultiPremiseArgumentInput, _extras: NoExtras) -> Result<SetNodeIsMultiPremiseArgumentResult, Error> {
let SetNodeIsMultiPremiseArgumentInput { id, multiPremiseArgument } = input;

Expand Down
7 changes: 3 additions & 4 deletions Packages/client/Source/UI/@Shared/Maps/MapUI.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AccessPolicy, DoesMapPolicyGiveMeAccess_ExtraCheck, GetAccessPolicy, GetMap, GetNodeL3, GetParentNodeL3, GetParentPath, IsNodeL2, IsNodeL3, IsPremiseOfSinglePremiseArgument, Map, NodeL3, NodeType, NodeType_Info} from "dm_common";
import {AccessPolicy, DoesMapPolicyGiveMeAccess_ExtraCheck, GetAccessPolicy, GetMap, GetNodeL3, GetParentNodeL3, GetParentPath, IsNodeL2, IsNodeL3, Map, NodeL3, NodeType, NodeType_Info} from "dm_common";
import React, {useCallback, useMemo, useState} from "react";
import {store} from "Store/index.js";
import {GetOpenMapID} from "Store/main.js";
Expand Down Expand Up @@ -321,7 +321,7 @@ export class MapUI extends BaseComponent<Props, {}> {
<ConnectorLinesUI/>
{/*playingTimeline != null &&
<TimelineIntroBox timeline={playingTimeline}/>*/}
<NodeUI indexInNodeList={0} map={map} node={rootNode} path={(Assert(rootNode.id != null), rootNode.id.toString())} treePath="0" widthOverride={NodeType_Info.for[rootNode.type].minWidth}/>
<NodeUI indexInNodeList={0} map={map} node={rootNode} path={(Assert(rootNode.id != null), rootNode.id.toString())} treePath="0" standardWidthInGroup={NodeType_Info.for[rootNode.type].minWidth}/>
{/* <ReactResizeDetector handleWidth handleHeight onResize={()=> { */}
{/* <ResizeSensor ref="resizeSensor" onResize={()=> {
this.LoadScroll();
Expand Down Expand Up @@ -438,8 +438,7 @@ export class MapUI extends BaseComponent<Props, {}> {
const {node, path} = nodeUI.props;
const parentPath = GetParentPath(path);
const parent = GetParentNodeL3(path);
const isPremiseOfSinglePremiseArg = IsPremiseOfSinglePremiseArgument(node, parent);
return path == nextPathTry || (isPremiseOfSinglePremiseArg && parentPath == nextPathTry);
return path == nextPathTry;
});
// if finding ancestors is disabled, or there are no ancestors left, stop up-search
if (!ifMissingFindAncestor || !nextPathTry.Contains("/")) break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {useCallback} from "react";
import {Observer} from "web-vcore";
import {liveSkin} from "Utils/Styles/SkinManager";
import {GetNodeColor} from "Store/db_ext/nodes";
import {GUTTER_WIDTH_SMALL, GUTTER_WIDTH} from "./NodeUI";
import {GUTTER_WIDTH_SMALL, GUTTER_WIDTH} from "./NodeUI.js";

@Observer
export class ArgumentsControlBar extends BaseComponentPlus({} as {map: Map, node: NodeL3, path: string, treePath: string, inBelowGroup: boolean, group: ChildGroup, childBeingAdded: boolean}, {premiseTitle: ""}) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ClaimForm, GetNodeForm, GetParentNodeL3, GetRatingSummary, GetRatingTypeInfo, GetRatingTypesForNode, IsPremiseOfSinglePremiseArgument, IsUserCreatorOrMod, Map, NodeL3, NodeType_Info, NodeView, MeID, NodeRatingType} from "dm_common";
import {ClaimForm, GetNodeForm, GetParentNodeL3, GetRatingSummary, GetRatingTypeInfo, GetRatingTypesForNode, IsUserCreatorOrMod, Map, NodeL3, NodeType_Info, NodeView, MeID, NodeRatingType} from "dm_common";
import React from "react";
import {GetNodeView} from "Store/main/maps/mapViews/$mapView.js";
import {liveSkin} from "Utils/Styles/SkinManager.js";
Expand Down Expand Up @@ -51,18 +51,7 @@ export class NodeUI_LeftBox extends BaseComponentPlus({panelsPosition: "left"} a
const nodeReversed = form == ClaimForm.negation;
const nodeTypeInfo = NodeType_Info.for[node.type];

const combinedWithParent = IsPremiseOfSinglePremiseArgument(node, parentNode);
let argumentNode: NodeL3|n, argumentPath: string|n;
if (combinedWithParent) {
argumentNode = parentNode;
argumentPath = SlicePath(path, 1);
}

let ratingTypes = GetRatingTypesForNode(node);
if (argumentNode) {
//ratingTypes = [{type: "impact" as RatingType, main: true}].concat(ratingTypes).concat([{type: "relevance" as RatingType, main: true}]);
ratingTypes = ratingTypes.concat([{type: NodeRatingType.relevance}, {type: NodeRatingType.impact, main: true}]);
}
const ratingTypes = GetRatingTypesForNode(node);

if (usePortal) {
/*UseEffect(()=>{
Expand Down Expand Up @@ -137,22 +126,18 @@ export class NodeUI_LeftBox extends BaseComponentPlus({panelsPosition: "left"} a
//background: liveSkin.BasePanelBackgroundColor().alpha(.9).css(),
}}>
{ratingTypes.map((ratingInfo, index)=>{
const nodeForRatingType = combinedWithParent && ["impact", "relevance"].Contains(ratingInfo.type) ? argumentNode! : node;
const pathForRatingType = combinedWithParent && ["impact", "relevance"].Contains(ratingInfo.type) ? argumentPath! : path;
const parentNodeForRatingType = GetParentNodeL3(pathForRatingType)!; // nn: bail

const ratingTypeInfo = GetRatingTypeInfo(ratingInfo.type, nodeForRatingType, parentNodeForRatingType, pathForRatingType);
const ratingTypeInfo = GetRatingTypeInfo(ratingInfo.type, node, parentNode, path);
//let ratingSet = ratingsRoot && ratingsRoot[ratingType];

let percentStr = "...";
/*const ratings = GetRatings(nodeForRatingType.id, ratingInfo.type);
const average = GetRatingAverage_AtPath(nodeForRatingType, ratingInfo.type, null, -1);*/
const ratingSummary = GetRatingSummary(nodeForRatingType.id, ratingInfo.type);
const ratingSummary = GetRatingSummary(node.id, ratingInfo.type);
if (ratingSummary.average != null) {
percentStr = `${ratingSummary.average.RoundTo(1)}%`;
}
return (
<PanelButton key={ratingInfo.type} {...{onPanelButtonHover, onPanelButtonClick, map, path: pathForRatingType, openPanel}}
<PanelButton key={ratingInfo.type} {...{onPanelButtonHover, onPanelButtonClick, map, path, openPanel}}
panel={ratingInfo.type} text={ratingTypeInfo.displayText}
style={E(
{fontSize: 13},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {runInAction} from "web-vcore/nm/mobx.js";
import {E, ToJSON, Clone, CE} from "web-vcore/nm/js-vextensions.js";
import {GetAsync} from "web-vcore/nm/mobx-graphlink.js";
import _ from "lodash";
import {NodeL3, GetParentNodeL3, GetParentNodeID, GetLinkUnderParent, IsPremiseOfSinglePremiseArgument, GetUser, MeID, IsUserCreatorOrMod, PermissionInfoType, UpdateLink, AddNodeRevision, Map, HasModPermissions, HasAdminPermissions, AsNodeRevisionInput} from "dm_common";
import {NodeL3, GetParentNodeL3, GetParentNodeID, GetLinkUnderParent, GetUser, MeID, IsUserCreatorOrMod, PermissionInfoType, UpdateLink, AddNodeRevision, Map, HasModPermissions, HasAdminPermissions, AsNodeRevisionInput} from "dm_common";
import {apolloClient} from "Utils/LibIntegrations/Apollo.js";
import {gql} from "web-vcore/nm/@apollo/client";
import {RunCommand_AddNodeRevision} from "Utils/DB/Command.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ArgumentType, AttachmentType, CanConvertFromClaimTypeXToY, ChangeClaimType, ClaimForm, GetAccessPolicy, GetAttachmentType_Node, GetNodeLinks, GetNodeDisplayText, GetNodeMirrorChildren, GetParentNodeL3, GetUserPermissionGroups, HasAdminPermissions, IsSinglePremiseArgument, IsUserCreatorOrMod, Map, NodeL3, NodeType, MeID, ReverseArgumentPolarity, SetNodeArgumentType, UpdateLink, UpdateNodeAccessPolicy, GetLinkUnderParent, GetLinkAtPath, ReversePolarity, Polarity, OrderKey} from "dm_common";
import {ArgumentType, AttachmentType, CanConvertFromClaimTypeXToY, ChangeClaimType, ClaimForm, GetAccessPolicy, GetAttachmentType_Node, GetNodeLinks, GetNodeDisplayText, GetNodeMirrorChildren, GetParentNodeL3, GetUserPermissionGroups, HasAdminPermissions, IsUserCreatorOrMod, Map, NodeL3, NodeType, MeID, ReverseArgumentPolarity, SetNodeArgumentType, UpdateLink, UpdateNodeAccessPolicy, GetLinkUnderParent, GetLinkAtPath, ReversePolarity, Polarity, OrderKey} from "dm_common";
import React, {Fragment} from "react";
import {GenericEntryInfoUI} from "UI/@Shared/CommonPropUIs/GenericEntryInfoUI.js";
import {UUIDPathStub, UUIDStub} from "UI/@Shared/UUIDStub.js";
Expand Down Expand Up @@ -37,30 +37,9 @@ export class OthersPanel extends BaseComponentPlus({} as {show: boolean, map?: M
const convertToTypes = GetEntries(AttachmentType).filter(pair=>CanConvertFromClaimTypeXToY(GetAttachmentType_Node(node), pair.value as any));
convertToType = convertToType ?? convertToTypes.map(a=>a.value as any as AttachmentType).FirstOrX();

const isArgument_any = node.argumentType === ArgumentType.any;
/* const parents = GetNodesByIDs(node.parents?.VKeys() ?? []);
const parentsArePrivateInSameMap = !IsSpecialEmptyArray(parents) && mapID && parents.All((a) => a.ownerMapID == mapID);
const canChangeOwnershipType = creatorOrMod && (
node.ownerMapID == null
// if making private, node must be in a private map, and all its parents must be private nodes within that map (to ensure we don't leave links in other maps, which would make the owner-map-id invalid)
? (mapID && map.type == MapType.private && parentsArePrivateInSameMap)
// if making public, can't be root node, and the owner map must allow public nodes (at some point, may remove this restriction, by having action cause node to be auto-replaced with in-map private-copy)
: (node.parents?.VKeys().length > 0) // && map.allowPublicNodes)
); */

const argumentWrapper = IsSinglePremiseArgument(parent) ? parent : null;

/*const changeControlType_currentType = node.ownerMapID != null ? "Private" : "Public";
// const changeControlType_newType = changeControlType_currentType == 'Private' ? 'Public' : 'Private';
const changeControlTypeCommand = new ChangeNodeOwnerMap(EV({nodeID: node.id, newOwnerMapID: node.ownerMapID != null ? null : mapID, argumentNodeID: OmitIfFalsy(argumentWrapper?.id)}));
//const changeChildOrderTypeCommand = new ChangeNodeChildOrderType(E({nodeID: node.id, newOrderType: node.childrenOrderType == ChildOrderType.manual ? ChildOrderType.byRating : ChildOrderType.manual}));*/

const parentLinks = GetNodeLinks(null, node.id);
const childLinks = GetNodeLinks(node.id);
const mirrorChildren = GetNodeMirrorChildren(node.id);
/*const childOrderTypeChangeable = node.ownerMapID != null // if private node
|| HasAdminPermissions(MeID()) // or has admin permissions
|| (node.type === NodeType.argument && node.multiPremiseArgument); // or it's a multi-premise argument (these start as manual)*/
return (
<Column sel style={{position: "relative", display: show ? null : "none"}}>
<GenericEntryInfoUI id={node.id} creatorID={node.creator} createdAt={node.createdAt} accessPolicyID={node.accessPolicy}
Expand Down Expand Up @@ -156,17 +135,6 @@ export class OthersPanel extends BaseComponentPlus({} as {show: boolean, map?: M
new ChangeClaimType({mapID, nodeID: node.id, newType: convertToType!}).RunOnServer();
}}/>
</Row>*/}
{/*childOrderTypeChangeable &&
<Row center>
<Text>Children order type:</Text>
<Select ml={5} options={GetEntries(ChildOrderType)} value={node.childrenOrderType} enabled={changeControlTypeCommand.Validate_Safe() == null} title={changeControlTypeCommand.ValidateErrorStr} onChange={val=>{
changeControlTypeCommand.RunOnServer();
}}/>
<InfoButton ml={5} text="Private nodes are locked to a given map, but allow more permission controls to the node-creator and map-editors."/>
</Row>*/}
{/*node.childrenOrderType == ChildOrderType.manual &&
<ChildrenOrder mapID={mapID} node={node}/>*/}
{/*<ChildrenOrder mapID={mapID} node={node}/>*/}
<AtThisLocation node={node} path={path}/>
</Column>
);
Expand Down Expand Up @@ -232,69 +200,4 @@ class AtThisLocation extends BaseComponent<{node: NodeL3, path: string}, {}> {
</Column>
);
}
}

/*@Observer
class ChildrenOrder extends BaseComponent<{mapID: string, node: NodeL3}, {}> {
render() {
const {mapID, node} = this.props;
const oldChildrenOrder = node.childrenOrder || [];
//const oldChildrenOrderValid = oldChildrenOrder.length == node.children.VKeys().length && oldChildrenOrder.every(id=>node.children[id] != null);
const childOrderType = node.childrenOrder ? ChildOrderType.manual : ChildOrderType.byRating;
const updateChildrenOrderCommand = new UpdateNodeChildrenOrder({mapID, nodeID: node.id, childrenOrder: null});
return (
<Column mt={5}>
<Row style={E(childOrderType == ChildOrderType.manual && {fontWeight: "bold"})}>
<Text>Children order:</Text>
<Select ml={5} options={GetEntries(ChildOrderType)} value={childOrderType} enabled={updateChildrenOrderCommand.Validate_Safe() == null} title={updateChildrenOrderCommand.ValidateErrorStr} onChange={val=>{
if (val == ChildOrderType.manual) {
const existingValidIDs = oldChildrenOrder.filter(id=>node.children[id] != null);
const missingChildIDs = (node.children || {}).Pairs().filter(pair=>!oldChildrenOrder.Contains(pair.key)).map(pair=>pair.key);
updateChildrenOrderCommand.payload.childrenOrder = existingValidIDs.concat(missingChildIDs);
updateChildrenOrderCommand.RunOnServer();
} else {
updateChildrenOrderCommand.RunOnServer();
}
}}/>
</Row>
{node.childrenOrder && oldChildrenOrder.map((childID, index)=>{
const childPath = (node.id ? `${node.id}/` : "") + childID;
const child = GetNodeL3(childPath);
const childTitle = child ? GetNodeDisplayText(child, childPath, GetNodeForm(child, node)) : "...";
return (
<Row key={index} style={{alignItems: "center"}}>
<Row mr={7} sel style={{opacity: 0.5}}>
<Text>#</Text>
<UUIDStub id={childID}/>
</Row>
<Div sel style={ES({flex: 1, whiteSpace: "normal"})}>{childTitle}</Div>
{/* <TextInput enabled={false} style={ES({flex: 1})} required pattern={NodeL1_id}
value={`#${childID.toString()}: ${childTitle}`}
//onChange={val=>Change(!IsNaN(val.ToInt()) && (newData.childrenOrder[index] = val.ToInt()))}
/> *#/}
<Button text={<Icon size={16} icon="arrow-up"/> as any} m={2} ml={5} style={{padding: 3}} enabled={index > 0}
onClick={()=>{
const newOrder = oldChildrenOrder.slice(0);
newOrder.RemoveAt(index);
newOrder.Insert(index - 1, childID);
new UpdateNodeChildrenOrder({mapID, nodeID: node.id, childrenOrder: newOrder}).RunOnServer();
}}/>
<Button text={<Icon size={16} icon="arrow-down"/> as any} m={2} ml={5} style={{padding: 3}} enabled={index < oldChildrenOrder.length - 1}
onClick={()=>{
const newOrder = oldChildrenOrder.slice(0);
newOrder.RemoveAt(index);
newOrder.Insert(index + 1, childID);
new UpdateNodeChildrenOrder({mapID, nodeID: node.id, childrenOrder: newOrder}).RunOnServer();
}}/>
</Row>
);
})}
{/*node.childrenOrder && !oldChildrenOrderValid && updateChildrenOrderCommand.Validate_Safe() == null &&
<Button mr="auto" text="Fix children-order" onClick={()=>{
InitializeChildrenOrder();
}}/>*#/}
</Column>
);
}
}*/
}
Loading

0 comments on commit 1b7277e

Please sign in to comment.