@ynput/ayon-frontend-shared 0.3.1 → 0.3.3

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 (363) hide show
  1. package/dist/node_modules/web-namespaces/index.cjs.js +1 -1
  2. package/dist/node_modules/web-namespaces/index.cjs.js.map +1 -1
  3. package/dist/node_modules/web-namespaces/index.es.js +3 -8
  4. package/dist/node_modules/web-namespaces/index.es.js.map +1 -1
  5. package/dist/shared/src/api/generated/graphql.cjs.js +12 -8
  6. package/dist/shared/src/api/generated/graphql.cjs.js.map +1 -1
  7. package/dist/shared/src/api/generated/graphql.es.js +11 -7
  8. package/dist/shared/src/api/generated/graphql.es.js.map +1 -1
  9. package/dist/shared/src/api/generated/graphqlLinks.cjs.js.map +1 -1
  10. package/dist/shared/src/api/generated/graphqlLinks.es.js.map +1 -1
  11. package/dist/shared/src/api/queries/entities/updateEntity.cjs.js +1 -1
  12. package/dist/shared/src/api/queries/entities/updateEntity.cjs.js.map +1 -1
  13. package/dist/shared/src/api/queries/entities/updateEntity.es.js +125 -120
  14. package/dist/shared/src/api/queries/entities/updateEntity.es.js.map +1 -1
  15. package/dist/shared/src/api/queries/views/updateViews.cjs.js +1 -1
  16. package/dist/shared/src/api/queries/views/updateViews.cjs.js.map +1 -1
  17. package/dist/shared/src/api/queries/views/updateViews.es.js +68 -63
  18. package/dist/shared/src/api/queries/views/updateViews.es.js.map +1 -1
  19. package/dist/shared/src/components/LinksManager/LinkManagerItem.cjs.js +1 -1
  20. package/dist/shared/src/components/LinksManager/LinkManagerItem.cjs.js.map +1 -1
  21. package/dist/shared/src/components/LinksManager/LinkManagerItem.es.js +30 -28
  22. package/dist/shared/src/components/LinksManager/LinkManagerItem.es.js.map +1 -1
  23. package/dist/shared/src/components/LinksManager/LinksManager.cjs.js +1 -1
  24. package/dist/shared/src/components/LinksManager/LinksManager.cjs.js.map +1 -1
  25. package/dist/shared/src/components/LinksManager/LinksManager.es.js +74 -56
  26. package/dist/shared/src/components/LinksManager/LinksManager.es.js.map +1 -1
  27. package/dist/shared/src/components/LinksManager/LinksManager.styled.cjs.js +2 -1
  28. package/dist/shared/src/components/LinksManager/LinksManager.styled.cjs.js.map +1 -1
  29. package/dist/shared/src/components/LinksManager/LinksManager.styled.es.js +5 -4
  30. package/dist/shared/src/components/LinksManager/LinksManager.styled.es.js.map +1 -1
  31. package/dist/shared/src/components/ProjectTableSettings/ColumnsSettings.cjs.js +2 -2
  32. package/dist/shared/src/components/ProjectTableSettings/ColumnsSettings.cjs.js.map +1 -1
  33. package/dist/shared/src/components/ProjectTableSettings/ColumnsSettings.es.js +66 -61
  34. package/dist/shared/src/components/ProjectTableSettings/ColumnsSettings.es.js.map +1 -1
  35. package/dist/shared/src/containers/Feed/Feed.cjs.js +1 -1
  36. package/dist/shared/src/containers/Feed/Feed.cjs.js.map +1 -1
  37. package/dist/shared/src/containers/Feed/Feed.es.js +123 -113
  38. package/dist/shared/src/containers/Feed/Feed.es.js.map +1 -1
  39. package/dist/shared/src/containers/Feed/hooks/useTransformActivities.cjs.js +1 -1
  40. package/dist/shared/src/containers/Feed/hooks/useTransformActivities.cjs.js.map +1 -1
  41. package/dist/shared/src/containers/Feed/hooks/useTransformActivities.es.js +6 -6
  42. package/dist/shared/src/containers/Feed/hooks/useTransformActivities.es.js.map +1 -1
  43. package/dist/shared/src/containers/ProjectTreeTable/context/ClipboardContext.cjs.js +3 -3
  44. package/dist/shared/src/containers/ProjectTreeTable/context/ClipboardContext.cjs.js.map +1 -1
  45. package/dist/shared/src/containers/ProjectTreeTable/context/ClipboardContext.es.js +178 -172
  46. package/dist/shared/src/containers/ProjectTreeTable/context/ClipboardContext.es.js.map +1 -1
  47. package/dist/shared/src/containers/ProjectTreeTable/widgets/LinksWidget.cjs.js +1 -1
  48. package/dist/shared/src/containers/ProjectTreeTable/widgets/LinksWidget.cjs.js.map +1 -1
  49. package/dist/shared/src/containers/ProjectTreeTable/widgets/LinksWidget.es.js +42 -41
  50. package/dist/shared/src/containers/ProjectTreeTable/widgets/LinksWidget.es.js.map +1 -1
  51. package/dist/shared/src/containers/ProjectTreeTable/widgets/TextWidget.cjs.js +2 -2
  52. package/dist/shared/src/containers/ProjectTreeTable/widgets/TextWidget.cjs.js.map +1 -1
  53. package/dist/shared/src/containers/ProjectTreeTable/widgets/TextWidget.es.js +10 -10
  54. package/dist/shared/src/containers/Views/ViewsMenuContainer/BaseViewsTags.cjs.js +1 -1
  55. package/dist/shared/src/containers/Views/ViewsMenuContainer/BaseViewsTags.cjs.js.map +1 -1
  56. package/dist/shared/src/containers/Views/ViewsMenuContainer/BaseViewsTags.es.js +26 -26
  57. package/dist/shared/src/containers/Views/ViewsMenuContainer/BaseViewsTags.es.js.map +1 -1
  58. package/dist/shared/src/containers/Views/context/ViewsContext.cjs.js +1 -1
  59. package/dist/shared/src/containers/Views/context/ViewsContext.cjs.js.map +1 -1
  60. package/dist/shared/src/containers/Views/context/ViewsContext.es.js +53 -51
  61. package/dist/shared/src/containers/Views/context/ViewsContext.es.js.map +1 -1
  62. package/dist/shared/src/containers/Views/hooks/useBaseViewMutations.cjs.js +1 -1
  63. package/dist/shared/src/containers/Views/hooks/useBaseViewMutations.cjs.js.map +1 -1
  64. package/dist/shared/src/containers/Views/hooks/useBaseViewMutations.es.js +95 -52
  65. package/dist/shared/src/containers/Views/hooks/useBaseViewMutations.es.js.map +1 -1
  66. package/dist/shared/src/containers/Views/hooks/useViewsMutations.cjs.js +1 -1
  67. package/dist/shared/src/containers/Views/hooks/useViewsMutations.cjs.js.map +1 -1
  68. package/dist/shared/src/containers/Views/hooks/useViewsMutations.es.js +13 -13
  69. package/dist/shared/src/containers/Views/hooks/useViewsMutations.es.js.map +1 -1
  70. package/dist/shared/src/containers/Views/utils/viewUpdateHelper.cjs.js +1 -1
  71. package/dist/shared/src/containers/Views/utils/viewUpdateHelper.cjs.js.map +1 -1
  72. package/dist/shared/src/containers/Views/utils/viewUpdateHelper.es.js +38 -37
  73. package/dist/shared/src/containers/Views/utils/viewUpdateHelper.es.js.map +1 -1
  74. package/dist/shared/src/hooks/useLoadModules.cjs.js +1 -1
  75. package/dist/shared/src/hooks/useLoadModules.cjs.js.map +1 -1
  76. package/dist/shared/src/hooks/useLoadModules.es.js +86 -80
  77. package/dist/shared/src/hooks/useLoadModules.es.js.map +1 -1
  78. package/dist/types/api/generated/graphql.d.ts +2 -1
  79. package/dist/types/api/generated/graphqlLinks.d.ts +1 -0
  80. package/dist/types/components/LinksManager/LinkManagerItem.d.ts +1 -0
  81. package/dist/types/containers/Views/context/ViewsContext.d.ts +1 -0
  82. package/dist/types/containers/Views/hooks/useBaseViewMutations.d.ts +5 -2
  83. package/package.json +2 -1
  84. package/dist/node_modules/@ungap/structured-clone/esm/deserialize.cjs.js +0 -2
  85. package/dist/node_modules/@ungap/structured-clone/esm/deserialize.cjs.js.map +0 -1
  86. package/dist/node_modules/@ungap/structured-clone/esm/deserialize.es.js +0 -63
  87. package/dist/node_modules/@ungap/structured-clone/esm/deserialize.es.js.map +0 -1
  88. package/dist/node_modules/@ungap/structured-clone/esm/index.cjs.js +0 -2
  89. package/dist/node_modules/@ungap/structured-clone/esm/index.cjs.js.map +0 -1
  90. package/dist/node_modules/@ungap/structured-clone/esm/index.es.js +0 -12
  91. package/dist/node_modules/@ungap/structured-clone/esm/index.es.js.map +0 -1
  92. package/dist/node_modules/@ungap/structured-clone/esm/serialize.cjs.js +0 -2
  93. package/dist/node_modules/@ungap/structured-clone/esm/serialize.cjs.js.map +0 -1
  94. package/dist/node_modules/@ungap/structured-clone/esm/serialize.es.js +0 -107
  95. package/dist/node_modules/@ungap/structured-clone/esm/serialize.es.js.map +0 -1
  96. package/dist/node_modules/@ungap/structured-clone/esm/types.cjs.js +0 -2
  97. package/dist/node_modules/@ungap/structured-clone/esm/types.cjs.js.map +0 -1
  98. package/dist/node_modules/@ungap/structured-clone/esm/types.es.js +0 -14
  99. package/dist/node_modules/@ungap/structured-clone/esm/types.es.js.map +0 -1
  100. package/dist/node_modules/devlop/lib/default.cjs.js +0 -2
  101. package/dist/node_modules/devlop/lib/default.cjs.js.map +0 -1
  102. package/dist/node_modules/devlop/lib/default.es.js +0 -6
  103. package/dist/node_modules/devlop/lib/default.es.js.map +0 -1
  104. package/dist/node_modules/entities/dist/esm/decode-codepoint.cjs.js +0 -2
  105. package/dist/node_modules/entities/dist/esm/decode-codepoint.cjs.js.map +0 -1
  106. package/dist/node_modules/entities/dist/esm/decode-codepoint.es.js +0 -39
  107. package/dist/node_modules/entities/dist/esm/decode-codepoint.es.js.map +0 -1
  108. package/dist/node_modules/entities/dist/esm/decode.cjs.js +0 -2
  109. package/dist/node_modules/entities/dist/esm/decode.cjs.js.map +0 -1
  110. package/dist/node_modules/entities/dist/esm/decode.es.js +0 -246
  111. package/dist/node_modules/entities/dist/esm/decode.es.js.map +0 -1
  112. package/dist/node_modules/entities/dist/esm/generated/decode-data-html.cjs.js +0 -2
  113. package/dist/node_modules/entities/dist/esm/generated/decode-data-html.cjs.js.map +0 -1
  114. package/dist/node_modules/entities/dist/esm/generated/decode-data-html.es.js +0 -8
  115. package/dist/node_modules/entities/dist/esm/generated/decode-data-html.es.js.map +0 -1
  116. package/dist/node_modules/hast-util-raw/lib/index.cjs.js +0 -2
  117. package/dist/node_modules/hast-util-raw/lib/index.cjs.js.map +0 -1
  118. package/dist/node_modules/hast-util-raw/lib/index.es.js +0 -218
  119. package/dist/node_modules/hast-util-raw/lib/index.es.js.map +0 -1
  120. package/dist/node_modules/hast-util-raw/node_modules/hast-util-from-parse5/lib/index.cjs.js +0 -2
  121. package/dist/node_modules/hast-util-raw/node_modules/hast-util-from-parse5/lib/index.cjs.js.map +0 -1
  122. package/dist/node_modules/hast-util-raw/node_modules/hast-util-from-parse5/lib/index.es.js +0 -146
  123. package/dist/node_modules/hast-util-raw/node_modules/hast-util-from-parse5/lib/index.es.js.map +0 -1
  124. package/dist/node_modules/hast-util-raw/node_modules/hast-util-parse-selector/lib/index.cjs.js +0 -2
  125. package/dist/node_modules/hast-util-raw/node_modules/hast-util-parse-selector/lib/index.cjs.js.map +0 -1
  126. package/dist/node_modules/hast-util-raw/node_modules/hast-util-parse-selector/lib/index.es.js +0 -21
  127. package/dist/node_modules/hast-util-raw/node_modules/hast-util-parse-selector/lib/index.es.js.map +0 -1
  128. package/dist/node_modules/hast-util-raw/node_modules/hastscript/lib/create-h.cjs.js +0 -2
  129. package/dist/node_modules/hast-util-raw/node_modules/hastscript/lib/create-h.cjs.js.map +0 -1
  130. package/dist/node_modules/hast-util-raw/node_modules/hastscript/lib/create-h.es.js +0 -113
  131. package/dist/node_modules/hast-util-raw/node_modules/hastscript/lib/create-h.es.js.map +0 -1
  132. package/dist/node_modules/hast-util-raw/node_modules/hastscript/lib/index.cjs.js +0 -2
  133. package/dist/node_modules/hast-util-raw/node_modules/hastscript/lib/index.cjs.js.map +0 -1
  134. package/dist/node_modules/hast-util-raw/node_modules/hastscript/lib/index.es.js +0 -9
  135. package/dist/node_modules/hast-util-raw/node_modules/hastscript/lib/index.es.js.map +0 -1
  136. package/dist/node_modules/hast-util-raw/node_modules/hastscript/lib/svg-case-sensitive-tag-names.cjs.js +0 -2
  137. package/dist/node_modules/hast-util-raw/node_modules/hastscript/lib/svg-case-sensitive-tag-names.cjs.js.map +0 -1
  138. package/dist/node_modules/hast-util-raw/node_modules/hastscript/lib/svg-case-sensitive-tag-names.es.js +0 -45
  139. package/dist/node_modules/hast-util-raw/node_modules/hastscript/lib/svg-case-sensitive-tag-names.es.js.map +0 -1
  140. package/dist/node_modules/hast-util-raw/node_modules/html-void-elements/index.cjs.js +0 -2
  141. package/dist/node_modules/hast-util-raw/node_modules/html-void-elements/index.cjs.js.map +0 -1
  142. package/dist/node_modules/hast-util-raw/node_modules/html-void-elements/index.es.js +0 -26
  143. package/dist/node_modules/hast-util-raw/node_modules/html-void-elements/index.es.js.map +0 -1
  144. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/doctype.cjs.js +0 -2
  145. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/doctype.cjs.js.map +0 -1
  146. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/doctype.es.js +0 -99
  147. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/doctype.es.js.map +0 -1
  148. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/error-codes.cjs.js +0 -2
  149. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/error-codes.cjs.js.map +0 -1
  150. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/error-codes.es.js +0 -8
  151. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/error-codes.es.js.map +0 -1
  152. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/foreign-content.cjs.js +0 -2
  153. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/foreign-content.cjs.js.map +0 -1
  154. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/foreign-content.es.js +0 -211
  155. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/foreign-content.es.js.map +0 -1
  156. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/html.cjs.js +0 -2
  157. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/html.cjs.js.map +0 -1
  158. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/html.es.js +0 -251
  159. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/html.es.js.map +0 -1
  160. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/token.cjs.js +0 -2
  161. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/token.cjs.js.map +0 -1
  162. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/token.es.js +0 -15
  163. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/token.es.js.map +0 -1
  164. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/unicode.cjs.js +0 -2
  165. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/unicode.cjs.js.map +0 -1
  166. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/unicode.es.js +0 -74
  167. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/common/unicode.es.js.map +0 -1
  168. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/parser/formatting-element-list.cjs.js +0 -2
  169. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/parser/formatting-element-list.cjs.js.map +0 -1
  170. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/parser/formatting-element-list.es.js +0 -85
  171. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/parser/formatting-element-list.es.js.map +0 -1
  172. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/parser/index.cjs.js +0 -2
  173. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/parser/index.cjs.js.map +0 -1
  174. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/parser/index.es.js +0 -2272
  175. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/parser/index.es.js.map +0 -1
  176. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/parser/open-element-stack.cjs.js +0 -2
  177. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/parser/open-element-stack.cjs.js.map +0 -1
  178. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/parser/open-element-stack.es.js +0 -241
  179. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/parser/open-element-stack.es.js.map +0 -1
  180. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/serializer/index.cjs.js +0 -2
  181. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/serializer/index.cjs.js.map +0 -1
  182. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/serializer/index.es.js +0 -3
  183. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/serializer/index.es.js.map +0 -1
  184. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/tokenizer/index.cjs.js +0 -2
  185. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/tokenizer/index.cjs.js.map +0 -1
  186. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/tokenizer/index.es.js +0 -1941
  187. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/tokenizer/index.es.js.map +0 -1
  188. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/tokenizer/preprocessor.cjs.js +0 -2
  189. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/tokenizer/preprocessor.cjs.js.map +0 -1
  190. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/tokenizer/preprocessor.es.js +0 -89
  191. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/tokenizer/preprocessor.es.js.map +0 -1
  192. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/tree-adapters/default.cjs.js +0 -2
  193. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/tree-adapters/default.cjs.js.map +0 -1
  194. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/tree-adapters/default.es.js +0 -163
  195. package/dist/node_modules/hast-util-raw/node_modules/parse5/dist/tree-adapters/default.es.js.map +0 -1
  196. package/dist/node_modules/hast-util-raw/node_modules/property-information/index.cjs.js +0 -2
  197. package/dist/node_modules/hast-util-raw/node_modules/property-information/index.cjs.js.map +0 -1
  198. package/dist/node_modules/hast-util-raw/node_modules/property-information/index.es.js +0 -13
  199. package/dist/node_modules/hast-util-raw/node_modules/property-information/index.es.js.map +0 -1
  200. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/aria.cjs.js +0 -2
  201. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/aria.cjs.js.map +0 -1
  202. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/aria.es.js +0 -62
  203. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/aria.es.js.map +0 -1
  204. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/find.cjs.js +0 -2
  205. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/find.cjs.js.map +0 -1
  206. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/find.es.js +0 -34
  207. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/find.es.js.map +0 -1
  208. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/html.cjs.js +0 -2
  209. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/html.cjs.js.map +0 -1
  210. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/html.es.js +0 -369
  211. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/html.es.js.map +0 -1
  212. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/normalize.cjs.js +0 -2
  213. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/normalize.cjs.js.map +0 -1
  214. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/normalize.es.js +0 -7
  215. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/normalize.es.js.map +0 -1
  216. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/svg.cjs.js +0 -2
  217. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/svg.cjs.js.map +0 -1
  218. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/svg.es.js +0 -567
  219. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/svg.es.js.map +0 -1
  220. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/case-insensitive-transform.cjs.js +0 -2
  221. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/case-insensitive-transform.cjs.js.map +0 -1
  222. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/case-insensitive-transform.es.js +0 -8
  223. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/case-insensitive-transform.es.js.map +0 -1
  224. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/case-sensitive-transform.cjs.js +0 -2
  225. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/case-sensitive-transform.cjs.js.map +0 -1
  226. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/case-sensitive-transform.es.js +0 -7
  227. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/case-sensitive-transform.es.js.map +0 -1
  228. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/create.cjs.js +0 -2
  229. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/create.cjs.js.map +0 -1
  230. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/create.es.js +0 -20
  231. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/create.es.js.map +0 -1
  232. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/defined-info.cjs.js +0 -2
  233. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/defined-info.cjs.js.map +0 -1
  234. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/defined-info.es.js +0 -37
  235. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/defined-info.es.js.map +0 -1
  236. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/info.cjs.js +0 -2
  237. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/info.cjs.js.map +0 -1
  238. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/info.es.js +0 -29
  239. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/info.es.js.map +0 -1
  240. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/merge.cjs.js +0 -2
  241. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/merge.cjs.js.map +0 -1
  242. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/merge.es.js +0 -11
  243. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/merge.es.js.map +0 -1
  244. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/schema.cjs.js +0 -2
  245. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/schema.cjs.js.map +0 -1
  246. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/schema.es.js +0 -22
  247. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/schema.es.js.map +0 -1
  248. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/types.cjs.js +0 -2
  249. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/types.cjs.js.map +0 -1
  250. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/types.es.js +0 -15
  251. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/util/types.es.js.map +0 -1
  252. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/xlink.cjs.js +0 -2
  253. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/xlink.cjs.js.map +0 -1
  254. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/xlink.es.js +0 -20
  255. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/xlink.es.js.map +0 -1
  256. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/xml.cjs.js +0 -2
  257. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/xml.cjs.js.map +0 -1
  258. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/xml.es.js +0 -12
  259. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/xml.es.js.map +0 -1
  260. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/xmlns.cjs.js +0 -2
  261. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/xmlns.cjs.js.map +0 -1
  262. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/xmlns.es.js +0 -12
  263. package/dist/node_modules/hast-util-raw/node_modules/property-information/lib/xmlns.es.js.map +0 -1
  264. package/dist/node_modules/hast-util-raw/node_modules/vfile-location/lib/index.cjs.js +0 -3
  265. package/dist/node_modules/hast-util-raw/node_modules/vfile-location/lib/index.cjs.js.map +0 -1
  266. package/dist/node_modules/hast-util-raw/node_modules/vfile-location/lib/index.es.js +0 -43
  267. package/dist/node_modules/hast-util-raw/node_modules/vfile-location/lib/index.es.js.map +0 -1
  268. package/dist/node_modules/hast-util-to-parse5/lib/index.cjs.js +0 -2
  269. package/dist/node_modules/hast-util-to-parse5/lib/index.cjs.js.map +0 -1
  270. package/dist/node_modules/hast-util-to-parse5/lib/index.es.js +0 -119
  271. package/dist/node_modules/hast-util-to-parse5/lib/index.es.js.map +0 -1
  272. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/index.cjs.js +0 -2
  273. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/index.cjs.js.map +0 -1
  274. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/index.es.js +0 -13
  275. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/index.es.js.map +0 -1
  276. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/aria.cjs.js +0 -2
  277. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/aria.cjs.js.map +0 -1
  278. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/aria.es.js +0 -62
  279. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/aria.es.js.map +0 -1
  280. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/find.cjs.js +0 -2
  281. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/find.cjs.js.map +0 -1
  282. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/find.es.js +0 -34
  283. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/find.es.js.map +0 -1
  284. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/html.cjs.js +0 -2
  285. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/html.cjs.js.map +0 -1
  286. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/html.es.js +0 -369
  287. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/html.es.js.map +0 -1
  288. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/normalize.cjs.js +0 -2
  289. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/normalize.cjs.js.map +0 -1
  290. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/normalize.es.js +0 -7
  291. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/normalize.es.js.map +0 -1
  292. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/svg.cjs.js +0 -2
  293. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/svg.cjs.js.map +0 -1
  294. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/svg.es.js +0 -567
  295. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/svg.es.js.map +0 -1
  296. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/case-insensitive-transform.cjs.js +0 -2
  297. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/case-insensitive-transform.cjs.js.map +0 -1
  298. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/case-insensitive-transform.es.js +0 -8
  299. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/case-insensitive-transform.es.js.map +0 -1
  300. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/case-sensitive-transform.cjs.js +0 -2
  301. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/case-sensitive-transform.cjs.js.map +0 -1
  302. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/case-sensitive-transform.es.js +0 -7
  303. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/case-sensitive-transform.es.js.map +0 -1
  304. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/create.cjs.js +0 -2
  305. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/create.cjs.js.map +0 -1
  306. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/create.es.js +0 -20
  307. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/create.es.js.map +0 -1
  308. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/defined-info.cjs.js +0 -2
  309. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/defined-info.cjs.js.map +0 -1
  310. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/defined-info.es.js +0 -37
  311. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/defined-info.es.js.map +0 -1
  312. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/info.cjs.js +0 -2
  313. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/info.cjs.js.map +0 -1
  314. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/info.es.js +0 -29
  315. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/info.es.js.map +0 -1
  316. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/merge.cjs.js +0 -2
  317. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/merge.cjs.js.map +0 -1
  318. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/merge.es.js +0 -11
  319. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/merge.es.js.map +0 -1
  320. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/schema.cjs.js +0 -2
  321. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/schema.cjs.js.map +0 -1
  322. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/schema.es.js +0 -22
  323. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/schema.es.js.map +0 -1
  324. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/types.cjs.js +0 -2
  325. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/types.cjs.js.map +0 -1
  326. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/types.es.js +0 -15
  327. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/util/types.es.js.map +0 -1
  328. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/xlink.cjs.js +0 -2
  329. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/xlink.cjs.js.map +0 -1
  330. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/xlink.es.js +0 -20
  331. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/xlink.es.js.map +0 -1
  332. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/xml.cjs.js +0 -2
  333. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/xml.cjs.js.map +0 -1
  334. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/xml.es.js +0 -12
  335. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/xml.es.js.map +0 -1
  336. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/xmlns.cjs.js +0 -2
  337. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/xmlns.cjs.js.map +0 -1
  338. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/xmlns.es.js +0 -12
  339. package/dist/node_modules/hast-util-to-parse5/node_modules/property-information/lib/xmlns.es.js.map +0 -1
  340. package/dist/node_modules/rehype-raw/lib/index.cjs.js +0 -2
  341. package/dist/node_modules/rehype-raw/lib/index.cjs.js.map +0 -1
  342. package/dist/node_modules/rehype-raw/lib/index.es.js +0 -13
  343. package/dist/node_modules/rehype-raw/lib/index.es.js.map +0 -1
  344. package/dist/node_modules/unist-util-is/lib/index.cjs.js +0 -2
  345. package/dist/node_modules/unist-util-is/lib/index.cjs.js.map +0 -1
  346. package/dist/node_modules/unist-util-is/lib/index.es.js +0 -92
  347. package/dist/node_modules/unist-util-is/lib/index.es.js.map +0 -1
  348. package/dist/node_modules/unist-util-position/lib/index.cjs.js +0 -2
  349. package/dist/node_modules/unist-util-position/lib/index.cjs.js.map +0 -1
  350. package/dist/node_modules/unist-util-position/lib/index.es.js +0 -18
  351. package/dist/node_modules/unist-util-position/lib/index.es.js.map +0 -1
  352. package/dist/node_modules/unist-util-visit/lib/index.cjs.js +0 -2
  353. package/dist/node_modules/unist-util-visit/lib/index.cjs.js.map +0 -1
  354. package/dist/node_modules/unist-util-visit/lib/index.es.js +0 -17
  355. package/dist/node_modules/unist-util-visit/lib/index.es.js.map +0 -1
  356. package/dist/node_modules/unist-util-visit-parents/lib/color.cjs.js +0 -2
  357. package/dist/node_modules/unist-util-visit-parents/lib/color.cjs.js.map +0 -1
  358. package/dist/node_modules/unist-util-visit-parents/lib/color.es.js +0 -7
  359. package/dist/node_modules/unist-util-visit-parents/lib/color.es.js.map +0 -1
  360. package/dist/node_modules/unist-util-visit-parents/lib/index.cjs.js +0 -2
  361. package/dist/node_modules/unist-util-visit-parents/lib/index.cjs.js.map +0 -1
  362. package/dist/node_modules/unist-util-visit-parents/lib/index.es.js +0 -57
  363. package/dist/node_modules/unist-util-visit-parents/lib/index.es.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"updateEntity.es.js","sources":["../../../../../../src/api/queries/entities/updateEntity.ts"],"sourcesContent":["// @ts-nocheck\n\nimport api from './getEntity'\nimport { detailsPanelQueries } from '@shared/api/queries'\nimport { patchDetailsPanelEntity } from '@shared/api'\nimport { toast } from 'react-toastify'\nimport { dashboardQueries, getKanbanTasks } from '@shared/api/queries/userDashboard'\nimport { patchOverviewFolders, patchOverviewTasks } from '@shared/api/queries/overview'\n\nconst patchKanban = (\n { assignees = [], projects = [] },\n { newAssignees, taskId, data, taskData },\n { dispatch },\n) => {\n let kanbanPatched = false\n const patchResult = dispatch(\n dashboardQueries.util.updateQueryData(\n 'GetKanban',\n { projects: projects, assignees: assignees },\n (draft) => {\n const taskIndex = draft.findIndex((task) => task.id === taskId)\n let patchData = { ...data }\n // if the data include attrib.priority it needs to be transformed to just priority\n // this is because priority is a top level field on kanban query\n if (data?.attrib?.priority) {\n const { priority } = patchData.attrib\n patchData = { ...patchData, priority }\n }\n // if the data include attrib.endDate it needs to be transformed to dueDate\n // this is because dueDate is a top level field on kanban query\n // NOTE TO SELF: Lets try to do these transforms after the cache the future.\n if (data?.attrib?.endDate) {\n const { endDate } = patchData.attrib\n patchData = { ...patchData, dueDate: endDate }\n delete patchData.attrib.endDate\n }\n\n if (taskIndex === -1) {\n // task not found, assignee must have just been added\n if (taskData) {\n // add the task to the cache\n draft.push(taskData)\n } else {\n // we don't have the task data, so we can't add it to the cache\n // we might add it later\n kanbanPatched = false\n }\n } else {\n kanbanPatched = true\n // first check that the task assignees still has a intersection with dashAssignees\n const hasSomeAssignees = newAssignees?.some((assignee) => assignees.includes(assignee))\n\n if (!hasSomeAssignees && newAssignees) {\n // remove from cache\n draft.splice(taskIndex, 1)\n } else {\n // task found: update the task in the cache\n const newData = { ...draft[taskIndex], ...patchData }\n draft[taskIndex] = newData\n }\n }\n },\n ),\n )\n\n return [patchResult, kanbanPatched]\n}\n\n// try to patch the progress view if there are queries that need to be updated\nconst patchProgressView = ({ operations = [], state, dispatch, entityType }) => {\n // create invalidation tags for progress view\n const invalidationTags = operations.map((o) => ({ type: 'progress', id: o.id }))\n // find the entries that need to be updated\n let entries = api.util.selectInvalidatedBy(state, invalidationTags)\n // if there are no entries, return\n if (!entries.length) return []\n\n try {\n // patch each entry with updated task data\n const patches = entries.map((entry) =>\n dispatch(\n api.util.updateQueryData(entry.endpointName, entry.originalArgs, (draft) => {\n for (const operation of operations) {\n const entityId = operation.id\n const patch = operation.data\n\n // patch the updated task data\n if (entityType === 'task') {\n const folderId = operation.meta?.folderId\n const folder = draft.find((folder) => folder.id === folderId)\n if (!folder) throw new Error('Patching progress view: folder not found')\n const task = folder.tasks?.find((task) => task.id === entityId)\n if (!task) throw new Error('Patching progress view: task not found')\n // update task\n const newTask = { ...task, ...patch }\n // update folder\n const newFolder = {\n ...folder,\n tasks: folder.tasks.map((t) => (t.id === entityId ? newTask : t)),\n }\n // update query\n const folderIndex = draft.findIndex((f) => f.id === folderId)\n draft[folderIndex] = newFolder\n } else if (entityType === 'folder') {\n const folder = draft.find((folder) => folder.id === entityId)\n if (!folder) throw new Error('Patching progress view: folder not found')\n\n // If name is being updated, also update the path\n let updatedPatch = { ...patch }\n if (patch.name && folder.path) {\n // Construct new path by replacing the last segment with the new name\n const pathParts = folder.path.split('/')\n pathParts[pathParts.length - 1] = patch.name\n updatedPatch.path = pathParts.join('/')\n }\n\n // update folder\n const newFolder = { ...folder, ...updatedPatch }\n // update query\n const folderIndex = draft.findIndex((f) => f.id === entityId)\n draft[folderIndex] = newFolder\n }\n }\n }),\n ),\n )\n return patches\n } catch (error) {\n console.error(error)\n // invalidate the progress view queries instead\n dispatch(api.util.invalidateTags(invalidationTags))\n return []\n }\n}\n\nconst updateEntity = api.injectEndpoints({\n endpoints: (build) => ({\n updateEntity: build.mutation({\n query: ({ projectName, entityId, data, entityType }) => ({\n url: `/api/projects/${projectName}/${entityType}s/${entityId}`,\n method: 'PATCH',\n body: data,\n }),\n async onQueryStarted(\n { projectName, entityId, data, currentAssignees, entityType },\n { dispatch, queryFulfilled, getState },\n ) {\n const state = getState()\n const patchResults = []\n\n let invalidationTagsAfterComplete = []\n // if task, patch the GetKanban query\n if (entityType === 'task') {\n const dashboardProjects = getState().dashboard?.selectedProjects || []\n const dashboardUsers = getState().dashboard?.tasks.assignees || []\n const dashboardAssigneesIsMe = getState().dashboard?.tasks.assigneesFilter === 'me'\n const newAssignees = data.assignees\n\n const cacheUsers = dashboardAssigneesIsMe ? [getState().user?.name] : dashboardUsers\n\n const entityAssignees = [...new Set([...currentAssignees, ...(newAssignees || [])])]\n const hasSomeAssignees = entityAssignees.some((assignee) => cacheUsers.includes(assignee))\n const hasSomeProjects = dashboardProjects.some((project) => project === projectName)\n const currentDashNeedsUpdating = hasSomeAssignees && hasSomeProjects\n\n if (currentDashNeedsUpdating) {\n const [result, wasPatched] = patchKanban(\n { assignees: cacheUsers, projects: dashboardProjects },\n { newAssignees, taskId: entityId, data },\n { dispatch },\n )\n\n if (wasPatched) patchResults.push(result)\n\n if (!wasPatched) {\n // this means the task is not in the current kanban and it needs to be added\n\n // get the new task data\n getKanbanTasks({ projects: [projectName], taskIds: [entityId] }, dispatch).then(\n // use .then so that the rest of the code can run\n (response) => {\n let newTask = response.find((task) => task.id === entityId)\n if (newTask) {\n // add newAssignees as the actual DB hasn't been updated yet\n newTask = { ...newTask, assignees: newAssignees }\n\n patchKanban(\n { assignees: cacheUsers, projects: dashboardProjects },\n { newAssignees, taskId: entityId, taskData: newTask },\n { dispatch },\n )\n }\n },\n )\n }\n }\n\n // always update the kanban if task id matches\n const tags = [{ type: 'task', id: entityId }]\n\n // are we changing the assignees?\n if (newAssignees?.length) {\n const currentAssigneesSet = new Set(currentAssignees)\n const newAssigneesSet = new Set(newAssignees)\n\n const removedAssignees = [...currentAssigneesSet].filter(\n (assignee) => !newAssigneesSet.has(assignee),\n )\n const addedAssignees = [...newAssigneesSet].filter(\n (assignee) => !currentAssigneesSet.has(assignee),\n )\n\n const changedAssignees = [...new Set([...removedAssignees, ...addedAssignees])]\n\n // any query that has those changed assignees, needs to be updated\n // we are changing the assignees\n const assigneesTags = changedAssignees.map((assignee) => ({\n type: 'kanban',\n id: 'user-' + assignee + '-project-' + projectName,\n }))\n\n tags.push(...assigneesTags)\n\n // invalidate the watchers query\n dispatch(\n dashboardQueries.util.invalidateTags([\n {\n type: 'watchers',\n id: entityId,\n },\n ]),\n )\n }\n\n // invalidate any other caches\n let entries = dashboardQueries.util.selectInvalidatedBy(state, tags)\n let entriesToInvalidate = []\n\n // for each entry try to patch the data into the cache first\n for (const entry of entries) {\n const [patchResult, wasPatched] = patchKanban(\n {\n assignees: entry.originalArgs.assignees,\n projects: entry.originalArgs.projects,\n },\n {\n newAssignees,\n taskId: entityId,\n data,\n },\n { dispatch },\n )\n\n if (wasPatched) {\n patchResults.push(patchResult)\n } else {\n // if we couldn't patch, we need to invalidate the cache\n entriesToInvalidate.push(entry)\n }\n }\n\n // filter out current kanban query if we were able to patch it\n const currentKanbanCacheArgs = { projects: dashboardProjects, assignees: cacheUsers }\n entriesToInvalidate = entriesToInvalidate.filter(\n (entry) =>\n JSON.stringify(entry.originalArgs) !== JSON.stringify(currentKanbanCacheArgs),\n )\n\n // create the invalidation tags from originalArgs\n const invalidationTags = entries.map((entry) => ({\n type: 'kanban',\n id: JSON.stringify(entry.originalArgs),\n }))\n\n // invalidate the tags later, once the query is complete\n invalidationTagsAfterComplete.push(...invalidationTags)\n }\n\n // get all details panel caches that would be affected by this update\n const detailsPanelTags = [\n {\n type: 'entities',\n id: entityId,\n },\n ]\n\n const detailsPanelEntries = api.util.selectInvalidatedBy(state, detailsPanelTags)\n\n for (const entry of detailsPanelEntries) {\n // patch any entity details panels in dashboard\n let entityDetailsResult = dispatch(\n detailsPanelQueries.util.updateQueryData(\n 'getEntitiesDetailsPanel',\n entry.originalArgs,\n (draft) => {\n for (const entity of draft) {\n patchDetailsPanelEntity([{ entityId, data, entityType }], entity)\n }\n },\n ),\n )\n\n patchResults.push(entityDetailsResult)\n }\n\n try {\n await queryFulfilled\n\n // now invalidate any tags\n if (invalidationTagsAfterComplete.length) {\n dispatch(dashboardQueries.util.invalidateTags(invalidationTagsAfterComplete))\n }\n } catch (error) {\n console.error('error updating ' + entityType, error)\n toast.error(error?.error?.data?.detail || 'Failed to update task')\n patchResults.forEach((result) => result?.undo())\n }\n },\n }),\n updateEntities: build.mutation({\n async queryFn({ operations = [], entityType }, { dispatch, getState }) {\n try {\n const state = getState()\n const promises = []\n for (const { projectName, data, id, currentAssignees = [] } of operations) {\n const promise = dispatch(\n updateEntity.endpoints.updateEntity.initiate({\n projectName: projectName,\n entityId: id,\n data,\n entityType,\n currentAssignees,\n }),\n )\n promises.push(promise)\n }\n\n let progressPatches = []\n if (entityType === 'task' || entityType === 'folder') {\n // patch the progress page\n progressPatches = patchProgressView({ operations, state, dispatch, entityType })\n }\n\n const overviewPatches = []\n // convert id in operations to entityId\n const operationsWithEntityId = operations.map((o) => ({ ...o, entityId: o.id }))\n if (entityType === 'task' || entityType === 'folder') {\n // patch the overview page\n if (entityType === 'task') {\n patchOverviewTasks(operationsWithEntityId, { state, dispatch }, overviewPatches)\n }\n if (entityType === 'folder') {\n // patch the overview page\n patchOverviewFolders(operationsWithEntityId, { state, dispatch }, overviewPatches)\n console.log('invalidate overview folders')\n // invalidate overview folders query\n dispatch(api.util.invalidateTags([{ type: 'folder', id: 'LIST' }]))\n // invalidate overview tasks with folder as a parent\n dispatch(\n api.util.invalidateTags(\n operationsWithEntityId.map((o) => ({ type: 'overviewTask', id: o.entityId })),\n ),\n )\n }\n }\n\n // check if any of the requests failed and invalidate the tasks cache again to refetch\n const results = await Promise.allSettled(promises)\n\n // did any of the requests fail?\n const someError = results.some((result) => result.value?.error)\n if (someError) {\n dispatch(\n api.util.invalidateTags(operations.map((o) => ({ type: 'kanBanTask', id: o.id }))),\n )\n\n // revert the progress view patches\n progressPatches.forEach((patch) => patch?.undo())\n\n // revert the overview patches\n overviewPatches.forEach((patch) => patch?.undo())\n\n throw 'Failed to update some tasks'\n }\n\n const activityTags = []\n\n if (activityTags.length) {\n dispatch(api.util.invalidateTags(activityTags))\n }\n\n return { data: operations }\n } catch (error) {\n console.error(error)\n return { error }\n }\n },\n invalidatesTags: (result, error, { operations }) => [\n ...operations.map((o) => ({ id: o.id, type: 'review' })),\n ],\n }),\n }),\n overrideExisting: true,\n})\n\nexport const { useUpdateEntitiesMutation, useUpdateEntityMutation } = updateEntity\nexport { updateEntity as entitiesQueries }\n"],"names":["patchKanban","assignees","projects","newAssignees","taskId","data","taskData","dispatch","kanbanPatched","dashboardQueries","draft","taskIndex","task","patchData","priority","endDate","assignee","newData","patchProgressView","operations","state","entityType","invalidationTags","o","entries","api","entry","operation","entityId","patch","folderId","folder","newTask","newFolder","t","folderIndex","f","updatedPatch","pathParts","error","updateEntity","build","projectName","currentAssignees","queryFulfilled","getState","patchResults","invalidationTagsAfterComplete","dashboardProjects","dashboardUsers","dashboardAssigneesIsMe","cacheUsers","hasSomeAssignees","hasSomeProjects","project","result","wasPatched","getKanbanTasks","response","tags","currentAssigneesSet","newAssigneesSet","removedAssignees","addedAssignees","assigneesTags","entriesToInvalidate","patchResult","currentKanbanCacheArgs","detailsPanelTags","detailsPanelEntries","entityDetailsResult","detailsPanelQueries","entity","patchDetailsPanelEntity","toast","promises","id","promise","progressPatches","overviewPatches","operationsWithEntityId","patchOverviewTasks","patchOverviewFolders","activityTags","useUpdateEntitiesMutation","useUpdateEntityMutation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAMA,IAAc,CAClB,EAAE,WAAAC,IAAY,CAAA,GAAI,UAAAC,IAAW,CAAA,EAAC,GAC9B,EAAE,cAAAC,GAAc,QAAAC,GAAQ,MAAAC,GAAM,UAAAC,KAC9B,EAAE,UAAAC,QACC;AACH,MAAIC,IAAgB;AAmDpB,SAAO,CAlDaD;AAAA,IAClBE,EAAiB,KAAK;AAAA,MACpB;AAAA,MACA,EAAE,UAAAP,GAAoB,WAAAD,EAAA;AAAA,MACtB,CAACS,MAAU;AACT,cAAMC,IAAYD,EAAM,UAAU,CAACE,MAASA,EAAK,OAAOR,CAAM;AAC9D,YAAIS,IAAY,EAAE,GAAGR,EAAA;AAGrB,YAAIA,GAAM,QAAQ,UAAU;AAC1B,gBAAM,EAAE,UAAAS,MAAaD,EAAU;AAC/B,UAAAA,IAAY,EAAE,GAAGA,GAAW,UAAAC,EAAA;AAAA,QAC9B;AAIA,YAAIT,GAAM,QAAQ,SAAS;AACzB,gBAAM,EAAE,SAAAU,MAAYF,EAAU;AAC9B,UAAAA,IAAY,EAAE,GAAGA,GAAW,SAASE,EAAA,GACrC,OAAOF,EAAU,OAAO;AAAA,QAC1B;AAEA,YAAIF,MAAc;AAEhB,UAAIL,IAEFI,EAAM,KAAKJ,CAAQ,IAInBE,IAAgB;AAAA,iBAGlBA,IAAgB,IAIZ,CAFqBL,GAAc,KAAK,CAACa,MAAaf,EAAU,SAASe,CAAQ,CAAC,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AAE,MAAM,gBAAgB,IAAIA,EAAE,WAAW;AAAA,YAAA;AAAA,UAC9E,MAMU,MAAM,QAAQ,WAAWoD,CAAQ,GAGvB,KAAK,CAACpB,MAAWA,EAAO,OAAO,KAAK;AAE5D,kBAAAhD;AAAA,cACEkB,EAAI,KAAK,eAAeN,EAAW,IAAI,CAACI,OAAO,EAAE,MAAM,cAAc,IAAIA,EAAE,GAAA,EAAK,CAAC;AAAA,YAAA,GAInFuD,EAAgB,QAAQ,CAACjD,MAAUA,GAAO,MAAM,GAGhDkD,EAAgB,QAAQ,CAAClD,MAAUA,GAAO,MAAM,GAE1C;AAGR,gBAAMsD,IAAe,CAAA;AAErB,iBAAIA,EAAa,UACf5E,EAASkB,EAAI,KAAK,eAAe0D,CAAY,CAAC,GAGzC,EAAE,MAAMhE,EAAA;AAAA,QACjB,SAASoB,GAAO;AACd,yBAAQ,MAAMA,CAAK,GACZ,EAAE,OAAAA,EAAA;AAAA,QACX;AAAA,MACF;AAAA,MACA,iBAAiB,CAACgB,GAAQhB,GAAO,EAAE,YAAApB,QAAiB;AAAA,QAClD,GAAGA,EAAW,IAAI,CAACI,OAAO,EAAE,IAAIA,EAAE,IAAI,MAAM,WAAW;AAAA,MAAA;AAAA,IACzD,CACD;AAAA,EAAA;AAAA,EAEH,kBAAkB;AACpB,CAAC,GAEY,EAAE,2BAAA6D,IAA2B,yBAAAC,OAA4B7C;"}
1
+ {"version":3,"file":"updateEntity.es.js","sources":["../../../../../../src/api/queries/entities/updateEntity.ts"],"sourcesContent":["// @ts-nocheck\n\nimport api from './getEntity'\nimport { detailsPanelQueries } from '@shared/api/queries'\nimport { patchDetailsPanelEntity } from '@shared/api'\nimport { toast } from 'react-toastify'\nimport { dashboardQueries, getKanbanTasks } from '@shared/api/queries/userDashboard'\nimport { patchOverviewFolders, patchOverviewTasks } from '@shared/api/queries/overview'\n\nconst patchKanban = (\n { assignees = [], projects = [] },\n { newAssignees, taskId, data, taskData },\n { dispatch },\n) => {\n let kanbanPatched = false\n const patchResult = dispatch(\n dashboardQueries.util.updateQueryData(\n 'GetKanban',\n { projects: projects, assignees: assignees },\n (draft) => {\n const taskIndex = draft.findIndex((task) => task.id === taskId)\n let patchData = { ...data }\n // if the data include attrib.priority it needs to be transformed to just priority\n // this is because priority is a top level field on kanban query\n if (data?.attrib?.priority) {\n const { priority } = patchData.attrib\n patchData = { ...patchData, priority }\n }\n // if the data include attrib.endDate it needs to be transformed to dueDate\n // this is because dueDate is a top level field on kanban query\n // NOTE TO SELF: Lets try to do these transforms after the cache the future.\n if (data?.attrib?.endDate) {\n const { endDate } = patchData.attrib\n patchData = { ...patchData, dueDate: endDate }\n delete patchData.attrib.endDate\n }\n\n if (taskIndex === -1) {\n // task not found, assignee must have just been added\n if (taskData) {\n // add the task to the cache\n draft.push(taskData)\n } else {\n // we don't have the task data, so we can't add it to the cache\n // we might add it later\n kanbanPatched = false\n }\n } else {\n kanbanPatched = true\n // first check that the task assignees still has a intersection with dashAssignees\n const hasSomeAssignees = newAssignees?.some((assignee) => assignees.includes(assignee))\n\n if (!hasSomeAssignees && newAssignees) {\n // remove from cache\n draft.splice(taskIndex, 1)\n } else {\n // task found: update the task in the cache\n const newData = { ...draft[taskIndex], ...patchData }\n draft[taskIndex] = newData\n }\n }\n },\n ),\n )\n\n return [patchResult, kanbanPatched]\n}\n\n// try to patch the progress view if there are queries that need to be updated\nconst patchProgressView = ({ operations = [], state, dispatch, entityType }) => {\n // create invalidation tags for progress view\n const invalidationTags = operations.map((o) => ({ type: 'progress', id: o.id }))\n // find the entries that need to be updated\n let entries = api.util.selectInvalidatedBy(state, invalidationTags)\n // if there are no entries, return\n if (!entries.length) return []\n\n try {\n // patch each entry with updated task data\n const patches = entries.map((entry) =>\n dispatch(\n api.util.updateQueryData(entry.endpointName, entry.originalArgs, (draft) => {\n for (const operation of operations) {\n const entityId = operation.id\n const patch = operation.data\n\n // patch the updated task data\n if (entityType === 'task') {\n const folderId = operation.meta?.folderId\n const folder = draft.find((folder) => folder.id === folderId)\n if (!folder) throw new Error('Patching progress view: folder not found')\n const task = folder.tasks?.find((task) => task.id === entityId)\n if (!task) throw new Error('Patching progress view: task not found')\n // update task\n const newTask = { ...task, ...patch }\n // update folder\n const newFolder = {\n ...folder,\n tasks: folder.tasks.map((t) => (t.id === entityId ? newTask : t)),\n }\n // update query\n const folderIndex = draft.findIndex((f) => f.id === folderId)\n draft[folderIndex] = newFolder\n } else if (entityType === 'folder') {\n const folder = draft.find((folder) => folder.id === entityId)\n if (!folder) throw new Error('Patching progress view: folder not found')\n\n // If name is being updated, also update the path\n let updatedPatch = { ...patch }\n if (patch.name && folder.path) {\n // Construct new path by replacing the last segment with the new name\n const pathParts = folder.path.split('/')\n pathParts[pathParts.length - 1] = patch.name\n updatedPatch.path = pathParts.join('/')\n }\n\n // update folder\n const newFolder = { ...folder, ...updatedPatch }\n // update query\n const folderIndex = draft.findIndex((f) => f.id === entityId)\n draft[folderIndex] = newFolder\n }\n }\n }),\n ),\n )\n return patches\n } catch (error) {\n console.error(error)\n // invalidate the progress view queries instead\n dispatch(api.util.invalidateTags(invalidationTags))\n return []\n }\n}\n\nconst updateEntity = api.injectEndpoints({\n endpoints: (build) => ({\n updateEntity: build.mutation({\n query: ({ projectName, entityId, data, entityType }) => ({\n url: `/api/projects/${projectName}/${entityType}s/${entityId}`,\n method: 'PATCH',\n body: data,\n }),\n invalidatesTags: (result, error, { entityId, entityType }) => {\n const tags = []\n if (entityType === 'product') {\n tags.push({ type: 'product', id: entityId })\n }\n if (entityType === 'version') {\n tags.push({ type: 'version', id: entityId })\n }\n return tags\n },\n async onQueryStarted(\n { projectName, entityId, data, currentAssignees, entityType },\n { dispatch, queryFulfilled, getState },\n ) {\n const state = getState()\n const patchResults = []\n\n let invalidationTagsAfterComplete = []\n // if task, patch the GetKanban query\n if (entityType === 'task') {\n const dashboardProjects = getState().dashboard?.selectedProjects || []\n const dashboardUsers = getState().dashboard?.tasks.assignees || []\n const dashboardAssigneesIsMe = getState().dashboard?.tasks.assigneesFilter === 'me'\n const newAssignees = data.assignees\n\n const cacheUsers = dashboardAssigneesIsMe ? [getState().user?.name] : dashboardUsers\n\n const entityAssignees = [...new Set([...currentAssignees, ...(newAssignees || [])])]\n const hasSomeAssignees = entityAssignees.some((assignee) => cacheUsers.includes(assignee))\n const hasSomeProjects = dashboardProjects.some((project) => project === projectName)\n const currentDashNeedsUpdating = hasSomeAssignees && hasSomeProjects\n\n if (currentDashNeedsUpdating) {\n const [result, wasPatched] = patchKanban(\n { assignees: cacheUsers, projects: dashboardProjects },\n { newAssignees, taskId: entityId, data },\n { dispatch },\n )\n\n if (wasPatched) patchResults.push(result)\n\n if (!wasPatched) {\n // this means the task is not in the current kanban and it needs to be added\n\n // get the new task data\n getKanbanTasks({ projects: [projectName], taskIds: [entityId] }, dispatch).then(\n // use .then so that the rest of the code can run\n (response) => {\n let newTask = response.find((task) => task.id === entityId)\n if (newTask) {\n // add newAssignees as the actual DB hasn't been updated yet\n newTask = { ...newTask, assignees: newAssignees }\n\n patchKanban(\n { assignees: cacheUsers, projects: dashboardProjects },\n { newAssignees, taskId: entityId, taskData: newTask },\n { dispatch },\n )\n }\n },\n )\n }\n }\n\n // always update the kanban if task id matches\n const tags = [{ type: 'task', id: entityId }]\n\n // are we changing the assignees?\n if (newAssignees?.length) {\n const currentAssigneesSet = new Set(currentAssignees)\n const newAssigneesSet = new Set(newAssignees)\n\n const removedAssignees = [...currentAssigneesSet].filter(\n (assignee) => !newAssigneesSet.has(assignee),\n )\n const addedAssignees = [...newAssigneesSet].filter(\n (assignee) => !currentAssigneesSet.has(assignee),\n )\n\n const changedAssignees = [...new Set([...removedAssignees, ...addedAssignees])]\n\n // any query that has those changed assignees, needs to be updated\n // we are changing the assignees\n const assigneesTags = changedAssignees.map((assignee) => ({\n type: 'kanban',\n id: 'user-' + assignee + '-project-' + projectName,\n }))\n\n tags.push(...assigneesTags)\n\n // invalidate the watchers query\n dispatch(\n dashboardQueries.util.invalidateTags([\n {\n type: 'watchers',\n id: entityId,\n },\n ]),\n )\n }\n\n // invalidate any other caches\n let entries = dashboardQueries.util.selectInvalidatedBy(state, tags)\n let entriesToInvalidate = []\n\n // for each entry try to patch the data into the cache first\n for (const entry of entries) {\n const [patchResult, wasPatched] = patchKanban(\n {\n assignees: entry.originalArgs.assignees,\n projects: entry.originalArgs.projects,\n },\n {\n newAssignees,\n taskId: entityId,\n data,\n },\n { dispatch },\n )\n\n if (wasPatched) {\n patchResults.push(patchResult)\n } else {\n // if we couldn't patch, we need to invalidate the cache\n entriesToInvalidate.push(entry)\n }\n }\n\n // filter out current kanban query if we were able to patch it\n const currentKanbanCacheArgs = { projects: dashboardProjects, assignees: cacheUsers }\n entriesToInvalidate = entriesToInvalidate.filter(\n (entry) =>\n JSON.stringify(entry.originalArgs) !== JSON.stringify(currentKanbanCacheArgs),\n )\n\n // create the invalidation tags from originalArgs\n const invalidationTags = entries.map((entry) => ({\n type: 'kanban',\n id: JSON.stringify(entry.originalArgs),\n }))\n\n // invalidate the tags later, once the query is complete\n invalidationTagsAfterComplete.push(...invalidationTags)\n }\n\n // get all details panel caches that would be affected by this update\n const detailsPanelTags = [\n {\n type: 'entities',\n id: entityId,\n },\n ]\n\n const detailsPanelEntries = api.util.selectInvalidatedBy(state, detailsPanelTags)\n\n for (const entry of detailsPanelEntries) {\n // patch any entity details panels in dashboard\n let entityDetailsResult = dispatch(\n detailsPanelQueries.util.updateQueryData(\n 'getEntitiesDetailsPanel',\n entry.originalArgs,\n (draft) => {\n for (const entity of draft) {\n patchDetailsPanelEntity([{ entityId, data, entityType }], entity)\n }\n },\n ),\n )\n\n patchResults.push(entityDetailsResult)\n }\n\n try {\n await queryFulfilled\n\n // now invalidate any tags\n if (invalidationTagsAfterComplete.length) {\n dispatch(dashboardQueries.util.invalidateTags(invalidationTagsAfterComplete))\n }\n } catch (error) {\n console.error('error updating ' + entityType, error)\n toast.error(error?.error?.data?.detail || 'Failed to update task')\n patchResults.forEach((result) => result?.undo())\n }\n },\n }),\n updateEntities: build.mutation({\n async queryFn({ operations = [], entityType }, { dispatch, getState }) {\n try {\n const state = getState()\n const promises = []\n for (const { projectName, data, id, currentAssignees = [] } of operations) {\n const promise = dispatch(\n updateEntity.endpoints.updateEntity.initiate({\n projectName: projectName,\n entityId: id,\n data,\n entityType,\n currentAssignees,\n }),\n )\n promises.push(promise)\n }\n\n let progressPatches = []\n if (entityType === 'task' || entityType === 'folder') {\n // patch the progress page\n progressPatches = patchProgressView({ operations, state, dispatch, entityType })\n }\n\n const overviewPatches = []\n // convert id in operations to entityId\n const operationsWithEntityId = operations.map((o) => ({ ...o, entityId: o.id }))\n if (entityType === 'task' || entityType === 'folder') {\n // patch the overview page\n if (entityType === 'task') {\n patchOverviewTasks(operationsWithEntityId, { state, dispatch }, overviewPatches)\n }\n if (entityType === 'folder') {\n // patch the overview page\n patchOverviewFolders(operationsWithEntityId, { state, dispatch }, overviewPatches)\n console.log('invalidate overview folders')\n // invalidate overview folders query\n dispatch(api.util.invalidateTags([{ type: 'folder', id: 'LIST' }]))\n // invalidate overview tasks with folder as a parent\n dispatch(\n api.util.invalidateTags(\n operationsWithEntityId.map((o) => ({ type: 'overviewTask', id: o.entityId })),\n ),\n )\n }\n }\n\n // check if any of the requests failed and invalidate the tasks cache again to refetch\n const results = await Promise.allSettled(promises)\n\n // did any of the requests fail?\n const someError = results.some((result) => result.value?.error)\n if (someError) {\n dispatch(\n api.util.invalidateTags(operations.map((o) => ({ type: 'kanBanTask', id: o.id }))),\n )\n\n // revert the progress view patches\n progressPatches.forEach((patch) => patch?.undo())\n\n // revert the overview patches\n overviewPatches.forEach((patch) => patch?.undo())\n\n throw 'Failed to update some tasks'\n }\n\n const activityTags = []\n\n if (activityTags.length) {\n dispatch(api.util.invalidateTags(activityTags))\n }\n\n return { data: operations }\n } catch (error) {\n console.error(error)\n return { error }\n }\n },\n invalidatesTags: (result, error, { operations, entityType }) => {\n const tags = operations.map((o) => ({ id: o.id, type: 'review' }))\n\n if (entityType === 'product') {\n tags.push({ type: 'product', id: 'LIST' }, { type: 'version', id: 'LIST' })\n operations.forEach((o) => tags.push({ type: 'product', id: o.id }))\n }\n if (entityType === 'version') {\n tags.push({ type: 'version', id: 'LIST' }, { type: 'product', id: 'LIST' })\n operations.forEach((o) => tags.push({ type: 'version', id: o.id }))\n }\n\n return tags\n },\n }),\n }),\n overrideExisting: true,\n})\n\nexport const { useUpdateEntitiesMutation, useUpdateEntityMutation } = updateEntity\nexport { updateEntity as entitiesQueries }\n"],"names":["patchKanban","assignees","projects","newAssignees","taskId","data","taskData","dispatch","kanbanPatched","dashboardQueries","draft","taskIndex","task","patchData","priority","endDate","assignee","newData","patchProgressView","operations","state","entityType","invalidationTags","o","entries","api","entry","operation","entityId","patch","folderId","folder","newTask","newFolder","t","folderIndex","f","updatedPatch","pathParts","error","updateEntity","build","projectName","result","tags","currentAssignees","queryFulfilled","getState","patchResults","invalidationTagsAfterComplete","dashboardProjects","dashboardUsers","dashboardAssigneesIsMe","cacheUsers","hasSomeAssignees","hasSomeProjects","project","wasPatched","getKanbanTasks","response","currentAssigneesSet","newAssigneesSet","removedAssignees","addedAssignees","assigneesTags","entriesToInvalidate","patchResult","currentKanbanCacheArgs","detailsPanelTags","detailsPanelEntries","entityDetailsResult","detailsPanelQueries","entity","patchDetailsPanelEntity","toast","promises","id","promise","progressPatches","overviewPatches","operationsWithEntityId","patchOverviewTasks","patchOverviewFolders","activityTags","useUpdateEntitiesMutation","useUpdateEntityMutation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAMA,IAAc,CAClB,EAAE,WAAAC,IAAY,CAAA,GAAI,UAAAC,IAAW,CAAA,EAAC,GAC9B,EAAE,cAAAC,GAAc,QAAAC,GAAQ,MAAAC,GAAM,UAAAC,KAC9B,EAAE,UAAAC,QACC;AACH,MAAIC,IAAgB;AAmDpB,SAAO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AInFuD,EAAgB,QAAQ,CAACjD,MAAUA,GAAO,MAAM,GAGhDkD,EAAgB,QAAQ,CAAClD,MAAUA,GAAO,MAAM,GAE1C;AAGR,gBAAMsD,IAAe,CAAA;AAErB,iBAAIA,EAAa,UACf5E,EAASkB,EAAI,KAAK,eAAe0D,CAAY,CAAC,GAGzC,EAAE,MAAMhE,EAAA;AAAA,QACjB,SAASoB,GAAO;AACd,yBAAQ,MAAMA,CAAK,GACZ,EAAE,OAAAA,EAAA;AAAA,QACX;AAAA,MACF;AAAA,MACA,iBAAiB,CAACI,GAAQJ,GAAO,EAAE,YAAApB,GAAY,YAAAE,QAAiB;AAC9D,cAAMuB,IAAOzB,EAAW,IAAI,CAACI,OAAO,EAAE,IAAIA,EAAE,IAAI,MAAM,SAAA,EAAW;AAEjE,eAAIF,MAAe,cACjBuB,EAAK,KAAK,EAAE,MAAM,WAAW,IAAI,OAAA,GAAU,EAAE,MAAM,WAAW,IAAI,OAAA,CAAQ,GAC1EzB,EAAW,QAAQ,CAACI,MAAMqB,EAAK,KAAK,EAAE,MAAM,WAAW,IAAIrB,EAAE,GAAA,CAAI,CAAC,IAEhEF,MAAe,cACjBuB,EAAK,KAAK,EAAE,MAAM,WAAW,IAAI,OAAA,GAAU,EAAE,MAAM,WAAW,IAAI,OAAA,CAAQ,GAC1EzB,EAAW,QAAQ,CAACI,MAAMqB,EAAK,KAAK,EAAE,MAAM,WAAW,IAAIrB,EAAE,GAAA,CAAI,CAAC,IAG7DqB;AAAA,MACT;AAAA,IAAA,CACD;AAAA,EAAA;AAAA,EAEH,kBAAkB;AACpB,CAAC,GAEY,EAAE,2BAAAwC,IAA2B,yBAAAC,OAA4B7C;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./getViews.cjs.js"),g=a.getViewsApi.enhanceEndpoints({endpoints:{createView:{onQueryStarted:async(e,{dispatch:p,queryFulfilled:n,getState:r})=>{const{payload:i}=e,l=r(),u=l.user?.name,V=p(a.getViewsApi.util.updateQueryData("listViews",{viewType:e.viewType,projectName:e.projectName},o=>{const t={...i,working:i.working||!1,scope:e.projectName?"project":"studio",visibility:"private",position:o.length+1,owner:u,accessLevel:30};if(i.working){const s=o.findIndex(c=>c.working===!0);if(s!==-1){const c=o[s].id;o[s]={...t,id:c}}else o.push(t)}else o.push(t);o.sort((s,c)=>s.position!==c.position?s.position-c.position:s.label.localeCompare(c.label))}));let w;i.working&&(w=p(a.getViewsApi.util.updateQueryData("getWorkingView",{viewType:e.viewType,projectName:e.projectName},o=>{const t=o?.id,s={...i,working:!0,scope:e.projectName?"project":"studio",visibility:"private",owner:u,...t&&{id:t}};Object.assign(o,s)})));let d;if(i.label==="__base__")if(a.getViewsApi.endpoints.getBaseView.select({viewType:e.viewType,projectName:e.projectName})(l)!==void 0){const t={...i,working:!1,scope:e.projectName?"project":"studio",visibility:"private",owner:u,accessLevel:30,position:0};d=p(a.getViewsApi.util.updateQueryData("getBaseView",{viewType:e.viewType,projectName:e.projectName},()=>t))}else console.log("Skipping optimistic update for getBaseView - cache does not exist yet");try{await n}catch(o){V.undo(),w&&w.undo(),d&&d.undo(),console.error("Failed to create view:",o)}},transformErrorResponse:e=>e.data?.detail,invalidatesTags:(e,p,{viewType:n,projectName:r,payload:i})=>[{type:"view",id:i.id},a.getScopeTag(n,r)]},updateView:{transformErrorResponse:e=>e.data?.detail,invalidatesTags:(e,p,{viewType:n,projectName:r,viewId:i})=>[{type:"view",id:i},a.getScopeTag(n,r)]},deleteView:{onQueryStarted:async(e,{dispatch:p,queryFulfilled:n,getState:r})=>{const{viewId:i,projectName:l,viewType:u}=e,V=r(),w=[];w.push(p(a.getViewsApi.util.updateQueryData("listViews",{viewType:u,projectName:l},t=>t.filter(s=>s.id!==i))));const d=[{projectName:l},{projectName:void 0}],o=["getBaseView","getDefaultView"];for(const t of d)for(const s of o){const c=a.getViewsApi.endpoints[s].select({viewType:u,projectName:t.projectName})(V);c?.isSuccess&&c.data?.id===i&&w.push(p(a.getViewsApi.util.updateQueryData(s,{viewType:u,projectName:t.projectName},()=>null)))}try{await n}catch(t){w.forEach(s=>s.undo()),console.error("Failed to delete view:",t)}},transformErrorResponse:e=>e.data?.detail,invalidatesTags:(e,p,{viewType:n,projectName:r,viewId:i})=>[{type:"view",id:i},a.getScopeTag(n,r),a.getScopeTag(n,void 0)]},setDefaultView:{onQueryStarted:async(e,{dispatch:p,queryFulfilled:n,getState:r})=>{const{setDefaultViewRequestModel:i,projectName:l,viewType:u}=e,{viewId:V}=i,w=r(),d=a.getViewsApi.endpoints.getDefaultView.select({viewType:u,projectName:l})(w);if(d?.isSuccess&&d.data?.id){const o=p(a.getViewsApi.util.updateQueryData("getDefaultView",{viewType:u,projectName:l},t=>{if(t){const c=a.getViewsApi.endpoints.listViews.select({viewType:u,projectName:l})(w)?.data?.find(v=>v.id===V);c?Object.assign(t,c):t.id=V}}));try{await n}catch(t){o.undo(),console.error("Failed to set default view:",t)}}else console.warn("No current default view found, skipping optimistic update and invalidating default view cache")},transformErrorResponse:e=>e.data?.detail,invalidatesTags:(e,p,{viewType:n,projectName:r,setDefaultViewRequestModel:i})=>[{type:"view",id:i.viewId},a.getScopeTag(n,r)]}}}),{useCreateViewMutation:y,useUpdateViewMutation:f,useDeleteViewMutation:m,useSetDefaultViewMutation:j}=g;exports.useCreateViewMutation=y;exports.useDeleteViewMutation=m;exports.useSetDefaultViewMutation=j;exports.useUpdateViewMutation=f;exports.viewsQueries=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./getViews.cjs.js"),y=require("uuid"),V=a.getViewsApi.enhanceEndpoints({endpoints:{createView:{onQueryStarted:async(e,{dispatch:r,queryFulfilled:n,getState:c})=>{const{payload:i}=e,u=c().user?.name,g=r(a.getViewsApi.util.updateQueryData("listViews",{viewType:e.viewType,projectName:e.projectName},s=>{const t={...i,working:i.working||!1,scope:e.projectName?"project":"studio",visibility:"private",position:s.length+1,owner:u,accessLevel:30};if(i.working){const o=s.findIndex(p=>p.working===!0);if(o!==-1){const p=s[o].id;s[o]={...t,id:p}}else s.push(t)}else s.push(t);s.sort((o,p)=>o.position!==p.position?o.position-p.position:o.label.localeCompare(p.label))}));let w;i.working&&(w=r(a.getViewsApi.util.updateQueryData("getWorkingView",{viewType:e.viewType,projectName:e.projectName},s=>{const t=s?.id,o={...i,working:!0,scope:e.projectName?"project":"studio",visibility:"private",owner:u,...t&&{id:t}};Object.assign(s,o)})));let l;if(i.label==="__base__"){const s={id:y.v4(),...i,working:!1,scope:e.projectName?"project":"studio",visibility:"private",owner:u,accessLevel:30,position:0};l=r(a.getViewsApi.util.updateQueryData("getBaseView",{viewType:e.viewType,projectName:e.projectName},t=>{t&&Object.assign(t,s)})),l?.patches?.length||r(a.getViewsApi.util.upsertQueryData("getBaseView",{viewType:e.viewType,projectName:e.projectName},s))}try{await n}catch{g.undo(),w&&w.undo(),l&&l.undo()}},transformErrorResponse:e=>e.data?.detail,invalidatesTags:(e,r,{viewType:n,projectName:c,payload:i})=>[{type:"view",id:i.id},a.getScopeTag(n,c)]},updateView:{transformErrorResponse:e=>e.data?.detail,invalidatesTags:(e,r,{viewType:n,projectName:c,viewId:i})=>[{type:"view",id:i},a.getScopeTag(n,c)]},deleteView:{onQueryStarted:async(e,{dispatch:r,queryFulfilled:n,getState:c})=>{const{viewId:i,projectName:d,viewType:u}=e,g=c(),w=[];w.push(r(a.getViewsApi.util.updateQueryData("listViews",{viewType:u,projectName:d},t=>t.filter(o=>o.id!==i))));const l=[{projectName:d},{projectName:void 0}],s=["getBaseView","getDefaultView"];for(const t of l)for(const o of s){const p=a.getViewsApi.endpoints[o].select({viewType:u,projectName:t.projectName})(g);p?.isSuccess&&p.data?.id===i&&w.push(r(a.getViewsApi.util.updateQueryData(o,{viewType:u,projectName:t.projectName},()=>null)))}try{await n}catch(t){w.forEach(o=>o.undo()),console.error("Failed to delete view:",t)}},transformErrorResponse:e=>e.data?.detail,invalidatesTags:(e,r,{viewType:n,projectName:c,viewId:i})=>[{type:"view",id:i},a.getScopeTag(n,c),a.getScopeTag(n,void 0)]},setDefaultView:{onQueryStarted:async(e,{dispatch:r,queryFulfilled:n,getState:c})=>{const{setDefaultViewRequestModel:i,projectName:d,viewType:u}=e,{viewId:g}=i,w=c(),l=a.getViewsApi.endpoints.getDefaultView.select({viewType:u,projectName:d})(w);if(l?.isSuccess&&l.data?.id){const s=r(a.getViewsApi.util.updateQueryData("getDefaultView",{viewType:u,projectName:d},t=>{if(t){const p=a.getViewsApi.endpoints.listViews.select({viewType:u,projectName:d})(w)?.data?.find(v=>v.id===g);p?Object.assign(t,p):t.id=g}}));try{await n}catch(t){s.undo(),console.error("Failed to set default view:",t)}}else console.warn("No current default view found, skipping optimistic update and invalidating default view cache")},transformErrorResponse:e=>e.data?.detail,invalidatesTags:(e,r,{viewType:n,projectName:c,setDefaultViewRequestModel:i})=>[{type:"view",id:i.viewId},a.getScopeTag(n,c)]}}}),{useCreateViewMutation:f,useUpdateViewMutation:m,useDeleteViewMutation:j,useSetDefaultViewMutation:T}=V;exports.useCreateViewMutation=f;exports.useDeleteViewMutation=j;exports.useSetDefaultViewMutation=T;exports.useUpdateViewMutation=m;exports.viewsQueries=V;
2
2
  //# sourceMappingURL=updateViews.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"updateViews.cjs.js","sources":["../../../../../../src/api/queries/views/updateViews.ts"],"sourcesContent":["import { ViewListItemModel } from '@shared/api/generated'\nimport { getScopeTag, getViewsApi } from './getViews'\n\nconst updateViewsApi = getViewsApi.enhanceEndpoints({\n endpoints: {\n createView: {\n onQueryStarted: async (arg, { dispatch, queryFulfilled, getState }) => {\n const { payload } = arg\n const state = getState()\n // @ts-expect-error - user is not typed in the state\n const user = state.user?.name\n\n // Optimistically update the view list\n const patch = dispatch(\n getViewsApi.util.updateQueryData(\n 'listViews',\n { viewType: arg.viewType, projectName: arg.projectName },\n (draft) => {\n const newView: ViewListItemModel = {\n ...payload,\n working: payload.working || false,\n scope: arg.projectName ? 'project' : 'studio',\n visibility: 'private',\n position: draft.length + 1, // Add to the end of the list\n owner: user,\n accessLevel: 30,\n }\n if (payload.working) {\n // For working views, find and replace the existing working view\n const existingWorkingIndex = draft.findIndex((view) => view.working === true)\n if (existingWorkingIndex !== -1) {\n // Keep the existing ID but update all other properties\n const existingId = draft[existingWorkingIndex].id\n draft[existingWorkingIndex] = { ...newView, id: existingId }\n } else {\n // No existing working view, add the new one\n draft.push(newView)\n }\n } else {\n // For non-working views, add to the list as usual\n draft.push(newView)\n }\n\n // finally sort the view by position and then by label\n draft.sort((a, b) => {\n if (a.position !== b.position) {\n return a.position - b.position\n }\n return a.label.localeCompare(b.label)\n })\n },\n ),\n )\n\n // Also update the getWorkingView cache if this is a working view\n let workingViewPatch\n if (payload.working) {\n workingViewPatch = dispatch(\n getViewsApi.util.updateQueryData(\n 'getWorkingView',\n { viewType: arg.viewType, projectName: arg.projectName },\n (draft) => {\n // Preserve the existing ID if there's already a working view\n const existingId = draft?.id\n const updatedWorkingView = {\n ...payload,\n working: true,\n scope: arg.projectName ? 'project' : 'studio',\n visibility: 'private',\n owner: user,\n ...(existingId && { id: existingId }), // Keep existing ID if it exists\n }\n // Update the working view cache with the new view data\n Object.assign(draft, updatedWorkingView)\n },\n ),\n )\n }\n\n // Also update the getBaseView cache if this is a base view\n let baseViewPatch\n if (payload.label === '__base__') {\n // Check if the getBaseView cache exists before updating\n const currentBaseView = getViewsApi.endpoints.getBaseView.select({\n viewType: arg.viewType,\n projectName: arg.projectName,\n })(state)\n\n // Only perform optimistic update if cache is initialized (even if data is null)\n if (currentBaseView !== undefined) {\n const newBaseView = {\n ...payload,\n working: false,\n scope: arg.projectName ? 'project' : 'studio',\n visibility: 'private',\n owner: user,\n accessLevel: 30,\n position: 0,\n }\n\n baseViewPatch = dispatch(\n getViewsApi.util.updateQueryData(\n 'getBaseView',\n { viewType: arg.viewType, projectName: arg.projectName },\n () => newBaseView as any,\n ),\n )\n } else {\n // No cache exists yet, optimistic update will be skipped\n // The invalidation tags will handle the refetch\n console.log('Skipping optimistic update for getBaseView - cache does not exist yet')\n }\n }\n\n try {\n await queryFulfilled\n } catch (error) {\n // If the query failed, we need to roll back the optimistic updates\n patch.undo()\n if (workingViewPatch) {\n workingViewPatch.undo()\n }\n if (baseViewPatch) {\n baseViewPatch.undo()\n }\n console.error('Failed to create view:', error)\n }\n },\n transformErrorResponse: (error: any) => error.data?.detail,\n // updates the view list cache for a specific view type and project\n invalidatesTags: (_r, _e, { viewType, projectName, payload }) => [\n { type: 'view', id: payload.id },\n getScopeTag(viewType, projectName),\n ],\n },\n updateView: {\n transformErrorResponse: (error: any) => error.data?.detail,\n invalidatesTags: (_r, _e, { viewType, projectName, viewId }) => [\n { type: 'view', id: viewId },\n getScopeTag(viewType, projectName),\n ],\n },\n deleteView: {\n onQueryStarted: async (arg, { dispatch, queryFulfilled, getState }) => {\n const { viewId, projectName, viewType } = arg\n const state = getState()\n\n // Optimistically remove the view from the list\n const patches: any[] = []\n\n patches.push(\n dispatch(\n getViewsApi.util.updateQueryData('listViews', { viewType, projectName }, (draft) => {\n return draft.filter((view) => view.id !== viewId)\n }),\n ),\n )\n\n // Check both project and studio level for base and default views\n const scopesToCheck = [\n { projectName },\n { projectName: undefined }, // studio level\n ]\n const queriesToCheck = ['getBaseView', 'getDefaultView'] as const\n\n for (const scope of scopesToCheck) {\n for (const queryName of queriesToCheck) {\n const currentView = getViewsApi.endpoints[queryName].select({\n viewType,\n projectName: scope.projectName,\n })(state)\n\n if (currentView?.isSuccess && currentView.data?.id === viewId) {\n patches.push(\n dispatch(\n getViewsApi.util.updateQueryData(\n queryName,\n { viewType, projectName: scope.projectName },\n () => null as any,\n ),\n ),\n )\n }\n }\n }\n\n try {\n await queryFulfilled\n } catch (error) {\n // If the query failed, roll back all optimistic updates\n patches.forEach((patch) => patch.undo())\n console.error('Failed to delete view:', error)\n }\n },\n transformErrorResponse: (error: any) => error.data?.detail,\n // updates the view list cache for a specific view type and project\n invalidatesTags: (_r, _e, { viewType, projectName, viewId }) => [\n { type: 'view', id: viewId },\n getScopeTag(viewType, projectName),\n getScopeTag(viewType, undefined),\n ],\n },\n setDefaultView: {\n onQueryStarted: async (arg, { dispatch, queryFulfilled, getState }) => {\n const { setDefaultViewRequestModel, projectName, viewType } = arg\n const { viewId } = setDefaultViewRequestModel\n const state = getState()\n // get current state of default view\n const currentDefaultView = getViewsApi.endpoints.getDefaultView.select({\n viewType,\n projectName,\n })(state)\n\n // check if there is even a cache for the default view\n if (currentDefaultView?.isSuccess && currentDefaultView.data?.id) {\n // Optimistically update the default view\n const patch = dispatch(\n getViewsApi.util.updateQueryData(\n 'getDefaultView',\n { viewType, projectName },\n (draft) => {\n if (draft) {\n // Try to find the view in the listViews cache\n const listViewData = getViewsApi.endpoints.listViews.select({\n viewType,\n projectName,\n })(state)\n const view = listViewData?.data?.find((v) => v.id === viewId)\n\n if (view) {\n // If the view is found in the listViews cache, update the getDefaultView cache with the full view data\n Object.assign(draft, view)\n } else {\n // If the view is not found, only update the ID\n draft.id = viewId\n }\n }\n },\n ),\n )\n\n try {\n await queryFulfilled\n } catch (error) {\n // If the query failed, we need to roll back the optimistic update\n patch.undo()\n console.error('Failed to set default view:', error)\n }\n } else {\n console.warn(\n 'No current default view found, skipping optimistic update and invalidating default view cache',\n )\n // If there is no current default view, we skip the optimistic update\n // it will be handled by the invalidation below\n }\n },\n transformErrorResponse: (error: any) => error.data?.detail,\n // updates the default view cache for a specific view type and project\n invalidatesTags: (_r, _e, { viewType, projectName, setDefaultViewRequestModel }) => [\n { type: 'view', id: setDefaultViewRequestModel.viewId },\n getScopeTag(viewType, projectName),\n ],\n },\n },\n})\n\nexport const {\n useCreateViewMutation,\n useUpdateViewMutation,\n useDeleteViewMutation,\n useSetDefaultViewMutation,\n} = updateViewsApi\nexport { updateViewsApi as viewsQueries }\n"],"names":["updateViewsApi","getViewsApi","arg","dispatch","queryFulfilled","getState","payload","state","user","patch","draft","newView","existingWorkingIndex","view","existingId","a","b","workingViewPatch","updatedWorkingView","baseViewPatch","newBaseView","error","_r","_e","viewType","projectName","getScopeTag","viewId","patches","scopesToCheck","queriesToCheck","scope","queryName","currentView","setDefaultViewRequestModel","currentDefaultView","useCreateViewMutation","useUpdateViewMutation","useDeleteViewMutation","useSetDefaultViewMutation"],"mappings":"qHAGMA,EAAiBC,EAAAA,YAAY,iBAAiB,CAClD,UAAW,CACT,WAAY,CACV,eAAgB,MAAOC,EAAK,CAAE,SAAAC,EAAU,eAAAC,EAAgB,SAAAC,KAAe,CACrE,KAAM,CAAE,QAAAC,GAAYJ,EACdK,EAAQF,EAAA,EAERG,EAAOD,EAAM,MAAM,KAGnBE,EAAQN,EACZF,EAAAA,YAAY,KAAK,gBACf,YACA,CAAE,SAAUC,EAAI,SAAU,YAAaA,EAAI,WAAA,EAC1CQ,GAAU,CACT,MAAMC,EAA6B,CACjC,GAAGL,EACH,QAASA,EAAQ,SAAW,GAC5B,MAAOJ,EAAI,YAAc,UAAY,SACrC,WAAY,UACZ,SAAUQ,EAAM,OAAS,EACzB,MAAOF,EACP,YAAa,EAAA,EAEf,GAAIF,EAAQ,QAAS,CAEnB,MAAMM,EAAuBF,EAAM,UAAWG,GAASA,EAAK,UAAY,EAAI,EAC5E,GAAID,IAAyB,GAAI,CAE/B,MAAME,EAAaJ,EAAME,CAAoB,EAAE,GAC/CF,EAAME,CAAoB,EAAI,CAAE,GAAGD,EAAS,GAAIG,CAAA,CAClD,MAEEJ,EAAM,KAAKC,CAAO,CAEtB,MAEED,EAAM,KAAKC,CAAO,EAIpBD,EAAM,KAAK,CAACK,EAAGC,IACTD,EAAE,WAAaC,EAAE,SACZD,EAAE,SAAWC,EAAE,SAEjBD,EAAE,MAAM,cAAcC,EAAE,KAAK,CACrC,CACH,CAAA,CACF,EAIF,IAAIC,EACAX,EAAQ,UACVW,EAAmBd,EACjBF,EAAAA,YAAY,KAAK,gBACf,iBACA,CAAE,SAAUC,EAAI,SA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CACjC,EAEF,eAAgB,CACd,eAAgB,MAAOtB,EAAK,CAAE,SAAAC,EAAU,eAAAC,EAAgB,SAAAC,KAAe,CACrE,KAAM,CAAE,2BAAA6B,EAA4B,YAAAT,EAAa,SAAAD,CAAA,EAAatB,EACxD,CAAE,OAAAyB,GAAWO,EACb3B,EAAQF,EAAA,EAER8B,EAAqBlC,EAAAA,YAAY,UAAU,eAAe,OAAO,CACrE,SAAAuB,EACA,YAAAC,CAAA,CACD,EAAElB,CAAK,EAGR,GAAI4B,GAAoB,WAAaA,EAAmB,MAAM,GAAI,CAEhE,MAAM1B,EAAQN,EACZF,EAAAA,YAAY,KAAK,gBACf,iBACA,CAAE,SAAAuB,EAAU,YAAAC,CAAA,EACXf,GAAU,CACT,GAAIA,EAAO,CAMT,MAAMG,EAJeZ,EAAAA,YAAY,UAAU,UAAU,OAAO,CAC1D,SAAAuB,EACA,YAAAC,CAAA,CACD,EAAElB,CAAK,GACmB,MAAM,KAAM,GAAM,EAAE,KAAOoB,CAAM,EAExDd,EAEF,OAAO,OAAOH,EAAOG,CAAI,EAGzBH,EAAM,GAAKiB,CAEf,CACF,CAAA,CACF,EAGF,GAAI,CACF,MAAMvB,CACR,OAASiB,EAAO,CAEdZ,EAAM,KAAA,EACN,QAAQ,MAAM,8BAA+BY,CAAK,CACpD,CACF,MACE,QAAQ,KACN,+FAAA,CAKN,EACA,uBAAyBA,GAAeA,EAAM,MAAM,OAEpD,gBAAiB,CAACC,EAAIC,EAAI,CAAE,SAAAC,EAAU,YAAAC,EAAa,2BAAAS,KAAiC,CAClF,CAAE,KAAM,OAAQ,GAAIA,EAA2B,MAAA,EAC/CR,EAAAA,YAAYF,EAAUC,CAAW,CAAA,CACnC,CACF,CAEJ,CAAC,EAEY,CACX,sBAAAW,EACA,sBAAAC,EACA,sBAAAC,EACA,0BAAAC,CACF,EAAIvC"}
1
+ {"version":3,"file":"updateViews.cjs.js","sources":["../../../../../../src/api/queries/views/updateViews.ts"],"sourcesContent":["import { ViewListItemModel } from '@shared/api/generated'\nimport { getScopeTag, getViewsApi } from './getViews'\nimport { v4 as uuidv4 } from 'uuid'\n\nconst updateViewsApi = getViewsApi.enhanceEndpoints({\n endpoints: {\n createView: {\n onQueryStarted: async (arg, { dispatch, queryFulfilled, getState }) => {\n const { payload } = arg\n const state = getState()\n // @ts-expect-error - user is not typed in the state\n const user = state.user?.name\n\n // Optimistically update the view list\n const patch = dispatch(\n getViewsApi.util.updateQueryData(\n 'listViews',\n { viewType: arg.viewType, projectName: arg.projectName },\n (draft) => {\n const newView: ViewListItemModel = {\n ...payload,\n working: payload.working || false,\n scope: arg.projectName ? 'project' : 'studio',\n visibility: 'private',\n position: draft.length + 1, // Add to the end of the list\n owner: user,\n accessLevel: 30,\n }\n if (payload.working) {\n // For working views, find and replace the existing working view\n const existingWorkingIndex = draft.findIndex((view) => view.working === true)\n if (existingWorkingIndex !== -1) {\n // Keep the existing ID but update all other properties\n const existingId = draft[existingWorkingIndex].id\n draft[existingWorkingIndex] = { ...newView, id: existingId }\n } else {\n // No existing working view, add the new one\n draft.push(newView)\n }\n } else {\n // For non-working views, add to the list as usual\n draft.push(newView)\n }\n\n // finally sort the view by position and then by label\n draft.sort((a, b) => {\n if (a.position !== b.position) {\n return a.position - b.position\n }\n return a.label.localeCompare(b.label)\n })\n },\n ),\n )\n\n // Also update the getWorkingView cache if this is a working view\n let workingViewPatch\n if (payload.working) {\n workingViewPatch = dispatch(\n getViewsApi.util.updateQueryData(\n 'getWorkingView',\n { viewType: arg.viewType, projectName: arg.projectName },\n (draft) => {\n // Preserve the existing ID if there's already a working view\n const existingId = draft?.id\n const updatedWorkingView = {\n ...payload,\n working: true,\n scope: arg.projectName ? 'project' : 'studio',\n visibility: 'private',\n owner: user,\n ...(existingId && { id: existingId }), // Keep existing ID if it exists\n }\n // Update the working view cache with the new view data\n Object.assign(draft, updatedWorkingView)\n },\n ),\n )\n }\n\n let baseViewPatch\n\n if (payload.label === '__base__') {\n const newBaseView = {\n id: uuidv4(),\n ...payload,\n working: false,\n scope: arg.projectName ? 'project' : 'studio',\n visibility: 'private',\n owner: user,\n accessLevel: 30,\n position: 0,\n }\n\n baseViewPatch = dispatch(\n getViewsApi.util.updateQueryData(\n 'getBaseView',\n { viewType: arg.viewType, projectName: arg.projectName },\n (draft) => {\n if (draft) {\n Object.assign(draft, newBaseView)\n }\n },\n ),\n )\n\n // If the cache wasn't updated (because it didn't exist), upsert it\n if (!baseViewPatch?.patches?.length) {\n dispatch(\n getViewsApi.util.upsertQueryData(\n 'getBaseView',\n { viewType: arg.viewType, projectName: arg.projectName },\n newBaseView as any,\n ),\n )\n }\n }\n\n try {\n await queryFulfilled\n } catch (error) {\n patch.undo()\n if (workingViewPatch) workingViewPatch.undo()\n if (baseViewPatch) baseViewPatch.undo()\n }\n },\n transformErrorResponse: (error: any) => error.data?.detail,\n // updates the view list cache for a specific view type and project\n invalidatesTags: (_r, _e, { viewType, projectName, payload }) => [\n { type: 'view', id: payload.id },\n getScopeTag(viewType, projectName),\n ],\n },\n updateView: {\n transformErrorResponse: (error: any) => error.data?.detail,\n invalidatesTags: (_r, _e, { viewType, projectName, viewId }) => [\n { type: 'view', id: viewId },\n getScopeTag(viewType, projectName),\n ],\n },\n deleteView: {\n onQueryStarted: async (arg, { dispatch, queryFulfilled, getState }) => {\n const { viewId, projectName, viewType } = arg\n const state = getState()\n\n // Optimistically remove the view from the list\n const patches: any[] = []\n\n patches.push(\n dispatch(\n getViewsApi.util.updateQueryData('listViews', { viewType, projectName }, (draft) => {\n return draft.filter((view) => view.id !== viewId)\n }),\n ),\n )\n\n // Check both project and studio level for base and default views\n const scopesToCheck = [\n { projectName },\n { projectName: undefined }, // studio level\n ]\n const queriesToCheck = ['getBaseView', 'getDefaultView'] as const\n\n for (const scope of scopesToCheck) {\n for (const queryName of queriesToCheck) {\n const currentView = getViewsApi.endpoints[queryName].select({\n viewType,\n projectName: scope.projectName,\n })(state)\n\n if (currentView?.isSuccess && currentView.data?.id === viewId) {\n patches.push(\n dispatch(\n getViewsApi.util.updateQueryData(\n queryName,\n { viewType, projectName: scope.projectName },\n () => null as any,\n ),\n ),\n )\n }\n }\n }\n\n try {\n await queryFulfilled\n } catch (error) {\n // If the query failed, roll back all optimistic updates\n patches.forEach((patch) => patch.undo())\n console.error('Failed to delete view:', error)\n }\n },\n transformErrorResponse: (error: any) => error.data?.detail,\n // updates the view list cache for a specific view type and project\n invalidatesTags: (_r, _e, { viewType, projectName, viewId }) => [\n { type: 'view', id: viewId },\n getScopeTag(viewType, projectName),\n getScopeTag(viewType, undefined),\n ],\n },\n setDefaultView: {\n onQueryStarted: async (arg, { dispatch, queryFulfilled, getState }) => {\n const { setDefaultViewRequestModel, projectName, viewType } = arg\n const { viewId } = setDefaultViewRequestModel\n const state = getState()\n // get current state of default view\n const currentDefaultView = getViewsApi.endpoints.getDefaultView.select({\n viewType,\n projectName,\n })(state)\n\n // check if there is even a cache for the default view\n if (currentDefaultView?.isSuccess && currentDefaultView.data?.id) {\n // Optimistically update the default view\n const patch = dispatch(\n getViewsApi.util.updateQueryData(\n 'getDefaultView',\n { viewType, projectName },\n (draft) => {\n if (draft) {\n // Try to find the view in the listViews cache\n const listViewData = getViewsApi.endpoints.listViews.select({\n viewType,\n projectName,\n })(state)\n const view = listViewData?.data?.find((v) => v.id === viewId)\n\n if (view) {\n // If the view is found in the listViews cache, update the getDefaultView cache with the full view data\n Object.assign(draft, view)\n } else {\n // If the view is not found, only update the ID\n draft.id = viewId\n }\n }\n },\n ),\n )\n\n try {\n await queryFulfilled\n } catch (error) {\n // If the query failed, we need to roll back the optimistic update\n patch.undo()\n console.error('Failed to set default view:', error)\n }\n } else {\n console.warn(\n 'No current default view found, skipping optimistic update and invalidating default view cache',\n )\n // If there is no current default view, we skip the optimistic update\n // it will be handled by the invalidation below\n }\n },\n transformErrorResponse: (error: any) => error.data?.detail,\n // updates the default view cache for a specific view type and project\n invalidatesTags: (_r, _e, { viewType, projectName, setDefaultViewRequestModel }) => [\n { type: 'view', id: setDefaultViewRequestModel.viewId },\n getScopeTag(viewType, projectName),\n ],\n },\n },\n})\n\nexport const {\n useCreateViewMutation,\n useUpdateViewMutation,\n useDeleteViewMutation,\n useSetDefaultViewMutation,\n} = updateViewsApi\nexport { updateViewsApi as viewsQueries }\n"],"names":["updateViewsApi","getViewsApi","arg","dispatch","queryFulfilled","getState","payload","user","patch","draft","newView","existingWorkingIndex","view","existingId","a","b","workingViewPatch","updatedWorkingView","baseViewPatch","newBaseView","uuidv4","error","_r","_e","viewType","projectName","getScopeTag","viewId","state","patches","scopesToCheck","queriesToCheck","scope","queryName","currentView","setDefaultViewRequestModel","currentDefaultView","useCreateViewMutation","useUpdateViewMutation","useDeleteViewMutation","useSetDefaultViewMutation"],"mappings":"uIAIMA,EAAiBC,EAAAA,YAAY,iBAAiB,CAClD,UAAW,CACT,WAAY,CACV,eAAgB,MAAOC,EAAK,CAAE,SAAAC,EAAU,eAAAC,EAAgB,SAAAC,KAAe,CACrE,KAAM,CAAE,QAAAC,GAAYJ,EAGdK,EAFQF,EAAA,EAEK,MAAM,KAGnBG,EAAQL,EACZF,EAAAA,YAAY,KAAK,gBACf,YACA,CAAE,SAAUC,EAAI,SAAU,YAAaA,EAAI,WAAA,EAC1CO,GAAU,CACT,MAAMC,EAA6B,CACjC,GAAGJ,EACH,QAASA,EAAQ,SAAW,GAC5B,MAAOJ,EAAI,YAAc,UAAY,SACrC,WAAY,UACZ,SAAUO,EAAM,OAAS,EACzB,MAAOF,EACP,YAAa,EAAA,EAEf,GAAID,EAAQ,QAAS,CAEnB,MAAMK,EAAuBF,EAAM,UAAWG,GAASA,EAAK,UAAY,EAAI,EAC5E,GAAID,IAAyB,GAAI,CAE/B,MAAME,EAAaJ,EAAME,CAAoB,EAAE,GAC/CF,EAAME,CAAoB,EAAI,CAAE,GAAGD,EAAS,GAAIG,CAAA,CAClD,MAEEJ,EAAM,KAAKC,CAAO,CAEtB,MAEED,EAAM,KAAKC,CAAO,EAIpBD,EAA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GAAIA,EAA2B,MAAA,EAC/CT,EAAAA,YAAYF,EAAUC,CAAW,CAAA,CACnC,CACF,CAEJ,CAAC,EAEY,CACX,sBAAAY,EACA,sBAAAC,EACA,sBAAAC,EACA,0BAAAC,CACF,EAAIxC"}
@@ -1,9 +1,10 @@
1
1
  import { getViewsApi as u, getScopeTag as y } from "./getViews.es.js";
2
- const f = u.enhanceEndpoints({
2
+ import { v4 as m } from "uuid";
3
+ const V = u.enhanceEndpoints({
3
4
  endpoints: {
4
5
  createView: {
5
- onQueryStarted: async (e, { dispatch: c, queryFulfilled: a, getState: n }) => {
6
- const { payload: i } = e, d = n(), p = d.user?.name, v = c(
6
+ onQueryStarted: async (e, { dispatch: n, queryFulfilled: a, getState: r }) => {
7
+ const { payload: i } = e, p = r().user?.name, v = n(
7
8
  u.util.updateQueryData(
8
9
  "listViews",
9
10
  { viewType: e.viewType, projectName: e.projectName },
@@ -19,20 +20,20 @@ const f = u.enhanceEndpoints({
19
20
  accessLevel: 30
20
21
  };
21
22
  if (i.working) {
22
- const s = o.findIndex((r) => r.working === !0);
23
+ const s = o.findIndex((c) => c.working === !0);
23
24
  if (s !== -1) {
24
- const r = o[s].id;
25
- o[s] = { ...t, id: r };
25
+ const c = o[s].id;
26
+ o[s] = { ...t, id: c };
26
27
  } else
27
28
  o.push(t);
28
29
  } else
29
30
  o.push(t);
30
- o.sort((s, r) => s.position !== r.position ? s.position - r.position : s.label.localeCompare(r.label));
31
+ o.sort((s, c) => s.position !== c.position ? s.position - c.position : s.label.localeCompare(c.label));
31
32
  }
32
33
  )
33
34
  );
34
35
  let l;
35
- i.working && (l = c(
36
+ i.working && (l = n(
36
37
  u.util.updateQueryData(
37
38
  "getWorkingView",
38
39
  { viewType: e.viewType, projectName: e.projectName },
@@ -51,54 +52,58 @@ const f = u.enhanceEndpoints({
51
52
  )
52
53
  ));
53
54
  let w;
54
- if (i.label === "__base__")
55
- if (u.endpoints.getBaseView.select({
56
- viewType: e.viewType,
57
- projectName: e.projectName
58
- })(d) !== void 0) {
59
- const t = {
60
- ...i,
61
- working: !1,
62
- scope: e.projectName ? "project" : "studio",
63
- visibility: "private",
64
- owner: p,
65
- accessLevel: 30,
66
- position: 0
67
- };
68
- w = c(
69
- u.util.updateQueryData(
70
- "getBaseView",
71
- { viewType: e.viewType, projectName: e.projectName },
72
- () => t
73
- )
74
- );
75
- } else
76
- console.log("Skipping optimistic update for getBaseView - cache does not exist yet");
55
+ if (i.label === "__base__") {
56
+ const o = {
57
+ id: m(),
58
+ ...i,
59
+ working: !1,
60
+ scope: e.projectName ? "project" : "studio",
61
+ visibility: "private",
62
+ owner: p,
63
+ accessLevel: 30,
64
+ position: 0
65
+ };
66
+ w = n(
67
+ u.util.updateQueryData(
68
+ "getBaseView",
69
+ { viewType: e.viewType, projectName: e.projectName },
70
+ (t) => {
71
+ t && Object.assign(t, o);
72
+ }
73
+ )
74
+ ), w?.patches?.length || n(
75
+ u.util.upsertQueryData(
76
+ "getBaseView",
77
+ { viewType: e.viewType, projectName: e.projectName },
78
+ o
79
+ )
80
+ );
81
+ }
77
82
  try {
78
83
  await a;
79
- } catch (o) {
80
- v.undo(), l && l.undo(), w && w.undo(), console.error("Failed to create view:", o);
84
+ } catch {
85
+ v.undo(), l && l.undo(), w && w.undo();
81
86
  }
82
87
  },
83
88
  transformErrorResponse: (e) => e.data?.detail,
84
89
  // updates the view list cache for a specific view type and project
85
- invalidatesTags: (e, c, { viewType: a, projectName: n, payload: i }) => [
90
+ invalidatesTags: (e, n, { viewType: a, projectName: r, payload: i }) => [
86
91
  { type: "view", id: i.id },
87
- y(a, n)
92
+ y(a, r)
88
93
  ]
89
94
  },
90
95
  updateView: {
91
96
  transformErrorResponse: (e) => e.data?.detail,
92
- invalidatesTags: (e, c, { viewType: a, projectName: n, viewId: i }) => [
97
+ invalidatesTags: (e, n, { viewType: a, projectName: r, viewId: i }) => [
93
98
  { type: "view", id: i },
94
- y(a, n)
99
+ y(a, r)
95
100
  ]
96
101
  },
97
102
  deleteView: {
98
- onQueryStarted: async (e, { dispatch: c, queryFulfilled: a, getState: n }) => {
99
- const { viewId: i, projectName: d, viewType: p } = e, v = n(), l = [];
103
+ onQueryStarted: async (e, { dispatch: n, queryFulfilled: a, getState: r }) => {
104
+ const { viewId: i, projectName: d, viewType: p } = e, v = r(), l = [];
100
105
  l.push(
101
- c(
106
+ n(
102
107
  u.util.updateQueryData("listViews", { viewType: p, projectName: d }, (t) => t.filter((s) => s.id !== i))
103
108
  )
104
109
  );
@@ -109,12 +114,12 @@ const f = u.enhanceEndpoints({
109
114
  ], o = ["getBaseView", "getDefaultView"];
110
115
  for (const t of w)
111
116
  for (const s of o) {
112
- const r = u.endpoints[s].select({
117
+ const c = u.endpoints[s].select({
113
118
  viewType: p,
114
119
  projectName: t.projectName
115
120
  })(v);
116
- r?.isSuccess && r.data?.id === i && l.push(
117
- c(
121
+ c?.isSuccess && c.data?.id === i && l.push(
122
+ n(
118
123
  u.util.updateQueryData(
119
124
  s,
120
125
  { viewType: p, projectName: t.projectName },
@@ -131,30 +136,30 @@ const f = u.enhanceEndpoints({
131
136
  },
132
137
  transformErrorResponse: (e) => e.data?.detail,
133
138
  // updates the view list cache for a specific view type and project
134
- invalidatesTags: (e, c, { viewType: a, projectName: n, viewId: i }) => [
139
+ invalidatesTags: (e, n, { viewType: a, projectName: r, viewId: i }) => [
135
140
  { type: "view", id: i },
136
- y(a, n),
141
+ y(a, r),
137
142
  y(a, void 0)
138
143
  ]
139
144
  },
140
145
  setDefaultView: {
141
- onQueryStarted: async (e, { dispatch: c, queryFulfilled: a, getState: n }) => {
142
- const { setDefaultViewRequestModel: i, projectName: d, viewType: p } = e, { viewId: v } = i, l = n(), w = u.endpoints.getDefaultView.select({
146
+ onQueryStarted: async (e, { dispatch: n, queryFulfilled: a, getState: r }) => {
147
+ const { setDefaultViewRequestModel: i, projectName: d, viewType: p } = e, { viewId: v } = i, l = r(), w = u.endpoints.getDefaultView.select({
143
148
  viewType: p,
144
149
  projectName: d
145
150
  })(l);
146
151
  if (w?.isSuccess && w.data?.id) {
147
- const o = c(
152
+ const o = n(
148
153
  u.util.updateQueryData(
149
154
  "getDefaultView",
150
155
  { viewType: p, projectName: d },
151
156
  (t) => {
152
157
  if (t) {
153
- const r = u.endpoints.listViews.select({
158
+ const c = u.endpoints.listViews.select({
154
159
  viewType: p,
155
160
  projectName: d
156
- })(l)?.data?.find((V) => V.id === v);
157
- r ? Object.assign(t, r) : t.id = v;
161
+ })(l)?.data?.find((f) => f.id === v);
162
+ c ? Object.assign(t, c) : t.id = v;
158
163
  }
159
164
  }
160
165
  )
@@ -171,23 +176,23 @@ const f = u.enhanceEndpoints({
171
176
  },
172
177
  transformErrorResponse: (e) => e.data?.detail,
173
178
  // updates the default view cache for a specific view type and project
174
- invalidatesTags: (e, c, { viewType: a, projectName: n, setDefaultViewRequestModel: i }) => [
179
+ invalidatesTags: (e, n, { viewType: a, projectName: r, setDefaultViewRequestModel: i }) => [
175
180
  { type: "view", id: i.viewId },
176
- y(a, n)
181
+ y(a, r)
177
182
  ]
178
183
  }
179
184
  }
180
185
  }), {
181
- useCreateViewMutation: g,
182
- useUpdateViewMutation: j,
183
- useDeleteViewMutation: N,
184
- useSetDefaultViewMutation: h
185
- } = f;
186
+ useCreateViewMutation: N,
187
+ useUpdateViewMutation: D,
188
+ useDeleteViewMutation: h,
189
+ useSetDefaultViewMutation: T
190
+ } = V;
186
191
  export {
187
- g as useCreateViewMutation,
188
- N as useDeleteViewMutation,
189
- h as useSetDefaultViewMutation,
190
- j as useUpdateViewMutation,
191
- f as viewsQueries
192
+ N as useCreateViewMutation,
193
+ h as useDeleteViewMutation,
194
+ T as useSetDefaultViewMutation,
195
+ D as useUpdateViewMutation,
196
+ V as viewsQueries
192
197
  };
193
198
  //# sourceMappingURL=updateViews.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"updateViews.es.js","sources":["../../../../../../src/api/queries/views/updateViews.ts"],"sourcesContent":["import { ViewListItemModel } from '@shared/api/generated'\nimport { getScopeTag, getViewsApi } from './getViews'\n\nconst updateViewsApi = getViewsApi.enhanceEndpoints({\n endpoints: {\n createView: {\n onQueryStarted: async (arg, { dispatch, queryFulfilled, getState }) => {\n const { payload } = arg\n const state = getState()\n // @ts-expect-error - user is not typed in the state\n const user = state.user?.name\n\n // Optimistically update the view list\n const patch = dispatch(\n getViewsApi.util.updateQueryData(\n 'listViews',\n { viewType: arg.viewType, projectName: arg.projectName },\n (draft) => {\n const newView: ViewListItemModel = {\n ...payload,\n working: payload.working || false,\n scope: arg.projectName ? 'project' : 'studio',\n visibility: 'private',\n position: draft.length + 1, // Add to the end of the list\n owner: user,\n accessLevel: 30,\n }\n if (payload.working) {\n // For working views, find and replace the existing working view\n const existingWorkingIndex = draft.findIndex((view) => view.working === true)\n if (existingWorkingIndex !== -1) {\n // Keep the existing ID but update all other properties\n const existingId = draft[existingWorkingIndex].id\n draft[existingWorkingIndex] = { ...newView, id: existingId }\n } else {\n // No existing working view, add the new one\n draft.push(newView)\n }\n } else {\n // For non-working views, add to the list as usual\n draft.push(newView)\n }\n\n // finally sort the view by position and then by label\n draft.sort((a, b) => {\n if (a.position !== b.position) {\n return a.position - b.position\n }\n return a.label.localeCompare(b.label)\n })\n },\n ),\n )\n\n // Also update the getWorkingView cache if this is a working view\n let workingViewPatch\n if (payload.working) {\n workingViewPatch = dispatch(\n getViewsApi.util.updateQueryData(\n 'getWorkingView',\n { viewType: arg.viewType, projectName: arg.projectName },\n (draft) => {\n // Preserve the existing ID if there's already a working view\n const existingId = draft?.id\n const updatedWorkingView = {\n ...payload,\n working: true,\n scope: arg.projectName ? 'project' : 'studio',\n visibility: 'private',\n owner: user,\n ...(existingId && { id: existingId }), // Keep existing ID if it exists\n }\n // Update the working view cache with the new view data\n Object.assign(draft, updatedWorkingView)\n },\n ),\n )\n }\n\n // Also update the getBaseView cache if this is a base view\n let baseViewPatch\n if (payload.label === '__base__') {\n // Check if the getBaseView cache exists before updating\n const currentBaseView = getViewsApi.endpoints.getBaseView.select({\n viewType: arg.viewType,\n projectName: arg.projectName,\n })(state)\n\n // Only perform optimistic update if cache is initialized (even if data is null)\n if (currentBaseView !== undefined) {\n const newBaseView = {\n ...payload,\n working: false,\n scope: arg.projectName ? 'project' : 'studio',\n visibility: 'private',\n owner: user,\n accessLevel: 30,\n position: 0,\n }\n\n baseViewPatch = dispatch(\n getViewsApi.util.updateQueryData(\n 'getBaseView',\n { viewType: arg.viewType, projectName: arg.projectName },\n () => newBaseView as any,\n ),\n )\n } else {\n // No cache exists yet, optimistic update will be skipped\n // The invalidation tags will handle the refetch\n console.log('Skipping optimistic update for getBaseView - cache does not exist yet')\n }\n }\n\n try {\n await queryFulfilled\n } catch (error) {\n // If the query failed, we need to roll back the optimistic updates\n patch.undo()\n if (workingViewPatch) {\n workingViewPatch.undo()\n }\n if (baseViewPatch) {\n baseViewPatch.undo()\n }\n console.error('Failed to create view:', error)\n }\n },\n transformErrorResponse: (error: any) => error.data?.detail,\n // updates the view list cache for a specific view type and project\n invalidatesTags: (_r, _e, { viewType, projectName, payload }) => [\n { type: 'view', id: payload.id },\n getScopeTag(viewType, projectName),\n ],\n },\n updateView: {\n transformErrorResponse: (error: any) => error.data?.detail,\n invalidatesTags: (_r, _e, { viewType, projectName, viewId }) => [\n { type: 'view', id: viewId },\n getScopeTag(viewType, projectName),\n ],\n },\n deleteView: {\n onQueryStarted: async (arg, { dispatch, queryFulfilled, getState }) => {\n const { viewId, projectName, viewType } = arg\n const state = getState()\n\n // Optimistically remove the view from the list\n const patches: any[] = []\n\n patches.push(\n dispatch(\n getViewsApi.util.updateQueryData('listViews', { viewType, projectName }, (draft) => {\n return draft.filter((view) => view.id !== viewId)\n }),\n ),\n )\n\n // Check both project and studio level for base and default views\n const scopesToCheck = [\n { projectName },\n { projectName: undefined }, // studio level\n ]\n const queriesToCheck = ['getBaseView', 'getDefaultView'] as const\n\n for (const scope of scopesToCheck) {\n for (const queryName of queriesToCheck) {\n const currentView = getViewsApi.endpoints[queryName].select({\n viewType,\n projectName: scope.projectName,\n })(state)\n\n if (currentView?.isSuccess && currentView.data?.id === viewId) {\n patches.push(\n dispatch(\n getViewsApi.util.updateQueryData(\n queryName,\n { viewType, projectName: scope.projectName },\n () => null as any,\n ),\n ),\n )\n }\n }\n }\n\n try {\n await queryFulfilled\n } catch (error) {\n // If the query failed, roll back all optimistic updates\n patches.forEach((patch) => patch.undo())\n console.error('Failed to delete view:', error)\n }\n },\n transformErrorResponse: (error: any) => error.data?.detail,\n // updates the view list cache for a specific view type and project\n invalidatesTags: (_r, _e, { viewType, projectName, viewId }) => [\n { type: 'view', id: viewId },\n getScopeTag(viewType, projectName),\n getScopeTag(viewType, undefined),\n ],\n },\n setDefaultView: {\n onQueryStarted: async (arg, { dispatch, queryFulfilled, getState }) => {\n const { setDefaultViewRequestModel, projectName, viewType } = arg\n const { viewId } = setDefaultViewRequestModel\n const state = getState()\n // get current state of default view\n const currentDefaultView = getViewsApi.endpoints.getDefaultView.select({\n viewType,\n projectName,\n })(state)\n\n // check if there is even a cache for the default view\n if (currentDefaultView?.isSuccess && currentDefaultView.data?.id) {\n // Optimistically update the default view\n const patch = dispatch(\n getViewsApi.util.updateQueryData(\n 'getDefaultView',\n { viewType, projectName },\n (draft) => {\n if (draft) {\n // Try to find the view in the listViews cache\n const listViewData = getViewsApi.endpoints.listViews.select({\n viewType,\n projectName,\n })(state)\n const view = listViewData?.data?.find((v) => v.id === viewId)\n\n if (view) {\n // If the view is found in the listViews cache, update the getDefaultView cache with the full view data\n Object.assign(draft, view)\n } else {\n // If the view is not found, only update the ID\n draft.id = viewId\n }\n }\n },\n ),\n )\n\n try {\n await queryFulfilled\n } catch (error) {\n // If the query failed, we need to roll back the optimistic update\n patch.undo()\n console.error('Failed to set default view:', error)\n }\n } else {\n console.warn(\n 'No current default view found, skipping optimistic update and invalidating default view cache',\n )\n // If there is no current default view, we skip the optimistic update\n // it will be handled by the invalidation below\n }\n },\n transformErrorResponse: (error: any) => error.data?.detail,\n // updates the default view cache for a specific view type and project\n invalidatesTags: (_r, _e, { viewType, projectName, setDefaultViewRequestModel }) => [\n { type: 'view', id: setDefaultViewRequestModel.viewId },\n getScopeTag(viewType, projectName),\n ],\n },\n },\n})\n\nexport const {\n useCreateViewMutation,\n useUpdateViewMutation,\n useDeleteViewMutation,\n useSetDefaultViewMutation,\n} = updateViewsApi\nexport { updateViewsApi as viewsQueries }\n"],"names":["updateViewsApi","getViewsApi","arg","dispatch","queryFulfilled","getState","payload","state","user","patch","draft","newView","existingWorkingIndex","view","existingId","a","b","workingViewPatch","updatedWorkingView","baseViewPatch","newBaseView","error","_r","_e","viewType","projectName","getScopeTag","viewId","patches","scopesToCheck","queriesToCheck","scope","queryName","currentView","setDefaultViewRequestModel","currentDefaultView","v","useCreateViewMutation","useUpdateViewMutation","useDeleteViewMutation","useSetDefaultViewMutation"],"mappings":";AAGA,MAAMA,IAAiBC,EAAY,iBAAiB;AAAA,EAClD,WAAW;AAAA,IACT,YAAY;AAAA,MACV,gBAAgB,OAAOC,GAAK,EAAE,UAAAC,GAAU,gBAAAC,GAAgB,UAAAC,QAAe;AACrE,cAAM,EAAE,SAAAC,MAAYJ,GACdK,IAAQF,EAAA,GAERG,IAAOD,EAAM,MAAM,MAGnBE,IAAQN;AAAA,UACZF,EAAY,KAAK;AAAA,YACf;AAAA,YACA,EAAE,UAAUC,EAAI,UAAU,aAAaA,EAAI,YAAA;AAAA,YAC3C,CAACQ,MAAU;AACT,oBAAMC,IAA6B;AAAA,gBACjC,GAAGL;AAAA,gBACH,SAASA,EAAQ,WAAW;AAAA,gBAC5B,OAAOJ,EAAI,cAAc,YAAY;AAAA,gBACrC,YAAY;AAAA,gBACZ,UAAUQ,EAAM,SAAS;AAAA;AAAA,gBACzB,OAAOF;AAAA,gBACP,aAAa;AAAA,cAAA;AAEf,kBAAIF,EAAQ,SAAS;AAEnB,sBAAMM,IAAuBF,EAAM,UAAU,CAACG,MAASA,EAAK,YAAY,EAAI;AAC5E,oBA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esContent":["import { ViewListItemModel } from '@shared/api/generated'\nimport { getScopeTag, getViewsApi } from './getViews'\nimport { v4 as uuidv4 } from 'uuid'\n\nconst updateViewsApi = getViewsApi.enhanceEndpoints({\n endpoints: {\n createView: {\n onQueryStarted: async (arg, { dispatch, queryFulfilled, getState }) => {\n const { payload } = arg\n const state = getState()\n // @ts-expect-error - user is not typed in the state\n const user = state.user?.name\n\n // Optimistically update the view list\n const patch = dispatch(\n getViewsApi.util.updateQueryData(\n 'listViews',\n { viewType: arg.viewType, projectName: arg.projectName },\n (draft) => {\n const newView: ViewListItemModel = {\n ...payload,\n working: payload.working || false,\n scope: arg.projectName ? 'project' : 'studio',\n visibility: 'private',\n position: draft.length + 1, // Add to the end of the list\n owner: user,\n accessLevel: 30,\n }\n if (payload.working) {\n // For working views, find and replace the existing working view\n const existingWorkingIndex = draft.findIndex((view) => view.working === true)\n if (existingWorkingIndex !== -1) {\n // Keep the existing ID but update all other properties\n const existingId = draft[existingWorkingIndex].id\n draft[existingWorkingIndex] = { ...newView, id: existingId }\n } else {\n // No existing working view, add the new one\n draft.push(newView)\n }\n } else {\n // For non-working views, add to the list as usual\n draft.push(newView)\n }\n\n // finally sort the view by position and then by label\n draft.sort((a, b) => {\n if (a.position !== b.position) {\n return a.position - b.position\n }\n return a.label.localeCompare(b.label)\n })\n },\n ),\n )\n\n // Also update the getWorkingView cache if this is a working view\n let workingViewPatch\n if (payload.working) {\n workingViewPatch = dispatch(\n getViewsApi.util.updateQueryData(\n 'getWorkingView',\n { viewType: arg.viewType, projectName: arg.projectName },\n (draft) => {\n // Preserve the existing ID if there's already a working view\n const existingId = draft?.id\n const updatedWorkingView = {\n ...payload,\n working: true,\n scope: arg.projectName ? 'project' : 'studio',\n visibility: 'private',\n owner: user,\n ...(existingId && { id: existingId }), // Keep existing ID if it exists\n }\n // Update the working view cache with the new view data\n Object.assign(draft, updatedWorkingView)\n },\n ),\n )\n }\n\n let baseViewPatch\n\n if (payload.label === '__base__') {\n const newBaseView = {\n id: uuidv4(),\n ...payload,\n working: false,\n scope: arg.projectName ? 'project' : 'studio',\n visibility: 'private',\n owner: user,\n accessLevel: 30,\n position: 0,\n }\n\n baseViewPatch = dispatch(\n getViewsApi.util.updateQueryData(\n 'getBaseView',\n { viewType: arg.viewType, projectName: arg.projectName },\n (draft) => {\n if (draft) {\n Object.assign(draft, newBaseView)\n }\n },\n ),\n )\n\n // If the cache wasn't updated (because it didn't exist), upsert it\n if (!baseViewPatch?.patches?.length) {\n dispatch(\n getViewsApi.util.upsertQueryData(\n 'getBaseView',\n { viewType: arg.viewType, projectName: arg.projectName },\n newBaseView as any,\n ),\n )\n }\n }\n\n try {\n await queryFulfilled\n } catch (error) {\n patch.undo()\n if (workingViewPatch) workingViewPatch.undo()\n if (baseViewPatch) baseViewPatch.undo()\n }\n },\n transformErrorResponse: (error: any) => error.data?.detail,\n // updates the view list cache for a specific view type and project\n invalidatesTags: (_r, _e, { viewType, projectName, payload }) => [\n { type: 'view', id: payload.id },\n getScopeTag(viewType, projectName),\n ],\n },\n updateView: {\n transformErrorResponse: (error: any) => error.data?.detail,\n invalidatesTags: (_r, _e, { viewType, projectName, viewId }) => [\n { type: 'view', id: viewId },\n getScopeTag(viewType, projectName),\n ],\n },\n deleteView: {\n onQueryStarted: async (arg, { dispatch, queryFulfilled, getState }) => {\n const { viewId, projectName, viewType } = arg\n const state = getState()\n\n // Optimistically remove the view from the list\n const patches: any[] = []\n\n patches.push(\n dispatch(\n getViewsApi.util.updateQueryData('listViews', { viewType, projectName }, (draft) => {\n return draft.filter((view) => view.id !== viewId)\n }),\n ),\n )\n\n // Check both project and studio level for base and default views\n const scopesToCheck = [\n { projectName },\n { projectName: undefined }, // studio level\n ]\n const queriesToCheck = ['getBaseView', 'getDefaultView'] as const\n\n for (const scope of scopesToCheck) {\n for (const queryName of queriesToCheck) {\n const currentView = getViewsApi.endpoints[queryName].select({\n viewType,\n projectName: scope.projectName,\n })(state)\n\n if (currentView?.isSuccess && currentView.data?.id === viewId) {\n patches.push(\n dispatch(\n getViewsApi.util.updateQueryData(\n queryName,\n { viewType, projectName: scope.projectName },\n () => null as any,\n ),\n ),\n )\n }\n }\n }\n\n try {\n await queryFulfilled\n } catch (error) {\n // If the query failed, roll back all optimistic updates\n patches.forEach((patch) => patch.undo())\n console.error('Failed to delete view:', error)\n }\n },\n transformErrorResponse: (error: any) => error.data?.detail,\n // updates the view list cache for a specific view type and project\n invalidatesTags: (_r, _e, { viewType, projectName, viewId }) => [\n { type: 'view', id: viewId },\n getScopeTag(viewType, projectName),\n getScopeTag(viewType, undefined),\n ],\n },\n setDefaultView: {\n onQueryStarted: async (arg, { dispatch, queryFulfilled, getState }) => {\n const { setDefaultViewRequestModel, projectName, viewType } = arg\n const { viewId } = setDefaultViewRequestModel\n const state = getState()\n // get current state of default view\n const currentDefaultView = getViewsApi.endpoints.getDefaultView.select({\n viewType,\n projectName,\n })(state)\n\n // check if there is even a cache for the default view\n if (currentDefaultView?.isSuccess && currentDefaultView.data?.id) {\n // Optimistically update the default view\n const patch = dispatch(\n getViewsApi.util.updateQueryData(\n 'getDefaultView',\n { viewType, projectName },\n (draft) => {\n if (draft) {\n // Try to find the view in the listViews cache\n const listViewData = getViewsApi.endpoints.listViews.select({\n viewType,\n projectName,\n })(state)\n const view = listViewData?.data?.find((v) => v.id === viewId)\n\n if (view) {\n // If the view is found in the listViews cache, update the getDefaultView cache with the full view data\n Object.assign(draft, view)\n } else {\n // If the view is not found, only update the ID\n draft.id = viewId\n }\n }\n },\n ),\n )\n\n try {\n await queryFulfilled\n } catch (error) {\n // If the query failed, we need to roll back the optimistic update\n patch.undo()\n console.error('Failed to set default view:', error)\n }\n } else {\n console.warn(\n 'No current default view found, skipping optimistic update and invalidating default view cache',\n )\n // If there is no current default view, we skip the optimistic update\n // it will be handled by the invalidation below\n }\n },\n transformErrorResponse: (error: any) => error.data?.detail,\n // updates the default view cache for a specific view type and project\n invalidatesTags: (_r, _e, { viewType, projectName, setDefaultViewRequestModel }) => [\n { type: 'view', id: setDefaultViewRequestModel.viewId },\n getScopeTag(viewType, projectName),\n ],\n },\n },\n})\n\nexport const {\n useCreateViewMutation,\n useUpdateViewMutation,\n useDeleteViewMutation,\n useSetDefaultViewMutation,\n} = updateViewsApi\nexport { updateViewsApi as viewsQueries }\n"],"names":["updateViewsApi","getViewsApi","arg","dispatch","queryFulfilled","getState","payload","user","patch","draft","newView","existingWorkingIndex","view","existingId","a","b","workingViewPatch","updatedWorkingView","baseViewPatch","newBaseView","uuidv4","error","_r","_e","viewType","projectName","getScopeTag","viewId","state","patches","scopesToCheck","queriesToCheck","scope","queryName","currentView","setDefaultViewRequestModel","currentDefaultView","v","useCreateViewMutation","useUpdateViewMutation","useDeleteViewMutation","useSetDefaultViewMutation"],"mappings":";;AAIA,MAAMA,IAAiBC,EAAY,iBAAiB;AAAA,EAClD,WAAW;AAAA,IACT,YAAY;AAAA,MACV,gBAAgB,OAAOC,GAAK,EAAE,UAAAC,GAAU,gBAAAC,GAAgB,UAAAC,QAAe;AACrE,cAAM,EAAE,SAAAC,MAAYJ,GAGdK,IAFQF,EAAA,EAEK,MAAM,MAGnBG,IAAQL;AAAA,UACZF,EAAY,KAAK;AAAA,YACf;AAAA,YACA,EAAE,UAAUC,EAAI,UAAU,aAAaA,EAAI,YAAA;AAAA,YAC3C,CAACO,MAAU;AACT,oBAAMC,IAA6B;AAAA,gBACjC,GAAGJ;AAAA,gBACH,SAASA,EAAQ,WAAW;AAAA,gBAC5B,OAAOJ,EAAI,cAAc,YAAY;AAAA,gBACrC,YAAY;AAAA,gBACZ,UAAUO,EAAM,SAAS;AAAA;AAAA,gBACzB,OAAOF;AAAA,gBACP,aAAa;AAAA,cAAA;AAEf,kBAAID,EAAQ,SAAS;AAEnB,sBAAMK,IAAuBF,EAAM,UAAU,CAACG,MAASA,EAAK,YAAY,EAAI;AAC5E,oBAAID,MAAyB,IAAI;AAE/B,wBAAME,IAAaJ,EAAME,CAAoB,EAAE;AAC/C,kBAAAF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UAAU,eAAe,OAAO;AAAA,UACrE,UAAAuB;AAAA,UACA,aAAAC;AAAA,QAAA,CACD,EAAEG,CAAK;AAGR,YAAIQ,GAAoB,aAAaA,EAAmB,MAAM,IAAI;AAEhE,gBAAM5B,IAAQL;AAAA,YACZF,EAAY,KAAK;AAAA,cACf;AAAA,cACA,EAAE,UAAAuB,GAAU,aAAAC,EAAA;AAAA,cACZ,CAAChB,MAAU;AACT,oBAAIA,GAAO;AAMT,wBAAMG,IAJeX,EAAY,UAAU,UAAU,OAAO;AAAA,oBAC1D,UAAAuB;AAAA,oBACA,aAAAC;AAAA,kBAAA,CACD,EAAEG,CAAK,GACmB,MAAM,KAAK,CAACS,MAAMA,EAAE,OAAOV,CAAM;AAE5D,kBAAIf,IAEF,OAAO,OAAOH,GAAOG,CAAI,IAGzBH,EAAM,KAAKkB;AAAA,gBAEf;AAAA,cACF;AAAA,YAAA;AAAA,UACF;AAGF,cAAI;AACF,kBAAMvB;AAAA,UACR,SAASiB,GAAO;AAEd,YAAAb,EAAM,KAAA,GACN,QAAQ,MAAM,+BAA+Ba,CAAK;AAAA,UACpD;AAAA,QACF;AACE,kBAAQ;AAAA,YACN;AAAA,UAAA;AAAA,MAKN;AAAA,MACA,wBAAwB,CAACA,MAAeA,EAAM,MAAM;AAAA;AAAA,MAEpD,iBAAiB,CAACC,GAAIC,GAAI,EAAE,UAAAC,GAAU,aAAAC,GAAa,4BAAAU,QAAiC;AAAA,QAClF,EAAE,MAAM,QAAQ,IAAIA,EAA2B,OAAA;AAAA,QAC/CT,EAAYF,GAAUC,CAAW;AAAA,MAAA;AAAA,IACnC;AAAA,EACF;AAEJ,CAAC,GAEY;AAAA,EACX,uBAAAa;AAAA,EACA,uBAAAC;AAAA,EACA,uBAAAC;AAAA,EACA,2BAAAC;AACF,IAAIzC;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../../../_virtual/jsx-runtime.cjs.js"),o=require("react"),t=require("@ynput/ayon-react-components");require("lodash");require("react-toastify");const a=require("../../util/getEntityTypeIcon.cjs.js");require("uuid");require("../../util/pubsub.cjs.js");require("../../api/base/client.cjs.js");require("../../api/generated/graphql.cjs.js");require("../../api/generated/graphqlLinks.cjs.js");require("../../api/generated/access.cjs.js");require("../../api/generated/actions.cjs.js");require("../../api/generated/activityFeed.cjs.js");require("../../api/generated/addons.cjs.js");require("../../api/generated/anatomy.cjs.js");require("../../api/generated/attributes.cjs.js");require("../../api/generated/authentication.cjs.js");require("../../api/generated/bundles.cjs.js");require("../../api/generated/configuration.cjs.js");require("../../api/generated/desktop.cjs.js");require("../../api/generated/entityLists.cjs.js");require("../../api/generated/events.cjs.js");require("../../api/generated/files.cjs.js");require("../../api/generated/folders.cjs.js");require("../../api/generated/inbox.cjs.js");require("../../api/generated/links.cjs.js");require("../../api/generated/market.cjs.js");require("../../api/generated/onboarding.cjs.js");require("../../api/generated/operations.cjs.js");require("../../api/generated/products.cjs.js");require("../../api/generated/projectDashboard.cjs.js");require("../../api/generated/projects.cjs.js");require("../../api/generated/reviewables.cjs.js");require("../../api/generated/services.cjs.js");require("../../api/generated/system.cjs.js");require("../../api/generated/tasks.cjs.js");require("../../api/generated/teams.cjs.js");require("../../api/generated/thumbnails.cjs.js");require("../../api/generated/uRIs.cjs.js");require("../../api/generated/users.cjs.js");require("../../api/generated/versions.cjs.js");require("../../api/generated/workfiles.cjs.js");require("../../api/generated/ynputCloud.cjs.js");require("../../api/generated/grouping.cjs.js");require("../../api/generated/views.cjs.js");require("../../api/queries/actions/getActions.cjs.js");require("../../api/queries/activities/getActivities.cjs.js");require("../../api/queries/activities/updateActivities.cjs.js");require("../../api/queries/activities/updateReaction.cjs.js");require("../../api/queries/activities/getMentions.cjs.js");require("../../api/queries/activities/getCategories.cjs.js");require("../../api/queries/addons/getAddons.cjs.js");require("../../api/queries/addons/updateAddons.cjs.js");require("../../api/queries/attributes/getAttributes.cjs.js");require("../../api/queries/attributes/updateAttributes.cjs.js");require("../../api/queries/authentication/getAuthentication.cjs.js");require("../../api/queries/cloud/cloud.cjs.js");require("../../api/queries/config/getConfig.cjs.js");require("../../api/queries/config/updateConfig.cjs.js");require("../../api/queries/entities/getEntity.cjs.js");require("../../api/queries/entities/getEntityPanel.cjs.js");const p=require("../../api/queries/entities/transformDetailsPanelData.cjs.js");require("../../api/queries/entities/updateEntity.cjs.js");require("../../api/queries/entityLists/getLists.cjs.js");require("../../api/queries/entityLists/updateLists.cjs.js");require("../../api/queries/entityLists/getListsAttributes.cjs.js");require("../../api/queries/entityLists/updateListsAttributes.cjs.js");require("../../api/queries/entityLists/listFolders.cjs.js");require("../../api/queries/folders/getFolders.cjs.js");require("../../api/queries/grouping/getGrouping.cjs.js");require("../../api/queries/links/updateLinks.cjs.js");require("../../api/queries/links/getLinks.cjs.js");require("../../api/queries/links/getEntityLinks.cjs.js");require("../../api/queries/overview/getOverview.cjs.js");require("../../api/queries/overview/updateOverview.cjs.js");require("../../api/queries/versions/getVersionsProducts.cjs.js");require("../../api/queries/permissions/getPermissions.cjs.js");require("../../api/queries/products/createProduct.cjs.js");require("../../api/queries/project/getProject.cjs.js");require("../../api/queries/project/updateProject.cjs.js");require("../../api/queries/review/getReview.cjs.js");require("../../api/queries/review/updateReview.cjs.js");require("../../api/queries/share/share.cjs.js");require("../../api/queries/system/getSystem.cjs.js");require("../../api/queries/userDashboard/getUserDashboard.cjs.js");require("../../api/queries/users/getUsers.cjs.js");require("../../api/queries/users/updateUsers.cjs.js");require("../../api/queries/users/guests.cjs.js");require("../../api/queries/versions/updateVersions.cjs.js");require("../../api/queries/views/getViews.cjs.js");require("../../api/queries/views/updateViews.cjs.js");require("../../api/queries/watchers/getWatchers.cjs.js");require("../../api/queries/uris/getUris.cjs.js");const x=require("./LinksManager.styled.cjs.js"),m=require("clsx"),l=({link:e,isSelected:q=!1,onEntityClick:n,onRemove:c})=>{const s=p.detailsPanelEntityTypes.includes(e.entityType)&&!e.isRestricted;return r.jsxRuntimeExports.jsxs(x.LinkItem,{onClick:()=>s&&n?.(e.entityId,e.entityType),"data-tooltip":e.isRestricted?"Access Restricted - Insufficient Permissions to Entity":e.parents.join("/")+"/"+e.label,className:m({clickable:s,selected:q,restricted:e.isRestricted}),children:[e.icon?r.jsxRuntimeExports.jsx(t.Icon,{icon:e.icon}):r.jsxRuntimeExports.jsx(t.Icon,{icon:a.getEntityTypeIcon(e.entityType)}),r.jsxRuntimeExports.jsx("span",{className:"title",children:e.isRestricted?r.jsxRuntimeExports.jsx("span",{className:"label",children:"Access Restricted"}):r.jsxRuntimeExports.jsxs(r.jsxRuntimeExports.Fragment,{children:[e.parents?.map((i,u)=>r.jsxRuntimeExports.jsxs(o.Fragment,{children:[r.jsxRuntimeExports.jsx("span",{children:i},u+"-path"),r.jsxRuntimeExports.jsx("span",{children:"/"},u+"-separator")]},u)),r.jsxRuntimeExports.jsx("span",{className:"label",children:e.label})]})}),!e.isRestricted&&r.jsxRuntimeExports.jsx(t.Button,{icon:"link_off",variant:"text",className:"remove",onClick:i=>c(i,e),"data-tooltip":"Remove link"})]},e.linkId)};exports.LinkManagerItem=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../../../_virtual/jsx-runtime.cjs.js"),a=require("react"),s=require("@ynput/ayon-react-components");require("lodash");require("react-toastify");const p=require("../../util/getEntityTypeIcon.cjs.js");require("uuid");require("../../util/pubsub.cjs.js");require("../../api/base/client.cjs.js");require("../../api/generated/graphql.cjs.js");require("../../api/generated/graphqlLinks.cjs.js");require("../../api/generated/access.cjs.js");require("../../api/generated/actions.cjs.js");require("../../api/generated/activityFeed.cjs.js");require("../../api/generated/addons.cjs.js");require("../../api/generated/anatomy.cjs.js");require("../../api/generated/attributes.cjs.js");require("../../api/generated/authentication.cjs.js");require("../../api/generated/bundles.cjs.js");require("../../api/generated/configuration.cjs.js");require("../../api/generated/desktop.cjs.js");require("../../api/generated/entityLists.cjs.js");require("../../api/generated/events.cjs.js");require("../../api/generated/files.cjs.js");require("../../api/generated/folders.cjs.js");require("../../api/generated/inbox.cjs.js");require("../../api/generated/links.cjs.js");require("../../api/generated/market.cjs.js");require("../../api/generated/onboarding.cjs.js");require("../../api/generated/operations.cjs.js");require("../../api/generated/products.cjs.js");require("../../api/generated/projectDashboard.cjs.js");require("../../api/generated/projects.cjs.js");require("../../api/generated/reviewables.cjs.js");require("../../api/generated/services.cjs.js");require("../../api/generated/system.cjs.js");require("../../api/generated/tasks.cjs.js");require("../../api/generated/teams.cjs.js");require("../../api/generated/thumbnails.cjs.js");require("../../api/generated/uRIs.cjs.js");require("../../api/generated/users.cjs.js");require("../../api/generated/versions.cjs.js");require("../../api/generated/workfiles.cjs.js");require("../../api/generated/ynputCloud.cjs.js");require("../../api/generated/grouping.cjs.js");require("../../api/generated/views.cjs.js");require("../../api/queries/actions/getActions.cjs.js");require("../../api/queries/activities/getActivities.cjs.js");require("../../api/queries/activities/updateActivities.cjs.js");require("../../api/queries/activities/updateReaction.cjs.js");require("../../api/queries/activities/getMentions.cjs.js");require("../../api/queries/activities/getCategories.cjs.js");require("../../api/queries/addons/getAddons.cjs.js");require("../../api/queries/addons/updateAddons.cjs.js");require("../../api/queries/attributes/getAttributes.cjs.js");require("../../api/queries/attributes/updateAttributes.cjs.js");require("../../api/queries/authentication/getAuthentication.cjs.js");require("../../api/queries/cloud/cloud.cjs.js");require("../../api/queries/config/getConfig.cjs.js");require("../../api/queries/config/updateConfig.cjs.js");require("../../api/queries/entities/getEntity.cjs.js");require("../../api/queries/entities/getEntityPanel.cjs.js");const x=require("../../api/queries/entities/transformDetailsPanelData.cjs.js");require("../../api/queries/entities/updateEntity.cjs.js");require("../../api/queries/entityLists/getLists.cjs.js");require("../../api/queries/entityLists/updateLists.cjs.js");require("../../api/queries/entityLists/getListsAttributes.cjs.js");require("../../api/queries/entityLists/updateListsAttributes.cjs.js");require("../../api/queries/entityLists/listFolders.cjs.js");require("../../api/queries/folders/getFolders.cjs.js");require("../../api/queries/grouping/getGrouping.cjs.js");require("../../api/queries/links/updateLinks.cjs.js");require("../../api/queries/links/getLinks.cjs.js");require("../../api/queries/links/getEntityLinks.cjs.js");require("../../api/queries/overview/getOverview.cjs.js");require("../../api/queries/overview/updateOverview.cjs.js");require("../../api/queries/versions/getVersionsProducts.cjs.js");require("../../api/queries/permissions/getPermissions.cjs.js");require("../../api/queries/products/createProduct.cjs.js");require("../../api/queries/project/getProject.cjs.js");require("../../api/queries/project/updateProject.cjs.js");require("../../api/queries/review/getReview.cjs.js");require("../../api/queries/review/updateReview.cjs.js");require("../../api/queries/share/share.cjs.js");require("../../api/queries/system/getSystem.cjs.js");require("../../api/queries/userDashboard/getUserDashboard.cjs.js");require("../../api/queries/users/getUsers.cjs.js");require("../../api/queries/users/updateUsers.cjs.js");require("../../api/queries/users/guests.cjs.js");require("../../api/queries/versions/updateVersions.cjs.js");require("../../api/queries/views/getViews.cjs.js");require("../../api/queries/views/updateViews.cjs.js");require("../../api/queries/watchers/getWatchers.cjs.js");require("../../api/queries/uris/getUris.cjs.js");const m=require("./LinksManager.styled.cjs.js"),l=require("clsx"),d=({link:e,isSelected:n=!1,onEntityClick:o,onRemove:c,isManager:i=!1})=>{const q=x.detailsPanelEntityTypes.includes(e.entityType)&&!e.isRestricted;return r.jsxRuntimeExports.jsxs(m.LinkItem,{onClick:()=>q&&o?.(e.entityId,e.entityType),"data-tooltip":e.isRestricted?i?"Unknown Link - Entity not found":"Access Restricted - Insufficient Permissions to Entity":e.parents.join("/")+"/"+e.label,className:l({clickable:q,selected:n,restricted:e.isRestricted&&!i,unknown:e.isRestricted&&i}),children:[e.icon?r.jsxRuntimeExports.jsx(s.Icon,{icon:e.icon}):r.jsxRuntimeExports.jsx(s.Icon,{icon:p.getEntityTypeIcon(e.entityType)}),r.jsxRuntimeExports.jsx("span",{className:"title",children:e.isRestricted?r.jsxRuntimeExports.jsx("span",{className:"label",children:i?"Unknown":"Access Restricted"}):r.jsxRuntimeExports.jsxs(r.jsxRuntimeExports.Fragment,{children:[e.parents?.map((t,u)=>r.jsxRuntimeExports.jsxs(a.Fragment,{children:[r.jsxRuntimeExports.jsx("span",{children:t},u+"-path"),r.jsxRuntimeExports.jsx("span",{children:"/"},u+"-separator")]},u)),r.jsxRuntimeExports.jsx("span",{className:"label",children:e.label})]})}),(!e.isRestricted||i)&&r.jsxRuntimeExports.jsx(s.Button,{icon:"link_off",variant:"text",className:"remove",onClick:t=>c(t,e),"data-tooltip":"Remove link"})]},e.linkId)};exports.LinkManagerItem=d;
2
2
  //# sourceMappingURL=LinkManagerItem.cjs.js.map