@procore/saved-views 5.0.0-alpha.4 → 5.0.0-alpha.90

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.
@@ -2011,9 +2011,9 @@ var require_dist = __commonJS({
2011
2011
  }
2012
2012
  });
2013
2013
 
2014
- // node_modules/react-is/cjs/react-is.production.min.js
2014
+ // ../../node_modules/styled-components/node_modules/react-is/cjs/react-is.production.min.js
2015
2015
  var require_react_is_production_min = __commonJS({
2016
- "node_modules/react-is/cjs/react-is.production.min.js"(exports2) {
2016
+ "../../node_modules/styled-components/node_modules/react-is/cjs/react-is.production.min.js"(exports2) {
2017
2017
  "use strict";
2018
2018
  var b2 = 60103;
2019
2019
  var c2 = 60106;
@@ -2149,9 +2149,9 @@ var require_react_is_production_min = __commonJS({
2149
2149
  }
2150
2150
  });
2151
2151
 
2152
- // node_modules/react-is/cjs/react-is.development.js
2152
+ // ../../node_modules/styled-components/node_modules/react-is/cjs/react-is.development.js
2153
2153
  var require_react_is_development = __commonJS({
2154
- "node_modules/react-is/cjs/react-is.development.js"(exports2) {
2154
+ "../../node_modules/styled-components/node_modules/react-is/cjs/react-is.development.js"(exports2) {
2155
2155
  "use strict";
2156
2156
  if (process.env.NODE_ENV !== "production") {
2157
2157
  (function() {
@@ -2341,9 +2341,9 @@ var require_react_is_development = __commonJS({
2341
2341
  }
2342
2342
  });
2343
2343
 
2344
- // node_modules/react-is/index.js
2344
+ // ../../node_modules/styled-components/node_modules/react-is/index.js
2345
2345
  var require_react_is = __commonJS({
2346
- "node_modules/react-is/index.js"(exports2, module2) {
2346
+ "../../node_modules/styled-components/node_modules/react-is/index.js"(exports2, module2) {
2347
2347
  "use strict";
2348
2348
  if (process.env.NODE_ENV === "production") {
2349
2349
  module2.exports = require_react_is_production_min();
@@ -9707,7 +9707,7 @@ function __rest(s2, e2) {
9707
9707
  return t2;
9708
9708
  }
9709
9709
 
9710
- // ../../node_modules/@procore/core-icons/dist/Icon.js
9710
+ // node_modules/@procore/core-icons/dist/Icon.js
9711
9711
  var React = __toESM(require("react"));
9712
9712
  function getSize(size) {
9713
9713
  if (size === "sm") {
@@ -9726,7 +9726,7 @@ function Icon(_a) {
9726
9726
  return React.isValidElement(children) ? React.cloneElement(children, __assign(__assign({ "aria-hidden": true, "data-qa": "ci-".concat(props.name) }, props), { width: getSize(props.size), height: getSize(props.size), focusable: false, style: __assign(__assign({}, props.style), { flex: "0 0 auto" }) })) : null;
9727
9727
  }
9728
9728
 
9729
- // ../../node_modules/@procore/core-icons/dist/icons/Building.js
9729
+ // node_modules/@procore/core-icons/dist/icons/Building.js
9730
9730
  var React2 = __toESM(require("react"));
9731
9731
  var Building = React2.forwardRef(function Building2(props, ref) {
9732
9732
  return React2.createElement(
@@ -9742,7 +9742,7 @@ var Building = React2.forwardRef(function Building2(props, ref) {
9742
9742
  Building.displayName = "Building";
9743
9743
  var Building_default = Building;
9744
9744
 
9745
- // ../../node_modules/@procore/core-icons/dist/icons/ChevronDown.js
9745
+ // node_modules/@procore/core-icons/dist/icons/ChevronDown.js
9746
9746
  var React3 = __toESM(require("react"));
9747
9747
  var ChevronDown = React3.forwardRef(function ChevronDown2(props, ref) {
9748
9748
  return React3.createElement(
@@ -9758,7 +9758,7 @@ var ChevronDown = React3.forwardRef(function ChevronDown2(props, ref) {
9758
9758
  ChevronDown.displayName = "ChevronDown";
9759
9759
  var ChevronDown_default = ChevronDown;
9760
9760
 
9761
- // ../../node_modules/@procore/core-icons/dist/icons/ChevronRight.js
9761
+ // node_modules/@procore/core-icons/dist/icons/ChevronRight.js
9762
9762
  var React4 = __toESM(require("react"));
9763
9763
  var ChevronRight = React4.forwardRef(function ChevronRight2(props, ref) {
9764
9764
  return React4.createElement(
@@ -9774,7 +9774,7 @@ var ChevronRight = React4.forwardRef(function ChevronRight2(props, ref) {
9774
9774
  ChevronRight.displayName = "ChevronRight";
9775
9775
  var ChevronRight_default = ChevronRight;
9776
9776
 
9777
- // ../../node_modules/@procore/core-icons/dist/icons/Excavator.js
9777
+ // node_modules/@procore/core-icons/dist/icons/Excavator.js
9778
9778
  var React5 = __toESM(require("react"));
9779
9779
  var Excavator = React5.forwardRef(function Excavator2(props, ref) {
9780
9780
  return React5.createElement(
@@ -9791,7 +9791,7 @@ var Excavator = React5.forwardRef(function Excavator2(props, ref) {
9791
9791
  Excavator.displayName = "Excavator";
9792
9792
  var Excavator_default = Excavator;
9793
9793
 
9794
- // ../../node_modules/@procore/core-icons/dist/icons/ExpandSidebar.js
9794
+ // node_modules/@procore/core-icons/dist/icons/ExpandSidebar.js
9795
9795
  var React6 = __toESM(require("react"));
9796
9796
  var ExpandSidebar = React6.forwardRef(function ExpandSidebar2(props, ref) {
9797
9797
  return React6.createElement(
@@ -9809,7 +9809,7 @@ var ExpandSidebar = React6.forwardRef(function ExpandSidebar2(props, ref) {
9809
9809
  ExpandSidebar.displayName = "ExpandSidebar";
9810
9810
  var ExpandSidebar_default = ExpandSidebar;
9811
9811
 
9812
- // ../../node_modules/@procore/core-icons/dist/icons/Help.js
9812
+ // node_modules/@procore/core-icons/dist/icons/Help.js
9813
9813
  var React7 = __toESM(require("react"));
9814
9814
  var Help = React7.forwardRef(function Help2(props, ref) {
9815
9815
  return React7.createElement(
@@ -9825,7 +9825,7 @@ var Help = React7.forwardRef(function Help2(props, ref) {
9825
9825
  Help.displayName = "Help";
9826
9826
  var Help_default = Help;
9827
9827
 
9828
- // ../../node_modules/@procore/core-icons/dist/icons/Person.js
9828
+ // node_modules/@procore/core-icons/dist/icons/Person.js
9829
9829
  var React8 = __toESM(require("react"));
9830
9830
  var Person = React8.forwardRef(function Person2(props, ref) {
9831
9831
  return React8.createElement(
@@ -9841,7 +9841,7 @@ var Person = React8.forwardRef(function Person2(props, ref) {
9841
9841
  Person.displayName = "Person";
9842
9842
  var Person_default = Person;
9843
9843
 
9844
- // ../../node_modules/@procore/core-icons/dist/icons/Plus.js
9844
+ // node_modules/@procore/core-icons/dist/icons/Plus.js
9845
9845
  var React9 = __toESM(require("react"));
9846
9846
  var Plus = React9.forwardRef(function Plus2(props, ref) {
9847
9847
  return React9.createElement(
@@ -9861,7 +9861,7 @@ var Plus_default = Plus;
9861
9861
  var import_core_react2 = require("@procore/core-react");
9862
9862
  var import_react3 = __toESM(require("react"));
9863
9863
 
9864
- // node_modules/styled-components/dist/styled-components.esm.js
9864
+ // ../../node_modules/styled-components/dist/styled-components.esm.js
9865
9865
  var import_react_is = __toESM(require_react_is());
9866
9866
  var import_react = __toESM(require("react"));
9867
9867
  var import_shallowequal = __toESM(require_shallowequal());
@@ -10416,7 +10416,7 @@ function memoize(fn) {
10416
10416
  };
10417
10417
  }
10418
10418
 
10419
- // ../../node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.esm.js
10419
+ // ../../node_modules/styled-components/node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.esm.js
10420
10420
  var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/;
10421
10421
  var isPropValid = /* @__PURE__ */ memoize(
10422
10422
  function(prop) {
@@ -10425,7 +10425,7 @@ var isPropValid = /* @__PURE__ */ memoize(
10425
10425
  /* Z+1 */
10426
10426
  );
10427
10427
 
10428
- // node_modules/styled-components/dist/styled-components.esm.js
10428
+ // ../../node_modules/styled-components/dist/styled-components.esm.js
10429
10429
  var import_hoist_non_react_statics = __toESM(require_hoist_non_react_statics_cjs());
10430
10430
  function m() {
10431
10431
  return (m = Object.assign || function(e2) {
@@ -11261,13 +11261,164 @@ var ExpandedPanel = styled_components_esm_default(import_core_react4.Panel)`
11261
11261
  `;
11262
11262
 
11263
11263
  // src/SavedViews/components/Panels/PanelContent.tsx
11264
- var import_core_react6 = require("@procore/core-react");
11264
+ var import_core_react7 = require("@procore/core-react");
11265
11265
  var import_toast_alert = require("@procore/toast-alert");
11266
11266
  var import_react9 = __toESM(require("react"));
11267
11267
 
11268
+ // node_modules/@procore/core-http/dist/modern/index.js
11269
+ function getCSRFToken() {
11270
+ const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
11271
+ return token ? decodeURIComponent(token.pop() || "") : "";
11272
+ }
11273
+ function getCSRFHeader() {
11274
+ const csrfToken = getCSRFToken();
11275
+ return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
11276
+ }
11277
+ function removeLeadingSlash(url) {
11278
+ return url.startsWith("/") ? url.substring(1, url.length) : url;
11279
+ }
11280
+ function removeTrailingSlash(url) {
11281
+ return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
11282
+ }
11283
+ function applyBaseUrl(url, baseUrl) {
11284
+ return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
11285
+ }
11286
+ function getOptions({ headers, ...options }) {
11287
+ const opts = {
11288
+ credentials: "same-origin",
11289
+ headers: {
11290
+ ...getCSRFHeader(),
11291
+ ...headers
11292
+ },
11293
+ mode: "same-origin",
11294
+ ...options
11295
+ };
11296
+ return opts;
11297
+ }
11298
+ function getUrl(url, baseUrl) {
11299
+ return baseUrl ? applyBaseUrl(url, baseUrl) : url;
11300
+ }
11301
+ function request(url, { baseUrl, ...options } = {}) {
11302
+ return fetch(getUrl(url, baseUrl), getOptions(options));
11303
+ }
11304
+ function requestJSON(url, requestParams = {}) {
11305
+ return request(url, requestParams).then(
11306
+ (response) => response.json()
11307
+ );
11308
+ }
11309
+
11310
+ // src/utils/Api/queries.ts
11311
+ var import_react_query2 = require("@tanstack/react-query");
11312
+
11313
+ // src/utils/Api/queriesHandler.ts
11314
+ var import_react_query = require("@tanstack/react-query");
11315
+ var import_core_react5 = require("@procore/core-react");
11316
+ var useApiRequest = (props, method, mutationKey) => {
11317
+ const { projectId, companyId, domain, tableName } = props;
11318
+ const queryClient2 = (0, import_react_query.useQueryClient)();
11319
+ const { locale: locale2 } = (0, import_core_react5.useI18nContext)();
11320
+ return (0, import_react_query.useMutation)({
11321
+ mutationKey,
11322
+ mutationFn: async (savedView) => {
11323
+ let url = "";
11324
+ if (method === "DELETE" || method === "PUT") {
11325
+ url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.id}?permissions_domain=${domain}`;
11326
+ } else {
11327
+ url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
11328
+ }
11329
+ const response = await requestJSON(url, {
11330
+ method,
11331
+ body: JSON.stringify(savedView),
11332
+ headers: {
11333
+ "Content-Type": "application/json",
11334
+ "Accept-Language": locale2
11335
+ }
11336
+ });
11337
+ if (response.error) {
11338
+ throw response.error;
11339
+ }
11340
+ return response.data;
11341
+ },
11342
+ onSuccess: (savedView) => {
11343
+ if (method === "DELETE" || method === "POST") {
11344
+ queryClient2.invalidateQueries({
11345
+ queryKey: ["savedViews", domain, tableName]
11346
+ });
11347
+ return;
11348
+ } else {
11349
+ const oldData = queryClient2.getQueryData([
11350
+ "savedViews",
11351
+ domain,
11352
+ tableName
11353
+ ]);
11354
+ const oldView = oldData == null ? void 0 : oldData.find((item) => item.id === savedView.id);
11355
+ if ((oldView == null ? void 0 : oldView.name) !== savedView.name) {
11356
+ queryClient2.invalidateQueries({
11357
+ queryKey: ["savedViews", domain, tableName]
11358
+ });
11359
+ return;
11360
+ }
11361
+ }
11362
+ queryClient2.setQueryData(
11363
+ ["savedViews", domain, tableName],
11364
+ (oldData) => {
11365
+ if (!oldData)
11366
+ return [savedView];
11367
+ return oldData.map(
11368
+ (item) => item.id === savedView.id ? savedView : item
11369
+ );
11370
+ }
11371
+ );
11372
+ }
11373
+ });
11374
+ };
11375
+
11268
11376
  // src/utils/Constants/viewLevels.ts
11269
11377
  var VIEW_LEVELS = ["company", "project", "personal"];
11270
11378
 
11379
+ // src/utils/Api/queries.ts
11380
+ var PAGE_SIZE = 50 * VIEW_LEVELS.length;
11381
+ var useSavedViewsQuery = (props) => {
11382
+ const { projectId, companyId, domain, tableName } = props;
11383
+ const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
11384
+ return (0, import_react_query2.useQuery)({
11385
+ enabled: props.enableSavedViews,
11386
+ queryKey: ["savedViews", domain, tableName],
11387
+ queryFn: async () => {
11388
+ const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
11389
+ const response = await requestJSON(getUrl2);
11390
+ return response.data;
11391
+ }
11392
+ });
11393
+ };
11394
+ var useSavedViewsPermissions = (props) => {
11395
+ const { projectId, companyId, domain } = props;
11396
+ const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
11397
+ return (0, import_react_query2.useQuery)({
11398
+ enabled: props.enableSavedViews,
11399
+ queryKey: ["savedViewsConfig", domain],
11400
+ queryFn: async () => {
11401
+ const response = await requestJSON(url);
11402
+ return response.data;
11403
+ }
11404
+ });
11405
+ };
11406
+ var useCreateSavedView = (props) => useApiRequest(props, "POST", [
11407
+ "createSavedView",
11408
+ props.domain,
11409
+ props.tableName
11410
+ ]);
11411
+ var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
11412
+ "updateSavedView",
11413
+ props.domain,
11414
+ props.tableName
11415
+ ]);
11416
+ var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
11417
+ "deleteSavedView",
11418
+ props.domain,
11419
+ props.tableName
11420
+ ]);
11421
+
11271
11422
  // src/SavedViews/components/Panels/PanelContentUtils.ts
11272
11423
  var import_lodash = __toESM(require_lodash());
11273
11424
 
@@ -11275,14 +11426,14 @@ var import_lodash = __toESM(require_lodash());
11275
11426
  function getSmartGridConfig(api) {
11276
11427
  const columnStateResult = api.getColumnState();
11277
11428
  const columnGroupStateResult = api.getColumnGroupState();
11278
- const rowGroupStateResult = api.getRowGroupColumns();
11429
+ const rowGroupStateResult = api.getRowGroupColumns().map((col) => col.getColId());
11279
11430
  const rowHeightResult = api.getGridOption("rowHeight") || api.getSizesForCurrentTheme().rowHeight;
11280
11431
  const serverFiltersResult = api.getFilterModel();
11281
11432
  const smartGridConfig = {
11282
11433
  columnState: columnStateResult,
11283
11434
  rowHeight: rowHeightResult,
11284
11435
  columnGroupState: columnGroupStateResult,
11285
- rowGroupState: rowGroupStateResult.filter((col) => typeof (col == null ? void 0 : col.getColId) === "function").map((col) => col.getColId()),
11436
+ rowGroupState: rowGroupStateResult,
11286
11437
  filterState: serverFiltersResult
11287
11438
  };
11288
11439
  return smartGridConfig;
@@ -11470,7 +11621,7 @@ var useGroups = () => {
11470
11621
  };
11471
11622
 
11472
11623
  // src/SavedViews/components/Panels/ViewLevelHeader.tsx
11473
- var import_core_react5 = require("@procore/core-react");
11624
+ var import_core_react6 = require("@procore/core-react");
11474
11625
  var import_react7 = __toESM(require("react"));
11475
11626
  var groupIcon = (group) => {
11476
11627
  switch (group) {
@@ -11482,26 +11633,26 @@ var groupIcon = (group) => {
11482
11633
  return /* @__PURE__ */ import_react7.default.createElement(Building_default, null);
11483
11634
  }
11484
11635
  };
11485
- var Header = styled_components_esm_default(import_core_react5.Flex)`
11636
+ var Header = styled_components_esm_default(import_core_react6.Flex)`
11486
11637
  width: 100%;
11487
11638
  &:hover {
11488
- background-color: ${import_core_react5.colors.gray98};
11639
+ background-color: ${import_core_react6.colors.gray98};
11489
11640
  }
11490
11641
  `;
11491
11642
  var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
11492
- const I18n = (0, import_core_react5.useI18nContext)();
11643
+ const I18n = (0, import_core_react6.useI18nContext)();
11493
11644
  return /* @__PURE__ */ import_react7.default.createElement(
11494
11645
  Header,
11495
11646
  {
11496
11647
  alignItems: "center",
11497
- padding: `${import_core_react5.spacing.sm}px`,
11498
- gap: `${import_core_react5.spacing.sm}px`,
11648
+ padding: `${import_core_react6.spacing.sm}px`,
11649
+ gap: `${import_core_react6.spacing.sm}px`,
11499
11650
  style: { cursor: "pointer" },
11500
11651
  onClick: () => toggleGroup(group)
11501
11652
  },
11502
11653
  expanded ? /* @__PURE__ */ import_react7.default.createElement(ChevronDown_default, { size: "sm" }) : /* @__PURE__ */ import_react7.default.createElement(ChevronRight_default, { size: "sm" }),
11503
11654
  groupIcon(group),
11504
- /* @__PURE__ */ import_react7.default.createElement(import_core_react5.Typography, { weight: "semibold" }, I18n.t(`savedViews.viewLevel.${group}`))
11655
+ /* @__PURE__ */ import_react7.default.createElement(import_core_react6.Typography, { weight: "semibold" }, I18n.t(`savedViews.viewLevel.${group}`))
11505
11656
  );
11506
11657
  };
11507
11658
  var ViewLevelHeader_default = ViewLevelHeader;
@@ -11519,29 +11670,28 @@ var useScrollToRef = (dependency) => {
11519
11670
  };
11520
11671
 
11521
11672
  // src/SavedViews/components/Panels/PanelContent.tsx
11522
- var Row = styled_components_esm_default(import_core_react6.UNSAFE_Menu.Item)`
11673
+ var Row = styled_components_esm_default(import_core_react7.UNSAFE_Menu.Item)`
11523
11674
  width: 100%;
11524
11675
  padding-left: 35px;
11525
11676
  padding-right: 4px;
11526
- background-color: ${({ selected }) => selected ? import_core_react6.colors.blue96 : "transparent"};
11677
+ background-color: ${({ selected }) => selected ? import_core_react7.colors.blue96 : "transparent"};
11527
11678
 
11528
11679
  &:hover {
11529
- background-color: ${({ selected }) => selected ? import_core_react6.colors.blue96 : import_core_react6.colors.gray98};
11680
+ background-color: ${({ selected }) => selected ? import_core_react7.colors.blue96 : import_core_react7.colors.gray98};
11530
11681
  }
11531
11682
  `;
11532
- var Panel2 = styled_components_esm_default(import_core_react6.DetailPage.Card)`
11683
+ var Panel2 = styled_components_esm_default(import_core_react7.DetailPage.Card)`
11533
11684
  margin: 0;
11534
11685
  height: 100%;
11535
- padding-top: ${import_core_react6.spacing.sm}px;
11686
+ padding-top: ${import_core_react7.spacing.sm}px;
11536
11687
  box-shadow: none;
11537
11688
  `;
11538
11689
  var PanelContent = (props) => {
11539
11690
  var _a;
11540
11691
  const { showToast } = (0, import_toast_alert.useToastAlertContext)();
11541
- const I18n = (0, import_core_react6.useI18nContext)();
11542
- const { useSavedViewsQuery: useSavedViewsQuery2, useSavedViewsPermissions: useSavedViewsPermissions2, useUpdateSavedView: useUpdateSavedView2 } = props.backend;
11543
- const { mutate: updateSavedView, isPending: isUpdateLoading } = useUpdateSavedView2(props.queryInput);
11544
- const { data: savedViews, error: savedViewsError } = useSavedViewsQuery2(
11692
+ const I18n = (0, import_core_react7.useI18nContext)();
11693
+ const { mutate: updateSavedView, isPending: isUpdateLoading } = useUpdateSavedView(props.queryInput);
11694
+ const { data: savedViews, error: savedViewsError } = useSavedViewsQuery(
11545
11695
  props.queryInput
11546
11696
  );
11547
11697
  const errorToastRef = import_react9.default.useRef(null);
@@ -11551,7 +11701,7 @@ var PanelContent = (props) => {
11551
11701
  errorToastRef.current = savedViewsError;
11552
11702
  }
11553
11703
  }, [savedViewsError]);
11554
- const { data: permissions } = useSavedViewsPermissions2(props.queryInput);
11704
+ const { data: permissions } = useSavedViewsPermissions(props.queryInput);
11555
11705
  const selectedRowRef = useScrollToRef(savedViews);
11556
11706
  const onUpdate = (data) => {
11557
11707
  const newSavedView = {
@@ -11572,7 +11722,7 @@ var PanelContent = (props) => {
11572
11722
  };
11573
11723
  const { groups, toggleGroup } = useGroups();
11574
11724
  const isDefaultSelected = ((_a = props.selectedSavedView) == null ? void 0 : _a.id) === "default";
11575
- return /* @__PURE__ */ import_react9.default.createElement(Panel2, { "data-testid": "inner-panel" }, /* @__PURE__ */ import_react9.default.createElement(import_core_react6.Flex, { direction: "column", style: { height: "100%", width: "100%" } }, /* @__PURE__ */ import_react9.default.createElement(
11725
+ return /* @__PURE__ */ import_react9.default.createElement(Panel2, { "data-testid": "inner-panel" }, /* @__PURE__ */ import_react9.default.createElement(import_core_react7.Flex, { direction: "column", style: { height: "100%", width: "100%" } }, /* @__PURE__ */ import_react9.default.createElement(
11576
11726
  Row,
11577
11727
  {
11578
11728
  selected: isDefaultSelected,
@@ -11641,9 +11791,9 @@ var PanelContent = (props) => {
11641
11791
  var import_react14 = __toESM(require("react"));
11642
11792
 
11643
11793
  // src/SavedViews/components/SavedViews/SmartGrid/SmartGridDefaultSavedView.tsx
11644
- var import_core_react7 = require("@procore/core-react");
11794
+ var import_core_react8 = require("@procore/core-react");
11645
11795
  var useDefaultViewName = (domain, defaultViewName) => {
11646
- const i18n = (0, import_core_react7.useI18nContext)();
11796
+ const i18n = (0, import_core_react8.useI18nContext)();
11647
11797
  return defaultViewName || i18n.t(domain, {
11648
11798
  scope: "savedViews.defaultViewTitle",
11649
11799
  defaultValue: "Default View"
@@ -11703,16 +11853,16 @@ var import_react13 = __toESM(require("react"));
11703
11853
  var import_react_query3 = require("@tanstack/react-query");
11704
11854
 
11705
11855
  // src/SavedViews/components/SavedViewsModals/SavedViewsDeleteConfirmationModalShared.tsx
11706
- var import_core_react8 = require("@procore/core-react");
11856
+ var import_core_react9 = require("@procore/core-react");
11707
11857
  var import_react11 = __toESM(require("react"));
11708
11858
  var SavedViewsDeleteConfirmationModalShared = ({
11709
11859
  onCancel,
11710
11860
  onDelete,
11711
11861
  open
11712
11862
  }) => {
11713
- const i18n = (0, import_core_react8.useI18nContext)();
11863
+ const i18n = (0, import_core_react9.useI18nContext)();
11714
11864
  return /* @__PURE__ */ import_react11.default.createElement(
11715
- import_core_react8.ConfirmModal,
11865
+ import_core_react9.ConfirmModal,
11716
11866
  {
11717
11867
  "data-testid": "delete-confirmation-modal",
11718
11868
  open,
@@ -11721,8 +11871,8 @@ var SavedViewsDeleteConfirmationModalShared = ({
11721
11871
  onClose: onCancel,
11722
11872
  style: { overflowWrap: "anywhere" }
11723
11873
  },
11724
- /* @__PURE__ */ import_react11.default.createElement(import_core_react8.Modal.Body, null, /* @__PURE__ */ import_react11.default.createElement(import_core_react8.P, null, i18n.t("savedViews.modal.delete.description"))),
11725
- /* @__PURE__ */ import_react11.default.createElement(import_core_react8.Modal.Footer, null, /* @__PURE__ */ import_react11.default.createElement(import_core_react8.Modal.FooterButtons, null, /* @__PURE__ */ import_react11.default.createElement(import_core_react8.Button, { variant: "secondary", onClick: onCancel }, i18n.t("savedViews.actions.cancel")), /* @__PURE__ */ import_react11.default.createElement(import_core_react8.Button, { variant: "primary", onClick: onDelete }, i18n.t("savedViews.actions.delete"))))
11874
+ /* @__PURE__ */ import_react11.default.createElement(import_core_react9.Modal.Body, null, /* @__PURE__ */ import_react11.default.createElement(import_core_react9.P, null, i18n.t("savedViews.modal.delete.description"))),
11875
+ /* @__PURE__ */ import_react11.default.createElement(import_core_react9.Modal.Footer, null, /* @__PURE__ */ import_react11.default.createElement(import_core_react9.Modal.FooterButtons, null, /* @__PURE__ */ import_react11.default.createElement(import_core_react9.Button, { variant: "secondary", onClick: onCancel }, i18n.t("savedViews.actions.cancel")), /* @__PURE__ */ import_react11.default.createElement(import_core_react9.Button, { variant: "primary", onClick: onDelete }, i18n.t("savedViews.actions.delete"))))
11726
11876
  );
11727
11877
  };
11728
11878
 
@@ -11730,7 +11880,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
11730
11880
  var import_react12 = __toESM(require("react"));
11731
11881
 
11732
11882
  // src/SavedViews/components/SavedViewsModals/SavedViewsCreateUpdateModalBase.tsx
11733
- var import_core_react9 = require("@procore/core-react");
11883
+ var import_core_react10 = require("@procore/core-react");
11734
11884
  var React17 = __toESM(require("react"));
11735
11885
 
11736
11886
  // ../../node_modules/yup/index.esm.js
@@ -14059,7 +14209,6 @@ function extractMessage(error, I18n) {
14059
14209
  }
14060
14210
 
14061
14211
  // src/SavedViews/components/SavedViewsModals/SavedViewsCreateUpdateModalBase.tsx
14062
- var { useEffect: useEffect3, useRef: useRef2 } = React17;
14063
14212
  var ScrollContainer = styled_components_esm_default("div")`
14064
14213
  overflow: auto;
14065
14214
  `;
@@ -14077,38 +14226,22 @@ var SavedViewsCreateUpdateModalBase = ({
14077
14226
  selectedSavedView,
14078
14227
  setSelectedSavedView,
14079
14228
  setOpenEditCreateModal,
14080
- onSelect,
14081
- backend
14229
+ onSelect
14082
14230
  }) => {
14083
- const I18n = (0, import_core_react9.useI18nContext)();
14231
+ const I18n = (0, import_core_react10.useI18nContext)();
14084
14232
  const NAME_MAX_LENGTH = 150;
14085
- const originalBodyWidth = useRef2("");
14086
- useEffect3(() => {
14087
- if (open) {
14088
- originalBodyWidth.current = document.body.style.width || "";
14089
- document.body.style.width = "100%";
14090
- } else {
14091
- document.body.style.width = originalBodyWidth.current;
14092
- }
14093
- return () => {
14094
- if (originalBodyWidth.current !== void 0) {
14095
- document.body.style.width = originalBodyWidth.current;
14096
- }
14097
- };
14098
- }, [open]);
14099
- const { useCreateSavedView: useCreateSavedView2, useUpdateSavedView: useUpdateSavedView2, useSavedViewsPermissions: useSavedViewsPermissions2 } = backend;
14100
14233
  const {
14101
14234
  mutate: createSavedView,
14102
14235
  isPending: isCreating,
14103
14236
  error: createError,
14104
14237
  reset: resetCreateMutation
14105
- } = useCreateSavedView2(queryInput);
14238
+ } = useCreateSavedView(queryInput);
14106
14239
  const {
14107
14240
  mutate: updateSavedView,
14108
14241
  isPending: isUpdating,
14109
14242
  error: updateError,
14110
14243
  reset: resetUpdateMutation
14111
- } = useUpdateSavedView2(queryInput);
14244
+ } = useUpdateSavedView(queryInput);
14112
14245
  const resetMutations = () => {
14113
14246
  resetCreateMutation();
14114
14247
  resetUpdateMutation();
@@ -14117,7 +14250,7 @@ var SavedViewsCreateUpdateModalBase = ({
14117
14250
  resetMutations();
14118
14251
  onCancel();
14119
14252
  };
14120
- const { data: permissions } = useSavedViewsPermissions2(queryInput);
14253
+ const { data: permissions } = useSavedViewsPermissions(queryInput);
14121
14254
  const isLoading = isCreating || isUpdating;
14122
14255
  const errors = extractMessage(createError || updateError, I18n);
14123
14256
  const handleOnSubmit = (data) => {
@@ -14150,7 +14283,7 @@ var SavedViewsCreateUpdateModalBase = ({
14150
14283
  };
14151
14284
  const viewLevelOptions = getViewLevelOptions(permissions, I18n);
14152
14285
  return /* @__PURE__ */ React17.createElement(
14153
- import_core_react9.Modal,
14286
+ import_core_react10.Modal,
14154
14287
  {
14155
14288
  "aria-label": I18n.t("savedViews.ariaLabels.modal"),
14156
14289
  onClickOverlay: onClose,
@@ -14159,14 +14292,14 @@ var SavedViewsCreateUpdateModalBase = ({
14159
14292
  "data-testid": "create-update-modal"
14160
14293
  },
14161
14294
  /* @__PURE__ */ React17.createElement(ScrollContainer, null, /* @__PURE__ */ React17.createElement(
14162
- import_core_react9.Modal.Header,
14295
+ import_core_react10.Modal.Header,
14163
14296
  {
14164
14297
  onClose,
14165
- style: { borderBottom: `1px solid ${import_core_react9.colors.gray85}` }
14298
+ style: { borderBottom: `1px solid ${import_core_react10.colors.gray85}` }
14166
14299
  },
14167
- /* @__PURE__ */ React17.createElement(import_core_react9.H2, null, header)
14300
+ /* @__PURE__ */ React17.createElement(import_core_react10.H2, null, header)
14168
14301
  ), /* @__PURE__ */ React17.createElement(
14169
- import_core_react9.Form,
14302
+ import_core_react10.Form,
14170
14303
  {
14171
14304
  initialValues: {
14172
14305
  name: initialName,
@@ -14191,14 +14324,14 @@ var SavedViewsCreateUpdateModalBase = ({
14191
14324
  onReset: onCancel,
14192
14325
  validateOnChange: true
14193
14326
  },
14194
- /* @__PURE__ */ React17.createElement(import_core_react9.Form.Form, { name: header }, /* @__PURE__ */ React17.createElement(
14195
- import_core_react9.Modal.Body,
14327
+ /* @__PURE__ */ React17.createElement(import_core_react10.Form.Form, { name: header }, /* @__PURE__ */ React17.createElement(
14328
+ import_core_react10.Modal.Body,
14196
14329
  {
14197
- style: { paddingTop: 0, paddingBottom: 0, marginTop: import_core_react9.spacing.lg }
14330
+ style: { paddingTop: 0, paddingBottom: 0, marginTop: import_core_react10.spacing.lg }
14198
14331
  },
14199
- errors && /* @__PURE__ */ React17.createElement(import_core_react9.ErrorBanner, { style: { marginBottom: import_core_react9.spacing.xl } }, /* @__PURE__ */ React17.createElement(import_core_react9.Banner.Content, null, /* @__PURE__ */ React17.createElement(import_core_react9.Banner.Title, null, I18n.t("savedViews.modal.errors.title", { mode })), /* @__PURE__ */ React17.createElement(import_core_react9.Banner.Body, null, (errors == null ? void 0 : errors.form) || I18n.t(`savedViews.modal.errors.description.${mode}`)))),
14200
- /* @__PURE__ */ React17.createElement(import_core_react9.Form.Row, null, /* @__PURE__ */ React17.createElement(
14201
- import_core_react9.Form.Text,
14332
+ errors && /* @__PURE__ */ React17.createElement(import_core_react10.ErrorBanner, { style: { marginBottom: import_core_react10.spacing.xl } }, /* @__PURE__ */ React17.createElement(import_core_react10.Banner.Content, null, /* @__PURE__ */ React17.createElement(import_core_react10.Banner.Title, null, I18n.t("savedViews.modal.errors.title", { mode })), /* @__PURE__ */ React17.createElement(import_core_react10.Banner.Body, null, (errors == null ? void 0 : errors.form) || I18n.t(`savedViews.modal.errors.description.${mode}`)))),
14333
+ /* @__PURE__ */ React17.createElement(import_core_react10.Form.Row, null, /* @__PURE__ */ React17.createElement(
14334
+ import_core_react10.Form.Text,
14202
14335
  {
14203
14336
  name: "name",
14204
14337
  error: errors == null ? void 0 : errors.name,
@@ -14209,12 +14342,12 @@ var SavedViewsCreateUpdateModalBase = ({
14209
14342
  }
14210
14343
  )),
14211
14344
  /* @__PURE__ */ React17.createElement(
14212
- import_core_react9.Form.Row,
14345
+ import_core_react10.Form.Row,
14213
14346
  {
14214
- style: { marginTop: (errors == null ? void 0 : errors.name) ? import_core_react9.spacing.xl : import_core_react9.spacing.none }
14347
+ style: { marginTop: (errors == null ? void 0 : errors.name) ? import_core_react10.spacing.xl : import_core_react10.spacing.none }
14215
14348
  },
14216
14349
  /* @__PURE__ */ React17.createElement(
14217
- import_core_react9.Form.TextArea,
14350
+ import_core_react10.Form.TextArea,
14218
14351
  {
14219
14352
  name: "description",
14220
14353
  placeholder: I18n.t("savedViews.modal.fields.description"),
@@ -14224,11 +14357,10 @@ var SavedViewsCreateUpdateModalBase = ({
14224
14357
  }
14225
14358
  )
14226
14359
  ),
14227
- viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React17.createElement(import_core_react9.Form.Row, null, /* @__PURE__ */ React17.createElement(
14228
- import_core_react9.Form.Select,
14360
+ viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React17.createElement(import_core_react10.Form.Row, null, /* @__PURE__ */ React17.createElement(
14361
+ import_core_react10.Form.Select,
14229
14362
  {
14230
14363
  name: "view_level",
14231
- qa: { label: "view-level" },
14232
14364
  options: viewLevelOptions,
14233
14365
  label: I18n.t("savedViews.modal.fields.viewLevel"),
14234
14366
  colWidth: 12,
@@ -14236,8 +14368,8 @@ var SavedViewsCreateUpdateModalBase = ({
14236
14368
  onClear: false
14237
14369
  }
14238
14370
  )) : /* @__PURE__ */ React17.createElement(React17.Fragment, null)
14239
- ), /* @__PURE__ */ React17.createElement(import_core_react9.Modal.Footer, { style: { borderTop: `1px solid ${import_core_react9.colors.gray85}` } }, /* @__PURE__ */ React17.createElement(import_core_react9.Flex, { grow: "1", justifyContent: "space-between", alignItems: "center" }, /* @__PURE__ */ React17.createElement(import_core_react9.Typography, { color: "gray45", italic: true }, /* @__PURE__ */ React17.createElement(import_core_react9.Typography, { color: "red45" }, "*"), " ", I18n.t("savedViews.modal.info.required_fields")), /* @__PURE__ */ React17.createElement(import_core_react9.Modal.FooterButtons, null, /* @__PURE__ */ React17.createElement(import_core_react9.Button, { type: "reset", variant: "tertiary", disabled: isLoading }, I18n.t("savedViews.actions.cancel")), /* @__PURE__ */ React17.createElement(
14240
- import_core_react9.Button,
14371
+ ), /* @__PURE__ */ React17.createElement(import_core_react10.Modal.Footer, { style: { borderTop: `1px solid ${import_core_react10.colors.gray85}` } }, /* @__PURE__ */ React17.createElement(import_core_react10.Flex, { grow: "1", justifyContent: "space-between", alignItems: "center" }, /* @__PURE__ */ React17.createElement(import_core_react10.Typography, { color: "gray45", italic: true }, /* @__PURE__ */ React17.createElement(import_core_react10.Typography, { color: "red45" }, "*"), " ", I18n.t("savedViews.modal.info.required_fields")), /* @__PURE__ */ React17.createElement(import_core_react10.Modal.FooterButtons, null, /* @__PURE__ */ React17.createElement(import_core_react10.Button, { type: "reset", variant: "tertiary", disabled: isLoading }, I18n.t("savedViews.actions.cancel")), /* @__PURE__ */ React17.createElement(
14372
+ import_core_react10.Button,
14241
14373
  {
14242
14374
  "data-testid": "create-update-modal-button",
14243
14375
  type: "submit",
@@ -14252,7 +14384,7 @@ var SavedViewsCreateUpdateModalBase = ({
14252
14384
  };
14253
14385
 
14254
14386
  // src/SavedViews/components/SavedViewsModals/SavedViewsFormModal.tsx
14255
- var import_core_react10 = require("@procore/core-react");
14387
+ var import_core_react11 = require("@procore/core-react");
14256
14388
  var SavedViewsFormModal = ({
14257
14389
  open,
14258
14390
  mode,
@@ -14264,10 +14396,9 @@ var SavedViewsFormModal = ({
14264
14396
  setSelectedSavedView,
14265
14397
  setOpenEditCreateModal,
14266
14398
  onSelect,
14267
- defaultView,
14268
- backend
14399
+ defaultView
14269
14400
  }) => {
14270
- const i18n = (0, import_core_react10.useI18nContext)();
14401
+ const i18n = (0, import_core_react11.useI18nContext)();
14271
14402
  return /* @__PURE__ */ import_react12.default.createElement(
14272
14403
  SavedViewsCreateUpdateModalBase,
14273
14404
  {
@@ -14284,170 +14415,11 @@ var SavedViewsFormModal = ({
14284
14415
  setSelectedSavedView,
14285
14416
  setOpenEditCreateModal,
14286
14417
  onSelect,
14287
- defaultView,
14288
- backend
14418
+ defaultView
14289
14419
  }
14290
14420
  );
14291
14421
  };
14292
14422
 
14293
- // ../../node_modules/@procore/core-http/dist/modern/index.js
14294
- function getCSRFToken() {
14295
- const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
14296
- return token ? decodeURIComponent(token.pop() || "") : "";
14297
- }
14298
- function getCSRFHeader() {
14299
- const csrfToken = getCSRFToken();
14300
- return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
14301
- }
14302
- function removeLeadingSlash(url) {
14303
- return url.startsWith("/") ? url.substring(1, url.length) : url;
14304
- }
14305
- function removeTrailingSlash(url) {
14306
- return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
14307
- }
14308
- function applyBaseUrl(url, baseUrl) {
14309
- return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
14310
- }
14311
- function getOptions({ headers, ...options }) {
14312
- const opts = {
14313
- credentials: "same-origin",
14314
- headers: {
14315
- ...getCSRFHeader(),
14316
- ...headers
14317
- },
14318
- mode: "same-origin",
14319
- ...options
14320
- };
14321
- return opts;
14322
- }
14323
- function getUrl(url, baseUrl) {
14324
- return baseUrl ? applyBaseUrl(url, baseUrl) : url;
14325
- }
14326
- function request(url, { baseUrl, ...options } = {}) {
14327
- return fetch(getUrl(url, baseUrl), getOptions(options));
14328
- }
14329
- function requestJSON(url, requestParams = {}) {
14330
- return request(url, requestParams).then(
14331
- (response) => response.json()
14332
- );
14333
- }
14334
-
14335
- // src/utils/Api/queries.ts
14336
- var import_react_query2 = require("@tanstack/react-query");
14337
-
14338
- // src/utils/Api/queriesHandler.ts
14339
- var import_react_query = require("@tanstack/react-query");
14340
- var import_core_react11 = require("@procore/core-react");
14341
- var useApiRequest = (props, method, mutationKey) => {
14342
- const { projectId, companyId, domain, tableName } = props;
14343
- const queryClient2 = (0, import_react_query.useQueryClient)();
14344
- const { locale: locale2 } = (0, import_core_react11.useI18nContext)();
14345
- return (0, import_react_query.useMutation)({
14346
- mutationKey,
14347
- mutationFn: async (savedView) => {
14348
- let url = "";
14349
- if (method === "DELETE" || method === "PUT") {
14350
- url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.id}?permissions_domain=${domain}`;
14351
- } else {
14352
- url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
14353
- }
14354
- const response = await requestJSON(url, {
14355
- method,
14356
- body: JSON.stringify(savedView),
14357
- headers: {
14358
- "Content-Type": "application/json",
14359
- "Accept-Language": locale2
14360
- }
14361
- });
14362
- if (response.error) {
14363
- throw response.error;
14364
- }
14365
- return response.data;
14366
- },
14367
- onSuccess: (savedView) => {
14368
- if (method === "DELETE" || method === "POST") {
14369
- queryClient2.invalidateQueries({
14370
- queryKey: ["savedViews", domain, tableName]
14371
- });
14372
- return;
14373
- } else {
14374
- const oldData = queryClient2.getQueryData([
14375
- "savedViews",
14376
- domain,
14377
- tableName
14378
- ]);
14379
- const oldView = oldData == null ? void 0 : oldData.find((item) => item.id === savedView.id);
14380
- if ((oldView == null ? void 0 : oldView.name) !== savedView.name) {
14381
- queryClient2.invalidateQueries({
14382
- queryKey: ["savedViews", domain, tableName]
14383
- });
14384
- return;
14385
- }
14386
- }
14387
- queryClient2.setQueryData(
14388
- ["savedViews", domain, tableName],
14389
- (oldData) => {
14390
- if (!oldData)
14391
- return [savedView];
14392
- return oldData.map(
14393
- (item) => item.id === savedView.id ? savedView : item
14394
- );
14395
- }
14396
- );
14397
- }
14398
- });
14399
- };
14400
-
14401
- // src/utils/Api/queries.ts
14402
- var PAGE_SIZE = 50 * VIEW_LEVELS.length;
14403
- var useSavedViewsQuery = (props) => {
14404
- const { projectId, companyId, domain, tableName } = props;
14405
- const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
14406
- return (0, import_react_query2.useQuery)({
14407
- enabled: props.enableSavedViews,
14408
- queryKey: ["savedViews", domain, tableName],
14409
- queryFn: async () => {
14410
- const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
14411
- const response = await requestJSON(getUrl2);
14412
- return response.data;
14413
- }
14414
- });
14415
- };
14416
- var useSavedViewsPermissions = (props) => {
14417
- const { projectId, companyId, domain } = props;
14418
- const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
14419
- return (0, import_react_query2.useQuery)({
14420
- enabled: props.enableSavedViews,
14421
- queryKey: ["savedViewsConfig", domain],
14422
- queryFn: async () => {
14423
- const response = await requestJSON(url);
14424
- return response.data;
14425
- }
14426
- });
14427
- };
14428
- var useCreateSavedView = (props) => useApiRequest(props, "POST", [
14429
- "createSavedView",
14430
- props.domain,
14431
- props.tableName
14432
- ]);
14433
- var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
14434
- "updateSavedView",
14435
- props.domain,
14436
- props.tableName
14437
- ]);
14438
- var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
14439
- "deleteSavedView",
14440
- props.domain,
14441
- props.tableName
14442
- ]);
14443
- var createQueries = (customBackend) => ({
14444
- useSavedViewsQuery: (customBackend == null ? void 0 : customBackend.useSavedViewsQuery) ?? useSavedViewsQuery,
14445
- useSavedViewsPermissions: (customBackend == null ? void 0 : customBackend.useSavedViewsPermissions) ?? useSavedViewsPermissions,
14446
- useCreateSavedView: (customBackend == null ? void 0 : customBackend.useCreateSavedView) ?? useCreateSavedView,
14447
- useUpdateSavedView: (customBackend == null ? void 0 : customBackend.useUpdateSavedView) ?? useUpdateSavedView,
14448
- useDeleteSavedView: (customBackend == null ? void 0 : customBackend.useDeleteSavedView) ?? useDeleteSavedView
14449
- });
14450
-
14451
14423
  // src/SavedViews/components/SavedViews/SavedViews.tsx
14452
14424
  var StyledPanel = styled_components_esm_default.div`
14453
14425
  border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
@@ -14462,8 +14434,7 @@ var SavedViewsContent = (props) => {
14462
14434
  projectId,
14463
14435
  companyId
14464
14436
  };
14465
- const backend = createQueries(props.backend);
14466
- const { mutate: deleteSavedView } = backend.useDeleteSavedView(queryInput);
14437
+ const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
14467
14438
  const [selectedSavedView, setSelectedSavedView] = (0, import_react13.useState)(() => {
14468
14439
  try {
14469
14440
  const savedView = JSON.parse(
@@ -14553,8 +14524,7 @@ var SavedViewsContent = (props) => {
14553
14524
  defaultView: props.defaultView,
14554
14525
  stickyViewsKey: props.stickyViewsKey,
14555
14526
  provider: props.provider,
14556
- userId: props.userId,
14557
- backend
14527
+ userId: props.userId
14558
14528
  }
14559
14529
  ))
14560
14530
  ), /* @__PURE__ */ import_react13.default.createElement(
@@ -14570,8 +14540,7 @@ var SavedViewsContent = (props) => {
14570
14540
  setSelectedSavedView,
14571
14541
  onSelect: (view) => handleViewItemSelect({ item: view }),
14572
14542
  setOpenEditCreateModal,
14573
- defaultView: props.defaultView,
14574
- backend
14543
+ defaultView: props.defaultView
14575
14544
  }
14576
14545
  ), selectedSavedView && /* @__PURE__ */ import_react13.default.createElement(
14577
14546
  SavedViewsDeleteConfirmationModalShared,
@@ -14599,7 +14568,6 @@ var SmartGridSavedViews = (props) => {
14599
14568
  domain: props.domain
14600
14569
  });
14601
14570
  const onSelect = ({ item }) => {
14602
- var _a;
14603
14571
  if (!gridApi)
14604
14572
  return item;
14605
14573
  if (item.id === "default") {
@@ -14610,13 +14578,11 @@ var SmartGridSavedViews = (props) => {
14610
14578
  gridApi.refreshCells();
14611
14579
  return item;
14612
14580
  }
14613
- const tableConfig2 = item.table_config;
14614
- const updatedItemConfig = ((_a = props.transformSettings) == null ? void 0 : _a.call(props, tableConfig2)) ?? tableConfig2;
14615
14581
  const updatedView = {
14616
14582
  ...item,
14617
14583
  table_config: customAndConfigSync(
14618
- updatedItemConfig,
14619
- tableConfig2
14584
+ item.table_config,
14585
+ tableConfig
14620
14586
  )
14621
14587
  };
14622
14588
  updateTableConfig(updatedView, gridApi, "smart-grid");
@@ -14636,8 +14602,7 @@ var SmartGridSavedViews = (props) => {
14636
14602
  tableName: props.tableName,
14637
14603
  tableConfig,
14638
14604
  stickyViewsKey: props.stickyViewsKey,
14639
- enableSavedViews: props.enableSavedViews,
14640
- backend: props.backend
14605
+ enableSavedViews: props.enableSavedViews
14641
14606
  }
14642
14607
  ));
14643
14608
  };