@webiny/app-record-locking 6.0.0-rc.1 → 6.0.0-rc.2

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.
@@ -4,11 +4,6 @@ import { useWebsockets } from "@webiny/app-websockets";
4
4
  import { parseIdentifier } from "@webiny/utils";
5
5
  import { useDialogs } from "@webiny/app-admin";
6
6
  const autoUpdateTimeout = 20;
7
- const ForceUnlocked = ({
8
- user
9
- }) => {
10
- return /*#__PURE__*/React.createElement(React.Fragment, null, "The entry you were editing was forcefully unlocked by", " ", /*#__PURE__*/React.createElement("strong", null, user.displayName || "Unknown user"), ". Unfortunately, this means you lost the unsaved changes.");
11
- };
12
7
  export const ContentEntryLocker = ({
13
8
  onEntryUnlocked,
14
9
  onDisablePrompt,
@@ -43,12 +38,10 @@ export const ContentEntryLocker = ({
43
38
  });
44
39
  showDialog({
45
40
  title: "Entry was forcefully unlocked!",
46
- content: /*#__PURE__*/React.createElement(ForceUnlocked, {
47
- user: user
48
- }),
41
+ content: /*#__PURE__*/React.createElement(React.Fragment, null, "The entry you were editing was forcefully unlocked by", " ", /*#__PURE__*/React.createElement("strong", null, user.displayName || "Unknown user"), ". Unfortunately, this means you lost the unsaved changes."),
49
42
  acceptLabel: "Ok",
50
43
  onClose: undefined,
51
- cancelLabel: undefined
44
+ cancelLabel: null
52
45
  });
53
46
  onEntryUnlocked();
54
47
  });
@@ -79,7 +72,7 @@ export const ContentEntryLocker = ({
79
72
  content: result.error.message,
80
73
  acceptLabel: "Ok",
81
74
  onClose: undefined,
82
- cancelLabel: undefined
75
+ cancelLabel: null
83
76
  });
84
77
  onEntryUnlocked();
85
78
  return;
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useRef","useRecordLocking","useWebsockets","parseIdentifier","useDialogs","autoUpdateTimeout","ForceUnlocked","user","createElement","Fragment","displayName","ContentEntryLocker","onEntryUnlocked","onDisablePrompt","entry","model","children","updateEntryLock","removeEntryLock","websockets","showDialog","entryLockerTimeout","id","entryId","onMessageSub","onMessage","incoming","data","$lockingType","modelId","title","content","acceptLabel","onClose","undefined","cancelLabel","off","current","updateLock","result","error","message","createTimeout","window","setTimeout","clearTimeout"],"sources":["ContentEntryLocker.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { useRecordLocking } from \"~/hooks/index.js\";\nimport type { IRecordLockingIdentity, IRecordLockingLockRecord } from \"~/types.js\";\nimport type { IncomingGenericData } from \"@webiny/app-websockets\";\nimport { useWebsockets } from \"@webiny/app-websockets\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { useDialogs } from \"@webiny/app-admin\";\nimport type { CmsContentEntry, CmsModel } from \"@webiny/app-headless-cms/types.js\";\n\nconst autoUpdateTimeout = 20;\n\nexport interface IContentEntryLockerProps {\n entry: CmsContentEntry;\n model: CmsModel;\n onEntryUnlocked: () => void;\n onDisablePrompt: (flag: boolean) => void;\n children: React.ReactElement;\n}\n\nexport interface IKickOutWebsocketsMessage extends IncomingGenericData {\n data: {\n record: IRecordLockingLockRecord;\n user: IRecordLockingIdentity;\n };\n}\ninterface IForceUnlockedProps {\n user: IRecordLockingIdentity;\n}\nconst ForceUnlocked = ({ user }: IForceUnlockedProps) => {\n return (\n <>\n The entry you were editing was forcefully unlocked by{\" \"}\n <strong>{user.displayName || \"Unknown user\"}</strong>. Unfortunately, this means you\n lost the unsaved changes.\n </>\n );\n};\n\nexport const ContentEntryLocker = ({\n onEntryUnlocked,\n onDisablePrompt,\n entry,\n model,\n children\n}: IContentEntryLockerProps) => {\n const { updateEntryLock, removeEntryLock } = useRecordLocking();\n const websockets = useWebsockets();\n const { showDialog } = useDialogs();\n\n const entryLockerTimeout = useRef<number | null>(null);\n\n useEffect(() => {\n if (!entry.id) {\n return;\n }\n const { id: entryId } = parseIdentifier(entry.id);\n\n let onMessageSub = websockets.onMessage<IKickOutWebsocketsMessage>(\n `recordLocking.entry.kickOut.${entryId}`,\n async incoming => {\n const { user } = incoming.data;\n onDisablePrompt(true);\n removeEntryLock({\n id: entryId,\n $lockingType: model.modelId\n });\n showDialog({\n title: \"Entry was forcefully unlocked!\",\n content: <ForceUnlocked user={user} />,\n acceptLabel: \"Ok\",\n onClose: undefined,\n cancelLabel: undefined\n });\n onEntryUnlocked();\n }\n );\n\n return () => {\n onMessageSub.off();\n /**\n * Lets null subscriptions, just in case it...\n */\n // @ts-expect-error\n onMessageSub = null;\n };\n }, [entry.id, onEntryUnlocked, model.modelId]);\n\n useEffect(() => {\n if (!entry.id) {\n return;\n }\n\n if (entryLockerTimeout.current) {\n return;\n }\n\n const updateLock = async () => {\n const result = await updateEntryLock({\n id: entry.id,\n $lockingType: model.modelId\n });\n if (result.error) {\n showDialog({\n title: \"There was an error while updating the entry lock.\",\n content: result.error.message,\n acceptLabel: \"Ok\",\n onClose: undefined,\n cancelLabel: undefined\n });\n onEntryUnlocked();\n return;\n }\n createTimeout();\n };\n\n const createTimeout = () => {\n entryLockerTimeout.current = window.setTimeout(() => {\n updateLock();\n }, autoUpdateTimeout * 1000);\n };\n\n updateLock();\n return () => {\n if (!entryLockerTimeout.current) {\n return;\n }\n clearTimeout(entryLockerTimeout.current);\n entryLockerTimeout.current = null;\n };\n }, [entry.id, onEntryUnlocked]);\n\n return <>{children}</>;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SAASC,gBAAgB;AAGzB,SAASC,aAAa,QAAQ,wBAAwB;AACtD,SAASC,eAAe,QAAQ,eAAe;AAC/C,SAASC,UAAU,QAAQ,mBAAmB;AAG9C,MAAMC,iBAAiB,GAAG,EAAE;AAmB5B,MAAMC,aAAa,GAAGA,CAAC;EAAEC;AAA0B,CAAC,KAAK;EACrD,oBACIT,KAAA,CAAAU,aAAA,CAAAV,KAAA,CAAAW,QAAA,QAAE,uDACuD,EAAC,GAAG,eACzDX,KAAA,CAAAU,aAAA,iBAASD,IAAI,CAACG,WAAW,IAAI,cAAuB,CA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,CAAC;AAC1B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","useEffect","useRef","useRecordLocking","useWebsockets","parseIdentifier","useDialogs","autoUpdateTimeout","ContentEntryLocker","onEntryUnlocked","onDisablePrompt","entry","model","children","updateEntryLock","removeEntryLock","websockets","showDialog","entryLockerTimeout","id","entryId","onMessageSub","onMessage","incoming","user","data","$lockingType","modelId","title","content","createElement","Fragment","displayName","acceptLabel","onClose","undefined","cancelLabel","off","current","updateLock","result","error","message","createTimeout","window","setTimeout","clearTimeout"],"sources":["ContentEntryLocker.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { useRecordLocking } from \"~/hooks/index.js\";\nimport type { IRecordLockingIdentity, IRecordLockingLockRecord } from \"~/types.js\";\nimport type { IncomingGenericData } from \"@webiny/app-websockets\";\nimport { useWebsockets } from \"@webiny/app-websockets\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { useDialogs } from \"@webiny/app-admin\";\nimport type { CmsContentEntry, CmsModel } from \"@webiny/app-headless-cms/types.js\";\n\nconst autoUpdateTimeout = 20;\n\nexport interface IContentEntryLockerProps {\n entry: CmsContentEntry;\n model: CmsModel;\n onEntryUnlocked: () => void;\n onDisablePrompt: (flag: boolean) => void;\n children: React.ReactElement;\n}\n\nexport interface IKickOutWebsocketsMessage extends IncomingGenericData {\n data: {\n record: IRecordLockingLockRecord;\n user: IRecordLockingIdentity;\n };\n}\n\nexport const ContentEntryLocker = ({\n onEntryUnlocked,\n onDisablePrompt,\n entry,\n model,\n children\n}: IContentEntryLockerProps) => {\n const { updateEntryLock, removeEntryLock } = useRecordLocking();\n const websockets = useWebsockets();\n const { showDialog } = useDialogs();\n\n const entryLockerTimeout = useRef<number | null>(null);\n\n useEffect(() => {\n if (!entry.id) {\n return;\n }\n const { id: entryId } = parseIdentifier(entry.id);\n\n let onMessageSub = websockets.onMessage<IKickOutWebsocketsMessage>(\n `recordLocking.entry.kickOut.${entryId}`,\n async incoming => {\n const { user } = incoming.data;\n onDisablePrompt(true);\n removeEntryLock({\n id: entryId,\n $lockingType: model.modelId\n });\n showDialog({\n title: \"Entry was forcefully unlocked!\",\n content: (\n <>\n The entry you were editing was forcefully unlocked by{\" \"}\n <strong>{user.displayName || \"Unknown user\"}</strong>. Unfortunately,\n this means you lost the unsaved changes.\n </>\n ),\n acceptLabel: \"Ok\",\n onClose: undefined,\n cancelLabel: null\n });\n onEntryUnlocked();\n }\n );\n\n return () => {\n onMessageSub.off();\n /**\n * Lets null subscriptions, just in case it...\n */\n // @ts-expect-error\n onMessageSub = null;\n };\n }, [entry.id, onEntryUnlocked, model.modelId]);\n\n useEffect(() => {\n if (!entry.id) {\n return;\n }\n\n if (entryLockerTimeout.current) {\n return;\n }\n\n const updateLock = async () => {\n const result = await updateEntryLock({\n id: entry.id,\n $lockingType: model.modelId\n });\n if (result.error) {\n showDialog({\n title: \"There was an error while updating the entry lock.\",\n content: result.error.message,\n acceptLabel: \"Ok\",\n onClose: undefined,\n cancelLabel: null\n });\n onEntryUnlocked();\n return;\n }\n createTimeout();\n };\n\n const createTimeout = () => {\n entryLockerTimeout.current = window.setTimeout(() => {\n updateLock();\n }, autoUpdateTimeout * 1000);\n };\n\n updateLock();\n return () => {\n if (!entryLockerTimeout.current) {\n return;\n }\n clearTimeout(entryLockerTimeout.current);\n entryLockerTimeout.current = null;\n };\n }, [entry.id, onEntryUnlocked]);\n\n return <>{children}</>;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SAASC,gBAAgB;AAGzB,SAASC,aAAa,QAAQ,wBAAwB;AACtD,SAASC,eAAe,QAAQ,eAAe;AAC/C,SAASC,UAAU,QAAQ,mBAAmB;AAG9C,MAAMC,iBAAiB,GAAG,EAAE;AAiB5B,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EAC/BC,eAAe;EACfC,eAAe;EACfC,KAAK;EACLC,KAAK;EACLC;AACsB,CAAC,KAAK;EAC5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6 @@
1
1
  {
2
2
  "name": "@webiny/app-record-locking",
3
- "version": "6.0.0-rc.1",
3
+ "version": "6.0.0-rc.2",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -15,15 +15,15 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@apollo/react-hooks": "3.1.5",
18
- "@webiny/admin-ui": "6.0.0-rc.1",
19
- "@webiny/app": "6.0.0-rc.1",
20
- "@webiny/app-aco": "6.0.0-rc.1",
21
- "@webiny/app-admin": "6.0.0-rc.1",
22
- "@webiny/app-headless-cms": "6.0.0-rc.1",
23
- "@webiny/app-websockets": "6.0.0-rc.1",
24
- "@webiny/error": "6.0.0-rc.1",
25
- "@webiny/icons": "6.0.0-rc.1",
26
- "@webiny/utils": "6.0.0-rc.1",
18
+ "@webiny/admin-ui": "6.0.0-rc.2",
19
+ "@webiny/app": "6.0.0-rc.2",
20
+ "@webiny/app-aco": "6.0.0-rc.2",
21
+ "@webiny/app-admin": "6.0.0-rc.2",
22
+ "@webiny/app-headless-cms": "6.0.0-rc.2",
23
+ "@webiny/app-websockets": "6.0.0-rc.2",
24
+ "@webiny/error": "6.0.0-rc.2",
25
+ "@webiny/icons": "6.0.0-rc.2",
26
+ "@webiny/utils": "6.0.0-rc.2",
27
27
  "apollo-client": "2.6.10",
28
28
  "apollo-link": "1.2.14",
29
29
  "crypto-hash": "3.1.0",
@@ -32,7 +32,7 @@
32
32
  "react-dom": "18.2.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@webiny/build-tools": "6.0.0-rc.1",
35
+ "@webiny/build-tools": "6.0.0-rc.2",
36
36
  "rimraf": "6.1.3",
37
37
  "typescript": "5.9.3"
38
38
  },
@@ -40,5 +40,5 @@
40
40
  "access": "public",
41
41
  "directory": "dist"
42
42
  },
43
- "gitHead": "36d702721ff9ed39fb21d6f5fe7922a2a8716e63"
43
+ "gitHead": "5facada4cbb8617cc60e3c98be0f1839f44be38e"
44
44
  }