@riboseinc/paneron-registry-kit 2.2.4 → 2.2.5

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.
Files changed (37) hide show
  1. package/package.json +4 -3
  2. package/types/item.d.ts +1 -0
  3. package/types/item.js +8 -0
  4. package/types/item.js.map +1 -1
  5. package/views/GenericRelatedItemView.js +89 -75
  6. package/views/GenericRelatedItemView.js.map +1 -1
  7. package/views/change-request/ChangeRequestContext.js +6 -4
  8. package/views/change-request/ChangeRequestContext.js.map +1 -1
  9. package/views/detail/ChangeRequest/index.d.ts +0 -1
  10. package/views/detail/ChangeRequest/index.js +143 -128
  11. package/views/detail/ChangeRequest/index.js.map +1 -1
  12. package/views/detail/ChangeRequest/transitions.js +14 -9
  13. package/views/detail/ChangeRequest/transitions.js.map +1 -1
  14. package/views/detail/RegisterItem/index.js +27 -40
  15. package/views/detail/RegisterItem/index.js.map +1 -1
  16. package/views/hooks/useItemClassConfig.d.ts +1 -2
  17. package/views/hooks/useItemClassConfig.js +1 -7
  18. package/views/hooks/useItemClassConfig.js.map +1 -1
  19. package/views/hooks/useSingleRegisterItemData.d.ts +1 -1
  20. package/views/hooks/useSingleRegisterItemData.js +4 -3
  21. package/views/hooks/useSingleRegisterItemData.js.map +1 -1
  22. package/views/index.js +32 -23
  23. package/views/index.js.map +1 -1
  24. package/views/itemPathUtils.d.ts +3 -8
  25. package/views/itemPathUtils.js +26 -1
  26. package/views/itemPathUtils.js.map +1 -1
  27. package/views/protocolRegistry.d.ts +1 -1
  28. package/views/protocolRegistry.js.map +1 -1
  29. package/views/sidebar/Browse/index.js +43 -35
  30. package/views/sidebar/Browse/index.js.map +1 -1
  31. package/views/sidebar/Registration/index.js +12 -11
  32. package/views/sidebar/Registration/index.js.map +1 -1
  33. package/views/sidebar/Search/index.js +48 -43
  34. package/views/sidebar/Search/index.js.map +1 -1
  35. package/views/util.d.ts +1 -0
  36. package/views/util.js +3 -1
  37. package/views/util.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riboseinc/paneron-registry-kit",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
4
4
  "main": "index.js",
5
5
  "author": "Ribose Inc. <open.source@ribose.com>",
6
6
  "scripts": {
@@ -28,7 +28,7 @@
28
28
  "@blueprintjs/select": "~4.9.10",
29
29
  "@emotion/react": "^11.10.6",
30
30
  "@emotion/styled": "^11.10.6",
31
- "@riboseinc/paneron-extension-kit": "2.2.2",
31
+ "@riboseinc/paneron-extension-kit": "2.2.3",
32
32
  "@types/react": "17.0.53",
33
33
  "@types/react-dom": "^17.0.2",
34
34
  "@types/react-helmet": "^6.1.2",
@@ -42,7 +42,8 @@
42
42
  "react-visual-diff": "^0.4.3",
43
43
  "react-window": "^1.8.8",
44
44
  "rough-notation": "^0.5.1",
45
- "typescript": "~4.6.0"
45
+ "typescript": "~4.6.0",
46
+ "use-debounce": "9.0.4"
46
47
  },
47
48
  "license": "MIT"
48
49
  }
package/types/item.d.ts CHANGED
@@ -20,6 +20,7 @@ interface ItemReference {
20
20
  }
21
21
  export declare type InternalItemReference = Omit<ItemReference, 'registerID'>;
22
22
  export declare function isInternalItemReference(val: any): val is InternalItemReference;
23
+ export declare const DUMMY_REF: InternalItemReference;
23
24
  interface AbstractItemSource {
24
25
  type: string;
25
26
  }
package/types/item.js CHANGED
@@ -5,12 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isInternalItemReference = isInternalItemReference;
7
7
  exports.isRegisterItem = isRegisterItem;
8
+ exports.DUMMY_REF = void 0;
8
9
  const ITEM_STATUSES = ['submitted', 'valid', 'superseded', 'retired', 'invalid'];
9
10
 
10
11
  function isInternalItemReference(val) {
11
12
  return val && val.hasOwnProperty('itemID') && val.hasOwnProperty('classID') && typeof val['itemID'] == 'string' && typeof val['classID'] == 'string';
12
13
  }
13
14
 
15
+ const DUMMY_REF = {
16
+ itemID: 'NONEXISTENT_ITEM_ID',
17
+ classID: 'NONEXISTENT_CLASS_ID',
18
+ subregisterID: undefined
19
+ };
20
+ exports.DUMMY_REF = DUMMY_REF;
21
+
14
22
  function isRegisterItem(val) {
15
23
  return val && val.hasOwnProperty('id') && val.hasOwnProperty('data') && val.hasOwnProperty('status') && ITEM_STATUSES.indexOf(val.status) >= 0;
16
24
  }
package/types/item.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"item.js","sourceRoot":"","sources":["../../src/types/item.ts"],"names":[],"mappings":"AAKA,MAAM,aAAa,GAAG;IACpB,WAAW;IACX,OAAO;IACP,YAAY;IACZ,SAAS;IACT,SAAS;CACD,CAAC;AA2BX,MAAM,UAAU,uBAAuB,CAAC,GAAQ;IAC9C,OAAO,CACL,GAAG;QACH,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC;QAC5B,GAAG,CAAC,cAAc,CAAC,SAAS,CAAC;QAC7B,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,QAAQ;QAChC,OAAO,GAAG,CAAC,SAAS,CAAC,IAAI,QAAQ,CAClC,CAAC;AACJ,CAAC;AA0CD,MAAM,UAAU,cAAc,CAAC,GAAQ;IACrC,OAAO,CACL,GAAG;QACH,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC;QACxB,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC;QAC1B,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC;QAC5B,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CACvC,CAAC;AACJ,CAAC","sourcesContent":["import type { Citation, LocalizedAlternative } from './util';\n\n\nexport type Payload = Record<string, any>\n\nconst ITEM_STATUSES = [\n 'submitted',\n 'valid',\n 'superseded',\n 'retired',\n 'invalid',\n] as const;\n\nexport type ItemStatus = typeof ITEM_STATUSES[number];\n\n\nexport interface RegisterItemID {\n classID: string\n itemID: string\n}\n\n\nexport interface RegisterItemClass {\n id: string\n title: string\n description?: string\n alternativeNames?: LocalizedAlternative<string>[]\n}\n\ninterface ItemReference {\n registerID: string\n subregisterID?: string\n classID: string\n itemID: string\n}\n\nexport type InternalItemReference = Omit<ItemReference, 'registerID'>\n\nexport function isInternalItemReference(val: any): val is InternalItemReference {\n return (\n val &&\n val.hasOwnProperty('itemID') &&\n val.hasOwnProperty('classID') &&\n typeof val['itemID'] == 'string' &&\n typeof val['classID'] == 'string'\n );\n}\n\n\ninterface AbstractItemSource {\n type: string\n}\ninterface PaneronRegisterItemSource extends AbstractItemSource {\n type: 'paneron_register'\n itemRef: ItemReference\n}\ninterface ExternalSource extends AbstractItemSource {\n type: 'external'\n citation: Citation\n}\ntype RegisterItemSource = PaneronRegisterItemSource | ExternalSource\n\nexport interface RegisterItem<P extends Payload> {\n id: string // UUID\n\n status: ItemStatus\n\n dateAccepted: Date\n // This is a mandatory property, since until their acceptance items “live” as part of their corresponding change requests\n\n /** UUID of change request that defined the current version. */\n amendedInCR?: string\n\n // TODO: Denormalized, should be validated with consistency checks\n supersededBy?: InternalItemReference[]\n supersedes?: InternalItemReference[]\n\n /**\n * Register item data. Domain-specific. May include additional human-readable identifiers.\n * In ISO 19135-1 was represented by “definition”.\n */\n data: P\n\n source?: RegisterItemSource\n // TODO: Citations were suggested to be moved to proposals, as motivating/substantiating evidence.\n // TODO: Register item, however, should have a relationship that points to the original proto-item from another register.\n}\n\nexport function isRegisterItem(val: any): val is RegisterItem<any> {\n return (\n val &&\n val.hasOwnProperty('id') &&\n val.hasOwnProperty('data') &&\n val.hasOwnProperty('status') &&\n ITEM_STATUSES.indexOf(val.status) >= 0\n );\n}\n"]}
1
+ {"version":3,"file":"item.js","sourceRoot":"","sources":["../../src/types/item.ts"],"names":[],"mappings":"AAKA,MAAM,aAAa,GAAG;IACpB,WAAW;IACX,OAAO;IACP,YAAY;IACZ,SAAS;IACT,SAAS;CACD,CAAC;AA2BX,MAAM,UAAU,uBAAuB,CAAC,GAAQ;IAC9C,OAAO,CACL,GAAG;QACH,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC;QAC5B,GAAG,CAAC,cAAc,CAAC,SAAS,CAAC;QAC7B,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,QAAQ;QAChC,OAAO,GAAG,CAAC,SAAS,CAAC,IAAI,QAAQ,CAClC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAA0B;IAC9C,MAAM,EAAE,qBAAqB;IAC7B,OAAO,EAAE,sBAAsB;IAC/B,aAAa,EAAE,SAAS;CAChB,CAAC;AA0CX,MAAM,UAAU,cAAc,CAAC,GAAQ;IACrC,OAAO,CACL,GAAG;QACH,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC;QACxB,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC;QAC1B,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC;QAC5B,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CACvC,CAAC;AACJ,CAAC","sourcesContent":["import type { Citation, LocalizedAlternative } from './util';\n\n\nexport type Payload = Record<string, any>\n\nconst ITEM_STATUSES = [\n 'submitted',\n 'valid',\n 'superseded',\n 'retired',\n 'invalid',\n] as const;\n\nexport type ItemStatus = typeof ITEM_STATUSES[number];\n\n\nexport interface RegisterItemID {\n classID: string\n itemID: string\n}\n\n\nexport interface RegisterItemClass {\n id: string\n title: string\n description?: string\n alternativeNames?: LocalizedAlternative<string>[]\n}\n\ninterface ItemReference {\n registerID: string\n subregisterID?: string\n classID: string\n itemID: string\n}\n\nexport type InternalItemReference = Omit<ItemReference, 'registerID'>\n\nexport function isInternalItemReference(val: any): val is InternalItemReference {\n return (\n val &&\n val.hasOwnProperty('itemID') &&\n val.hasOwnProperty('classID') &&\n typeof val['itemID'] == 'string' &&\n typeof val['classID'] == 'string'\n );\n}\n\nexport const DUMMY_REF: InternalItemReference = {\n itemID: 'NONEXISTENT_ITEM_ID',\n classID: 'NONEXISTENT_CLASS_ID',\n subregisterID: undefined,\n} as const;\n\n\ninterface AbstractItemSource {\n type: string\n}\ninterface PaneronRegisterItemSource extends AbstractItemSource {\n type: 'paneron_register'\n itemRef: ItemReference\n}\ninterface ExternalSource extends AbstractItemSource {\n type: 'external'\n citation: Citation\n}\ntype RegisterItemSource = PaneronRegisterItemSource | ExternalSource\n\nexport interface RegisterItem<P extends Payload> {\n id: string // UUID\n\n status: ItemStatus\n\n dateAccepted: Date\n // This is a mandatory property, since until their acceptance items “live” as part of their corresponding change requests\n\n /** UUID of change request that defined the current version. */\n amendedInCR?: string\n\n // TODO: Denormalized, should be validated with consistency checks\n supersededBy?: InternalItemReference[]\n supersedes?: InternalItemReference[]\n\n /**\n * Register item data. Domain-specific. May include additional human-readable identifiers.\n * In ISO 19135-1 was represented by “definition”.\n */\n data: P\n\n source?: RegisterItemSource\n // TODO: Citations were suggested to be moved to proposals, as motivating/substantiating evidence.\n // TODO: Register item, however, should have a relationship that points to the original proto-item from another register.\n}\n\nexport function isRegisterItem(val: any): val is RegisterItem<any> {\n return (\n val &&\n val.hasOwnProperty('id') &&\n val.hasOwnProperty('data') &&\n val.hasOwnProperty('status') &&\n ITEM_STATUSES.indexOf(val.status) >= 0\n );\n}\n"]}
@@ -30,6 +30,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
30
30
  /** @jsx jsx */
31
31
 
32
32
  /** @jsxFrag React.Fragment */
33
+ const DUMMY_REF = {
34
+ classID: '',
35
+ itemID: '',
36
+ subregisterID: ''
37
+ };
38
+
33
39
  const GenericRelatedItemView = function ({
34
40
  itemRef,
35
41
  className,
@@ -41,7 +47,7 @@ const GenericRelatedItemView = function ({
41
47
  // itemSorter,
42
48
 
43
49
  }) {
44
- var _a, _b, _c, _d;
50
+ var _a, _b, _c;
45
51
 
46
52
  const {
47
53
  useRegisterItemData,
@@ -55,11 +61,7 @@ const GenericRelatedItemView = function ({
55
61
  classID,
56
62
  itemID,
57
63
  subregisterID
58
- } = itemRef !== null && itemRef !== void 0 ? itemRef : {
59
- classID: '',
60
- itemID: '',
61
- subregisterID: ''
62
- };
64
+ } = itemRef !== null && itemRef !== void 0 ? itemRef : DUMMY_REF;
63
65
  const itemPathWithClass = `${classID}/${itemID}.yaml`; // If curretn register has subregisters, specify subregister-relative path
64
66
 
65
67
  const itemPathWithSubregister = subregisterID ? `subregisters/${subregisterID}/${itemPathWithClass}` : `${itemPathWithClass}`; // If a change request is active
@@ -75,32 +77,29 @@ const GenericRelatedItemView = function ({
75
77
  itemPaths: [itemPath]
76
78
  });
77
79
  const item = ((_a = itemResult.value) === null || _a === void 0 ? void 0 : _a[itemPath]) || null;
78
- let classConfigured;
79
- let cfg;
80
-
81
- try {
82
- cfg = getRelatedItemClassConfiguration(classID);
83
- classConfigured = true;
84
- } catch (e) {
85
- cfg = {
86
- title: classID,
87
- itemView: () => (0, _react.jsx)("span", null, itemID)
88
- };
89
- classConfigured = false;
90
- }
91
-
92
- const Item = cfg.itemView;
93
-
94
- async function handleCreateNew() {
95
- if (!onCreateNew) {
96
- return;
80
+ const [classConfigured, cfg] = (0, _react2.useMemo)(() => {
81
+ let classConfigured;
82
+ let cfg;
83
+
84
+ try {
85
+ cfg = getRelatedItemClassConfiguration(classID);
86
+ classConfigured = true;
87
+ } catch (e) {
88
+ cfg = {
89
+ title: classID,
90
+ itemView: () => (0, _react.jsx)("span", null, itemID)
91
+ };
92
+ classConfigured = false;
97
93
  }
98
94
 
99
- const itemRef = await onCreateNew();
100
- console.debug("Created new", itemRef);
101
- }
95
+ return [classConfigured, cfg];
96
+ }, [itemID, classID, getRelatedItemClassConfiguration]);
97
+ const Item = cfg.itemView;
98
+ const classIDs = (0, _react2.useMemo)(() => {
99
+ var _a;
102
100
 
103
- const classIDs = availableClassIDs !== null && availableClassIDs !== void 0 ? availableClassIDs : ((_b = itemRef === null || itemRef === void 0 ? void 0 : itemRef.classID) !== null && _b !== void 0 ? _b : '') !== '' ? [itemRef.classID] : [];
101
+ return availableClassIDs !== null && availableClassIDs !== void 0 ? availableClassIDs : ((_a = itemRef === null || itemRef === void 0 ? void 0 : itemRef.classID) !== null && _a !== void 0 ? _a : '') !== '' ? [itemRef.classID] : [];
102
+ }, [availableClassIDs === null || availableClassIDs === void 0 ? void 0 : availableClassIDs.join(','), itemRef === null || itemRef === void 0 ? void 0 : itemRef.classID]);
104
103
 
105
104
  function jump() {
106
105
  //jumpToItem?.(classID, itemID, subregisterID);
@@ -109,26 +108,48 @@ const GenericRelatedItemView = function ({
109
108
 
110
109
  const hasItem = item !== null && classConfigured && (0, _types.isRegisterItem)(item);
111
110
  const itemIsMissing = itemID !== '' && item === null && !itemResult.isUpdating;
112
- const canAutoCreateRelatedItem = itemID === '' && onCreateNew && !itemResult.isUpdating;
113
- const canChangeRelatedItem =
114
- /*classIDs.length >= 1 && */
115
- onChange && !itemResult.isUpdating;
116
- const canClear = onClear && itemID !== '' && !itemResult.isUpdating;
111
+ const willShowItemView = hasItem || itemIsMissing || !onChange;
117
112
  const canJump = (item !== null || itemIsMissing) && classConfigured && !itemResult.isUpdating && (onJump || jumpTo);
118
- let itemView;
119
- let itemButtons = [];
120
-
121
- if (hasItem) {
122
- itemView = (0, _react.jsx)(Item, {
123
- itemRef: {
124
- classID,
125
- itemID,
126
- subregisterID
127
- },
128
- itemData: item.data
129
- });
130
- } else {
131
- if (canAutoCreateRelatedItem) {
113
+ const itemView = (0, _react2.useMemo)(() => {
114
+ let itemView;
115
+
116
+ if (hasItem) {
117
+ itemView = (0, _react.jsx)(Item, {
118
+ itemRef: {
119
+ classID,
120
+ itemID,
121
+ subregisterID
122
+ },
123
+ itemData: item.data
124
+ });
125
+ } else {
126
+ if (itemIsMissing) {
127
+ itemView = (0, _react.jsx)("span", null, "Item not found: ", itemID !== null && itemID !== void 0 ? itemID : 'N/A');
128
+ } else {
129
+ itemView = (0, _react.jsx)("span", null, "Item not specified");
130
+ }
131
+ }
132
+
133
+ return itemView;
134
+ }, [itemID, classID, subregisterID, item, hasItem, itemIsMissing]);
135
+ const itemButtons = (0, _react2.useMemo)(() => {
136
+ const canAutoCreateRelatedItem = itemID === '' && onCreateNew && !itemResult.isUpdating;
137
+ const canChangeRelatedItem =
138
+ /*classIDs.length >= 1 && */
139
+ onChange && !itemResult.isUpdating;
140
+ const canClear = onClear && itemID !== '' && !itemResult.isUpdating;
141
+ let itemButtons = [];
142
+
143
+ async function handleCreateNew() {
144
+ if (!onCreateNew) {
145
+ return;
146
+ }
147
+
148
+ const itemRef = await onCreateNew();
149
+ console.debug("Created new item", itemRef);
150
+ }
151
+
152
+ if (!hasItem && canAutoCreateRelatedItem) {
132
153
  itemButtons.push({
133
154
  onClick: handleCreateNew,
134
155
  icon: 'add',
@@ -137,34 +158,27 @@ const GenericRelatedItemView = function ({
137
158
  });
138
159
  }
139
160
 
140
- if (itemIsMissing) {
141
- itemView = (0, _react.jsx)("span", null, "Item not found: ", itemID !== null && itemID !== void 0 ? itemID : 'N/A');
142
- } else {
143
- itemView = (0, _react.jsx)("span", null, "Item not specified");
144
- }
145
- }
146
-
147
- const willShowItemView = hasItem || itemIsMissing || !onChange;
148
-
149
- if (canChangeRelatedItem) {
150
- itemButtons.push({
151
- onClick: () => setSelectDialogState(true),
152
- icon: 'edit',
153
- text: willShowItemView ? undefined : 'Specify',
154
- intent: 'primary'
155
- /*disabled: classIDs.length < 1,*/
161
+ if (canChangeRelatedItem) {
162
+ itemButtons.push({
163
+ onClick: () => setSelectDialogState(true),
164
+ icon: 'edit',
165
+ text: willShowItemView ? undefined : 'Specify',
166
+ intent: 'primary'
167
+ /*disabled: classIDs.length < 1,*/
156
168
 
157
- });
158
- }
169
+ });
170
+ }
159
171
 
160
- if (canClear) {
161
- itemButtons.push({
162
- onClick: onClear,
163
- icon: 'cross',
164
- intent: 'danger'
165
- });
166
- } //log.debug("Rendering generic related item view: got item", item);
172
+ if (canClear) {
173
+ itemButtons.push({
174
+ onClick: onClear,
175
+ icon: 'cross',
176
+ intent: 'danger'
177
+ });
178
+ }
167
179
 
180
+ return itemButtons;
181
+ }, [itemID, itemResult.isUpdating, onCreateNew, onChange, onClear]); //log.debug("Rendering generic related item view: got item", item);
168
182
 
169
183
  return (0, _react.jsx)(_core.ButtonGroup, {
170
184
  fill: true,
@@ -174,10 +188,10 @@ const GenericRelatedItemView = function ({
174
188
  }, classID ? (0, _react.jsx)(_core.Button, {
175
189
  alignText: "left",
176
190
  css: (0, _react.css)`width: 180px;`,
177
- title: `Item class: ${(_c = cfg.title) !== null && _c !== void 0 ? _c : "N/A"}`,
191
+ title: `Item class: ${(_b = cfg.title) !== null && _b !== void 0 ? _b : "N/A"}`,
178
192
  outlined: true,
179
193
  disabled: true
180
- }, (_d = cfg.title) !== null && _d !== void 0 ? _d : "Class N/A") : null, willShowItemView ? (0, _react.jsx)(_core.Button, {
194
+ }, (_c = cfg.title) !== null && _c !== void 0 ? _c : "Class N/A") : null, willShowItemView ? (0, _react.jsx)(_core.Button, {
181
195
  alignText: "left",
182
196
  fill: hasItem,
183
197
  outlined: true,
@@ -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,OAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAe,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAIL,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,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,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BAAiB,CAAC,YAAY,KAAK,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;gBAClE,OAAO,EAAE,CAAC;YACZ,CAAC,GACD,CACK,CACV,CAAC;AACJ,CAAC,CAAA;AAGD,eAAe,sBAAsB,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport { jsx, css } from '@emotion/react';\nimport React, { useContext, useState } from 'react';\nimport { Button, ButtonGroup, ButtonProps, Dialog } from '@blueprintjs/core';\nimport {\n type GenericRelatedItemViewProps,\n type InternalItemReference,\n type RelatedItemClassConfiguration,\n isRegisterItem,\n} from '../types';\nimport { BrowserCtx } from './BrowserCtx';\nimport { ChangeRequestContext } from './change-request/ChangeRequestContext';\nimport { isDrafted } from '../types/cr';\nimport Search from './sidebar/Search';\nimport { itemPathToItemRef } from './itemPathUtils';\nimport type { Criterion, CriteriaGroup } from './FilterCriteria/models';\nimport { Protocols } from './protocolRegistry';\n\n\nexport const GenericRelatedItemView: React.FC<GenericRelatedItemViewProps> = function ({\n itemRef, className,\n onCreateNew, onClear, onChange,\n availableClassIDs,\n onJump,\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 ?? {\n classID: '',\n itemID: '',\n subregisterID: '',\n };\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 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\n const Item = cfg.itemView;\n\n async function handleCreateNew() {\n if (!onCreateNew) { return; }\n const itemRef = await onCreateNew();\n console.debug(\"Created new\", itemRef);\n }\n\n const classIDs = availableClassIDs ?? ((itemRef?.classID ?? '') !== '' ? [itemRef!.classID] : []);\n\n function jump() {\n //jumpToItem?.(classID, itemID, subregisterID);\n onJump\n ? onJump()\n : jumpTo?.(`${Protocols.ITEM_DETAILS}:/${itemPathWithSubregister}`);\n }\n\n const hasItem = item !== null && classConfigured && isRegisterItem(item);\n const itemIsMissing = itemID !== '' && (item === null && !itemResult.isUpdating);\n const canAutoCreateRelatedItem = itemID === '' && onCreateNew && !itemResult.isUpdating;\n const canChangeRelatedItem = /*classIDs.length >= 1 && */onChange && !itemResult.isUpdating;\n const canClear = onClear && itemID !== '' && !itemResult.isUpdating;\n const canJump = (item !== null || itemIsMissing) && classConfigured && !itemResult.isUpdating && (onJump || jumpTo);\n\n let itemView: JSX.Element | null;\n let itemButtons: ButtonProps[] = [];\n\n if (hasItem) {\n itemView = <Item\n itemRef={{ classID, itemID, subregisterID }}\n itemData={item.data}\n />;\n } else {\n if (canAutoCreateRelatedItem) {\n itemButtons.push({\n onClick: handleCreateNew,\n icon: 'add',\n text: 'Auto create',\n intent: 'primary',\n });\n }\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\n const willShowItemView = hasItem || itemIsMissing || !onChange;\n\n if (canChangeRelatedItem) {\n itemButtons.push({\n onClick: () => setSelectDialogState(true),\n icon: 'edit',\n text: willShowItemView ? undefined : 'Specify',\n intent: 'primary',\n /*disabled: classIDs.length < 1,*/\n });\n }\n\n if (canClear) {\n itemButtons.push({ onClick: onClear, icon: 'cross', intent: 'danger' });\n }\n\n //log.debug(\"Rendering generic related item view: got item\", item);\n return (\n <ButtonGroup\n fill\n dir=\"ltr\"\n className={className}\n css={css`.bp4-button-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }`}>\n {classID\n ? <Button\n alignText=\"left\"\n css={css`width: 180px;`}\n title={`Item class: ${cfg.title ?? \"N/A\"}`}\n outlined disabled>\n {cfg.title ?? \"Class N/A\"}\n </Button>\n : null}\n {willShowItemView\n ? <Button\n alignText=\"left\"\n fill={hasItem} outlined\n disabled={!canJump}\n onClick={jump}\n loading={itemResult.isUpdating}\n title={hasItem\n ? `${cfg.title} (click to jump to item)`\n : undefined}>\n {itemView}\n </Button>\n : null}\n\n {itemButtons.map((props, idx) =>\n <Button key={idx} outlined {...props} />\n )}\n\n {onChange\n ? <RelatedItemSelectionDialog\n isOpen={selectDialogState}\n onClose={() => setSelectDialogState(false)}\n onChange={onChange}\n availableClassIDs={classIDs}\n />\n : null}\n </ButtonGroup>\n );\n};\n\n\nconst RelatedItemSelectionDialog: React.FC<{\n isOpen: boolean\n onClose: () => void\n onChange: (itemRef: InternalItemReference) => void\n availableClassIDs: string[]\n}> = function ({\n isOpen, onClose, onChange,\n availableClassIDs,\n}) {\n const { subregisters } = useContext(BrowserCtx);\n\n const classCriteria: Criterion[] = availableClassIDs.map(clsID => ({\n key: 'item-class',\n query: `objPath.indexOf(\\\"/${clsID}/\\\") >= 0`,\n }));\n\n const implicitCriteria: CriteriaGroup | undefined = classCriteria.length > 0\n ? {\n require: 'any',\n criteria: classCriteria,\n }\n : undefined;\n\n return (\n <Dialog\n isOpen={isOpen}\n onClose={onClose}\n enforceFocus={false}\n style={{ padding: '0', width: 'unset' }}>\n <Search\n style={{ height: '90vh', width: '90vw' }}\n availableClassIDs={availableClassIDs}\n implicitCriteria={implicitCriteria}\n stateName=\"superseding-item-selector-search\"\n onOpenItem={(itemPath) => {\n onChange(itemPathToItemRef(subregisters !== undefined, itemPath));\n onClose();\n }}\n />\n </Dialog>\n );\n}\n\n\nexport default GenericRelatedItemView;\n"]}
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,OAAc,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAe,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAIL,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,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,MAAM,SAAS,GAAG;IAChB,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,EAAE;IACV,aAAa,EAAE,EAAE;CACT,CAAC;AAGX,MAAM,CAAC,MAAM,sBAAsB,GAA0C,UAAU,EACrF,OAAO,EAAE,SAAS,EAClB,WAAW,EAAE,OAAO,EAAE,QAAQ,EAC9B,iBAAiB,EACjB,MAAM;AACN,2BAA2B;AAC3B,cAAc;EACf;;IACC,MAAM,EACJ,mBAAmB,EACnB,g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C,CAAC;YACE,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,aAAa;SACxB;QACH,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO,CACL,IAAC,MAAM,IACH,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,KAAK,EACnB,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE;QACzC,IAAC,MAAM,IACL,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EACxC,iBAAiB,EAAE,iBAAiB,EACpC,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAC,kCAAkC,EAC5C,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE;gBACvB,QAAQ,CAAC,iBAAiB,CAAC,YAAY,KAAK,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;gBAClE,OAAO,EAAE,CAAC;YACZ,CAAC,GACD,CACK,CACV,CAAC;AACJ,CAAC,CAAA;AAGD,eAAe,sBAAsB,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport { jsx, css } from '@emotion/react';\nimport React, { useContext, useMemo, useState } from 'react';\nimport { Button, ButtonGroup, ButtonProps, Dialog } from '@blueprintjs/core';\nimport {\n type GenericRelatedItemViewProps,\n type InternalItemReference,\n type RelatedItemClassConfiguration,\n isRegisterItem,\n} from '../types';\nimport { BrowserCtx } from './BrowserCtx';\nimport { ChangeRequestContext } from './change-request/ChangeRequestContext';\nimport { isDrafted } from '../types/cr';\nimport Search from './sidebar/Search';\nimport { itemPathToItemRef } from './itemPathUtils';\nimport type { Criterion, CriteriaGroup } from './FilterCriteria/models';\nimport { Protocols } from './protocolRegistry';\n\n\nconst DUMMY_REF = {\n classID: '',\n itemID: '',\n subregisterID: '',\n} as const;\n\n\nexport const GenericRelatedItemView: React.FC<GenericRelatedItemViewProps> = function ({\n itemRef, className,\n onCreateNew, onClear, onChange,\n availableClassIDs,\n onJump,\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 function jump() {\n //jumpToItem?.(classID, itemID, subregisterID);\n onJump\n ? onJump()\n : jumpTo?.(`${Protocols.ITEM_DETAILS}:/${itemPathWithSubregister}`);\n }\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 itemView: JSX.Element | null = useMemo(() => {\n let itemView: JSX.Element | null;\n\n if (hasItem) {\n itemView = <Item\n itemRef={{ classID, itemID, subregisterID }}\n itemData={item.data}\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[] = [];\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 });\n }\n if (canChangeRelatedItem) {\n itemButtons.push({\n onClick: () => setSelectDialogState(true),\n icon: 'edit',\n text: willShowItemView ? undefined : 'Specify',\n intent: 'primary',\n /*disabled: classIDs.length < 1,*/\n });\n }\n if (canClear) {\n itemButtons.push({ onClick: onClear, icon: 'cross', intent: 'danger' });\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 <ButtonGroup\n fill\n dir=\"ltr\"\n className={className}\n css={css`.bp4-button-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }`}>\n\n {classID\n ? <Button\n alignText=\"left\"\n css={css`width: 180px;`}\n title={`Item class: ${cfg.title ?? \"N/A\"}`}\n outlined disabled>\n {cfg.title ?? \"Class N/A\"}\n </Button>\n : null}\n\n {willShowItemView\n ? <Button\n alignText=\"left\"\n fill={hasItem} outlined\n disabled={!canJump}\n onClick={jump}\n loading={itemResult.isUpdating}\n title={hasItem\n ? `${cfg.title} (click to jump to item)`\n : undefined}>\n {itemView}\n </Button>\n : null}\n\n {itemButtons.map((props, idx) =>\n <Button key={idx} outlined {...props} />\n )}\n\n {onChange\n ? <RelatedItemSelectionDialog\n isOpen={selectDialogState}\n onClose={() => setSelectDialogState(false)}\n onChange={onChange}\n availableClassIDs={classIDs}\n />\n : null}\n </ButtonGroup>\n );\n};\n\n\nconst RelatedItemSelectionDialog: React.FC<{\n isOpen: boolean\n onClose: () => void\n onChange: (itemRef: InternalItemReference) => void\n availableClassIDs: string[]\n}> = function ({\n isOpen, onClose, onChange,\n availableClassIDs,\n}) {\n const { subregisters } = useContext(BrowserCtx);\n\n const classCriteria: Criterion[] = availableClassIDs.map(clsID => ({\n key: 'item-class',\n query: `objPath.indexOf(\\\"/${clsID}/\\\") >= 0`,\n }));\n\n const implicitCriteria: CriteriaGroup | undefined = classCriteria.length > 0\n ? {\n require: 'any',\n criteria: classCriteria,\n }\n : undefined;\n\n return (\n <Dialog\n isOpen={isOpen}\n onClose={onClose}\n enforceFocus={false}\n style={{ padding: '0', width: 'unset' }}>\n <Search\n style={{ height: '90vh', width: '90vw' }}\n availableClassIDs={availableClassIDs}\n implicitCriteria={implicitCriteria}\n stateName=\"superseding-item-selector-search\"\n onOpenItem={(itemPath) => {\n onChange(itemPathToItemRef(subregisters !== undefined, itemPath));\n onClose();\n }}\n />\n </Dialog>\n );\n}\n\n\nexport default GenericRelatedItemView;\n"]}
@@ -46,11 +46,13 @@ const ChangeRequestContextProvider = function ({
46
46
  objectPaths: crPath ? [crPath] : [],
47
47
  nounLabel: 'proposal(s)'
48
48
  }).value) === null || _a === void 0 ? void 0 : _a.data[crPath !== null && crPath !== void 0 ? crPath : '']) !== null && _b !== void 0 ? _b : crPath ? undefined : null;
49
+ const canEdit = changeRequest && stakeholder && (0, _cr.canBeEditedBy)(stakeholder, changeRequest) ? true : false;
50
+ const ctx = (0, _react2.useMemo)(() => ({
51
+ changeRequest,
52
+ canEdit
53
+ }), [changeRequest, canEdit]);
49
54
  return (0, _react.jsx)(ChangeRequestContext.Provider, {
50
- value: {
51
- changeRequest,
52
- canEdit: changeRequest && stakeholder && (0, _cr.canBeEditedBy)(stakeholder, changeRequest) ? true : false
53
- }
55
+ value: ctx
54
56
  }, children);
55
57
  };
56
58
 
@@ -1 +1 @@
1
- {"version":3,"file":"ChangeRequestContext.js","sourceRoot":"","sources":["../../../src/views/change-request/ChangeRequestContext.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAqB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAiB3C,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC,aAAa,CAA2B;IAChF,aAAa,EAAE,IAAI;IACnB,OAAO,EAAE,KAAK;CACf,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAEpC,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE;;IAC1C,MAAM,EAAE,aAAa,EAAE,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAErD,MAAM,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IAE/C,MAAM,MAAM,GAAG,eAAe;QAC5B,CAAC,CAAC,cAAc,eAAe,YAAY;QAC3C,CAAC,CAAC,IAAI,CAAC;IAET,MAAM,aAAa,GAAG,MAAA,MAAA,aAAa,CAAC;QAClC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;QACnC,SAAS,EAAE,aAAa;KACzB,CAAC,CAAC,KAAK,0CAAE,IAAI,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAO,mCAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAElE,OAAO,CACL,IAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE;YACpC,aAAa;YACb,OAAO,EACL,aAAa;mBACV,WAAW;mBACX,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC;gBAC1C,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,KAAK;SACZ,IACE,QAAQ,CACqB,CACjC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport { jsx } from '@emotion/react';\nimport React, { useContext } from 'react';\nimport { DatasetContext } from '@riboseinc/paneron-extension-kit/context';\nimport { type SomeCR as CR, canBeEditedBy } from '../../types/cr';\nimport { BrowserCtx } from '../BrowserCtx';\n\n\nexport interface ChangeRequestContextSpec {\n /**\n * Change request object, undefined if not available/loading,\n * null if not expected (i.e. changeRequestID is not given).\n */\n changeRequest?: CR | null\n\n /**\n * Current user can edit the contents of this CR.\n * Always false if `changeRequest` is not defined or `null`.\n */\n canEdit: boolean\n}\n\nexport const ChangeRequestContext = React.createContext<ChangeRequestContextSpec>({\n changeRequest: null,\n canEdit: false,\n});\n\nexport const ChangeRequestContextProvider: React.FC<{\n changeRequestID: string | null\n}> = function ({ changeRequestID, children }) {\n const { useObjectData } = useContext(DatasetContext);\n\n const { stakeholder } = useContext(BrowserCtx);\n\n const crPath = changeRequestID\n ? `/proposals/${changeRequestID}/main.yaml`\n : null;\n\n const changeRequest = useObjectData({\n objectPaths: crPath ? [crPath] : [],\n nounLabel: 'proposal(s)',\n }).value?.data[crPath ?? ''] as CR ?? (crPath ? undefined : null);\n\n return (\n <ChangeRequestContext.Provider value={{\n changeRequest,\n canEdit:\n changeRequest\n && stakeholder\n && canBeEditedBy(stakeholder, changeRequest)\n ? true\n : false,\n }}>\n {children}\n </ChangeRequestContext.Provider>\n );\n};\n"]}
1
+ {"version":3,"file":"ChangeRequestContext.js","sourceRoot":"","sources":["../../../src/views/change-request/ChangeRequestContext.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAqB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAiB3C,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC,aAAa,CAA2B;IAChF,aAAa,EAAE,IAAI;IACnB,OAAO,EAAE,KAAK;CACf,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAEpC,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE;;IAC1C,MAAM,EAAE,aAAa,EAAE,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IACrD,MAAM,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IAE/C,MAAM,MAAM,GAAG,eAAe;QAC5B,CAAC,CAAC,cAAc,eAAe,YAAY;QAC3C,CAAC,CAAC,IAAI,CAAC;IAET,MAAM,aAAa,GAAG,MAAA,MAAA,aAAa,CAAC;QAClC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;QACnC,SAAS,EAAE,aAAa;KACzB,CAAC,CAAC,KAAK,0CAAE,IAAI,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAO,mCAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAElE,MAAM,OAAO,GAAG,aAAa;WACxB,WAAW;WACX,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC;QAC1C,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,KAAK,CAAC;IAEZ,MAAM,GAAG,GAA6B,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;QACpD,aAAa;QACb,OAAO;KACR,CAAC,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IAE/B,OAAO,CACL,IAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,GAAG,IACtC,QAAQ,CACqB,CACjC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport { jsx } from '@emotion/react';\nimport React, { useMemo, useContext } from 'react';\nimport { DatasetContext } from '@riboseinc/paneron-extension-kit/context';\nimport { type SomeCR as CR, canBeEditedBy } from '../../types/cr';\nimport { BrowserCtx } from '../BrowserCtx';\n\n\nexport interface ChangeRequestContextSpec {\n /**\n * Change request object, undefined if not available/loading,\n * null if not expected (i.e. changeRequestID is not given).\n */\n changeRequest?: CR | null\n\n /**\n * Current user can edit the contents of this CR.\n * Always false if `changeRequest` is not defined or `null`.\n */\n canEdit: boolean\n}\n\nexport const ChangeRequestContext = React.createContext<ChangeRequestContextSpec>({\n changeRequest: null,\n canEdit: false,\n});\n\nexport const ChangeRequestContextProvider: React.FC<{\n changeRequestID: string | null\n}> = function ({ changeRequestID, children }) {\n const { useObjectData } = useContext(DatasetContext);\n const { stakeholder } = useContext(BrowserCtx);\n\n const crPath = changeRequestID\n ? `/proposals/${changeRequestID}/main.yaml`\n : null;\n\n const changeRequest = useObjectData({\n objectPaths: crPath ? [crPath] : [],\n nounLabel: 'proposal(s)',\n }).value?.data[crPath ?? ''] as CR ?? (crPath ? undefined : null);\n\n const canEdit = changeRequest\n && stakeholder\n && canBeEditedBy(stakeholder, changeRequest)\n ? true\n : false;\n\n const ctx: ChangeRequestContextSpec = useMemo((() => ({\n changeRequest,\n canEdit,\n })), [changeRequest, canEdit]);\n\n return (\n <ChangeRequestContext.Provider value={ctx}>\n {children}\n </ChangeRequestContext.Provider>\n );\n};\n"]}
@@ -8,6 +8,5 @@ declare const _default: {
8
8
  title: React.FC<{
9
9
  uri: string;
10
10
  }>;
11
- plainTitle: (uri: string) => Promise<string>;
12
11
  };
13
12
  export default _default;