@riboseinc/paneron-registry-kit 2.2.16 → 2.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/views/GenericRelatedItemView.js +11 -6
- package/views/GenericRelatedItemView.js.map +1 -1
- package/views/ItemDetailsDrawer.d.ts +11 -0
- package/views/ItemDetailsDrawer.js +69 -0
- package/views/ItemDetailsDrawer.js.map +1 -0
- package/views/{ItemDrawer.d.ts → ItemSearchDrawer.d.ts} +1 -1
- package/views/{ItemDrawer.js → ItemSearchDrawer.js} +5 -4
- package/views/ItemSearchDrawer.js.map +1 -0
- package/views/change-request/Proposals.d.ts +3 -2
- package/views/change-request/Proposals.js +125 -146
- package/views/change-request/Proposals.js.map +1 -1
- package/views/detail/ChangeRequest/index.js +4 -1
- package/views/detail/ChangeRequest/index.js.map +1 -1
- package/views/detail/RegisterHome/index.js +12 -5
- package/views/detail/RegisterHome/index.js.map +1 -1
- package/views/detail/RegisterItem/index.js +1 -10
- package/views/detail/RegisterItem/index.js.map +1 -1
- package/views/index.js +27 -20
- package/views/index.js.map +1 -1
- package/views/ItemDrawer.js.map +0 -1
package/package.json
CHANGED
|
@@ -19,9 +19,9 @@ var _ChangeRequestContext = require("./change-request/ChangeRequestContext");
|
|
|
19
19
|
|
|
20
20
|
var _cr = require("../types/cr");
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _ItemSearchDrawer = _interopRequireDefault(require("./ItemSearchDrawer"));
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _ItemDetailsDrawer = _interopRequireDefault(require("./ItemDetailsDrawer"));
|
|
25
25
|
|
|
26
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
27
|
|
|
@@ -74,7 +74,8 @@ const GenericRelatedItemView = function ({
|
|
|
74
74
|
|
|
75
75
|
const affectedByActiveCR = activeChangeRequest && (0, _cr.isDrafted)(activeChangeRequest) && activeChangeRequest.items[itemPathWithSubregister];
|
|
76
76
|
const itemPath = affectedByActiveCR ? `/proposals/${activeChangeRequest.id}/items/${itemPathWithSubregister}` : `/${itemPathWithSubregister}`;
|
|
77
|
-
const [selectDialogState, setSelectDialogState] = (0, _react2.useState)(false);
|
|
77
|
+
const [selectDialogState, setSelectDialogState] = (0, _react2.useState)(false);
|
|
78
|
+
const [peekingDrawerState, setPeekingDrawerState] = (0, _react2.useState)(false); //log.debug("Rendering generic related item view", itemRef);
|
|
78
79
|
//const { jumpToItem } = useContext(BrowserCtx);
|
|
79
80
|
|
|
80
81
|
const itemResult = useRegisterItemData({
|
|
@@ -109,7 +110,7 @@ const GenericRelatedItemView = function ({
|
|
|
109
110
|
const willShowItemView = hasItem || itemIsMissing || !onChange;
|
|
110
111
|
const canJump = (item !== null || itemIsMissing) && classConfigured && !itemResult.isUpdating && (onJump || jumpTo);
|
|
111
112
|
const jump = (0, _react2.useCallback)(function jump() {
|
|
112
|
-
return onJump ? onJump() :
|
|
113
|
+
return onJump ? onJump() : setPeekingDrawerState(true);
|
|
113
114
|
}, [onJump, jumpTo]);
|
|
114
115
|
const itemView = (0, _react2.useMemo)(() => {
|
|
115
116
|
var _a;
|
|
@@ -216,16 +217,20 @@ const GenericRelatedItemView = function ({
|
|
|
216
217
|
}), canJump ? (0, _react.jsx)(_core.Button, {
|
|
217
218
|
outlined: true,
|
|
218
219
|
onClick: jump,
|
|
219
|
-
icon: "
|
|
220
|
+
icon: "maximize"
|
|
220
221
|
}) : null, itemButtons.map((props, idx) => (0, _react.jsx)(_core.Button, {
|
|
221
222
|
key: idx,
|
|
222
223
|
outlined: true,
|
|
223
224
|
...props
|
|
224
|
-
})),
|
|
225
|
+
})), (0, _react.jsx)(_ItemSearchDrawer.default, {
|
|
225
226
|
isOpen: selectDialogState,
|
|
226
227
|
onClose: () => setSelectDialogState(false),
|
|
227
228
|
onChooseItem: onChange,
|
|
228
229
|
availableClassIDs: classIDs
|
|
230
|
+
}), itemRef ? (0, _react.jsx)(_ItemDetailsDrawer.default, {
|
|
231
|
+
isOpen: peekingDrawerState,
|
|
232
|
+
onClose: () => setPeekingDrawerState(false),
|
|
233
|
+
itemRef: itemRef
|
|
229
234
|
}) : null);
|
|
230
235
|
};
|
|
231
236
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericRelatedItemView.js","sourceRoot":"","sources":["../../src/views/GenericRelatedItemView.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAA4C,MAAM,mBAAmB,CAAC;AAC/G,OAAO,EAGL,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,gBAAgB,MAAM,cAAc,CAAC;AAG5C,MAAM,SAAS,GAAG;IAChB,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,EAAE;IACV,aAAa,EAAE,EAAE;CACT,CAAC;AAGX,MAAM,CAAC,MAAM,sBAAsB,GAE9B,UAAU,EACb,OAAO,EAAE,SAAS,EAClB,WAAW,EAAE,OAAO,EAAE,QAAQ,EAC9B,iBAAiB,EACjB,MAAM,EACN,QAAQ,EACR,iBAAiB;AACjB,2BAA2B;AAC3B,cAAc;EACf;;IACC,MAAM,EACJ,mBAAmB,EACnB,gCAAgC,EAChC,MAAM,GACP,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;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/react';\nimport React, { useContext, useCallback, useMemo, useState } from 'react';\nimport { InputGroup, Button, ControlGroup, type ControlGroupProps, type ButtonProps } from '@blueprintjs/core';\nimport {\n type GenericRelatedItemViewProps,\n type RelatedItemClassConfiguration,\n isRegisterItem,\n} from '../types';\nimport { BrowserCtx } from './BrowserCtx';\nimport { ChangeRequestContext } from './change-request/ChangeRequestContext';\nimport { isDrafted } from '../types/cr';\nimport { Protocols } from './protocolRegistry';\nimport ItemSearchDrawer from './ItemDrawer';\n\n\nconst DUMMY_REF = {\n classID: '',\n itemID: '',\n subregisterID: '',\n} as const;\n\n\nexport const GenericRelatedItemView: React.FC<GenericRelatedItemViewProps & {\n controlGroupProps?: ControlGroupProps\n}> = function ({\n itemRef, className,\n onCreateNew, onClear, onChange,\n availableClassIDs,\n onJump,\n inputRef,\n controlGroupProps,\n // availableSubregisterIDs,\n // itemSorter,\n}) {\n const {\n useRegisterItemData,\n getRelatedItemClassConfiguration,\n jumpTo,\n } = useContext(BrowserCtx);\n const { changeRequest: activeChangeRequest } = useContext(ChangeRequestContext);\n const { classID, itemID, subregisterID } = itemRef ?? DUMMY_REF;\n\n const itemPathWithClass = `${classID}/${itemID}.yaml`;\n // If curretn register has subregisters, specify subregister-relative path\n const itemPathWithSubregister = subregisterID\n ? `subregisters/${subregisterID}/${itemPathWithClass}`\n : `${itemPathWithClass}`;\n // If a change request is active\n // and this item is among clarifications or additions\n // then use item path relative to the change request\n const affectedByActiveCR = (\n activeChangeRequest &&\n isDrafted(activeChangeRequest) &&\n activeChangeRequest.items[itemPathWithSubregister]\n );\n const itemPath = affectedByActiveCR\n ? `/proposals/${activeChangeRequest.id}/items/${itemPathWithSubregister}`\n : `/${itemPathWithSubregister}`;\n\n const [selectDialogState, setSelectDialogState] = useState(false);\n\n //log.debug(\"Rendering generic related item view\", itemRef);\n //const { jumpToItem } = useContext(BrowserCtx);\n\n const itemResult = useRegisterItemData({ itemPaths: [itemPath] });\n const item = (itemResult.value?.[itemPath] || null);\n\n const [classConfigured, cfg]: [boolean, RelatedItemClassConfiguration] = useMemo(() => {\n let classConfigured: boolean;\n let cfg: RelatedItemClassConfiguration;\n try {\n cfg = getRelatedItemClassConfiguration(classID);\n classConfigured = true;\n } catch (e) {\n cfg = {\n title: classID,\n itemView: () => <span>{itemID}</span>\n };\n classConfigured = false;\n }\n return [classConfigured, cfg];\n }, [itemID, classID, getRelatedItemClassConfiguration]);\n\n const Item = cfg.itemView;\n\n const classIDs = useMemo((() =>\n availableClassIDs ?? ((itemRef?.classID ?? '') !== '' ? [itemRef!.classID] : [])\n ), [availableClassIDs?.join(','), itemRef?.classID]);\n\n const hasItem = item !== null && classConfigured && isRegisterItem(item);\n const itemIsMissing = itemID !== '' && (item === null && !itemResult.isUpdating);\n const willShowItemView = hasItem || itemIsMissing || !onChange;\n const canJump = (item !== null || itemIsMissing) && classConfigured && !itemResult.isUpdating && (onJump || jumpTo);\n\n const jump = useCallback(function jump() {\n return onJump\n ? onJump()\n : jumpTo?.(`${Protocols.ITEM_DETAILS}:/${itemPathWithSubregister}`);\n }, [onJump, jumpTo]);\n\n const itemView: JSX.Element | null = useMemo(() => {\n let itemView: JSX.Element | null;\n\n if (hasItem) {\n itemView = <>\n <Item\n itemRef={{ classID, itemID, subregisterID }}\n itemData={item.data}\n /> <small>{cfg.title ?? 'unknown class'}</small>\n </>;\n } else {\n if (itemIsMissing) {\n itemView = <span>Item not found: {itemID ?? 'N/A'}</span>;\n } else {\n itemView = <span>Item not specified</span>;\n }\n }\n return itemView;\n }, [itemID, classID, subregisterID, item, hasItem, itemIsMissing]);\n\n const itemButtons = useMemo(() => {\n const canAutoCreateRelatedItem = itemID === '' && onCreateNew && !itemResult.isUpdating;\n const canChangeRelatedItem = /*classIDs.length >= 1 && */onChange && !itemResult.isUpdating;\n const canClear = onClear && itemID !== '' && !itemResult.isUpdating;\n\n let itemButtons: (ButtonProps & { title: string })[] = [];\n\n async function handleCreateNew() {\n if (!onCreateNew) { return; }\n const itemRef = await onCreateNew();\n console.debug(\"Created new item\", itemRef);\n }\n\n if (!hasItem && canAutoCreateRelatedItem) {\n itemButtons.push({\n onClick: handleCreateNew,\n icon: 'add',\n text: 'Auto create',\n intent: 'primary',\n title: \"Automatically create new item\",\n });\n }\n if (canChangeRelatedItem) {\n itemButtons.push({\n onClick: () => setSelectDialogState(true),\n icon: 'edit',\n text: willShowItemView ? undefined : 'Specify',\n intent: 'primary',\n title: \"Select related item\",\n /*disabled: classIDs.length < 1,*/\n });\n }\n if (canClear) {\n itemButtons.push({\n onClick: onClear,\n icon: 'eraser',\n intent: 'danger',\n title: \"Clear related item selection\",\n });\n }\n\n return itemButtons;\n }, [itemID, itemResult.isUpdating, onCreateNew, onChange, onClear]);\n\n //log.debug(\"Rendering generic related item view: got item\", item);\n return (\n <ControlGroup\n dir=\"ltr\"\n className={className}\n title={hasItem\n ? `${cfg.title ?? 'unknown class'} item ${itemID ?? 'with unknown ID'}`\n : undefined}\n {...controlGroupProps}>\n\n <InputGroup\n fill={hasItem}\n readOnly={!onChange && !onClear}\n onChange={() => void 0}\n inputRef={inputRef}\n css={css`\n /* leftElement which displays itemView */\n .bp4-input-left-container {\n top: unset;\n bottom: .45em;\n padding-left: 10px;\n padding-right: 5px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n\n max-width: 70%;\n }\n `}\n leftElement={itemView}\n value={itemID ?? ''}\n title={hasItem\n ? `${cfg.title ?? 'unknown class'} item ${itemID ?? 'with unknown ID'}`\n : undefined}\n />\n\n {canJump\n ? <Button outlined onClick={jump} icon=\"open-application\" />\n : null}\n\n {itemButtons.map((props, idx) =>\n <Button key={idx} outlined {...props} />\n )}\n\n {onChange\n ? <ItemSearchDrawer\n isOpen={selectDialogState}\n onClose={() => setSelectDialogState(false)}\n onChooseItem={onChange}\n availableClassIDs={classIDs}\n />\n : null}\n </ControlGroup>\n );\n};\n\n\nexport default GenericRelatedItemView;\n"]}
|
|
1
|
+
{"version":3,"file":"GenericRelatedItemView.js","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AAO,EAC/B,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,EACtB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,CAAA;;;;;;;;;;;;;SAaP,EACD,WAAW,EAAE,QAAQ,EACrB,KAAK,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,EACnB,KAAK,EAAE,OAAO;gBACZ,CAAC,CAAC,GAAG,MAAA,GAAG,CAAC,KAAK,mCAAI,eAAe,SAAS,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,iBAAiB,EAAE;gBACvE,CAAC,CAAC,SAAS,GACb;QAED,OAAO;YACN,CAAC,CAAC,IAAC,MAAM,IAAC,QAAQ,QAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAC,UAAU,GAAG;YACpD,CAAC,CAAC,IAAI;QAEP,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAC9B,IAAC,MAAM,IAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,WAAK,KAAK,GAAI,CACzC;QAED,IAAC,gBAAgB,IACf,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAC1C,YAAY,EAAE,QAAQ,EACtB,iBAAiB,EAAE,QAAQ,GAC3B;QAED,OAAO;YACN,CAAC,CAAC,IAAC,iBAAiB,IAChB,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,GAAG,EAAE,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAC3C,OAAO,EAAE,OAAO,GAChB;YACJ,CAAC,CAAC,IAAI,CAEK,CAChB,CAAC;AACJ,CAAC,CAAC;AAGF,eAAe,sBAAsB,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport { jsx, css } from '@emotion/react';\nimport React, { useContext, useCallback, useMemo, useState } from 'react';\nimport { InputGroup, Button, ControlGroup, type ControlGroupProps, type ButtonProps } from '@blueprintjs/core';\nimport {\n type GenericRelatedItemViewProps,\n type RelatedItemClassConfiguration,\n isRegisterItem,\n} from '../types';\nimport { BrowserCtx } from './BrowserCtx';\nimport { ChangeRequestContext } from './change-request/ChangeRequestContext';\nimport { isDrafted } from '../types/cr';\nimport ItemSearchDrawer from './ItemSearchDrawer';\nimport ItemDetailsDrawer from './ItemDetailsDrawer';\n\n\nconst DUMMY_REF = {\n classID: '',\n itemID: '',\n subregisterID: '',\n} as const;\n\n\nexport const GenericRelatedItemView: React.FC<GenericRelatedItemViewProps & {\n controlGroupProps?: ControlGroupProps\n}> = function ({\n itemRef, className,\n onCreateNew, onClear, onChange,\n availableClassIDs,\n onJump,\n inputRef,\n controlGroupProps,\n // availableSubregisterIDs,\n // itemSorter,\n}) {\n const {\n useRegisterItemData,\n getRelatedItemClassConfiguration,\n jumpTo,\n } = useContext(BrowserCtx);\n const { changeRequest: activeChangeRequest } = useContext(ChangeRequestContext);\n const { classID, itemID, subregisterID } = itemRef ?? DUMMY_REF;\n\n const itemPathWithClass = `${classID}/${itemID}.yaml`;\n // If curretn register has subregisters, specify subregister-relative path\n const itemPathWithSubregister = subregisterID\n ? `subregisters/${subregisterID}/${itemPathWithClass}`\n : `${itemPathWithClass}`;\n // If a change request is active\n // and this item is among clarifications or additions\n // then use item path relative to the change request\n const affectedByActiveCR = (\n activeChangeRequest &&\n isDrafted(activeChangeRequest) &&\n activeChangeRequest.items[itemPathWithSubregister]\n );\n const itemPath = affectedByActiveCR\n ? `/proposals/${activeChangeRequest.id}/items/${itemPathWithSubregister}`\n : `/${itemPathWithSubregister}`;\n\n const [selectDialogState, setSelectDialogState] = useState(false);\n const [peekingDrawerState, setPeekingDrawerState] = useState(false);\n\n //log.debug(\"Rendering generic related item view\", itemRef);\n //const { jumpToItem } = useContext(BrowserCtx);\n\n const itemResult = useRegisterItemData({ itemPaths: [itemPath] });\n const item = (itemResult.value?.[itemPath] || null);\n\n const [classConfigured, cfg]: [boolean, RelatedItemClassConfiguration] = useMemo(() => {\n let classConfigured: boolean;\n let cfg: RelatedItemClassConfiguration;\n try {\n cfg = getRelatedItemClassConfiguration(classID);\n classConfigured = true;\n } catch (e) {\n cfg = {\n title: classID,\n itemView: () => <span>{itemID}</span>\n };\n classConfigured = false;\n }\n return [classConfigured, cfg];\n }, [itemID, classID, getRelatedItemClassConfiguration]);\n\n const Item = cfg.itemView;\n\n const classIDs = useMemo((() =>\n availableClassIDs ?? ((itemRef?.classID ?? '') !== '' ? [itemRef!.classID] : [])\n ), [availableClassIDs?.join(','), itemRef?.classID]);\n\n const hasItem = item !== null && classConfigured && isRegisterItem(item);\n const itemIsMissing = itemID !== '' && (item === null && !itemResult.isUpdating);\n const willShowItemView = hasItem || itemIsMissing || !onChange;\n const canJump = (item !== null || itemIsMissing) && classConfigured && !itemResult.isUpdating && (onJump || jumpTo);\n\n const jump = useCallback(function jump() {\n return onJump\n ? onJump()\n : setPeekingDrawerState(true)\n }, [onJump, jumpTo]);\n\n const itemView: JSX.Element | null = useMemo(() => {\n let itemView: JSX.Element | null;\n\n if (hasItem) {\n itemView = <>\n <Item\n itemRef={{ classID, itemID, subregisterID }}\n itemData={item.data}\n /> <small>{cfg.title ?? 'unknown class'}</small>\n </>;\n } else {\n if (itemIsMissing) {\n itemView = <span>Item not found: {itemID ?? 'N/A'}</span>;\n } else {\n itemView = <span>Item not specified</span>;\n }\n }\n return itemView;\n }, [itemID, classID, subregisterID, item, hasItem, itemIsMissing]);\n\n const itemButtons = useMemo(() => {\n const canAutoCreateRelatedItem = itemID === '' && onCreateNew && !itemResult.isUpdating;\n const canChangeRelatedItem = /*classIDs.length >= 1 && */onChange && !itemResult.isUpdating;\n const canClear = onClear && itemID !== '' && !itemResult.isUpdating;\n\n let itemButtons: (ButtonProps & { title: string })[] = [];\n\n async function handleCreateNew() {\n if (!onCreateNew) { return; }\n const itemRef = await onCreateNew();\n console.debug(\"Created new item\", itemRef);\n }\n\n if (!hasItem && canAutoCreateRelatedItem) {\n itemButtons.push({\n onClick: handleCreateNew,\n icon: 'add',\n text: 'Auto create',\n intent: 'primary',\n title: \"Automatically create new item\",\n });\n }\n if (canChangeRelatedItem) {\n itemButtons.push({\n onClick: () => setSelectDialogState(true),\n icon: 'edit',\n text: willShowItemView ? undefined : 'Specify',\n intent: 'primary',\n title: \"Select related item\",\n /*disabled: classIDs.length < 1,*/\n });\n }\n if (canClear) {\n itemButtons.push({\n onClick: onClear,\n icon: 'eraser',\n intent: 'danger',\n title: \"Clear related item selection\",\n });\n }\n\n return itemButtons;\n }, [itemID, itemResult.isUpdating, onCreateNew, onChange, onClear]);\n\n //log.debug(\"Rendering generic related item view: got item\", item);\n return (\n <ControlGroup\n dir=\"ltr\"\n className={className}\n title={hasItem\n ? `${cfg.title ?? 'unknown class'} item ${itemID ?? 'with unknown ID'}`\n : undefined}\n {...controlGroupProps}>\n\n <InputGroup\n fill={hasItem}\n readOnly={!onChange && !onClear}\n onChange={() => void 0}\n inputRef={inputRef}\n css={css`\n /* leftElement which displays itemView */\n .bp4-input-left-container {\n top: unset;\n bottom: .45em;\n padding-left: 10px;\n padding-right: 5px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n\n max-width: 70%;\n }\n `}\n leftElement={itemView}\n value={itemID ?? ''}\n title={hasItem\n ? `${cfg.title ?? 'unknown class'} item ${itemID ?? 'with unknown ID'}`\n : undefined}\n />\n\n {canJump\n ? <Button outlined onClick={jump} icon=\"maximize\" />\n : null}\n\n {itemButtons.map((props, idx) =>\n <Button key={idx} outlined {...props} />\n )}\n\n <ItemSearchDrawer\n isOpen={selectDialogState}\n onClose={() => setSelectDialogState(false)}\n onChooseItem={onChange}\n availableClassIDs={classIDs}\n />\n\n {itemRef\n ? <ItemDetailsDrawer\n isOpen={peekingDrawerState}\n onClose={() => setPeekingDrawerState(false)}\n itemRef={itemRef}\n />\n : null}\n\n </ControlGroup>\n );\n};\n\n\nexport default GenericRelatedItemView;\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
/** @jsxFrag React.Fragment */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import type { InternalItemReference } from '../types';
|
|
5
|
+
declare const ItemDetailDrawer: React.FC<{
|
|
6
|
+
itemRef: InternalItemReference;
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
usePortal?: boolean;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
}>;
|
|
11
|
+
export default ItemDetailDrawer;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("@emotion/react");
|
|
9
|
+
|
|
10
|
+
var _react2 = require("react");
|
|
11
|
+
|
|
12
|
+
var _core = require("@blueprintjs/core");
|
|
13
|
+
|
|
14
|
+
var _context = require("@riboseinc/paneron-extension-kit/widgets/TabbedWorkspace/context");
|
|
15
|
+
|
|
16
|
+
var _RegisterItem = _interopRequireDefault(require("./detail/RegisterItem"));
|
|
17
|
+
|
|
18
|
+
var _protocolRegistry = require("./protocolRegistry");
|
|
19
|
+
|
|
20
|
+
var _itemPathUtils = require("./itemPathUtils");
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
/** @jsx jsx */
|
|
25
|
+
|
|
26
|
+
/** @jsxFrag React.Fragment */
|
|
27
|
+
const ItemDetailDrawer = function ({
|
|
28
|
+
itemRef,
|
|
29
|
+
usePortal,
|
|
30
|
+
isOpen,
|
|
31
|
+
onClose
|
|
32
|
+
}) {
|
|
33
|
+
const {
|
|
34
|
+
spawnTab
|
|
35
|
+
} = (0, _react2.useContext)(_context.TabbedWorkspaceContext);
|
|
36
|
+
const path = (0, _itemPathUtils.itemRefToItemPath)(itemRef);
|
|
37
|
+
return (0, _react.jsx)(_core.Drawer, {
|
|
38
|
+
isOpen: isOpen,
|
|
39
|
+
usePortal: usePortal,
|
|
40
|
+
onClose: onClose,
|
|
41
|
+
enforceFocus: false,
|
|
42
|
+
size: _core.DrawerSize.LARGE,
|
|
43
|
+
css: (0, _react.css)`display: flex; flex-flow: column nowrap;`,
|
|
44
|
+
style: {
|
|
45
|
+
padding: '0',
|
|
46
|
+
width: 'unset'
|
|
47
|
+
}
|
|
48
|
+
}, (0, _react.jsx)(_core.ButtonGroup, {
|
|
49
|
+
fill: true
|
|
50
|
+
}, (0, _react.jsx)(_core.Button, {
|
|
51
|
+
icon: "open-application",
|
|
52
|
+
onClick: () => {
|
|
53
|
+
onClose();
|
|
54
|
+
spawnTab(`${_protocolRegistry.Protocols.ITEM_DETAILS}:${path}`);
|
|
55
|
+
},
|
|
56
|
+
text: "Open in a tab"
|
|
57
|
+
}), (0, _react.jsx)(_core.Button, {
|
|
58
|
+
icon: "minimize",
|
|
59
|
+
onClick: onClose,
|
|
60
|
+
text: "Minimize"
|
|
61
|
+
})), (0, _react.jsx)("div", {
|
|
62
|
+
css: (0, _react.css)`position: relative; flex: 1;`
|
|
63
|
+
}, (0, _react.jsx)(_RegisterItem.default.main, {
|
|
64
|
+
uri: path
|
|
65
|
+
})));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
var _default = ItemDetailDrawer;
|
|
69
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemDetailsDrawer.js","sourceRoot":"","sources":["../../src/views/ItemDetailsDrawer.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAA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.Fragment */\n\nimport { jsx, css } from '@emotion/react';\nimport React, { useContext } from 'react';\nimport { Button, ButtonGroup, Drawer, DrawerSize } from '@blueprintjs/core';\nimport type { InternalItemReference } from '../types';\nimport { TabbedWorkspaceContext } from '@riboseinc/paneron-extension-kit/widgets/TabbedWorkspace/context';\nimport MaybeItemDetail from './detail/RegisterItem';\nimport { Protocols } from './protocolRegistry';\nimport { itemRefToItemPath } from './itemPathUtils';\n\n\nconst ItemDetailDrawer: React.FC<{\n itemRef: InternalItemReference\n isOpen: boolean\n usePortal?: boolean\n onClose: () => void\n}> = function ({ itemRef, usePortal, isOpen, onClose }) {\n const { spawnTab } = useContext(TabbedWorkspaceContext);\n const path = itemRefToItemPath(itemRef);\n\n return (\n <Drawer\n isOpen={isOpen}\n usePortal={usePortal}\n onClose={onClose}\n enforceFocus={false}\n size={DrawerSize.LARGE}\n css={css`display: flex; flex-flow: column nowrap;`}\n style={{ padding: '0', width: 'unset' }}>\n <ButtonGroup fill>\n <Button\n icon=\"open-application\"\n onClick={() => { onClose(); spawnTab(`${Protocols.ITEM_DETAILS}:${path}`); }}\n text=\"Open in a tab\"\n />\n <Button\n icon=\"minimize\"\n onClick={onClose}\n text=\"Minimize\"\n />\n </ButtonGroup>\n <div css={css`position: relative; flex: 1;`}>\n <MaybeItemDetail.main uri={path} />\n </div>\n </Drawer>\n );\n};\n\n\nexport default ItemDetailDrawer;\n"]}
|
|
@@ -5,7 +5,7 @@ import type { InternalItemReference } from '../types';
|
|
|
5
5
|
declare const ItemSearchDrawer: React.FC<{
|
|
6
6
|
isOpen: boolean;
|
|
7
7
|
onClose: () => void;
|
|
8
|
-
onChooseItem
|
|
8
|
+
onChooseItem?: (itemRef: InternalItemReference) => void;
|
|
9
9
|
availableClassIDs: string[];
|
|
10
10
|
}>;
|
|
11
11
|
export default ItemSearchDrawer;
|
|
@@ -40,13 +40,14 @@ const ItemSearchDrawer = function ({
|
|
|
40
40
|
criteria: classCriteria
|
|
41
41
|
} : undefined, [classCriteria]);
|
|
42
42
|
const handleOpenItem = (0, _react2.useCallback)(itemPath => {
|
|
43
|
-
onChooseItem((0, _itemPathUtils.itemPathToItemRef)(subregisters !== undefined, itemPath));
|
|
43
|
+
onChooseItem === null || onChooseItem === void 0 ? void 0 : onChooseItem((0, _itemPathUtils.itemPathToItemRef)(subregisters !== undefined, itemPath));
|
|
44
44
|
onClose();
|
|
45
45
|
}, [onChooseItem, onClose]);
|
|
46
46
|
return (0, _react.jsx)(_core.Drawer, {
|
|
47
47
|
isOpen: isOpen,
|
|
48
48
|
onClose: onClose,
|
|
49
49
|
enforceFocus: false,
|
|
50
|
+
size: "50vw",
|
|
50
51
|
style: {
|
|
51
52
|
padding: '0',
|
|
52
53
|
width: 'unset'
|
|
@@ -54,14 +55,14 @@ const ItemSearchDrawer = function ({
|
|
|
54
55
|
}, (0, _react.jsx)(_Search.default, {
|
|
55
56
|
style: {
|
|
56
57
|
height: '100vh',
|
|
57
|
-
width: '
|
|
58
|
+
width: '50vw',
|
|
58
59
|
minWidth: '500px',
|
|
59
|
-
maxWidth: '
|
|
60
|
+
maxWidth: '90vw'
|
|
60
61
|
},
|
|
61
62
|
availableClassIDs: availableClassIDs,
|
|
62
63
|
implicitCriteria: implicitCriteria,
|
|
63
64
|
stateName: "superseding-item-selector-search",
|
|
64
|
-
onOpenItem: handleOpenItem
|
|
65
|
+
onOpenItem: onChooseItem ? handleOpenItem : undefined
|
|
65
66
|
}));
|
|
66
67
|
};
|
|
67
68
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemSearchDrawer.js","sourceRoot":"","sources":["../../src/views/ItemSearchDrawer.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAc,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAA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,KAAK,EAAE,OAAO,EAAE;QACzC,IAAC,MAAM,IACL,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAC9E,iBAAiB,EAAE,iBAAiB,EACpC,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAC,kCAAkC,EAC5C,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,GACrD,CACK,CACV,CAAC;AACJ,CAAC,CAAC;AAGF,eAAe,gBAAgB,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport { jsx } from '@emotion/react';\nimport React, { useContext, useMemo, useCallback } from 'react';\nimport { Drawer } from '@blueprintjs/core';\nimport type { InternalItemReference } from '../types';\nimport type { Criterion, CriteriaGroup } from './FilterCriteria/models';\nimport { BrowserCtx } from './BrowserCtx';\nimport Search from './sidebar/Search';\nimport { itemPathToItemRef } from './itemPathUtils';\n\n\nconst ItemSearchDrawer: React.FC<{\n isOpen: boolean\n onClose: () => void\n onChooseItem?: (itemRef: InternalItemReference) => void\n availableClassIDs: string[]\n}> = function ({\n isOpen, onClose, onChooseItem,\n availableClassIDs,\n}) {\n const { subregisters } = useContext(BrowserCtx);\n\n const classCriteria: Criterion[] = useMemo(() => (\n availableClassIDs.map(clsID => ({\n key: 'item-class',\n query: `objPath.indexOf(\\\"/${clsID}/\\\") >= 0`,\n }))\n ), [availableClassIDs.toString()]);\n\n const implicitCriteria: CriteriaGroup | undefined = useMemo(() => (\n classCriteria.length > 0\n ? {\n require: 'any',\n criteria: classCriteria,\n }\n : undefined\n ), [classCriteria]);\n\n const handleOpenItem = useCallback((itemPath) => {\n onChooseItem?.(itemPathToItemRef(subregisters !== undefined, itemPath));\n onClose();\n }, [onChooseItem, onClose]);\n\n return (\n <Drawer\n isOpen={isOpen}\n onClose={onClose}\n enforceFocus={false}\n size=\"50vw\"\n style={{ padding: '0', width: 'unset' }}>\n <Search\n style={{ height: '100vh', width: '50vw', minWidth: '500px', maxWidth: '90vw' }}\n availableClassIDs={availableClassIDs}\n implicitCriteria={implicitCriteria}\n stateName=\"superseding-item-selector-search\"\n onOpenItem={onChooseItem ? handleOpenItem : undefined}\n />\n </Drawer>\n );\n};\n\n\nexport default ItemSearchDrawer;\n"]}
|
|
@@ -6,12 +6,13 @@ import type { ChangeProposal, Clarification, InternalItemReference, Payload, Reg
|
|
|
6
6
|
import type { Drafted } from '../../types/cr';
|
|
7
7
|
interface ProposalBrowserProps<CR extends Drafted> {
|
|
8
8
|
proposals: CR['items'];
|
|
9
|
+
selectedItem?: (string & keyof CR['items']) | null;
|
|
10
|
+
onSelectItem: (selectedItem: (string & keyof CR['items']) | null) => void;
|
|
9
11
|
/**
|
|
10
12
|
* If provided, button to delete each proposed change
|
|
11
13
|
* is shown in change card list mode.
|
|
12
14
|
*/
|
|
13
15
|
onDeleteProposalForItemAtPath?: (itemPath: string) => void;
|
|
14
|
-
className?: string;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Shows a list of individual proposed changes as cards by default,
|
|
@@ -19,7 +20,7 @@ interface ProposalBrowserProps<CR extends Drafted> {
|
|
|
19
20
|
*
|
|
20
21
|
* If no proposals exist, returns null.
|
|
21
22
|
*/
|
|
22
|
-
export declare function Proposals<CR extends Drafted>({ proposals, onDeleteProposalForItemAtPath,
|
|
23
|
+
export declare function Proposals<CR extends Drafted>({ proposals, onDeleteProposalForItemAtPath, selectedItem, onSelectItem: selectProposal }: ProposalBrowserProps<CR>): jsx.JSX.Element;
|
|
23
24
|
interface ProposalProps<P extends ChangeProposal> {
|
|
24
25
|
proposal: P;
|
|
25
26
|
/** Highlight changes. */
|
|
@@ -59,12 +59,13 @@ function stringifiedJSONEqual(i1, i2) {
|
|
|
59
59
|
function Proposals({
|
|
60
60
|
proposals,
|
|
61
61
|
onDeleteProposalForItemAtPath,
|
|
62
|
-
|
|
62
|
+
selectedItem,
|
|
63
|
+
onSelectItem: selectProposal
|
|
63
64
|
}) {
|
|
64
|
-
var _a
|
|
65
|
+
var _a;
|
|
65
66
|
|
|
66
|
-
const [
|
|
67
|
-
const
|
|
67
|
+
const [preferDiff, setPreferDiff] = (0, _react.useState)(false);
|
|
68
|
+
const selectedProposal = selectedItem !== null && selectedItem !== void 0 ? selectedItem : null; // TODO: Temporarily unsupported
|
|
68
69
|
// (limitations of current change annotation implementation)
|
|
69
70
|
//const [ showOnlyChanged, setShowOnlyChanged ] = useState(true);
|
|
70
71
|
|
|
@@ -150,156 +151,134 @@ function Proposals({
|
|
|
150
151
|
};
|
|
151
152
|
}), [proposals, getCurrentItem, getProposedItem]);
|
|
152
153
|
const haveSelectedItem = selectedProposal && selectedItemRef && proposals[selectedProposal] && (selectedItemProposed || selectedItemCurrent);
|
|
153
|
-
const proposalCount = Object.keys(proposals).length;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}, [selectedProposal === null]);
|
|
154
|
+
const proposalCount = Object.keys(proposals).length; //useEffect(() => {
|
|
155
|
+
// // if (!selectedProposal) {
|
|
156
|
+
// // const firstProposal = Object.keys(proposals)[0];
|
|
157
|
+
// // if (firstProposal) {
|
|
158
|
+
// // if (getCurrentItem(firstProposal) || getProposedItem(firstProposal)) {
|
|
159
|
+
// // selectProposal(firstProposal);
|
|
160
|
+
// // }
|
|
161
|
+
// // }
|
|
162
|
+
// // }
|
|
163
|
+
// if (selectedProposal) {
|
|
164
|
+
// if (selectedProposalDetailRef.current) {
|
|
165
|
+
// selectedProposalDetailRef.current.scrollIntoView({ block: 'center' });
|
|
166
|
+
// }
|
|
167
|
+
// }
|
|
168
|
+
//}, [selectedProposal === null]);
|
|
169
|
+
|
|
172
170
|
const canShowDiff = haveSelectedItem && ((_a = proposals[selectedProposal]) === null || _a === void 0 ? void 0 : _a.type) === 'clarification' ? true : false;
|
|
173
171
|
const showDiff = canShowDiff && preferDiff;
|
|
172
|
+
const selectedItemSummary = haveSelectedItem ? (0, _react2.jsx)(ProposalSummary, {
|
|
173
|
+
itemRef: selectedItemRef,
|
|
174
|
+
item: selectedItemProposed !== null && selectedItemProposed !== void 0 ? selectedItemProposed : selectedItemCurrent,
|
|
175
|
+
itemBefore: selectedItemCurrent !== null && selectedItemCurrent !== void 0 ? selectedItemCurrent : undefined,
|
|
176
|
+
proposal: proposals[selectedProposal]
|
|
177
|
+
}) : (0, _react2.jsx)(_react.default.Fragment, null, "Select item\u2026");
|
|
178
|
+
const icon = haveSelectedItem ? getProposalIcon(proposals[selectedProposal]) : undefined;
|
|
179
|
+
const selectedItemDrawer = (0, _react.useMemo)(() => {
|
|
180
|
+
var _a;
|
|
174
181
|
|
|
175
|
-
|
|
176
|
-
|
|
182
|
+
return (0, _react2.jsx)(_core.Drawer, {
|
|
183
|
+
isOpen: proposalCount > 0 && haveSelectedItem ? true : false,
|
|
184
|
+
onClose: () => selectProposal(null),
|
|
185
|
+
size: _core.DrawerSize.LARGE,
|
|
186
|
+
enforceFocus: false
|
|
187
|
+
}, proposalCount > 0 && haveSelectedItem ? (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_core.ButtonGroup, null, (0, _react2.jsx)(_core.Button, {
|
|
188
|
+
disabled: !jumpTo || ((_a = proposals[selectedProposal]) === null || _a === void 0 ? void 0 : _a.type) === 'addition',
|
|
189
|
+
icon: 'open-application',
|
|
190
|
+
onClick: () => jumpTo === null || jumpTo === void 0 ? void 0 : jumpTo(`${_protocolRegistry.Protocols.ITEM_DETAILS}:${selectedProposal}`),
|
|
191
|
+
title: "Open selected item in a new tab (not applicable to proposed additions)"
|
|
192
|
+
}), (0, _react2.jsx)(_core.Button, {
|
|
193
|
+
active: preferDiff,
|
|
194
|
+
onClick: () => setPreferDiff(v => !v),
|
|
195
|
+
// Diffing only makes sense for clarifications.
|
|
196
|
+
// Additions are entire new items, and for amendments
|
|
197
|
+
// item data is unchanged.
|
|
198
|
+
disabled: !canShowDiff,
|
|
199
|
+
text: "Compare",
|
|
200
|
+
title: "Annotate proposed clarifications for this item"
|
|
201
|
+
}), (0, _react2.jsx)(_react2.ClassNames, null, ({
|
|
202
|
+
css: css2
|
|
203
|
+
}) => (0, _react2.jsx)(_select.Select2, {
|
|
204
|
+
filterable: false,
|
|
205
|
+
itemsEqual: stringifiedJSONEqual,
|
|
206
|
+
menuProps: {
|
|
207
|
+
className: css2(`max-height: 50vh; overflow-y: auto;`)
|
|
208
|
+
},
|
|
209
|
+
activeItem: activeItem,
|
|
210
|
+
items: allItems,
|
|
211
|
+
popoverProps: {
|
|
212
|
+
minimal: true,
|
|
213
|
+
matchTargetWidth: true
|
|
214
|
+
},
|
|
215
|
+
fill: true,
|
|
216
|
+
itemRenderer: ChangeProposalItemView,
|
|
217
|
+
onItemSelect: handleItemSelect
|
|
218
|
+
}, (0, _react2.jsx)(_core.Button, {
|
|
219
|
+
fill: true,
|
|
220
|
+
rightIcon: "chevron-down",
|
|
221
|
+
icon: icon,
|
|
222
|
+
title: "Switch between items in this proposal",
|
|
223
|
+
css: (0, _react2.css)`white-space: nowrap;`
|
|
224
|
+
}, selectedItemSummary))), (0, _react2.jsx)(_core.Button, {
|
|
225
|
+
onClick: () => selectProposal(null),
|
|
226
|
+
icon: "minimize",
|
|
227
|
+
title: "Minimize proposed change view",
|
|
228
|
+
text: "Minimize"
|
|
229
|
+
})), (0, _react2.jsx)("div", {
|
|
230
|
+
css: (0, _react2.css)`position: relative; flex: 1;`
|
|
231
|
+
}, (0, _react2.jsx)(_BrowserCtx.BrowserCtx.Provider, {
|
|
232
|
+
value: proposalBrowserCtx
|
|
233
|
+
}, (0, _react2.jsx)(_ErrorBoundary.default, {
|
|
234
|
+
viewName: "Proposal detail"
|
|
235
|
+
}, (0, _react2.jsx)(ProposalDetail, {
|
|
177
236
|
itemRef: selectedItemRef,
|
|
237
|
+
showDiff: showDiff,
|
|
238
|
+
//showOnlyChanged={showOnlyChanged}
|
|
178
239
|
item: selectedItemProposed !== null && selectedItemProposed !== void 0 ? selectedItemProposed : selectedItemCurrent,
|
|
179
240
|
itemBefore: selectedItemCurrent !== null && selectedItemCurrent !== void 0 ? selectedItemCurrent : undefined,
|
|
180
241
|
proposal: proposals[selectedProposal]
|
|
181
|
-
}) :
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
flex-flow: column nowrap;
|
|
199
|
-
transition:
|
|
200
|
-
width .5s linear
|
|
201
|
-
height .5s linear;
|
|
202
|
-
`,
|
|
203
|
-
className: className
|
|
204
|
-
}, (0, _react2.jsx)(_core.ButtonGroup, null, (0, _react2.jsx)(_core.Button, {
|
|
205
|
-
disabled: !jumpTo || ((_b = proposals[selectedProposal]) === null || _b === void 0 ? void 0 : _b.type) === 'addition',
|
|
206
|
-
icon: 'open-application',
|
|
207
|
-
onClick: () => jumpTo === null || jumpTo === void 0 ? void 0 : jumpTo(`${_protocolRegistry.Protocols.ITEM_DETAILS}:${selectedProposal}`),
|
|
208
|
-
title: "Open selected item in a new tab (not applicable to proposed additions)"
|
|
209
|
-
}), (0, _react2.jsx)(_core.Button, {
|
|
210
|
-
active: preferDiff,
|
|
211
|
-
onClick: () => setPreferDiff(v => !v),
|
|
212
|
-
// Diffing only makes sense for clarifications.
|
|
213
|
-
// Additions are entire new items, and for amendments
|
|
214
|
-
// item data is unchanged.
|
|
215
|
-
disabled: !canShowDiff,
|
|
216
|
-
text: "Compare",
|
|
217
|
-
title: "Annotate proposed clarifications for this item"
|
|
218
|
-
}), (0, _react2.jsx)(_react2.ClassNames, null, ({
|
|
219
|
-
css: css2
|
|
220
|
-
}) => (0, _react2.jsx)(_select.Select2, {
|
|
221
|
-
filterable: false,
|
|
222
|
-
itemsEqual: stringifiedJSONEqual,
|
|
223
|
-
menuProps: {
|
|
224
|
-
className: css2(`max-height: 50vh; overflow-y: auto;`)
|
|
225
|
-
},
|
|
226
|
-
activeItem: activeItem,
|
|
227
|
-
items: allItems,
|
|
228
|
-
popoverProps: {
|
|
229
|
-
minimal: true,
|
|
230
|
-
matchTargetWidth: true
|
|
231
|
-
},
|
|
232
|
-
fill: true,
|
|
233
|
-
itemRenderer: ChangeProposalItemView,
|
|
234
|
-
onItemSelect: handleItemSelect
|
|
235
|
-
}, (0, _react2.jsx)(_core.Button, {
|
|
236
|
-
fill: true,
|
|
237
|
-
rightIcon: "chevron-down",
|
|
238
|
-
icon: icon,
|
|
239
|
-
css: (0, _react2.css)`white-space: nowrap;`
|
|
240
|
-
}, selectedItemSummary))), (0, _react2.jsx)(_core.Button, {
|
|
241
|
-
onClick: () => selectProposal(null),
|
|
242
|
-
icon: "minimize",
|
|
243
|
-
title: "Minimize proposed change view",
|
|
244
|
-
text: "Minimize"
|
|
245
|
-
})), (0, _react2.jsx)("div", {
|
|
246
|
-
css: (0, _react2.css)`position: relative; flex: 1;`,
|
|
247
|
-
ref: selectedProposalDetailRef
|
|
248
|
-
}, (0, _react2.jsx)(_BrowserCtx.BrowserCtx.Provider, {
|
|
249
|
-
value: proposalBrowserCtx
|
|
250
|
-
}, (0, _react2.jsx)(_ErrorBoundary.default, {
|
|
251
|
-
viewName: "Proposal detail"
|
|
252
|
-
}, (0, _react2.jsx)(ProposalDetail, {
|
|
253
|
-
itemRef: selectedItemRef,
|
|
254
|
-
showDiff: showDiff,
|
|
255
|
-
//showOnlyChanged={showOnlyChanged}
|
|
256
|
-
item: selectedItemProposed !== null && selectedItemProposed !== void 0 ? selectedItemProposed : selectedItemCurrent,
|
|
257
|
-
itemBefore: selectedItemCurrent !== null && selectedItemCurrent !== void 0 ? selectedItemCurrent : undefined,
|
|
258
|
-
proposal: proposals[selectedProposal]
|
|
259
|
-
})))));
|
|
260
|
-
} else {
|
|
261
|
-
return (0, _react2.jsx)(_react.default.Fragment, null, allItems.map(cpi => {
|
|
262
|
-
const actions = [{
|
|
263
|
-
onClick: () => selectProposal(cpi.itemPath),
|
|
264
|
-
text: "Expand",
|
|
265
|
-
title: "Expand proposed change to see item details",
|
|
266
|
-
icon: 'maximize'
|
|
267
|
-
}];
|
|
268
|
-
|
|
269
|
-
if (onDeleteProposalForItemAtPath) {
|
|
270
|
-
actions.push({
|
|
271
|
-
text: "Delete this proposal",
|
|
272
|
-
intent: 'danger',
|
|
273
|
-
onClick: () => onDeleteProposalForItemAtPath(cpi.itemPath),
|
|
274
|
-
icon: 'trash'
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return (0, _react2.jsx)(_Block.HomeBlockCard, {
|
|
279
|
-
css: (0, _react2.css)`
|
|
280
|
-
flex-basis: calc(33.33% - 10px*2/3);
|
|
281
|
-
`,
|
|
282
|
-
description: `${cpi.proposal.type} proposal`,
|
|
283
|
-
key: cpi.itemPath
|
|
284
|
-
}, (0, _react2.jsx)(ProposalType, {
|
|
285
|
-
item: cpi
|
|
286
|
-
}), (0, _react2.jsx)("div", {
|
|
287
|
-
css: (0, _react2.css)`padding: 5px; flex-grow: 1;`
|
|
288
|
-
}, cpi.item !== null ? (0, _react2.jsx)(_core.H5, {
|
|
289
|
-
css: (0, _react2.css)`margin: 0; overflow: hidden; text-overflow: ellipsis;`
|
|
290
|
-
}, (0, _react2.jsx)(ProposalSummary, {
|
|
291
|
-
itemRef: cpi.itemRef,
|
|
292
|
-
proposal: cpi.proposal,
|
|
293
|
-
itemBefore: cpi.itemBefore,
|
|
294
|
-
item: cpi.item
|
|
295
|
-
})) : (0, _react2.jsx)(_react.default.Fragment, null, "Problem reading proposed item data.")), actions.length > 0 ? (0, _react2.jsx)(_Block.HomeBlockActions, {
|
|
296
|
-
actions: actions
|
|
297
|
-
}) : null);
|
|
298
|
-
}));
|
|
242
|
+
}))))) : null);
|
|
243
|
+
}, [proposalCount > 0, haveSelectedItem, selectedItemProposed, selectedItemCurrent, preferDiff, jumpTo, handleItemSelect, selectedProposal && proposals[selectedProposal]]);
|
|
244
|
+
return (0, _react2.jsx)(_react.default.Fragment, null, selectedItemDrawer, allItems.map(cpi => {
|
|
245
|
+
const actions = [{
|
|
246
|
+
onClick: () => selectProposal(cpi.itemPath),
|
|
247
|
+
text: "Expand",
|
|
248
|
+
title: "Expand proposed change to see item details",
|
|
249
|
+
icon: 'maximize'
|
|
250
|
+
}];
|
|
251
|
+
|
|
252
|
+
if (onDeleteProposalForItemAtPath) {
|
|
253
|
+
actions.push({
|
|
254
|
+
text: "Delete this proposal",
|
|
255
|
+
intent: 'danger',
|
|
256
|
+
onClick: () => onDeleteProposalForItemAtPath(cpi.itemPath),
|
|
257
|
+
icon: 'trash'
|
|
258
|
+
});
|
|
299
259
|
}
|
|
300
|
-
|
|
301
|
-
return
|
|
302
|
-
|
|
260
|
+
|
|
261
|
+
return (0, _react2.jsx)(_Block.HomeBlockCard, {
|
|
262
|
+
css: (0, _react2.css)`
|
|
263
|
+
flex-basis: calc(33.33% - 10px*2/3);
|
|
264
|
+
`,
|
|
265
|
+
description: `${cpi.proposal.type} proposal`,
|
|
266
|
+
key: cpi.itemPath
|
|
267
|
+
}, (0, _react2.jsx)(ProposalType, {
|
|
268
|
+
item: cpi
|
|
269
|
+
}), (0, _react2.jsx)("div", {
|
|
270
|
+
css: (0, _react2.css)`padding: 5px; flex-grow: 1;`
|
|
271
|
+
}, cpi.item !== null ? (0, _react2.jsx)(_core.H5, {
|
|
272
|
+
css: (0, _react2.css)`margin: 0; overflow: hidden; text-overflow: ellipsis;`
|
|
273
|
+
}, (0, _react2.jsx)(ProposalSummary, {
|
|
274
|
+
itemRef: cpi.itemRef,
|
|
275
|
+
proposal: cpi.proposal,
|
|
276
|
+
itemBefore: cpi.itemBefore,
|
|
277
|
+
item: cpi.item
|
|
278
|
+
})) : (0, _react2.jsx)(_react.default.Fragment, null, "Problem reading proposed item data.")), actions.length > 0 ? (0, _react2.jsx)(_Block.HomeBlockActions, {
|
|
279
|
+
actions: actions
|
|
280
|
+
}) : null);
|
|
281
|
+
}));
|
|
303
282
|
}
|
|
304
283
|
|
|
305
284
|
;
|