@riboseinc/paneron-registry-kit 2.2.35 → 2.2.36

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riboseinc/paneron-registry-kit",
3
- "version": "2.2.35",
3
+ "version": "2.2.36",
4
4
  "main": "index.js",
5
5
  "author": "Ribose Inc. <open.source@ribose.com>",
6
6
  "scripts": {
@@ -4,6 +4,13 @@ import { jsx } from '@emotion/react';
4
4
  import type { Drafted } from './types';
5
5
  interface ProposalBrowserProps<CR extends Drafted> {
6
6
  proposals: CR['items'];
7
+ /**
8
+ * Whether the proposal had been accepted.
9
+ * Influences the jump to current version of the item behavior
10
+ * (for non-accepted proposals, jumping to additions is not allowed
11
+ * since they would not be present in the registry).
12
+ */
13
+ hadBeenAccepted?: boolean;
7
14
  selectedItem?: (string & keyof CR['items']) | null;
8
15
  onSelectItem: (selectedItem: (string & keyof CR['items']) | null) => void;
9
16
  /**
@@ -18,5 +25,5 @@ interface ProposalBrowserProps<CR extends Drafted> {
18
25
  *
19
26
  * If no proposals exist, returns null.
20
27
  */
21
- export declare function ProposalBrowser<CR extends Drafted>({ proposals, onDeleteProposalForItemAtPath, selectedItem, onSelectItem: selectProposal }: ProposalBrowserProps<CR>): jsx.JSX.Element;
28
+ export declare function ProposalBrowser<CR extends Drafted>({ proposals, hadBeenAccepted, onDeleteProposalForItemAtPath, selectedItem, onSelectItem: selectProposal }: ProposalBrowserProps<CR>): jsx.JSX.Element;
22
29
  export default ProposalBrowser;
@@ -46,6 +46,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
46
46
  */
47
47
  function ProposalBrowser({
48
48
  proposals,
49
+ hadBeenAccepted,
49
50
  onDeleteProposalForItemAtPath,
50
51
  selectedItem,
51
52
  onSelectItem: selectProposal
@@ -168,7 +169,7 @@ function ProposalBrowser({
168
169
  size: _core.DrawerSize.LARGE,
169
170
  enforceFocus: false
170
171
  }, proposalCount > 0 && haveSelectedItem ? (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_core.ButtonGroup, null, (0, _react2.jsx)(_core.Button, {
171
- disabled: !jumpTo || ((_a = proposals[selectedProposal]) === null || _a === void 0 ? void 0 : _a.type) === 'addition',
172
+ disabled: !jumpTo || ((_a = proposals[selectedProposal]) === null || _a === void 0 ? void 0 : _a.type) === 'addition' && !hadBeenAccepted,
172
173
  icon: 'open-application',
173
174
  onClick: () => jumpTo === null || jumpTo === void 0 ? void 0 : jumpTo(`${_protocolRegistry.Protocols.ITEM_DETAILS}:${selectedProposal}`),
174
175
  title: "Open selected item in a new tab (not applicable to proposed additions)"
@@ -1 +1 @@
1
- {"version":3,"file":"ProposalBrowser.js","sourceRoot":"","sources":["../../src/proposals/ProposalBrowser.tsx"],"names":[],"mappings":"AACA,eAAe;AACf,8BAA8B;AAE9B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE5E,OAAO,aAAa,MAAM,wDAAwD,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAqC,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAiB,MAAM,2BAA2B,CAAC;AAGrE,OAAO,EAA2B,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAClG,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,cAAc,MAAM,kBAAkB,CAA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AAoB,cAApB,oBAAoB,GAAI,mBAAmB,CAAE,EACpD,UAAU,EAAE,mBAAmB,aAAnB,mBAAmB,cAAnB,mBAAmB,GAAI,SAAS,EAC5C,QAAQ,EAAE,SAAS,CAAC,gBAAgB,CAAC,GACrC,CACY,CACI,CAClB,CACL;YACL,CAAC,CAAC,IAAI,CACD,CAAA;KAAA,CACV,EAAE,CAAC,aAAa,GAAG,CAAC,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAEhK,OAAO,CACL,0BACG,kBAAkB,CAClB,CACJ,CAAC;AACJ,CAAC;AAAA,CAAC;AAEF,SAAS,oBAAoB,CAAC,EAAO,EAAE,EAAO;IAC5C,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,eAAe,eAAe,CAAC","sourcesContent":["\n/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport React, { useContext, useCallback, useMemo } from 'react';\nimport { ClassNames, jsx, css } from '@emotion/react';\nimport { Select2 as Select } from '@blueprintjs/select';\nimport { ButtonGroup, Button, Drawer, DrawerSize } from '@blueprintjs/core';\n\nimport ErrorBoundary from '@riboseinc/paneron-extension-kit/widgets/ErrorBoundary';\n\nimport { useItemRef, itemPathToItemRef } from '../views/itemPathUtils';\nimport { BrowserCtx, type BrowserCtx as BrowserCtxType } from '../views/BrowserCtx';\nimport { Protocols, type Protocol } from '../views/protocolRegistry';\n\nimport type { Drafted } from './types';\nimport { type ChangeProposalItem, ChangeProposalItemView, getProposalIcon } from './ProposalItem';\nimport ProposalSummary from './ProposalSummary';\nimport ProposalDetail from './ProposalDetail';\n\n\ninterface ProposalBrowserProps<CR extends Drafted> {\n proposals: CR['items']\n\n selectedItem?: (string & keyof CR['items']) | null\n onSelectItem: (selectedItem: (string & keyof CR['items']) | null) => void\n\n /**\n * If provided, button to delete each proposed change\n * is shown in change card list mode.\n */\n onDeleteProposalForItemAtPath?: (itemPath: string) => void\n}\n/**\n * Shows a list of individual proposed changes as cards by default,\n * allowing to expand a proposal and view item details.\n *\n * If no proposals exist, returns null.\n */\nexport function ProposalBrowser<CR extends Drafted>\n({ proposals, onDeleteProposalForItemAtPath, selectedItem, onSelectItem: selectProposal }:\nProposalBrowserProps<CR>) {\n const selectedProposal = selectedItem ?? null;\n\n // TODO: Temporarily unsupported\n // (limitations of current change annotation implementation)\n //const [ showOnlyChanged, setShowOnlyChanged ] = useState(true);\n\n const outerBrowserCtx = useContext(BrowserCtx);\n const { jumpTo, subregisters, useRegisterItemData } = outerBrowserCtx;\n\n /**\n * When jumping to an item affected by current CR,\n * jump in-CR instead of spawning tab.\n */\n const handleCRJump = useCallback(function _handleCRJump(uri: `${Protocol}:${string}`): void {\n if (uri.startsWith(Protocols.ITEM_DETAILS)) {\n const itemPath = uri.split(':')[1];\n if (proposals[itemPath]) {\n selectProposal(itemPath);\n } else {\n jumpTo?.(uri);\n }\n }\n }, [Object.keys(proposals), jumpTo]);\n\n const proposalBrowserCtx: BrowserCtxType = useMemo((() => ({\n ...outerBrowserCtx,\n jumpTo: handleCRJump,\n })), [handleCRJump, outerBrowserCtx]);\n\n /** Paths of register items in proposal. */\n const proposedItemPaths = Object.entries(proposals).map(([itemPath, proposal]) => {\n if (proposal.type === 'clarification' || proposal.type === 'addition') {\n return itemPath;\n } else {\n return undefined;\n }\n }).filter(s => s !== undefined) as string[];\n\n /** Proposed data of register items in proposal. */\n const proposedItemDataReq = useRegisterItemData({\n itemPaths: proposedItemPaths,\n });\n\n /** Pre-existing data of register items in proposal. */\n const currentItemDataReq = useRegisterItemData({\n itemPaths: Object.keys(proposals),\n ignoreActiveCR: true,\n });\n\n const getCurrentItem = useCallback(\n ((itemPath: string) => currentItemDataReq.value[itemPath] ?? null),\n [currentItemDataReq.value]);\n const getProposedItem = useCallback(\n ((itemPath: string) => proposedItemDataReq.value[itemPath] ?? null),\n [proposedItemDataReq.value]);\n\n /** Current register item (if any) corresponding to selected proposal. */\n const selectedItemCurrent = selectedProposal ? getCurrentItem(selectedProposal) : null;\n\n /** Proposed register item corresponding to selected proposal. */\n const selectedItemProposed = selectedProposal ? getProposedItem(selectedProposal) : null;\n\n const selectedItemRef = useItemRef(subregisters !== undefined, selectedProposal);\n\n const handleItemSelect = useCallback(\n ((item: ChangeProposalItem) => selectProposal(item.itemPath)),\n [selectProposal]);\n\n const activeItem: ChangeProposalItem | null = useMemo((() =>\n selectedProposal\n ? ({\n itemPath: selectedProposal,\n proposal: proposals[selectedProposal],\n item: (selectedItemProposed ?? selectedItemCurrent)!,\n itemBefore: selectedItemCurrent ?? undefined,\n itemRef: itemPathToItemRef(subregisters !== undefined, selectedProposal),\n })\n : null\n ), [selectedProposal, proposals, subregisters]);\n\n const allItems: ChangeProposalItem[] = useMemo((() =>\n Object.entries(proposals).map(([itemPath, proposal]) => ({\n itemPath,\n proposal,\n item: (getProposedItem(itemPath) ?? getCurrentItem(itemPath))! ?? null,\n itemBefore: undefined,\n itemRef: itemPathToItemRef(subregisters !== undefined, itemPath),\n }))\n ), [proposals, getCurrentItem, getProposedItem, subregisters !== undefined]);\n\n const haveSelectedItem =\n selectedProposal\n && selectedItemRef\n && proposals[selectedProposal]\n && (selectedItemProposed || selectedItemCurrent);\n\n const proposalCount = Object.keys(proposals).length;\n\n //useEffect(() => {\n // // if (!selectedProposal) {\n // // const firstProposal = Object.keys(proposals)[0];\n // // if (firstProposal) {\n // // if (getCurrentItem(firstProposal) || getProposedItem(firstProposal)) {\n // // selectProposal(firstProposal);\n // // }\n // // }\n // // }\n // if (selectedProposal) {\n // if (selectedProposalDetailRef.current) {\n // selectedProposalDetailRef.current.scrollIntoView({ block: 'center' });\n // }\n // }\n //}, [selectedProposal === null]);\n\n const selectedItemSummary = haveSelectedItem\n ? <ProposalSummary\n itemRef={selectedItemRef}\n item={(selectedItemProposed ?? selectedItemCurrent)!}\n itemBefore={selectedItemCurrent ?? undefined}\n proposal={proposals[selectedProposal]}\n />\n : <>Select item…</>;\n const icon = haveSelectedItem\n ? getProposalIcon(proposals[selectedProposal])\n : undefined;\n\n const selectedItemDrawer = useMemo((() =>\n <Drawer\n isOpen={proposalCount > 0 && haveSelectedItem ? true : false}\n onClose={() => selectProposal(null)}\n size={DrawerSize.LARGE}\n enforceFocus={false}>\n {proposalCount > 0 && haveSelectedItem\n ? <>\n <ButtonGroup>\n <Button\n disabled={!jumpTo || proposals[selectedProposal]?.type === 'addition'}\n icon='open-application'\n onClick={() => jumpTo?.(`${Protocols.ITEM_DETAILS}:${selectedProposal}`)}\n title=\"Open selected item in a new tab (not applicable to proposed additions)\"\n />\n <ClassNames>\n {(({ css: css2 }) =>\n <Select<ChangeProposalItem>\n filterable={false}\n itemsEqual={stringifiedJSONEqual}\n menuProps={{ className: css2(`max-height: 50vh; overflow-y: auto;`) }}\n activeItem={activeItem}\n items={allItems}\n popoverProps={{ minimal: true, matchTargetWidth: true }}\n fill\n itemRenderer={ChangeProposalItemView}\n onItemSelect={handleItemSelect}>\n <Button\n fill\n rightIcon=\"chevron-down\"\n icon={icon}\n title=\"Switch between items in this proposal\"\n css={css`white-space: nowrap;`}>\n {selectedItemSummary}\n </Button>\n </Select>\n )}\n </ClassNames>\n <Button\n onClick={() => selectProposal(null)}\n icon=\"minimize\"\n title=\"Minimize proposed change view\"\n text=\"Minimize\"\n />\n </ButtonGroup>\n <div css={css`position: relative; flex: 1;`}>\n <BrowserCtx.Provider value={proposalBrowserCtx}>\n <ErrorBoundary viewName=\"Proposal detail\">\n <ProposalDetail\n itemRef={selectedItemRef}\n //showOnlyChanged={showOnlyChanged}\n item={(selectedItemProposed ?? selectedItemCurrent)!}\n itemBefore={selectedItemCurrent ?? undefined}\n proposal={proposals[selectedProposal]}\n />\n </ErrorBoundary>\n </BrowserCtx.Provider>\n </div>\n </>\n : null}\n </Drawer>\n ), [proposalCount > 0, haveSelectedItem, selectedItemProposed, selectedItemCurrent, jumpTo, handleItemSelect, selectedProposal && proposals[selectedProposal]]);\n\n return (\n <>\n {selectedItemDrawer}\n </>\n );\n};\n\nfunction stringifiedJSONEqual(i1: any, i2: any): boolean {\n return JSON.stringify(i1) === JSON.stringify(i2);\n}\n\nexport default ProposalBrowser;\n"]}
1
+ {"version":3,"file":"ProposalBrowser.js","sourceRoot":"","sources":["../../src/proposals/ProposalBrowser.tsx"],"names":[],"mappings":"AACA,eAAe;AACf,8BAA8B;AAE9B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE5E,OAAO,aAAa,MAAM,wDAAwD,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAqC,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAiB,MAAM,2BAA2B,CAAC;AAGrE,OAAO,EAA2B,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAClG,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAuB9C;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC9B,EAAE,SAAS,EAAE,eAAe,EAAE,6BAA6B,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAChF;IACtB,MAAM,gBAAgB,GAAG,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,IAAI,CAAC;IAE9C,gCAAgC;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L;YACL,CAAC,CAAC,IAAI,CACD,CAAA;KAAA,CACV,EAAE,CAAC,aAAa,GAAG,CAAC,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAEhK,OAAO,CACL,0BACG,kBAAkB,CAClB,CACJ,CAAC;AACJ,CAAC;AAAA,CAAC;AAEF,SAAS,oBAAoB,CAAC,EAAO,EAAE,EAAO;IAC5C,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,eAAe,eAAe,CAAC","sourcesContent":["\n/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport React, { useContext, useCallback, useMemo } from 'react';\nimport { ClassNames, jsx, css } from '@emotion/react';\nimport { Select2 as Select } from '@blueprintjs/select';\nimport { ButtonGroup, Button, Drawer, DrawerSize } from '@blueprintjs/core';\n\nimport ErrorBoundary from '@riboseinc/paneron-extension-kit/widgets/ErrorBoundary';\n\nimport { useItemRef, itemPathToItemRef } from '../views/itemPathUtils';\nimport { BrowserCtx, type BrowserCtx as BrowserCtxType } from '../views/BrowserCtx';\nimport { Protocols, type Protocol } from '../views/protocolRegistry';\n\nimport type { Drafted } from './types';\nimport { type ChangeProposalItem, ChangeProposalItemView, getProposalIcon } from './ProposalItem';\nimport ProposalSummary from './ProposalSummary';\nimport ProposalDetail from './ProposalDetail';\n\n\ninterface ProposalBrowserProps<CR extends Drafted> {\n proposals: CR['items']\n\n /**\n * Whether the proposal had been accepted.\n * Influences the jump to current version of the item behavior\n * (for non-accepted proposals, jumping to additions is not allowed\n * since they would not be present in the registry).\n */\n hadBeenAccepted?: boolean\n\n selectedItem?: (string & keyof CR['items']) | null\n onSelectItem: (selectedItem: (string & keyof CR['items']) | null) => void\n\n /**\n * If provided, button to delete each proposed change\n * is shown in change card list mode.\n */\n onDeleteProposalForItemAtPath?: (itemPath: string) => void\n}\n/**\n * Shows a list of individual proposed changes as cards by default,\n * allowing to expand a proposal and view item details.\n *\n * If no proposals exist, returns null.\n */\nexport function ProposalBrowser<CR extends Drafted>\n({ proposals, hadBeenAccepted, onDeleteProposalForItemAtPath, selectedItem, onSelectItem: selectProposal }:\nProposalBrowserProps<CR>) {\n const selectedProposal = selectedItem ?? null;\n\n // TODO: Temporarily unsupported\n // (limitations of current change annotation implementation)\n //const [ showOnlyChanged, setShowOnlyChanged ] = useState(true);\n\n const outerBrowserCtx = useContext(BrowserCtx);\n const { jumpTo, subregisters, useRegisterItemData } = outerBrowserCtx;\n\n /**\n * When jumping to an item affected by current CR,\n * jump in-CR instead of spawning tab.\n */\n const handleCRJump = useCallback(function _handleCRJump(uri: `${Protocol}:${string}`): void {\n if (uri.startsWith(Protocols.ITEM_DETAILS)) {\n const itemPath = uri.split(':')[1];\n if (proposals[itemPath]) {\n selectProposal(itemPath);\n } else {\n jumpTo?.(uri);\n }\n }\n }, [Object.keys(proposals), jumpTo]);\n\n const proposalBrowserCtx: BrowserCtxType = useMemo((() => ({\n ...outerBrowserCtx,\n jumpTo: handleCRJump,\n })), [handleCRJump, outerBrowserCtx]);\n\n /** Paths of register items in proposal. */\n const proposedItemPaths = Object.entries(proposals).map(([itemPath, proposal]) => {\n if (proposal.type === 'clarification' || proposal.type === 'addition') {\n return itemPath;\n } else {\n return undefined;\n }\n }).filter(s => s !== undefined) as string[];\n\n /** Proposed data of register items in proposal. */\n const proposedItemDataReq = useRegisterItemData({\n itemPaths: proposedItemPaths,\n });\n\n /** Pre-existing data of register items in proposal. */\n const currentItemDataReq = useRegisterItemData({\n itemPaths: Object.keys(proposals),\n ignoreActiveCR: true,\n });\n\n const getCurrentItem = useCallback(\n ((itemPath: string) => currentItemDataReq.value[itemPath] ?? null),\n [currentItemDataReq.value]);\n const getProposedItem = useCallback(\n ((itemPath: string) => proposedItemDataReq.value[itemPath] ?? null),\n [proposedItemDataReq.value]);\n\n /** Current register item (if any) corresponding to selected proposal. */\n const selectedItemCurrent = selectedProposal ? getCurrentItem(selectedProposal) : null;\n\n /** Proposed register item corresponding to selected proposal. */\n const selectedItemProposed = selectedProposal ? getProposedItem(selectedProposal) : null;\n\n const selectedItemRef = useItemRef(subregisters !== undefined, selectedProposal);\n\n const handleItemSelect = useCallback(\n ((item: ChangeProposalItem) => selectProposal(item.itemPath)),\n [selectProposal]);\n\n const activeItem: ChangeProposalItem | null = useMemo((() =>\n selectedProposal\n ? ({\n itemPath: selectedProposal,\n proposal: proposals[selectedProposal],\n item: (selectedItemProposed ?? selectedItemCurrent)!,\n itemBefore: selectedItemCurrent ?? undefined,\n itemRef: itemPathToItemRef(subregisters !== undefined, selectedProposal),\n })\n : null\n ), [selectedProposal, proposals, subregisters]);\n\n const allItems: ChangeProposalItem[] = useMemo((() =>\n Object.entries(proposals).map(([itemPath, proposal]) => ({\n itemPath,\n proposal,\n item: (getProposedItem(itemPath) ?? getCurrentItem(itemPath))! ?? null,\n itemBefore: undefined,\n itemRef: itemPathToItemRef(subregisters !== undefined, itemPath),\n }))\n ), [proposals, getCurrentItem, getProposedItem, subregisters !== undefined]);\n\n const haveSelectedItem =\n selectedProposal\n && selectedItemRef\n && proposals[selectedProposal]\n && (selectedItemProposed || selectedItemCurrent);\n\n const proposalCount = Object.keys(proposals).length;\n\n //useEffect(() => {\n // // if (!selectedProposal) {\n // // const firstProposal = Object.keys(proposals)[0];\n // // if (firstProposal) {\n // // if (getCurrentItem(firstProposal) || getProposedItem(firstProposal)) {\n // // selectProposal(firstProposal);\n // // }\n // // }\n // // }\n // if (selectedProposal) {\n // if (selectedProposalDetailRef.current) {\n // selectedProposalDetailRef.current.scrollIntoView({ block: 'center' });\n // }\n // }\n //}, [selectedProposal === null]);\n\n const selectedItemSummary = haveSelectedItem\n ? <ProposalSummary\n itemRef={selectedItemRef}\n item={(selectedItemProposed ?? selectedItemCurrent)!}\n itemBefore={selectedItemCurrent ?? undefined}\n proposal={proposals[selectedProposal]}\n />\n : <>Select item…</>;\n const icon = haveSelectedItem\n ? getProposalIcon(proposals[selectedProposal])\n : undefined;\n\n const selectedItemDrawer = useMemo((() =>\n <Drawer\n isOpen={proposalCount > 0 && haveSelectedItem ? true : false}\n onClose={() => selectProposal(null)}\n size={DrawerSize.LARGE}\n enforceFocus={false}>\n {proposalCount > 0 && haveSelectedItem\n ? <>\n <ButtonGroup>\n <Button\n disabled={!jumpTo || (proposals[selectedProposal]?.type === 'addition' && !hadBeenAccepted)}\n icon='open-application'\n onClick={() => jumpTo?.(`${Protocols.ITEM_DETAILS}:${selectedProposal}`)}\n title=\"Open selected item in a new tab (not applicable to proposed additions)\"\n />\n <ClassNames>\n {(({ css: css2 }) =>\n <Select<ChangeProposalItem>\n filterable={false}\n itemsEqual={stringifiedJSONEqual}\n menuProps={{ className: css2(`max-height: 50vh; overflow-y: auto;`) }}\n activeItem={activeItem}\n items={allItems}\n popoverProps={{ minimal: true, matchTargetWidth: true }}\n fill\n itemRenderer={ChangeProposalItemView}\n onItemSelect={handleItemSelect}>\n <Button\n fill\n rightIcon=\"chevron-down\"\n icon={icon}\n title=\"Switch between items in this proposal\"\n css={css`white-space: nowrap;`}>\n {selectedItemSummary}\n </Button>\n </Select>\n )}\n </ClassNames>\n <Button\n onClick={() => selectProposal(null)}\n icon=\"minimize\"\n title=\"Minimize proposed change view\"\n text=\"Minimize\"\n />\n </ButtonGroup>\n <div css={css`position: relative; flex: 1;`}>\n <BrowserCtx.Provider value={proposalBrowserCtx}>\n <ErrorBoundary viewName=\"Proposal detail\">\n <ProposalDetail\n itemRef={selectedItemRef}\n //showOnlyChanged={showOnlyChanged}\n item={(selectedItemProposed ?? selectedItemCurrent)!}\n itemBefore={selectedItemCurrent ?? undefined}\n proposal={proposals[selectedProposal]}\n />\n </ErrorBoundary>\n </BrowserCtx.Provider>\n </div>\n </>\n : null}\n </Drawer>\n ), [proposalCount > 0, haveSelectedItem, selectedItemProposed, selectedItemCurrent, jumpTo, handleItemSelect, selectedProposal && proposals[selectedProposal]]);\n\n return (\n <>\n {selectedItemDrawer}\n </>\n );\n};\n\nfunction stringifiedJSONEqual(i1: any, i2: any): boolean {\n return JSON.stringify(i1) === JSON.stringify(i2);\n}\n\nexport default ProposalBrowser;\n"]}
@@ -92,6 +92,7 @@ const ProposalTab = function ({
92
92
  stakeholder: stakeholder,
93
93
  onOpenItem: selectItem
94
94
  }), (0, _react2.jsx)(_ProposalBrowser.default, {
95
+ hadBeenAccepted: (0, _types.hadBeenAccepted)(proposal),
95
96
  proposals: proposal.items,
96
97
  onSelectItem: selectItem,
97
98
  selectedItem: selectedItem
@@ -1 +1 @@
1
- {"version":3,"file":"ProposalTab.js","sourceRoot":"","sources":["../../src/proposals/ProposalTab.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,EAAE,GAGH,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAqB,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEzE,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAGhD,MAAM,WAAW,GAKZ,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE;IAC1D,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtC,MAAM,cAAc,GAAG;;QACV,eAAe,CAAC,QAAQ,CAAC;YAClC,CAAC,CAAC,IAAC,SAAS,IAAC,IAAI,EAAE,QAAQ,CAAC,YAAY,GAAI;YAC5C,CAAC,CAAC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AAQ;4BACV,CAAC,CAAC,QAAQ,CAAC,KAAK,KAAK,OAAO;gCAC1B,CAAC,CAAC,SAAS;gCACX,CAAC,CAAC,SAAmB;aAC9B,CAAC,CAAC;IACL,CAAC,EAAE;QACD,QAAQ,CAAC,KAAK;QACd,OAAO;QACP,YAAY,EAAE,cAAc,EAAE,cAAc;KAC7C,CAAC,CAAC;IAEH,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAEjE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE;QAC3B,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,IAAI,QAAQ,EAAE;YACZ,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,sBAAsB;gBAC5B,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;SACJ;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,CACL,IAAC,qBAAqB,IAClB,KAAK,EAAE,0BAAG,QAAQ,CAAC,aAAa,CAAI,EACpC,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO;QAClB,IAAC,SAAS,IACR,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,GACtB;QACF,IAAC,eAAe,IACd,SAAS,EAAE,QAAQ,CAAC,KAAK,EACzB,YAAY,EAAE,UAAU,EACxB,YAAY,EAAE,YAAY,GAC1B,CACoB,CACzB,CAAC;AAEJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport React, { useMemo, useState } from 'react';\nimport { jsx, css } from '@emotion/react';\nimport {\n UL,\n type Intent,\n type IconName,\n} from '@blueprintjs/core';\n\nimport type { Register, RegisterStakeholder } from '../types';\nimport { TabContentsWithHeader, Datestamp } from '../views/util';\nimport { type SomeCR as CR, isDisposed, hadBeenProposed } from './types';\n\nimport Workspace from './ProposalWorkspace';\nimport ProposalBrowser from './ProposalBrowser';\n\n\nconst ProposalTab: React.VoidFunctionComponent<{\n proposal: CR\n onDelete?: () => void\n register: Register\n stakeholder?: RegisterStakeholder\n}> = function ({ proposal, onDelete, register, stakeholder }) {\n const pending = !isDisposed(proposal);\n const proposedMarker = <>\n Proposed: {hadBeenProposed(proposal)\n ? <Datestamp date={proposal.timeProposed} />\n : 'not yet'}\n </>;\n const disposedMarker = <>\n Disposed: {!pending\n ? <Datestamp date={proposal.timeDisposed} />\n : 'not yet'}\n </>;\n const editedMarker = <>Edited: <Datestamp date={proposal.timeEdited} /></>;\n const classification = useMemo(() => {\n return [{\n icon: 'lightbulb' as IconName,\n children: \"Proposal\",\n tooltip: {\n icon: 'info-sign' as IconName,\n content: <UL css={css`margin: 0;`}>\n <li>Proposal ID: {proposal.id}</li>\n </UL>,\n },\n }, {\n children: pending\n ? <>pending</>\n : <>disposed</>,\n }, {\n children: proposal.state?.replaceAll('-', ' ') || 'N/A',\n tooltip: {\n icon: 'history' as IconName,\n content: <UL css={css`margin: 0;`}>\n <li>{editedMarker}</li>\n <li>{proposedMarker}</li>\n <li>{disposedMarker}</li>\n </UL>,\n },\n intent: proposal.state === 'accepted'\n ? 'success'\n : proposal.state === 'returned-for-clarification'\n ? 'warning'\n : proposal.state === 'withdrawn' || proposal.state === 'rejected'\n ? 'danger'\n : proposal.state === 'draft'\n ? undefined\n : 'primary' as Intent,\n }];\n }, [\n proposal.state,\n pending,\n editedMarker, proposedMarker, disposedMarker,\n ]);\n\n const [selectedItem, selectItem] = useState<string | null>(null);\n\n const actions = useMemo(() => {\n const actions = [];\n if (onDelete) {\n actions.push({\n text: \"Delete this proposal\",\n onClick: onDelete,\n });\n }\n return actions;\n }, [onDelete]);\n\n return (\n <TabContentsWithHeader\n title={<>{proposal.justification}</>}\n classification={classification}\n actions={actions}>\n <Workspace\n proposal={proposal}\n register={register}\n stakeholder={stakeholder}\n onOpenItem={selectItem}\n />\n <ProposalBrowser\n proposals={proposal.items}\n onSelectItem={selectItem}\n selectedItem={selectedItem}\n />\n </TabContentsWithHeader>\n );\n\n};\n\nexport default ProposalTab;\n"]}
1
+ {"version":3,"file":"ProposalTab.js","sourceRoot":"","sources":["../../src/proposals/ProposalTab.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,EAAE,GAGH,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAqB,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1F,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAGhD,MAAM,WAAW,GAKZ,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE;IAC1D,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtC,MAAM,cAAc,GAAG;;QACV,eAAe,CAAC,QAAQ,CAAC;YAClC,CAAC,CAAC,IAAC,SAAS,IAAC,IAAI,EAAE,QAAQ,CAAC,YAAY,GAAI;YAC5C,CAAC,CAAC,SAAS,CACZ,CAAC;IACJ,MAAM,cAAc,GAAG;;QACV,CAAC,OAAO;YACjB,CAAC,CAAC,IAAC,SAAS,IAAC,IAAI,EAAE,QAAQ,CAAC,YAAY,GAAI;YAC5C,CAAC,CAAC,SAAS,CACZ,CAAC;IACJ,MAAM,YAAY,GAAG;;QAAU,IAAC,SAAS,IAAC,IAAI,EAAE,QAAQ,CAAC,UAAU,GAAI,C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E,UAAU,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAEjE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE;QAC3B,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,IAAI,QAAQ,EAAE;YACZ,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,sBAAsB;gBAC5B,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;SACJ;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,CACL,IAAC,qBAAqB,IAClB,KAAK,EAAE,0BAAG,QAAQ,CAAC,aAAa,CAAI,EACpC,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO;QAClB,IAAC,SAAS,IACR,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,GACtB;QACF,IAAC,eAAe,IACd,eAAe,EAAE,eAAe,CAAC,QAAQ,CAAC,EAC1C,SAAS,EAAE,QAAQ,CAAC,KAAK,EACzB,YAAY,EAAE,UAAU,EACxB,YAAY,EAAE,YAAY,GAC1B,CACoB,CACzB,CAAC;AAEJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport React, { useMemo, useState } from 'react';\nimport { jsx, css } from '@emotion/react';\nimport {\n UL,\n type Intent,\n type IconName,\n} from '@blueprintjs/core';\n\nimport type { Register, RegisterStakeholder } from '../types';\nimport { TabContentsWithHeader, Datestamp } from '../views/util';\nimport { type SomeCR as CR, isDisposed, hadBeenProposed, hadBeenAccepted } from './types';\n\nimport Workspace from './ProposalWorkspace';\nimport ProposalBrowser from './ProposalBrowser';\n\n\nconst ProposalTab: React.VoidFunctionComponent<{\n proposal: CR\n onDelete?: () => void\n register: Register\n stakeholder?: RegisterStakeholder\n}> = function ({ proposal, onDelete, register, stakeholder }) {\n const pending = !isDisposed(proposal);\n const proposedMarker = <>\n Proposed: {hadBeenProposed(proposal)\n ? <Datestamp date={proposal.timeProposed} />\n : 'not yet'}\n </>;\n const disposedMarker = <>\n Disposed: {!pending\n ? <Datestamp date={proposal.timeDisposed} />\n : 'not yet'}\n </>;\n const editedMarker = <>Edited: <Datestamp date={proposal.timeEdited} /></>;\n const classification = useMemo(() => {\n return [{\n icon: 'lightbulb' as IconName,\n children: \"Proposal\",\n tooltip: {\n icon: 'info-sign' as IconName,\n content: <UL css={css`margin: 0;`}>\n <li>Proposal ID: {proposal.id}</li>\n </UL>,\n },\n }, {\n children: pending\n ? <>pending</>\n : <>disposed</>,\n }, {\n children: proposal.state?.replaceAll('-', ' ') || 'N/A',\n tooltip: {\n icon: 'history' as IconName,\n content: <UL css={css`margin: 0;`}>\n <li>{editedMarker}</li>\n <li>{proposedMarker}</li>\n <li>{disposedMarker}</li>\n </UL>,\n },\n intent: proposal.state === 'accepted'\n ? 'success'\n : proposal.state === 'returned-for-clarification'\n ? 'warning'\n : proposal.state === 'withdrawn' || proposal.state === 'rejected'\n ? 'danger'\n : proposal.state === 'draft'\n ? undefined\n : 'primary' as Intent,\n }];\n }, [\n proposal.state,\n pending,\n editedMarker, proposedMarker, disposedMarker,\n ]);\n\n const [selectedItem, selectItem] = useState<string | null>(null);\n\n const actions = useMemo(() => {\n const actions = [];\n if (onDelete) {\n actions.push({\n text: \"Delete this proposal\",\n onClick: onDelete,\n });\n }\n return actions;\n }, [onDelete]);\n\n return (\n <TabContentsWithHeader\n title={<>{proposal.justification}</>}\n classification={classification}\n actions={actions}>\n <Workspace\n proposal={proposal}\n register={register}\n stakeholder={stakeholder}\n onOpenItem={selectItem}\n />\n <ProposalBrowser\n hadBeenAccepted={hadBeenAccepted(proposal)}\n proposals={proposal.items}\n onSelectItem={selectItem}\n selectedItem={selectedItem}\n />\n </TabContentsWithHeader>\n );\n\n};\n\nexport default ProposalTab;\n"]}
@@ -169,6 +169,7 @@ export declare function isWithdrawn(cr: Base): cr is Withdrawn;
169
169
  export declare function hadBeenProposed(cr: Base): cr is Base & {
170
170
  timeProposed: Date;
171
171
  };
172
+ export declare function hadBeenAccepted(cr: Base): cr is Accepted | AcceptedOnAppeal;
172
173
  /** A proposal that had been disposed is not pending, not actionable. */
173
174
  export declare function isDisposed(cr: Base): cr is Base & {
174
175
  timeDisposed: Date;
@@ -23,6 +23,7 @@ exports.isDrafted = isDrafted;
23
23
  exports.isProposed = isProposed;
24
24
  exports.isWithdrawn = isWithdrawn;
25
25
  exports.hadBeenProposed = hadBeenProposed;
26
+ exports.hadBeenAccepted = hadBeenAccepted;
26
27
  exports.isDisposed = isDisposed;
27
28
  exports.isSubmittedForControlBodyReview = isSubmittedForControlBodyReview;
28
29
  exports.isReturnedForClarification = isReturnedForClarification;
@@ -182,6 +183,10 @@ function isWithdrawn(cr) {
182
183
  function hadBeenProposed(cr) {
183
184
  return cr && cr.hasOwnProperty('timeProposed') && !!cr.timeProposed;
184
185
  }
186
+
187
+ function hadBeenAccepted(cr) {
188
+ return isDisposed(cr) && (isAccepted(cr) || isAcceptedOnAppeal(cr));
189
+ }
185
190
  /** A proposal that had been disposed is not pending, not actionable. */
186
191
 
187
192
 
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/proposals/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8BH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,eAAe;IAC9B,SAAS,EAAE,WAAW;CACd,CAAC;AACX,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,kBAAkB,CAAC,QAAQ;IAC3B,kBAAkB,CAAC,aAAa;IAChC,kBAAkB,CAAC,SAAS;CACpB,CAAC;AAqBX,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,YAAY;IACxB,YAAY,EAAE,cAA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CAAC,EAAQ;IACpD,OAAO,SAAS,CAAC,EAAE,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;AAC/C,CAAC;AASD,MAAM,UAAU,iBAAiB,CAAC,GAAQ;IACxC,OAAO,GAAG,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,OAAO,GAAG,CAAC,aAAa,KAAK,QAAQ,CAAC;AACtF,CAAC;AAID,MAAM,UAAU,uBAAuB,CAAC,GAAQ;IAC9C,OAAO,GAAG,CAAC,cAAc,CAAC,sBAAsB,CAAC,IAAI,OAAO,GAAG,CAAC,oBAAoB,KAAK,QAAQ,CAAC;AACpG,CAAC;AAKD,MAAM,UAAU,mBAAmB,CAAC,GAAQ;IAC1C,OAAO,CACL,GAAG,CAAC,cAAc,CAAC,kBAAkB,CAAC,IAAI,OAAO,GAAG,CAAC,gBAAgB,KAAK,QAAQ;QAClF,GAAG,CAAC,cAAc,CAAC,0BAA0B,CAAC,IAAI,OAAO,GAAG,CAAC,wBAAwB,KAAK,QAAQ,CAAC,CAAC;AACxG,CAAC;AAID,MAAM,UAAU,gBAAgB,CAAC,GAAQ;IACvC,OAAO,GAAG,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,OAAO,GAAG,CAAC,YAAY,KAAK,QAAQ,CAAC;AACpF,CAAC;AAID,MAAM,UAAU,qBAAqB,CAAC,GAAQ;IAC5C,OAAO,GAAG,CAAC,cAAc,CAAC,oBAAoB,CAAC,IAAI,OAAO,GAAG,CAAC,kBAAkB,KAAK,QAAQ,CAAC;AAChG,CAAC;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,SAAS,SAAS,CAAkB,EAAQ,EAAE,CAAc;IAC1D,OAAO,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC;AACxB,CAAC","sourcesContent":["/**\n * Proposals, group proposals,\n * group proposal states and state transitions.\n */\n\nimport type React from 'react';\nimport type { DatasetContext } from '@riboseinc/paneron-extension-kit/types/renderer';\n\nimport type {\n InternalItemReference,\n Payload,\n RegisterItem,\n} from '../types';\n\nimport type { RegisterStakeholder } from '../types/stakeholder';\nimport type { Citation } from '../types/util';\n\n\n// Proposal items\n// ==============\n\n/**\n * Item paths in proposal set must start with a slash\n * and will be treated relative to dataset root.\n * Object paths should conform to registry item path shape\n * of `/<classID>/<itemID>.yaml`.\n * (the `[/subregisterID]/<classID>/<itemID>.yaml` is acceptable\n * but deprecated, as subregisters are deprecated).\n */\nexport type ProposalSet = {\n [objectPath: string]: ChangeProposal\n}\n\nexport const ChangeProposalType = {\n ADDITION: 'addition',\n CLARIFICATION: 'clarification',\n AMENDMENT: 'amendment',\n} as const;\nexport const PROPOSAL_TYPES = [\n ChangeProposalType.ADDITION,\n ChangeProposalType.CLARIFICATION,\n ChangeProposalType.AMENDMENT,\n] as const;\n\ninterface BaseProposal {\n //itemID: RegisterItemID\n disposition?: 'accepted' | 'notAccepted'\n type: typeof PROPOSAL_TYPES[number]\n sources?: Citation[]\n}\n\nexport interface Addition extends BaseProposal {\n type: typeof ChangeProposalType.ADDITION\n ///** New item data. */\n //payload: Payload\n}\n\nexport interface Clarification extends BaseProposal {\n type: typeof ChangeProposalType.CLARIFICATION\n ///** Updated item data */\n //payload: Payload\n}\n\nexport const AmendmentType = {\n SUPERSESSION: 'supersession',\n RETIREMENT: 'retirement',\n INVALIDATION: 'invalidation',\n} as const;\nexport type AmendmentTypeType = typeof AmendmentType[keyof typeof AmendmentType];\nexport const AMENDMENT_TYPES = [\n AmendmentType.SUPERSESSION,\n AmendmentType.RETIREMENT,\n AmendmentType.INVALIDATION,\n] as const;\n\ninterface BaseAmendment extends BaseProposal {\n type: typeof ChangeProposalType.AMENDMENT\n amendmentType: AmendmentTypeType\n}\nexport interface Retirement extends BaseAmendment {\n amendmentType: typeof AmendmentType.RETIREMENT\n}\nexport interface Supersession extends BaseAmendment {\n amendmentType: typeof AmendmentType.SUPERSESSION\n supersedingItemIDs: string[]\n}\nexport interface Invalidation extends BaseAmendment {\n amendmentType: typeof AmendmentType.INVALIDATION\n}\nexport type Amendment = Supersession | Retirement | Invalidation\n\nexport type ChangeProposal = Amendment | Clarification | Addition\n\nexport function isBaseProposal(val: any): val is BaseProposal {\n return PROPOSAL_TYPES.indexOf(val?.type) >= 0;\n}\nexport function isProposal(val: any): val is ChangeProposal {\n return (isBaseProposal(val) && (\n isAddition(val)\n || isClarification(val)\n || isAmendment(val)));\n}\nexport function isAddition(val: BaseProposal): val is Addition {\n return (val.type === ChangeProposalType.ADDITION);\n}\nexport function isClarification(val: BaseProposal): val is Clarification {\n return (val.type === ChangeProposalType.CLARIFICATION);\n}\nexport function isBaseAmendment(val: BaseProposal): val is BaseAmendment {\n return (\n val.type === ChangeProposalType.AMENDMENT\n && AMENDMENT_TYPES.indexOf((val as Amendment).amendmentType) >= 0);\n}\nexport function isAmendment(val: any): val is Amendment {\n return (isBaseAmendment(val) && (\n isRetirement(val)\n || isSupersession(val)\n || isInvalidation(val)));\n}\nexport function isRetirement(val: BaseAmendment): val is Retirement {\n return val.amendmentType === AmendmentType.RETIREMENT;\n}\nexport function isSupersession(val: BaseAmendment): val is Supersession {\n return val.amendmentType === AmendmentType.SUPERSESSION;\n}\nexport function isInvalidation(val: BaseAmendment): val is Invalidation {\n return val.amendmentType === AmendmentType.INVALIDATION;\n}\n\n\n// Change request types, states and state transitions.\n\nexport function isSubmittedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return (\n //isSubmitter(stakeholder) &&\n stakeholder.gitServerUsername === cr.submittingStakeholderGitServerUsername);\n}\n\n\ntype ItemDataset = Record<string, RegisterItem<any> | null>;\n\n\n// =====================\n// Change request states\n// =====================\n\n/** Used in place of enum for convenience. */\nexport const State = {\n DRAFT: 'draft',\n PROPOSED: 'proposed',\n SUBMITTED_FOR_CONTROL_BODY_REVIEW: 'pending-control-body-review',\n RETURNED_FOR_CLARIFICATION: 'returned-for-clarification',\n WITHDRAWN: 'withdrawn',\n ACCEPTED: 'accepted',\n REJECTED: 'rejected',\n APPEALED: 'rejection-appealed-to-owner',\n ACCEPTED_ON_APPEAL: 'accepted-on-appeal',\n REJECTION_UPHELD_ON_APPEAL: 'rejection-upheld-on-appeal',\n APPEAL_WITHDRAWN: 'appeal-withdrawn',\n} as const;\n\nexport type StateType = typeof State[keyof typeof State];\n\nexport function isState(val: string): val is StateType {\n return Object.values(State).indexOf(val as StateType) >= 0;\n}\n\n/** A subset of `State` that represents editable states. */\nexport const EditableState = [\n State.DRAFT,\n State.RETURNED_FOR_CLARIFICATION,\n] as const;\n\nexport type EditableStateType = StateType & typeof EditableState[number];\n\nexport function isEditableState(state: StateType): state is EditableStateType {\n return EditableState.indexOf(state as EditableStateType) >= 0;\n}\n\n\n\n// ======================\n// Change request classes\n// ======================\n\n/**\n * Base change request type.\n *\n * Note that e.g. type Base<typeof State.DRAFT> does not equal to Drafted\n * because Drafted includes additional information (namely, SubmitterInput).\n *\n * If the state of a CR matters, this type should not be used directly\n * and concrete types should be used instead.\n */\nexport interface Base<S extends StateType = StateType>\n{\n id: string;\n // decision: typeof Decision[keyof typeof Decision]\n // disposition?: typeof Disposition[keyof typeof Disposition]\n state: S;\n\n /**\n * Used to match against stakeholders declared in register metadata.\n */\n submittingStakeholderGitServerUsername: string;\n\n items: ProposalSet;\n\n /**\n * Against which register version changes were proposed.\n */\n registerVersion: string;\n\n /**\n * A link to external discussion.\n */\n externalDiscussionURI?: string;\n\n pastTransitions?: TransitionEntry[];\n}\n\n\nexport interface TransitionEntry {\n /** Verb in past tense. */\n label: string;\n\n timestamp: Date;\n fromState: StateType;\n toState: StateType;\n stakeholder: RegisterStakeholder;\n input: StateInput;\n}\n\n\nexport function isCreatedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return stakeholder.gitServerUsername?.trim() !== '' && stakeholder.gitServerUsername === cr.submittingStakeholderGitServerUsername;\n}\n\n/** Whether given `cr` can be edited (as in, items changed) by specified stakeholder. */\nexport function canBeEditedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return isCreatedBy(stakeholder, cr) && isEditableState(cr.state);\n}\n\n/**\n * Whether given `cr` can be deleted by given stakeholder.\n * Unlike editing, deletion is possible only if there are no items\n * and CR was never proposed.\n */\nexport function canBeDeletedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return (\n isCreatedBy(stakeholder, cr)\n && isDrafted(cr)\n //&& Object.keys(cr.items).length < 1 // Only allow deleting empty CRs\n && !hadBeenProposed(cr) // If it had been proposed, it should be withdrawn instead.\n );\n}\n\n\n/** Proposal structure for single-file proposal import format. */\nexport interface ImportableCR {\n /** Proposal data. */\n proposalDraft: Drafted,\n /** Register item data for additions & clarifications. */\n itemPayloads: ItemDataset,\n // TODO: Rename ImportableCR.itemPayloads to newItemData\n}\nexport function isImportableCR(val: any): val is ImportableCR {\n // TODO: More complete check\n return (\n val.proposalDraft.id\n && isDrafted(val.proposalDraft as Base)\n && Object.keys(val.itemPayloads).length > 0);\n}\n\n\n/**\n * A change request in any state.\n * Contains a superset of all possible properties, but all optional.\n * XXX: ^^^ This is a lie. Should be changed from | to & with Partial<>?\n */\nexport type SomeCR = \n | Drafted\n | Proposed\n | Withdrawn\n | ReturnedForClarificationByManager\n | SubmittedForControlBodyReview\n | ReturnedForClarificationByControlBody\n | Accepted\n | Rejected\n | RejectionUpheld\n | AcceptedOnAppeal\n | RejectedWithAppealWithdrawn;\n\nexport type Withdrawable =\n | Proposed\n | SubmittedForControlBodyReview\n | ReturnedForClarificationByManager\n | ReturnedForClarificationByControlBody;\n\nexport type Proposable =\n | Drafted\n | ReturnedForClarificationByManager\n | ReturnedForClarificationByControlBody;\n\nexport type SomeEditable =\n | Drafted\n | ReturnedForClarificationByManager\n | ReturnedForClarificationByControlBody;\n\nexport type Disposed =\n | Withdrawn\n | Accepted\n | Rejected\n | AcceptedOnAppeal\n | RejectionUpheld;\n\n\n// More specific change request types.\n// TODO: Refactor to avoid confusiong between current state e.g. Proposed)\n// and type (Proposed, to which all inheriting classes also conform)\n\nexport interface Drafted extends\n SubmitterInput,\n Base<typeof State.DRAFT> { timeStarted: Date, timeEdited: Date }\nexport function isDrafted(cr: Base): cr is Drafted {\n return isInState(cr, State.DRAFT);\n}\n\nexport interface Proposed extends\n Omit<Drafted, 'state'>,\n Base<typeof State.PROPOSED> { timeProposed: Date }\nexport function isProposed(cr: Base): cr is Proposed {\n return isInState(cr, State.PROPOSED);\n}\n\nexport interface Withdrawn extends\n Omit<Withdrawable, 'state'>,\n Base<typeof State.WITHDRAWN> { timeDisposed: Date }\nexport function isWithdrawn(cr: Base): cr is Withdrawn {\n return isInState(cr, State.WITHDRAWN);\n}\n\n/** CR was proposed at least once. */\nexport function hadBeenProposed(cr: Base): cr is Base & { timeProposed: Date } {\n return cr && cr.hasOwnProperty('timeProposed') && !!(cr as Proposed).timeProposed;\n}\n/** A proposal that had been disposed is not pending, not actionable. */\nexport function isDisposed(cr: Base): cr is Base & { timeDisposed: Date } {\n return cr && cr.hasOwnProperty('timeDisposed') && !!(cr as Disposed).timeDisposed;\n // TODO: include status checks, too?\n //return [\n // State.WITHDRAWN,\n // State.ACCEPTED,\n // State.REJECTED,\n // State.REJECTION_UPHELD_ON_APPEAL,\n // State.ACCEPTED_ON_APPEAL,\n //].some(s => cr.state === s);\n}\n\nexport interface SubmittedForControlBodyReview extends\n Omit<Proposed, 'state'>,\n RegisterManagerInput,\n Base<typeof State.SUBMITTED_FOR_CONTROL_BODY_REVIEW> {}\n\nexport function isSubmittedForControlBodyReview(cr: Base): cr is SubmittedForControlBodyReview {\n return isInState(cr, State.SUBMITTED_FOR_CONTROL_BODY_REVIEW)\n}\n\nexport interface ReturnedForClarificationByManager extends\n Omit<Proposed, 'state'>,\n RegisterManagerInput,\n Base<typeof State.RETURNED_FOR_CLARIFICATION> {}\n\nexport interface ReturnedForClarificationByControlBody extends\n Omit<SubmittedForControlBodyReview, 'state'>,\n ControlBodyInput,\n Base<typeof State.RETURNED_FOR_CLARIFICATION> {}\n\nexport function isReturnedForClarification(cr: Base): cr is (ReturnedForClarificationByManager | ReturnedForClarificationByControlBody) {\n return isInState(cr, State.RETURNED_FOR_CLARIFICATION)\n}\n\nexport interface Accepted extends\n Omit<SubmittedForControlBodyReview, 'state'>,\n ControlBodyInput,\n Base<typeof State.ACCEPTED> { timeDisposed: Date }\nexport function isAccepted(cr: Base): cr is Accepted {\n return isInState(cr, State.ACCEPTED);\n}\n\nexport interface Rejected extends\n Omit<SubmittedForControlBodyReview, 'state'>,\n ControlBodyInput,\n Base<typeof State.REJECTED> { timeDisposed: Date }\nexport function isRejected(cr: Base): cr is Rejected {\n return isInState(cr, State.REJECTED);\n}\n\nexport interface Appealed extends\n Omit<Rejected, 'state' | 'timeDisposed'>,\n AppealRequest,\n Base<typeof State.APPEALED> { timeDisposed: undefined }\nexport function isAppealed(cr: Base): cr is Appealed {\n return isInState(cr, State.APPEALED);\n}\n\nexport interface RejectionUpheld extends\n Omit<Appealed, 'state' | 'timeDisposed'>,\n RegisterOwnerInput,\n Base<typeof State.REJECTION_UPHELD_ON_APPEAL> { timeDisposed: Date }\nexport function isRejectedOnAppeal(cr: Base): cr is RejectionUpheld {\n return isInState(cr, State.REJECTION_UPHELD_ON_APPEAL);\n}\n\nexport interface AcceptedOnAppeal extends\n Omit<Appealed, 'state' | 'timeDisposed'>,\n RegisterOwnerInput,\n Base<typeof State.ACCEPTED_ON_APPEAL> { timeDisposed: Date }\nexport function isAcceptedOnAppeal(cr: Base): cr is AcceptedOnAppeal {\n return isInState(cr, State.ACCEPTED_ON_APPEAL);\n}\n\nexport interface RejectedWithAppealWithdrawn extends\n Omit<Appealed, 'state' | 'timeDisposed'>,\n Base<typeof State.APPEAL_WITHDRAWN> { timeDisposed: Date }\nexport function isRejectedWithAppealWithdrawn(cr: Base): cr is RejectedWithAppealWithdrawn {\n return isInState(cr, State.APPEAL_WITHDRAWN);\n}\n\n\n\n// Input required when transitioning to different states\n\nexport interface SubmitterInput {\n justification: string;\n}\nexport function hasSubmitterInput(val: any): val is SubmitterInput {\n return val.hasOwnProperty('justification') && typeof val.justification === 'string';\n}\nexport interface RegisterManagerInput {\n registerManagerNotes: string;\n}\nexport function hasRegisterManagerInput(val: any): val is RegisterManagerInput {\n return val.hasOwnProperty('registerManagerNotes') && typeof val.registerManagerNotes === 'string';\n}\nexport interface ControlBodyInput {\n controlBodyNotes: string;\n controlBodyDecisionEvent: string;\n}\nexport function hasControlBodyInput(val: any): val is ControlBodyInput {\n return (\n val.hasOwnProperty('controlBodyNotes') && typeof val.controlBodyNotes === 'string' &&\n val.hasOwnProperty('controlBodyDecisionEvent') && typeof val.controlBodyDecisionEvent === 'string');\n}\nexport interface AppealRequest {\n appealReason: string;\n}\nexport function hasAppealRequest(val: any): val is AppealRequest {\n return val.hasOwnProperty('appealReason') && typeof val.appealReason === 'string';\n}\nexport interface RegisterOwnerInput {\n registerOwnerNotes: string;\n}\nexport function hasRegisterOwnerInput(val: any): val is RegisterOwnerInput {\n return val.hasOwnProperty('registerOwnerNotes') && typeof val.registerOwnerNotes === 'string';\n}\n\nexport type StateInput =\n | SubmitterInput\n | RegisterManagerInput\n | ControlBodyInput\n | AppealRequest\n | RegisterOwnerInput;\n\n\n/** \n * CR type guard helper.\n * Normally you would not use it directly and instead use\n * more specific is[Type]() helper from this module.\n *\n * Checks CR type using the `state` property.\n * Does not validate other properties.\n *\n * Usage:\n *\n * @example\n * ```ts\n * let someCR;\n * if (isInState<Drafted>(someCR, State.DRAFT)) {\n * // Can assume someCR is Drafted\n * }\n * ```\n *\n * It’ll try to tell you if you mismatch those.\n *\n * @example\n * Will not compile:\n * ```ts\n * let someCR;\n * if (isInState<Drafted>(someCR, State.PROPOSED)) {\n * // Compile error\n * // because State.PROPOSED is not a possible value of Drafted[\"state\"]\n * }\n * ```\n *\n * @example\n * Incorrect usage (do not do this):\n * ```ts\n * let someCR;\n * if (isInState(someCR, State.DRAFT)) {\n * // Can NOT assume someCR is Drafted\n * // The compiler must know the expected concrete CR type\n * }\n * ```\n */\nfunction isInState<CR extends Base>(cr: Base, s: CR[\"state\"]): cr is CR {\n return cr.state === s;\n}\n\n\n\n\n// ===========\n// Transitions\n// ===========\n\n/**\n * A function that transitions CR1 to CR2.\n *\n * The function is declared to return the object\n * without the `state` field, it is set\n * by common wrapper function to reduce duplication.\n */\nexport type Transition<\n /** From CR of this subtype */\n CR1 extends Base,\n /** To CR of this subtype */\n CR2 extends Base,\n /** Using this extra information */\n P extends Record<string, any> | null = null,\n> = (cr: CR1, payload: P) => Omit<CR2, 'state'>;\n\n\nexport type AlterApprovedCR = (\n crID: string,\n proposals: ProposalSet,\n origItemData: ItemDataset,\n newItemData: ItemDataset,\n opts: Pick<DatasetContext, 'getMapReducedData'>,\n) => Promise<{\n proposals: ProposalSet,\n origItemData: ItemDataset,\n newItemData: ItemDataset,\n}>\n\n\n/**\n * Describes a transition.\n *\n * @typeParam CR1: Change request source state type\n * @typeParam CR2: Change request target state type\n * @typeParam P: Extra input needed to transition, if any\n */\nexport interface TransitionConfig<CR1 extends Base, CR2 extends Base, P extends Record<string, any> | null = null> {\n /**\n * Function that implements the transition.\n * Takes a CR in the original state and returns CR in the new state.\n * Additionally, takes appropriate payload, if any, for the transition\n * (e.g., register manager or control body notes).\n *\n * For function implementor:\n *\n * - Function MUST NOT modify CR in place.\n * - Function should throw if submitted payload does not conform to requirements.\n */\n func: Transition<CR1, CR2, P>;\n\n targetState: CR2[\"state\"];\n\n /** Title. Use verb. */\n title: string;\n\n hint?: string | JSX.Element;\n\n /** Widget that can be used to view or enter extra input. */\n Widget: P extends null ? null : React.FC<{ value: P, onChange?: (userInput: P) => void }>;\n\n /**\n * Function that returns true\n * if given stakeholder can perform this transition on given CR.\n */\n canBeTransitionedBy: (stakeholder: RegisterStakeholder, cr: CR1) => boolean;\n}\n\n\n// type TransitionSpec = {\n// [S1 in StateType]?: {\n// [S2 in StateType]?: Transition<Base<S1>, Base<S2>, Record<string, any>>\n// }\n// }\n\n\n/**\n * Source of truth for available transitions.\n * When updating change request business logic,\n * this is the type that should be modified.\n *\n * It will cause compile errors until transition implementation\n * is updated correspondingly.\n */\nexport type Transitions = {\n [State.DRAFT]: {\n // [State.DRAFT]:\n // TransitionConfig<Drafted, Drafted, SubmitterInput>;\n [State.WITHDRAWN]:\n TransitionConfig<Proposed, Withdrawn>;\n [State.PROPOSED]:\n TransitionConfig<Drafted, Proposed, SubmitterInput>;\n };\n [State.PROPOSED]: {\n [State.WITHDRAWN]:\n TransitionConfig<Proposed, Withdrawn>;\n [State.SUBMITTED_FOR_CONTROL_BODY_REVIEW]:\n TransitionConfig<Proposed, SubmittedForControlBodyReview, RegisterManagerInput>;\n [State.RETURNED_FOR_CLARIFICATION]:\n TransitionConfig<Proposed, ReturnedForClarificationByManager, RegisterManagerInput>;\n };\n [State.SUBMITTED_FOR_CONTROL_BODY_REVIEW]: {\n [State.WITHDRAWN]:\n TransitionConfig<SubmittedForControlBodyReview, Withdrawn>;\n [State.RETURNED_FOR_CLARIFICATION]:\n TransitionConfig<SubmittedForControlBodyReview, ReturnedForClarificationByControlBody, ControlBodyInput>;\n [State.REJECTED]:\n TransitionConfig<SubmittedForControlBodyReview, Rejected, ControlBodyInput>;\n [State.ACCEPTED]:\n TransitionConfig<SubmittedForControlBodyReview, Accepted, ControlBodyInput>;\n };\n [State.RETURNED_FOR_CLARIFICATION]: {\n [State.PROPOSED]:\n TransitionConfig<ReturnedForClarificationByManager | ReturnedForClarificationByControlBody, Proposed, SubmitterInput>;\n [State.WITHDRAWN]:\n TransitionConfig<ReturnedForClarificationByManager | ReturnedForClarificationByControlBody, Withdrawn>;\n };\n [State.REJECTED]: {\n [State.APPEALED]:\n TransitionConfig<Rejected, Appealed, AppealRequest>;\n };\n [State.APPEALED]: {\n [State.APPEAL_WITHDRAWN]:\n TransitionConfig<Appealed, RejectedWithAppealWithdrawn>;\n [State.ACCEPTED_ON_APPEAL]:\n TransitionConfig<Appealed, AcceptedOnAppeal, RegisterOwnerInput>;\n [State.REJECTION_UPHELD_ON_APPEAL]:\n TransitionConfig<Appealed, RejectionUpheld, RegisterOwnerInput>;\n };\n}\n\n\n// Utility\n// =======\n\nexport interface ProposalProps<P extends ChangeProposal> {\n proposal: P\n\n /** Highlight changes. */\n showDiff?: boolean\n\n /** In diff mode, only show changed data. (Provisional.) */\n showOnlyChanged?: boolean\n\n itemRef: InternalItemReference\n item: RegisterItem<Payload>\n itemBefore: P extends Clarification ? RegisterItem<Payload> : undefined\n onChange?: (newProposal: P) => void\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/proposals/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8BH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,eAAe;IAC9B,SAAS,EAAE,WAAW;CACd,CAAC;AACX,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,kBAAkB,CAAC,QAAQ;IAC3B,kBAAkB,CAAC,aAAa;IAChC,kBAAkB,CAAC,SAAS;CACpB,CAAC;AAqBX,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,YAAY;IACxB,YAAY,EAAE,cAAc;CACpB,CAAC;AAEX,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,aAAa,CAAC,YAAY;IAC1B,aAAa,CAAC,UAAU;IACxB,aAAa,CAAC,YAAY;CAClB,CAAC;AAoBX,MAAM,UAAU,cAAc,CAAC,GAAQ;IACrC,OAAO,cAAc,CAAC,OAAO,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AAChD,CAAC;AACD,MAAM,UAAU,UAAU,CAAC,GAAQ;IACjC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAC7B,UAAU,CAAC,GAAG,CAAC;WACZ,eAAe,CAAC,GAAG,CAAC;WACpB,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC;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IAAI,OAAO,GAAG,CAAC,oBAAoB,KAAK,QAAQ,CAAC;AACpG,CAAC;AAKD,MAAM,UAAU,mBAAmB,CAAC,GAAQ;IAC1C,OAAO,CACL,GAAG,CAAC,cAAc,CAAC,kBAAkB,CAAC,IAAI,OAAO,GAAG,CAAC,gBAAgB,KAAK,QAAQ;QAClF,GAAG,CAAC,cAAc,CAAC,0BAA0B,CAAC,IAAI,OAAO,GAAG,CAAC,wBAAwB,KAAK,QAAQ,CAAC,CAAC;AACxG,CAAC;AAID,MAAM,UAAU,gBAAgB,CAAC,GAAQ;IACvC,OAAO,GAAG,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,OAAO,GAAG,CAAC,YAAY,KAAK,QAAQ,CAAC;AACpF,CAAC;AAID,MAAM,UAAU,qBAAqB,CAAC,GAAQ;IAC5C,OAAO,GAAG,CAAC,cAAc,CAAC,oBAAoB,CAAC,IAAI,OAAO,GAAG,CAAC,kBAAkB,KAAK,QAAQ,CAAC;AAChG,CAAC;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,SAAS,SAAS,CAAkB,EAAQ,EAAE,CAAc;IAC1D,OAAO,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC;AACxB,CAAC","sourcesContent":["/**\n * Proposals, group proposals,\n * group proposal states and state transitions.\n */\n\nimport type React from 'react';\nimport type { DatasetContext } from '@riboseinc/paneron-extension-kit/types/renderer';\n\nimport type {\n InternalItemReference,\n Payload,\n RegisterItem,\n} from '../types';\n\nimport type { RegisterStakeholder } from '../types/stakeholder';\nimport type { Citation } from '../types/util';\n\n\n// Proposal items\n// ==============\n\n/**\n * Item paths in proposal set must start with a slash\n * and will be treated relative to dataset root.\n * Object paths should conform to registry item path shape\n * of `/<classID>/<itemID>.yaml`.\n * (the `[/subregisterID]/<classID>/<itemID>.yaml` is acceptable\n * but deprecated, as subregisters are deprecated).\n */\nexport type ProposalSet = {\n [objectPath: string]: ChangeProposal\n}\n\nexport const ChangeProposalType = {\n ADDITION: 'addition',\n CLARIFICATION: 'clarification',\n AMENDMENT: 'amendment',\n} as const;\nexport const PROPOSAL_TYPES = [\n ChangeProposalType.ADDITION,\n ChangeProposalType.CLARIFICATION,\n ChangeProposalType.AMENDMENT,\n] as const;\n\ninterface BaseProposal {\n //itemID: RegisterItemID\n disposition?: 'accepted' | 'notAccepted'\n type: typeof PROPOSAL_TYPES[number]\n sources?: Citation[]\n}\n\nexport interface Addition extends BaseProposal {\n type: typeof ChangeProposalType.ADDITION\n ///** New item data. */\n //payload: Payload\n}\n\nexport interface Clarification extends BaseProposal {\n type: typeof ChangeProposalType.CLARIFICATION\n ///** Updated item data */\n //payload: Payload\n}\n\nexport const AmendmentType = {\n SUPERSESSION: 'supersession',\n RETIREMENT: 'retirement',\n INVALIDATION: 'invalidation',\n} as const;\nexport type AmendmentTypeType = typeof AmendmentType[keyof typeof AmendmentType];\nexport const AMENDMENT_TYPES = [\n AmendmentType.SUPERSESSION,\n AmendmentType.RETIREMENT,\n AmendmentType.INVALIDATION,\n] as const;\n\ninterface BaseAmendment extends BaseProposal {\n type: typeof ChangeProposalType.AMENDMENT\n amendmentType: AmendmentTypeType\n}\nexport interface Retirement extends BaseAmendment {\n amendmentType: typeof AmendmentType.RETIREMENT\n}\nexport interface Supersession extends BaseAmendment {\n amendmentType: typeof AmendmentType.SUPERSESSION\n supersedingItemIDs: string[]\n}\nexport interface Invalidation extends BaseAmendment {\n amendmentType: typeof AmendmentType.INVALIDATION\n}\nexport type Amendment = Supersession | Retirement | Invalidation\n\nexport type ChangeProposal = Amendment | Clarification | Addition\n\nexport function isBaseProposal(val: any): val is BaseProposal {\n return PROPOSAL_TYPES.indexOf(val?.type) >= 0;\n}\nexport function isProposal(val: any): val is ChangeProposal {\n return (isBaseProposal(val) && (\n isAddition(val)\n || isClarification(val)\n || isAmendment(val)));\n}\nexport function isAddition(val: BaseProposal): val is Addition {\n return (val.type === ChangeProposalType.ADDITION);\n}\nexport function isClarification(val: BaseProposal): val is Clarification {\n return (val.type === ChangeProposalType.CLARIFICATION);\n}\nexport function isBaseAmendment(val: BaseProposal): val is BaseAmendment {\n return (\n val.type === ChangeProposalType.AMENDMENT\n && AMENDMENT_TYPES.indexOf((val as Amendment).amendmentType) >= 0);\n}\nexport function isAmendment(val: any): val is Amendment {\n return (isBaseAmendment(val) && (\n isRetirement(val)\n || isSupersession(val)\n || isInvalidation(val)));\n}\nexport function isRetirement(val: BaseAmendment): val is Retirement {\n return val.amendmentType === AmendmentType.RETIREMENT;\n}\nexport function isSupersession(val: BaseAmendment): val is Supersession {\n return val.amendmentType === AmendmentType.SUPERSESSION;\n}\nexport function isInvalidation(val: BaseAmendment): val is Invalidation {\n return val.amendmentType === AmendmentType.INVALIDATION;\n}\n\n\n// Change request types, states and state transitions.\n\nexport function isSubmittedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return (\n //isSubmitter(stakeholder) &&\n stakeholder.gitServerUsername === cr.submittingStakeholderGitServerUsername);\n}\n\n\ntype ItemDataset = Record<string, RegisterItem<any> | null>;\n\n\n// =====================\n// Change request states\n// =====================\n\n/** Used in place of enum for convenience. */\nexport const State = {\n DRAFT: 'draft',\n PROPOSED: 'proposed',\n SUBMITTED_FOR_CONTROL_BODY_REVIEW: 'pending-control-body-review',\n RETURNED_FOR_CLARIFICATION: 'returned-for-clarification',\n WITHDRAWN: 'withdrawn',\n ACCEPTED: 'accepted',\n REJECTED: 'rejected',\n APPEALED: 'rejection-appealed-to-owner',\n ACCEPTED_ON_APPEAL: 'accepted-on-appeal',\n REJECTION_UPHELD_ON_APPEAL: 'rejection-upheld-on-appeal',\n APPEAL_WITHDRAWN: 'appeal-withdrawn',\n} as const;\n\nexport type StateType = typeof State[keyof typeof State];\n\nexport function isState(val: string): val is StateType {\n return Object.values(State).indexOf(val as StateType) >= 0;\n}\n\n/** A subset of `State` that represents editable states. */\nexport const EditableState = [\n State.DRAFT,\n State.RETURNED_FOR_CLARIFICATION,\n] as const;\n\nexport type EditableStateType = StateType & typeof EditableState[number];\n\nexport function isEditableState(state: StateType): state is EditableStateType {\n return EditableState.indexOf(state as EditableStateType) >= 0;\n}\n\n\n\n// ======================\n// Change request classes\n// ======================\n\n/**\n * Base change request type.\n *\n * Note that e.g. type Base<typeof State.DRAFT> does not equal to Drafted\n * because Drafted includes additional information (namely, SubmitterInput).\n *\n * If the state of a CR matters, this type should not be used directly\n * and concrete types should be used instead.\n */\nexport interface Base<S extends StateType = StateType>\n{\n id: string;\n // decision: typeof Decision[keyof typeof Decision]\n // disposition?: typeof Disposition[keyof typeof Disposition]\n state: S;\n\n /**\n * Used to match against stakeholders declared in register metadata.\n */\n submittingStakeholderGitServerUsername: string;\n\n items: ProposalSet;\n\n /**\n * Against which register version changes were proposed.\n */\n registerVersion: string;\n\n /**\n * A link to external discussion.\n */\n externalDiscussionURI?: string;\n\n pastTransitions?: TransitionEntry[];\n}\n\n\nexport interface TransitionEntry {\n /** Verb in past tense. */\n label: string;\n\n timestamp: Date;\n fromState: StateType;\n toState: StateType;\n stakeholder: RegisterStakeholder;\n input: StateInput;\n}\n\n\nexport function isCreatedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return stakeholder.gitServerUsername?.trim() !== '' && stakeholder.gitServerUsername === cr.submittingStakeholderGitServerUsername;\n}\n\n/** Whether given `cr` can be edited (as in, items changed) by specified stakeholder. */\nexport function canBeEditedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return isCreatedBy(stakeholder, cr) && isEditableState(cr.state);\n}\n\n/**\n * Whether given `cr` can be deleted by given stakeholder.\n * Unlike editing, deletion is possible only if there are no items\n * and CR was never proposed.\n */\nexport function canBeDeletedBy(stakeholder: RegisterStakeholder, cr: Base): boolean {\n return (\n isCreatedBy(stakeholder, cr)\n && isDrafted(cr)\n //&& Object.keys(cr.items).length < 1 // Only allow deleting empty CRs\n && !hadBeenProposed(cr) // If it had been proposed, it should be withdrawn instead.\n );\n}\n\n\n/** Proposal structure for single-file proposal import format. */\nexport interface ImportableCR {\n /** Proposal data. */\n proposalDraft: Drafted,\n /** Register item data for additions & clarifications. */\n itemPayloads: ItemDataset,\n // TODO: Rename ImportableCR.itemPayloads to newItemData\n}\nexport function isImportableCR(val: any): val is ImportableCR {\n // TODO: More complete check\n return (\n val.proposalDraft.id\n && isDrafted(val.proposalDraft as Base)\n && Object.keys(val.itemPayloads).length > 0);\n}\n\n\n/**\n * A change request in any state.\n * Contains a superset of all possible properties, but all optional.\n * XXX: ^^^ This is a lie. Should be changed from | to & with Partial<>?\n */\nexport type SomeCR = \n | Drafted\n | Proposed\n | Withdrawn\n | ReturnedForClarificationByManager\n | SubmittedForControlBodyReview\n | ReturnedForClarificationByControlBody\n | Accepted\n | Rejected\n | RejectionUpheld\n | AcceptedOnAppeal\n | RejectedWithAppealWithdrawn;\n\nexport type Withdrawable =\n | Proposed\n | SubmittedForControlBodyReview\n | ReturnedForClarificationByManager\n | ReturnedForClarificationByControlBody;\n\nexport type Proposable =\n | Drafted\n | ReturnedForClarificationByManager\n | ReturnedForClarificationByControlBody;\n\nexport type SomeEditable =\n | Drafted\n | ReturnedForClarificationByManager\n | ReturnedForClarificationByControlBody;\n\nexport type Disposed =\n | Withdrawn\n | Accepted\n | Rejected\n | AcceptedOnAppeal\n | RejectionUpheld;\n\n\n// More specific change request types.\n// TODO: Refactor to avoid confusiong between current state e.g. Proposed)\n// and type (Proposed, to which all inheriting classes also conform)\n\nexport interface Drafted extends\n SubmitterInput,\n Base<typeof State.DRAFT> { timeStarted: Date, timeEdited: Date }\nexport function isDrafted(cr: Base): cr is Drafted {\n return isInState(cr, State.DRAFT);\n}\n\nexport interface Proposed extends\n Omit<Drafted, 'state'>,\n Base<typeof State.PROPOSED> { timeProposed: Date }\nexport function isProposed(cr: Base): cr is Proposed {\n return isInState(cr, State.PROPOSED);\n}\n\nexport interface Withdrawn extends\n Omit<Withdrawable, 'state'>,\n Base<typeof State.WITHDRAWN> { timeDisposed: Date }\nexport function isWithdrawn(cr: Base): cr is Withdrawn {\n return isInState(cr, State.WITHDRAWN);\n}\n\n/** CR was proposed at least once. */\nexport function hadBeenProposed(cr: Base): cr is Base & { timeProposed: Date } {\n return cr && cr.hasOwnProperty('timeProposed') && !!(cr as Proposed).timeProposed;\n}\nexport function hadBeenAccepted(cr: Base): cr is Accepted | AcceptedOnAppeal {\n return isDisposed(cr) && (isAccepted(cr) || isAcceptedOnAppeal(cr));\n}\n/** A proposal that had been disposed is not pending, not actionable. */\nexport function isDisposed(cr: Base): cr is Base & { timeDisposed: Date } {\n return cr && cr.hasOwnProperty('timeDisposed') && !!(cr as Disposed).timeDisposed;\n // TODO: include status checks, too?\n //return [\n // State.WITHDRAWN,\n // State.ACCEPTED,\n // State.REJECTED,\n // State.REJECTION_UPHELD_ON_APPEAL,\n // State.ACCEPTED_ON_APPEAL,\n //].some(s => cr.state === s);\n}\n\nexport interface SubmittedForControlBodyReview extends\n Omit<Proposed, 'state'>,\n RegisterManagerInput,\n Base<typeof State.SUBMITTED_FOR_CONTROL_BODY_REVIEW> {}\n\nexport function isSubmittedForControlBodyReview(cr: Base): cr is SubmittedForControlBodyReview {\n return isInState(cr, State.SUBMITTED_FOR_CONTROL_BODY_REVIEW)\n}\n\nexport interface ReturnedForClarificationByManager extends\n Omit<Proposed, 'state'>,\n RegisterManagerInput,\n Base<typeof State.RETURNED_FOR_CLARIFICATION> {}\n\nexport interface ReturnedForClarificationByControlBody extends\n Omit<SubmittedForControlBodyReview, 'state'>,\n ControlBodyInput,\n Base<typeof State.RETURNED_FOR_CLARIFICATION> {}\n\nexport function isReturnedForClarification(cr: Base): cr is (ReturnedForClarificationByManager | ReturnedForClarificationByControlBody) {\n return isInState(cr, State.RETURNED_FOR_CLARIFICATION)\n}\n\nexport interface Accepted extends\n Omit<SubmittedForControlBodyReview, 'state'>,\n ControlBodyInput,\n Base<typeof State.ACCEPTED> { timeDisposed: Date }\nexport function isAccepted(cr: Base): cr is Accepted {\n return isInState(cr, State.ACCEPTED);\n}\n\nexport interface Rejected extends\n Omit<SubmittedForControlBodyReview, 'state'>,\n ControlBodyInput,\n Base<typeof State.REJECTED> { timeDisposed: Date }\nexport function isRejected(cr: Base): cr is Rejected {\n return isInState(cr, State.REJECTED);\n}\n\nexport interface Appealed extends\n Omit<Rejected, 'state' | 'timeDisposed'>,\n AppealRequest,\n Base<typeof State.APPEALED> { timeDisposed: undefined }\nexport function isAppealed(cr: Base): cr is Appealed {\n return isInState(cr, State.APPEALED);\n}\n\nexport interface RejectionUpheld extends\n Omit<Appealed, 'state' | 'timeDisposed'>,\n RegisterOwnerInput,\n Base<typeof State.REJECTION_UPHELD_ON_APPEAL> { timeDisposed: Date }\nexport function isRejectedOnAppeal(cr: Base): cr is RejectionUpheld {\n return isInState(cr, State.REJECTION_UPHELD_ON_APPEAL);\n}\n\nexport interface AcceptedOnAppeal extends\n Omit<Appealed, 'state' | 'timeDisposed'>,\n RegisterOwnerInput,\n Base<typeof State.ACCEPTED_ON_APPEAL> { timeDisposed: Date }\nexport function isAcceptedOnAppeal(cr: Base): cr is AcceptedOnAppeal {\n return isInState(cr, State.ACCEPTED_ON_APPEAL);\n}\n\nexport interface RejectedWithAppealWithdrawn extends\n Omit<Appealed, 'state' | 'timeDisposed'>,\n Base<typeof State.APPEAL_WITHDRAWN> { timeDisposed: Date }\nexport function isRejectedWithAppealWithdrawn(cr: Base): cr is RejectedWithAppealWithdrawn {\n return isInState(cr, State.APPEAL_WITHDRAWN);\n}\n\n\n\n// Input required when transitioning to different states\n\nexport interface SubmitterInput {\n justification: string;\n}\nexport function hasSubmitterInput(val: any): val is SubmitterInput {\n return val.hasOwnProperty('justification') && typeof val.justification === 'string';\n}\nexport interface RegisterManagerInput {\n registerManagerNotes: string;\n}\nexport function hasRegisterManagerInput(val: any): val is RegisterManagerInput {\n return val.hasOwnProperty('registerManagerNotes') && typeof val.registerManagerNotes === 'string';\n}\nexport interface ControlBodyInput {\n controlBodyNotes: string;\n controlBodyDecisionEvent: string;\n}\nexport function hasControlBodyInput(val: any): val is ControlBodyInput {\n return (\n val.hasOwnProperty('controlBodyNotes') && typeof val.controlBodyNotes === 'string' &&\n val.hasOwnProperty('controlBodyDecisionEvent') && typeof val.controlBodyDecisionEvent === 'string');\n}\nexport interface AppealRequest {\n appealReason: string;\n}\nexport function hasAppealRequest(val: any): val is AppealRequest {\n return val.hasOwnProperty('appealReason') && typeof val.appealReason === 'string';\n}\nexport interface RegisterOwnerInput {\n registerOwnerNotes: string;\n}\nexport function hasRegisterOwnerInput(val: any): val is RegisterOwnerInput {\n return val.hasOwnProperty('registerOwnerNotes') && typeof val.registerOwnerNotes === 'string';\n}\n\nexport type StateInput =\n | SubmitterInput\n | RegisterManagerInput\n | ControlBodyInput\n | AppealRequest\n | RegisterOwnerInput;\n\n\n/** \n * CR type guard helper.\n * Normally you would not use it directly and instead use\n * more specific is[Type]() helper from this module.\n *\n * Checks CR type using the `state` property.\n * Does not validate other properties.\n *\n * Usage:\n *\n * @example\n * ```ts\n * let someCR;\n * if (isInState<Drafted>(someCR, State.DRAFT)) {\n * // Can assume someCR is Drafted\n * }\n * ```\n *\n * It’ll try to tell you if you mismatch those.\n *\n * @example\n * Will not compile:\n * ```ts\n * let someCR;\n * if (isInState<Drafted>(someCR, State.PROPOSED)) {\n * // Compile error\n * // because State.PROPOSED is not a possible value of Drafted[\"state\"]\n * }\n * ```\n *\n * @example\n * Incorrect usage (do not do this):\n * ```ts\n * let someCR;\n * if (isInState(someCR, State.DRAFT)) {\n * // Can NOT assume someCR is Drafted\n * // The compiler must know the expected concrete CR type\n * }\n * ```\n */\nfunction isInState<CR extends Base>(cr: Base, s: CR[\"state\"]): cr is CR {\n return cr.state === s;\n}\n\n\n\n\n// ===========\n// Transitions\n// ===========\n\n/**\n * A function that transitions CR1 to CR2.\n *\n * The function is declared to return the object\n * without the `state` field, it is set\n * by common wrapper function to reduce duplication.\n */\nexport type Transition<\n /** From CR of this subtype */\n CR1 extends Base,\n /** To CR of this subtype */\n CR2 extends Base,\n /** Using this extra information */\n P extends Record<string, any> | null = null,\n> = (cr: CR1, payload: P) => Omit<CR2, 'state'>;\n\n\nexport type AlterApprovedCR = (\n crID: string,\n proposals: ProposalSet,\n origItemData: ItemDataset,\n newItemData: ItemDataset,\n opts: Pick<DatasetContext, 'getMapReducedData'>,\n) => Promise<{\n proposals: ProposalSet,\n origItemData: ItemDataset,\n newItemData: ItemDataset,\n}>\n\n\n/**\n * Describes a transition.\n *\n * @typeParam CR1: Change request source state type\n * @typeParam CR2: Change request target state type\n * @typeParam P: Extra input needed to transition, if any\n */\nexport interface TransitionConfig<CR1 extends Base, CR2 extends Base, P extends Record<string, any> | null = null> {\n /**\n * Function that implements the transition.\n * Takes a CR in the original state and returns CR in the new state.\n * Additionally, takes appropriate payload, if any, for the transition\n * (e.g., register manager or control body notes).\n *\n * For function implementor:\n *\n * - Function MUST NOT modify CR in place.\n * - Function should throw if submitted payload does not conform to requirements.\n */\n func: Transition<CR1, CR2, P>;\n\n targetState: CR2[\"state\"];\n\n /** Title. Use verb. */\n title: string;\n\n hint?: string | JSX.Element;\n\n /** Widget that can be used to view or enter extra input. */\n Widget: P extends null ? null : React.FC<{ value: P, onChange?: (userInput: P) => void }>;\n\n /**\n * Function that returns true\n * if given stakeholder can perform this transition on given CR.\n */\n canBeTransitionedBy: (stakeholder: RegisterStakeholder, cr: CR1) => boolean;\n}\n\n\n// type TransitionSpec = {\n// [S1 in StateType]?: {\n// [S2 in StateType]?: Transition<Base<S1>, Base<S2>, Record<string, any>>\n// }\n// }\n\n\n/**\n * Source of truth for available transitions.\n * When updating change request business logic,\n * this is the type that should be modified.\n *\n * It will cause compile errors until transition implementation\n * is updated correspondingly.\n */\nexport type Transitions = {\n [State.DRAFT]: {\n // [State.DRAFT]:\n // TransitionConfig<Drafted, Drafted, SubmitterInput>;\n [State.WITHDRAWN]:\n TransitionConfig<Proposed, Withdrawn>;\n [State.PROPOSED]:\n TransitionConfig<Drafted, Proposed, SubmitterInput>;\n };\n [State.PROPOSED]: {\n [State.WITHDRAWN]:\n TransitionConfig<Proposed, Withdrawn>;\n [State.SUBMITTED_FOR_CONTROL_BODY_REVIEW]:\n TransitionConfig<Proposed, SubmittedForControlBodyReview, RegisterManagerInput>;\n [State.RETURNED_FOR_CLARIFICATION]:\n TransitionConfig<Proposed, ReturnedForClarificationByManager, RegisterManagerInput>;\n };\n [State.SUBMITTED_FOR_CONTROL_BODY_REVIEW]: {\n [State.WITHDRAWN]:\n TransitionConfig<SubmittedForControlBodyReview, Withdrawn>;\n [State.RETURNED_FOR_CLARIFICATION]:\n TransitionConfig<SubmittedForControlBodyReview, ReturnedForClarificationByControlBody, ControlBodyInput>;\n [State.REJECTED]:\n TransitionConfig<SubmittedForControlBodyReview, Rejected, ControlBodyInput>;\n [State.ACCEPTED]:\n TransitionConfig<SubmittedForControlBodyReview, Accepted, ControlBodyInput>;\n };\n [State.RETURNED_FOR_CLARIFICATION]: {\n [State.PROPOSED]:\n TransitionConfig<ReturnedForClarificationByManager | ReturnedForClarificationByControlBody, Proposed, SubmitterInput>;\n [State.WITHDRAWN]:\n TransitionConfig<ReturnedForClarificationByManager | ReturnedForClarificationByControlBody, Withdrawn>;\n };\n [State.REJECTED]: {\n [State.APPEALED]:\n TransitionConfig<Rejected, Appealed, AppealRequest>;\n };\n [State.APPEALED]: {\n [State.APPEAL_WITHDRAWN]:\n TransitionConfig<Appealed, RejectedWithAppealWithdrawn>;\n [State.ACCEPTED_ON_APPEAL]:\n TransitionConfig<Appealed, AcceptedOnAppeal, RegisterOwnerInput>;\n [State.REJECTION_UPHELD_ON_APPEAL]:\n TransitionConfig<Appealed, RejectionUpheld, RegisterOwnerInput>;\n };\n}\n\n\n// Utility\n// =======\n\nexport interface ProposalProps<P extends ChangeProposal> {\n proposal: P\n\n /** Highlight changes. */\n showDiff?: boolean\n\n /** In diff mode, only show changed data. (Provisional.) */\n showOnlyChanged?: boolean\n\n itemRef: InternalItemReference\n item: RegisterItem<Payload>\n itemBefore: P extends Clarification ? RegisterItem<Payload> : undefined\n onChange?: (newProposal: P) => void\n}\n"]}