@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.
- package/dist/legacy/index.d.mts +7 -24
- package/dist/legacy/index.d.ts +7 -24
- package/dist/legacy/index.js +230 -265
- package/dist/legacy/index.mjs +198 -233
- package/dist/modern/index.d.mts +7 -24
- package/dist/modern/index.d.ts +7 -24
- package/dist/modern/index.js +230 -264
- package/dist/modern/index.mjs +198 -232
- package/package.json +1 -1
package/dist/modern/index.js
CHANGED
|
@@ -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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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) {
|
|
@@ -11259,13 +11259,164 @@ var ExpandedPanel = styled_components_esm_default(import_core_react4.Panel)`
|
|
|
11259
11259
|
`;
|
|
11260
11260
|
|
|
11261
11261
|
// src/SavedViews/components/Panels/PanelContent.tsx
|
|
11262
|
-
var
|
|
11262
|
+
var import_core_react7 = require("@procore/core-react");
|
|
11263
11263
|
var import_toast_alert = require("@procore/toast-alert");
|
|
11264
11264
|
var import_react9 = __toESM(require("react"));
|
|
11265
11265
|
|
|
11266
|
+
// node_modules/@procore/core-http/dist/modern/index.js
|
|
11267
|
+
function getCSRFToken() {
|
|
11268
|
+
const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
|
|
11269
|
+
return token ? decodeURIComponent(token.pop() || "") : "";
|
|
11270
|
+
}
|
|
11271
|
+
function getCSRFHeader() {
|
|
11272
|
+
const csrfToken = getCSRFToken();
|
|
11273
|
+
return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
|
|
11274
|
+
}
|
|
11275
|
+
function removeLeadingSlash(url) {
|
|
11276
|
+
return url.startsWith("/") ? url.substring(1, url.length) : url;
|
|
11277
|
+
}
|
|
11278
|
+
function removeTrailingSlash(url) {
|
|
11279
|
+
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
11280
|
+
}
|
|
11281
|
+
function applyBaseUrl(url, baseUrl) {
|
|
11282
|
+
return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
|
|
11283
|
+
}
|
|
11284
|
+
function getOptions({ headers, ...options }) {
|
|
11285
|
+
const opts = {
|
|
11286
|
+
credentials: "same-origin",
|
|
11287
|
+
headers: {
|
|
11288
|
+
...getCSRFHeader(),
|
|
11289
|
+
...headers
|
|
11290
|
+
},
|
|
11291
|
+
mode: "same-origin",
|
|
11292
|
+
...options
|
|
11293
|
+
};
|
|
11294
|
+
return opts;
|
|
11295
|
+
}
|
|
11296
|
+
function getUrl(url, baseUrl) {
|
|
11297
|
+
return baseUrl ? applyBaseUrl(url, baseUrl) : url;
|
|
11298
|
+
}
|
|
11299
|
+
function request(url, { baseUrl, ...options } = {}) {
|
|
11300
|
+
return fetch(getUrl(url, baseUrl), getOptions(options));
|
|
11301
|
+
}
|
|
11302
|
+
function requestJSON(url, requestParams = {}) {
|
|
11303
|
+
return request(url, requestParams).then(
|
|
11304
|
+
(response) => response.json()
|
|
11305
|
+
);
|
|
11306
|
+
}
|
|
11307
|
+
|
|
11308
|
+
// src/utils/Api/queries.ts
|
|
11309
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
11310
|
+
|
|
11311
|
+
// src/utils/Api/queriesHandler.ts
|
|
11312
|
+
var import_react_query = require("@tanstack/react-query");
|
|
11313
|
+
var import_core_react5 = require("@procore/core-react");
|
|
11314
|
+
var useApiRequest = (props, method, mutationKey) => {
|
|
11315
|
+
const { projectId, companyId, domain, tableName } = props;
|
|
11316
|
+
const queryClient2 = (0, import_react_query.useQueryClient)();
|
|
11317
|
+
const { locale: locale2 } = (0, import_core_react5.useI18nContext)();
|
|
11318
|
+
return (0, import_react_query.useMutation)({
|
|
11319
|
+
mutationKey,
|
|
11320
|
+
mutationFn: async (savedView) => {
|
|
11321
|
+
let url = "";
|
|
11322
|
+
if (method === "DELETE" || method === "PUT") {
|
|
11323
|
+
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.id}?permissions_domain=${domain}`;
|
|
11324
|
+
} else {
|
|
11325
|
+
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
11326
|
+
}
|
|
11327
|
+
const response = await requestJSON(url, {
|
|
11328
|
+
method,
|
|
11329
|
+
body: JSON.stringify(savedView),
|
|
11330
|
+
headers: {
|
|
11331
|
+
"Content-Type": "application/json",
|
|
11332
|
+
"Accept-Language": locale2
|
|
11333
|
+
}
|
|
11334
|
+
});
|
|
11335
|
+
if (response.error) {
|
|
11336
|
+
throw response.error;
|
|
11337
|
+
}
|
|
11338
|
+
return response.data;
|
|
11339
|
+
},
|
|
11340
|
+
onSuccess: (savedView) => {
|
|
11341
|
+
if (method === "DELETE" || method === "POST") {
|
|
11342
|
+
queryClient2.invalidateQueries({
|
|
11343
|
+
queryKey: ["savedViews", domain, tableName]
|
|
11344
|
+
});
|
|
11345
|
+
return;
|
|
11346
|
+
} else {
|
|
11347
|
+
const oldData = queryClient2.getQueryData([
|
|
11348
|
+
"savedViews",
|
|
11349
|
+
domain,
|
|
11350
|
+
tableName
|
|
11351
|
+
]);
|
|
11352
|
+
const oldView = oldData?.find((item) => item.id === savedView.id);
|
|
11353
|
+
if (oldView?.name !== savedView.name) {
|
|
11354
|
+
queryClient2.invalidateQueries({
|
|
11355
|
+
queryKey: ["savedViews", domain, tableName]
|
|
11356
|
+
});
|
|
11357
|
+
return;
|
|
11358
|
+
}
|
|
11359
|
+
}
|
|
11360
|
+
queryClient2.setQueryData(
|
|
11361
|
+
["savedViews", domain, tableName],
|
|
11362
|
+
(oldData) => {
|
|
11363
|
+
if (!oldData)
|
|
11364
|
+
return [savedView];
|
|
11365
|
+
return oldData.map(
|
|
11366
|
+
(item) => item.id === savedView.id ? savedView : item
|
|
11367
|
+
);
|
|
11368
|
+
}
|
|
11369
|
+
);
|
|
11370
|
+
}
|
|
11371
|
+
});
|
|
11372
|
+
};
|
|
11373
|
+
|
|
11266
11374
|
// src/utils/Constants/viewLevels.ts
|
|
11267
11375
|
var VIEW_LEVELS = ["company", "project", "personal"];
|
|
11268
11376
|
|
|
11377
|
+
// src/utils/Api/queries.ts
|
|
11378
|
+
var PAGE_SIZE = 50 * VIEW_LEVELS.length;
|
|
11379
|
+
var useSavedViewsQuery = (props) => {
|
|
11380
|
+
const { projectId, companyId, domain, tableName } = props;
|
|
11381
|
+
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
11382
|
+
return (0, import_react_query2.useQuery)({
|
|
11383
|
+
enabled: props.enableSavedViews,
|
|
11384
|
+
queryKey: ["savedViews", domain, tableName],
|
|
11385
|
+
queryFn: async () => {
|
|
11386
|
+
const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
|
|
11387
|
+
const response = await requestJSON(getUrl2);
|
|
11388
|
+
return response.data;
|
|
11389
|
+
}
|
|
11390
|
+
});
|
|
11391
|
+
};
|
|
11392
|
+
var useSavedViewsPermissions = (props) => {
|
|
11393
|
+
const { projectId, companyId, domain } = props;
|
|
11394
|
+
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
|
|
11395
|
+
return (0, import_react_query2.useQuery)({
|
|
11396
|
+
enabled: props.enableSavedViews,
|
|
11397
|
+
queryKey: ["savedViewsConfig", domain],
|
|
11398
|
+
queryFn: async () => {
|
|
11399
|
+
const response = await requestJSON(url);
|
|
11400
|
+
return response.data;
|
|
11401
|
+
}
|
|
11402
|
+
});
|
|
11403
|
+
};
|
|
11404
|
+
var useCreateSavedView = (props) => useApiRequest(props, "POST", [
|
|
11405
|
+
"createSavedView",
|
|
11406
|
+
props.domain,
|
|
11407
|
+
props.tableName
|
|
11408
|
+
]);
|
|
11409
|
+
var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
|
|
11410
|
+
"updateSavedView",
|
|
11411
|
+
props.domain,
|
|
11412
|
+
props.tableName
|
|
11413
|
+
]);
|
|
11414
|
+
var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
11415
|
+
"deleteSavedView",
|
|
11416
|
+
props.domain,
|
|
11417
|
+
props.tableName
|
|
11418
|
+
]);
|
|
11419
|
+
|
|
11269
11420
|
// src/SavedViews/components/Panels/PanelContentUtils.ts
|
|
11270
11421
|
var import_lodash = __toESM(require_lodash());
|
|
11271
11422
|
|
|
@@ -11273,14 +11424,14 @@ var import_lodash = __toESM(require_lodash());
|
|
|
11273
11424
|
function getSmartGridConfig(api) {
|
|
11274
11425
|
const columnStateResult = api.getColumnState();
|
|
11275
11426
|
const columnGroupStateResult = api.getColumnGroupState();
|
|
11276
|
-
const rowGroupStateResult = api.getRowGroupColumns();
|
|
11427
|
+
const rowGroupStateResult = api.getRowGroupColumns().map((col) => col.getColId());
|
|
11277
11428
|
const rowHeightResult = api.getGridOption("rowHeight") || api.getSizesForCurrentTheme().rowHeight;
|
|
11278
11429
|
const serverFiltersResult = api.getFilterModel();
|
|
11279
11430
|
const smartGridConfig = {
|
|
11280
11431
|
columnState: columnStateResult,
|
|
11281
11432
|
rowHeight: rowHeightResult,
|
|
11282
11433
|
columnGroupState: columnGroupStateResult,
|
|
11283
|
-
rowGroupState: rowGroupStateResult
|
|
11434
|
+
rowGroupState: rowGroupStateResult,
|
|
11284
11435
|
filterState: serverFiltersResult
|
|
11285
11436
|
};
|
|
11286
11437
|
return smartGridConfig;
|
|
@@ -11468,7 +11619,7 @@ var useGroups = () => {
|
|
|
11468
11619
|
};
|
|
11469
11620
|
|
|
11470
11621
|
// src/SavedViews/components/Panels/ViewLevelHeader.tsx
|
|
11471
|
-
var
|
|
11622
|
+
var import_core_react6 = require("@procore/core-react");
|
|
11472
11623
|
var import_react7 = __toESM(require("react"));
|
|
11473
11624
|
var groupIcon = (group) => {
|
|
11474
11625
|
switch (group) {
|
|
@@ -11480,26 +11631,26 @@ var groupIcon = (group) => {
|
|
|
11480
11631
|
return /* @__PURE__ */ import_react7.default.createElement(Building_default, null);
|
|
11481
11632
|
}
|
|
11482
11633
|
};
|
|
11483
|
-
var Header = styled_components_esm_default(
|
|
11634
|
+
var Header = styled_components_esm_default(import_core_react6.Flex)`
|
|
11484
11635
|
width: 100%;
|
|
11485
11636
|
&:hover {
|
|
11486
|
-
background-color: ${
|
|
11637
|
+
background-color: ${import_core_react6.colors.gray98};
|
|
11487
11638
|
}
|
|
11488
11639
|
`;
|
|
11489
11640
|
var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
|
|
11490
|
-
const I18n = (0,
|
|
11641
|
+
const I18n = (0, import_core_react6.useI18nContext)();
|
|
11491
11642
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
11492
11643
|
Header,
|
|
11493
11644
|
{
|
|
11494
11645
|
alignItems: "center",
|
|
11495
|
-
padding: `${
|
|
11496
|
-
gap: `${
|
|
11646
|
+
padding: `${import_core_react6.spacing.sm}px`,
|
|
11647
|
+
gap: `${import_core_react6.spacing.sm}px`,
|
|
11497
11648
|
style: { cursor: "pointer" },
|
|
11498
11649
|
onClick: () => toggleGroup(group)
|
|
11499
11650
|
},
|
|
11500
11651
|
expanded ? /* @__PURE__ */ import_react7.default.createElement(ChevronDown_default, { size: "sm" }) : /* @__PURE__ */ import_react7.default.createElement(ChevronRight_default, { size: "sm" }),
|
|
11501
11652
|
groupIcon(group),
|
|
11502
|
-
/* @__PURE__ */ import_react7.default.createElement(
|
|
11653
|
+
/* @__PURE__ */ import_react7.default.createElement(import_core_react6.Typography, { weight: "semibold" }, I18n.t(`savedViews.viewLevel.${group}`))
|
|
11503
11654
|
);
|
|
11504
11655
|
};
|
|
11505
11656
|
var ViewLevelHeader_default = ViewLevelHeader;
|
|
@@ -11517,28 +11668,27 @@ var useScrollToRef = (dependency) => {
|
|
|
11517
11668
|
};
|
|
11518
11669
|
|
|
11519
11670
|
// src/SavedViews/components/Panels/PanelContent.tsx
|
|
11520
|
-
var Row = styled_components_esm_default(
|
|
11671
|
+
var Row = styled_components_esm_default(import_core_react7.UNSAFE_Menu.Item)`
|
|
11521
11672
|
width: 100%;
|
|
11522
11673
|
padding-left: 35px;
|
|
11523
11674
|
padding-right: 4px;
|
|
11524
|
-
background-color: ${({ selected }) => selected ?
|
|
11675
|
+
background-color: ${({ selected }) => selected ? import_core_react7.colors.blue96 : "transparent"};
|
|
11525
11676
|
|
|
11526
11677
|
&:hover {
|
|
11527
|
-
background-color: ${({ selected }) => selected ?
|
|
11678
|
+
background-color: ${({ selected }) => selected ? import_core_react7.colors.blue96 : import_core_react7.colors.gray98};
|
|
11528
11679
|
}
|
|
11529
11680
|
`;
|
|
11530
|
-
var Panel2 = styled_components_esm_default(
|
|
11681
|
+
var Panel2 = styled_components_esm_default(import_core_react7.DetailPage.Card)`
|
|
11531
11682
|
margin: 0;
|
|
11532
11683
|
height: 100%;
|
|
11533
|
-
padding-top: ${
|
|
11684
|
+
padding-top: ${import_core_react7.spacing.sm}px;
|
|
11534
11685
|
box-shadow: none;
|
|
11535
11686
|
`;
|
|
11536
11687
|
var PanelContent = (props) => {
|
|
11537
11688
|
const { showToast } = (0, import_toast_alert.useToastAlertContext)();
|
|
11538
|
-
const I18n = (0,
|
|
11539
|
-
const {
|
|
11540
|
-
const {
|
|
11541
|
-
const { data: savedViews, error: savedViewsError } = useSavedViewsQuery2(
|
|
11689
|
+
const I18n = (0, import_core_react7.useI18nContext)();
|
|
11690
|
+
const { mutate: updateSavedView, isPending: isUpdateLoading } = useUpdateSavedView(props.queryInput);
|
|
11691
|
+
const { data: savedViews, error: savedViewsError } = useSavedViewsQuery(
|
|
11542
11692
|
props.queryInput
|
|
11543
11693
|
);
|
|
11544
11694
|
const errorToastRef = import_react9.default.useRef(null);
|
|
@@ -11548,7 +11698,7 @@ var PanelContent = (props) => {
|
|
|
11548
11698
|
errorToastRef.current = savedViewsError;
|
|
11549
11699
|
}
|
|
11550
11700
|
}, [savedViewsError]);
|
|
11551
|
-
const { data: permissions } =
|
|
11701
|
+
const { data: permissions } = useSavedViewsPermissions(props.queryInput);
|
|
11552
11702
|
const selectedRowRef = useScrollToRef(savedViews);
|
|
11553
11703
|
const onUpdate = (data) => {
|
|
11554
11704
|
const newSavedView = {
|
|
@@ -11569,7 +11719,7 @@ var PanelContent = (props) => {
|
|
|
11569
11719
|
};
|
|
11570
11720
|
const { groups, toggleGroup } = useGroups();
|
|
11571
11721
|
const isDefaultSelected = props.selectedSavedView?.id === "default";
|
|
11572
|
-
return /* @__PURE__ */ import_react9.default.createElement(Panel2, { "data-testid": "inner-panel" }, /* @__PURE__ */ import_react9.default.createElement(
|
|
11722
|
+
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(
|
|
11573
11723
|
Row,
|
|
11574
11724
|
{
|
|
11575
11725
|
selected: isDefaultSelected,
|
|
@@ -11637,9 +11787,9 @@ var PanelContent = (props) => {
|
|
|
11637
11787
|
var import_react14 = __toESM(require("react"));
|
|
11638
11788
|
|
|
11639
11789
|
// src/SavedViews/components/SavedViews/SmartGrid/SmartGridDefaultSavedView.tsx
|
|
11640
|
-
var
|
|
11790
|
+
var import_core_react8 = require("@procore/core-react");
|
|
11641
11791
|
var useDefaultViewName = (domain, defaultViewName) => {
|
|
11642
|
-
const i18n = (0,
|
|
11792
|
+
const i18n = (0, import_core_react8.useI18nContext)();
|
|
11643
11793
|
return defaultViewName || i18n.t(domain, {
|
|
11644
11794
|
scope: "savedViews.defaultViewTitle",
|
|
11645
11795
|
defaultValue: "Default View"
|
|
@@ -11699,16 +11849,16 @@ var import_react13 = __toESM(require("react"));
|
|
|
11699
11849
|
var import_react_query3 = require("@tanstack/react-query");
|
|
11700
11850
|
|
|
11701
11851
|
// src/SavedViews/components/SavedViewsModals/SavedViewsDeleteConfirmationModalShared.tsx
|
|
11702
|
-
var
|
|
11852
|
+
var import_core_react9 = require("@procore/core-react");
|
|
11703
11853
|
var import_react11 = __toESM(require("react"));
|
|
11704
11854
|
var SavedViewsDeleteConfirmationModalShared = ({
|
|
11705
11855
|
onCancel,
|
|
11706
11856
|
onDelete,
|
|
11707
11857
|
open
|
|
11708
11858
|
}) => {
|
|
11709
|
-
const i18n = (0,
|
|
11859
|
+
const i18n = (0, import_core_react9.useI18nContext)();
|
|
11710
11860
|
return /* @__PURE__ */ import_react11.default.createElement(
|
|
11711
|
-
|
|
11861
|
+
import_core_react9.ConfirmModal,
|
|
11712
11862
|
{
|
|
11713
11863
|
"data-testid": "delete-confirmation-modal",
|
|
11714
11864
|
open,
|
|
@@ -11717,8 +11867,8 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
11717
11867
|
onClose: onCancel,
|
|
11718
11868
|
style: { overflowWrap: "anywhere" }
|
|
11719
11869
|
},
|
|
11720
|
-
/* @__PURE__ */ import_react11.default.createElement(
|
|
11721
|
-
/* @__PURE__ */ import_react11.default.createElement(
|
|
11870
|
+
/* @__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"))),
|
|
11871
|
+
/* @__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"))))
|
|
11722
11872
|
);
|
|
11723
11873
|
};
|
|
11724
11874
|
|
|
@@ -11726,7 +11876,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
11726
11876
|
var import_react12 = __toESM(require("react"));
|
|
11727
11877
|
|
|
11728
11878
|
// src/SavedViews/components/SavedViewsModals/SavedViewsCreateUpdateModalBase.tsx
|
|
11729
|
-
var
|
|
11879
|
+
var import_core_react10 = require("@procore/core-react");
|
|
11730
11880
|
var React17 = __toESM(require("react"));
|
|
11731
11881
|
|
|
11732
11882
|
// ../../node_modules/yup/index.esm.js
|
|
@@ -14055,7 +14205,6 @@ function extractMessage(error, I18n) {
|
|
|
14055
14205
|
}
|
|
14056
14206
|
|
|
14057
14207
|
// src/SavedViews/components/SavedViewsModals/SavedViewsCreateUpdateModalBase.tsx
|
|
14058
|
-
var { useEffect: useEffect3, useRef: useRef2 } = React17;
|
|
14059
14208
|
var ScrollContainer = styled_components_esm_default("div")`
|
|
14060
14209
|
overflow: auto;
|
|
14061
14210
|
`;
|
|
@@ -14073,38 +14222,22 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14073
14222
|
selectedSavedView,
|
|
14074
14223
|
setSelectedSavedView,
|
|
14075
14224
|
setOpenEditCreateModal,
|
|
14076
|
-
onSelect
|
|
14077
|
-
backend
|
|
14225
|
+
onSelect
|
|
14078
14226
|
}) => {
|
|
14079
|
-
const I18n = (0,
|
|
14227
|
+
const I18n = (0, import_core_react10.useI18nContext)();
|
|
14080
14228
|
const NAME_MAX_LENGTH = 150;
|
|
14081
|
-
const originalBodyWidth = useRef2("");
|
|
14082
|
-
useEffect3(() => {
|
|
14083
|
-
if (open) {
|
|
14084
|
-
originalBodyWidth.current = document.body.style.width || "";
|
|
14085
|
-
document.body.style.width = "100%";
|
|
14086
|
-
} else {
|
|
14087
|
-
document.body.style.width = originalBodyWidth.current;
|
|
14088
|
-
}
|
|
14089
|
-
return () => {
|
|
14090
|
-
if (originalBodyWidth.current !== void 0) {
|
|
14091
|
-
document.body.style.width = originalBodyWidth.current;
|
|
14092
|
-
}
|
|
14093
|
-
};
|
|
14094
|
-
}, [open]);
|
|
14095
|
-
const { useCreateSavedView: useCreateSavedView2, useUpdateSavedView: useUpdateSavedView2, useSavedViewsPermissions: useSavedViewsPermissions2 } = backend;
|
|
14096
14229
|
const {
|
|
14097
14230
|
mutate: createSavedView,
|
|
14098
14231
|
isPending: isCreating,
|
|
14099
14232
|
error: createError,
|
|
14100
14233
|
reset: resetCreateMutation
|
|
14101
|
-
} =
|
|
14234
|
+
} = useCreateSavedView(queryInput);
|
|
14102
14235
|
const {
|
|
14103
14236
|
mutate: updateSavedView,
|
|
14104
14237
|
isPending: isUpdating,
|
|
14105
14238
|
error: updateError,
|
|
14106
14239
|
reset: resetUpdateMutation
|
|
14107
|
-
} =
|
|
14240
|
+
} = useUpdateSavedView(queryInput);
|
|
14108
14241
|
const resetMutations = () => {
|
|
14109
14242
|
resetCreateMutation();
|
|
14110
14243
|
resetUpdateMutation();
|
|
@@ -14113,7 +14246,7 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14113
14246
|
resetMutations();
|
|
14114
14247
|
onCancel();
|
|
14115
14248
|
};
|
|
14116
|
-
const { data: permissions } =
|
|
14249
|
+
const { data: permissions } = useSavedViewsPermissions(queryInput);
|
|
14117
14250
|
const isLoading = isCreating || isUpdating;
|
|
14118
14251
|
const errors = extractMessage(createError || updateError, I18n);
|
|
14119
14252
|
const handleOnSubmit = (data) => {
|
|
@@ -14146,7 +14279,7 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14146
14279
|
};
|
|
14147
14280
|
const viewLevelOptions = getViewLevelOptions(permissions, I18n);
|
|
14148
14281
|
return /* @__PURE__ */ React17.createElement(
|
|
14149
|
-
|
|
14282
|
+
import_core_react10.Modal,
|
|
14150
14283
|
{
|
|
14151
14284
|
"aria-label": I18n.t("savedViews.ariaLabels.modal"),
|
|
14152
14285
|
onClickOverlay: onClose,
|
|
@@ -14155,14 +14288,14 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14155
14288
|
"data-testid": "create-update-modal"
|
|
14156
14289
|
},
|
|
14157
14290
|
/* @__PURE__ */ React17.createElement(ScrollContainer, null, /* @__PURE__ */ React17.createElement(
|
|
14158
|
-
|
|
14291
|
+
import_core_react10.Modal.Header,
|
|
14159
14292
|
{
|
|
14160
14293
|
onClose,
|
|
14161
|
-
style: { borderBottom: `1px solid ${
|
|
14294
|
+
style: { borderBottom: `1px solid ${import_core_react10.colors.gray85}` }
|
|
14162
14295
|
},
|
|
14163
|
-
/* @__PURE__ */ React17.createElement(
|
|
14296
|
+
/* @__PURE__ */ React17.createElement(import_core_react10.H2, null, header)
|
|
14164
14297
|
), /* @__PURE__ */ React17.createElement(
|
|
14165
|
-
|
|
14298
|
+
import_core_react10.Form,
|
|
14166
14299
|
{
|
|
14167
14300
|
initialValues: {
|
|
14168
14301
|
name: initialName,
|
|
@@ -14187,14 +14320,14 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14187
14320
|
onReset: onCancel,
|
|
14188
14321
|
validateOnChange: true
|
|
14189
14322
|
},
|
|
14190
|
-
/* @__PURE__ */ React17.createElement(
|
|
14191
|
-
|
|
14323
|
+
/* @__PURE__ */ React17.createElement(import_core_react10.Form.Form, { name: header }, /* @__PURE__ */ React17.createElement(
|
|
14324
|
+
import_core_react10.Modal.Body,
|
|
14192
14325
|
{
|
|
14193
|
-
style: { paddingTop: 0, paddingBottom: 0, marginTop:
|
|
14326
|
+
style: { paddingTop: 0, paddingBottom: 0, marginTop: import_core_react10.spacing.lg }
|
|
14194
14327
|
},
|
|
14195
|
-
errors && /* @__PURE__ */ React17.createElement(
|
|
14196
|
-
/* @__PURE__ */ React17.createElement(
|
|
14197
|
-
|
|
14328
|
+
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?.form || I18n.t(`savedViews.modal.errors.description.${mode}`)))),
|
|
14329
|
+
/* @__PURE__ */ React17.createElement(import_core_react10.Form.Row, null, /* @__PURE__ */ React17.createElement(
|
|
14330
|
+
import_core_react10.Form.Text,
|
|
14198
14331
|
{
|
|
14199
14332
|
name: "name",
|
|
14200
14333
|
error: errors?.name,
|
|
@@ -14205,12 +14338,12 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14205
14338
|
}
|
|
14206
14339
|
)),
|
|
14207
14340
|
/* @__PURE__ */ React17.createElement(
|
|
14208
|
-
|
|
14341
|
+
import_core_react10.Form.Row,
|
|
14209
14342
|
{
|
|
14210
|
-
style: { marginTop: errors?.name ?
|
|
14343
|
+
style: { marginTop: errors?.name ? import_core_react10.spacing.xl : import_core_react10.spacing.none }
|
|
14211
14344
|
},
|
|
14212
14345
|
/* @__PURE__ */ React17.createElement(
|
|
14213
|
-
|
|
14346
|
+
import_core_react10.Form.TextArea,
|
|
14214
14347
|
{
|
|
14215
14348
|
name: "description",
|
|
14216
14349
|
placeholder: I18n.t("savedViews.modal.fields.description"),
|
|
@@ -14220,11 +14353,10 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14220
14353
|
}
|
|
14221
14354
|
)
|
|
14222
14355
|
),
|
|
14223
|
-
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React17.createElement(
|
|
14224
|
-
|
|
14356
|
+
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React17.createElement(import_core_react10.Form.Row, null, /* @__PURE__ */ React17.createElement(
|
|
14357
|
+
import_core_react10.Form.Select,
|
|
14225
14358
|
{
|
|
14226
14359
|
name: "view_level",
|
|
14227
|
-
qa: { label: "view-level" },
|
|
14228
14360
|
options: viewLevelOptions,
|
|
14229
14361
|
label: I18n.t("savedViews.modal.fields.viewLevel"),
|
|
14230
14362
|
colWidth: 12,
|
|
@@ -14232,8 +14364,8 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14232
14364
|
onClear: false
|
|
14233
14365
|
}
|
|
14234
14366
|
)) : /* @__PURE__ */ React17.createElement(React17.Fragment, null)
|
|
14235
|
-
), /* @__PURE__ */ React17.createElement(
|
|
14236
|
-
|
|
14367
|
+
), /* @__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(
|
|
14368
|
+
import_core_react10.Button,
|
|
14237
14369
|
{
|
|
14238
14370
|
"data-testid": "create-update-modal-button",
|
|
14239
14371
|
type: "submit",
|
|
@@ -14248,7 +14380,7 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14248
14380
|
};
|
|
14249
14381
|
|
|
14250
14382
|
// src/SavedViews/components/SavedViewsModals/SavedViewsFormModal.tsx
|
|
14251
|
-
var
|
|
14383
|
+
var import_core_react11 = require("@procore/core-react");
|
|
14252
14384
|
var SavedViewsFormModal = ({
|
|
14253
14385
|
open,
|
|
14254
14386
|
mode,
|
|
@@ -14260,10 +14392,9 @@ var SavedViewsFormModal = ({
|
|
|
14260
14392
|
setSelectedSavedView,
|
|
14261
14393
|
setOpenEditCreateModal,
|
|
14262
14394
|
onSelect,
|
|
14263
|
-
defaultView
|
|
14264
|
-
backend
|
|
14395
|
+
defaultView
|
|
14265
14396
|
}) => {
|
|
14266
|
-
const i18n = (0,
|
|
14397
|
+
const i18n = (0, import_core_react11.useI18nContext)();
|
|
14267
14398
|
return /* @__PURE__ */ import_react12.default.createElement(
|
|
14268
14399
|
SavedViewsCreateUpdateModalBase,
|
|
14269
14400
|
{
|
|
@@ -14280,170 +14411,11 @@ var SavedViewsFormModal = ({
|
|
|
14280
14411
|
setSelectedSavedView,
|
|
14281
14412
|
setOpenEditCreateModal,
|
|
14282
14413
|
onSelect,
|
|
14283
|
-
defaultView
|
|
14284
|
-
backend
|
|
14414
|
+
defaultView
|
|
14285
14415
|
}
|
|
14286
14416
|
);
|
|
14287
14417
|
};
|
|
14288
14418
|
|
|
14289
|
-
// ../../node_modules/@procore/core-http/dist/modern/index.js
|
|
14290
|
-
function getCSRFToken() {
|
|
14291
|
-
const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
|
|
14292
|
-
return token ? decodeURIComponent(token.pop() || "") : "";
|
|
14293
|
-
}
|
|
14294
|
-
function getCSRFHeader() {
|
|
14295
|
-
const csrfToken = getCSRFToken();
|
|
14296
|
-
return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
|
|
14297
|
-
}
|
|
14298
|
-
function removeLeadingSlash(url) {
|
|
14299
|
-
return url.startsWith("/") ? url.substring(1, url.length) : url;
|
|
14300
|
-
}
|
|
14301
|
-
function removeTrailingSlash(url) {
|
|
14302
|
-
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
14303
|
-
}
|
|
14304
|
-
function applyBaseUrl(url, baseUrl) {
|
|
14305
|
-
return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
|
|
14306
|
-
}
|
|
14307
|
-
function getOptions({ headers, ...options }) {
|
|
14308
|
-
const opts = {
|
|
14309
|
-
credentials: "same-origin",
|
|
14310
|
-
headers: {
|
|
14311
|
-
...getCSRFHeader(),
|
|
14312
|
-
...headers
|
|
14313
|
-
},
|
|
14314
|
-
mode: "same-origin",
|
|
14315
|
-
...options
|
|
14316
|
-
};
|
|
14317
|
-
return opts;
|
|
14318
|
-
}
|
|
14319
|
-
function getUrl(url, baseUrl) {
|
|
14320
|
-
return baseUrl ? applyBaseUrl(url, baseUrl) : url;
|
|
14321
|
-
}
|
|
14322
|
-
function request(url, { baseUrl, ...options } = {}) {
|
|
14323
|
-
return fetch(getUrl(url, baseUrl), getOptions(options));
|
|
14324
|
-
}
|
|
14325
|
-
function requestJSON(url, requestParams = {}) {
|
|
14326
|
-
return request(url, requestParams).then(
|
|
14327
|
-
(response) => response.json()
|
|
14328
|
-
);
|
|
14329
|
-
}
|
|
14330
|
-
|
|
14331
|
-
// src/utils/Api/queries.ts
|
|
14332
|
-
var import_react_query2 = require("@tanstack/react-query");
|
|
14333
|
-
|
|
14334
|
-
// src/utils/Api/queriesHandler.ts
|
|
14335
|
-
var import_react_query = require("@tanstack/react-query");
|
|
14336
|
-
var import_core_react11 = require("@procore/core-react");
|
|
14337
|
-
var useApiRequest = (props, method, mutationKey) => {
|
|
14338
|
-
const { projectId, companyId, domain, tableName } = props;
|
|
14339
|
-
const queryClient2 = (0, import_react_query.useQueryClient)();
|
|
14340
|
-
const { locale: locale2 } = (0, import_core_react11.useI18nContext)();
|
|
14341
|
-
return (0, import_react_query.useMutation)({
|
|
14342
|
-
mutationKey,
|
|
14343
|
-
mutationFn: async (savedView) => {
|
|
14344
|
-
let url = "";
|
|
14345
|
-
if (method === "DELETE" || method === "PUT") {
|
|
14346
|
-
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.id}?permissions_domain=${domain}`;
|
|
14347
|
-
} else {
|
|
14348
|
-
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
14349
|
-
}
|
|
14350
|
-
const response = await requestJSON(url, {
|
|
14351
|
-
method,
|
|
14352
|
-
body: JSON.stringify(savedView),
|
|
14353
|
-
headers: {
|
|
14354
|
-
"Content-Type": "application/json",
|
|
14355
|
-
"Accept-Language": locale2
|
|
14356
|
-
}
|
|
14357
|
-
});
|
|
14358
|
-
if (response.error) {
|
|
14359
|
-
throw response.error;
|
|
14360
|
-
}
|
|
14361
|
-
return response.data;
|
|
14362
|
-
},
|
|
14363
|
-
onSuccess: (savedView) => {
|
|
14364
|
-
if (method === "DELETE" || method === "POST") {
|
|
14365
|
-
queryClient2.invalidateQueries({
|
|
14366
|
-
queryKey: ["savedViews", domain, tableName]
|
|
14367
|
-
});
|
|
14368
|
-
return;
|
|
14369
|
-
} else {
|
|
14370
|
-
const oldData = queryClient2.getQueryData([
|
|
14371
|
-
"savedViews",
|
|
14372
|
-
domain,
|
|
14373
|
-
tableName
|
|
14374
|
-
]);
|
|
14375
|
-
const oldView = oldData?.find((item) => item.id === savedView.id);
|
|
14376
|
-
if (oldView?.name !== savedView.name) {
|
|
14377
|
-
queryClient2.invalidateQueries({
|
|
14378
|
-
queryKey: ["savedViews", domain, tableName]
|
|
14379
|
-
});
|
|
14380
|
-
return;
|
|
14381
|
-
}
|
|
14382
|
-
}
|
|
14383
|
-
queryClient2.setQueryData(
|
|
14384
|
-
["savedViews", domain, tableName],
|
|
14385
|
-
(oldData) => {
|
|
14386
|
-
if (!oldData)
|
|
14387
|
-
return [savedView];
|
|
14388
|
-
return oldData.map(
|
|
14389
|
-
(item) => item.id === savedView.id ? savedView : item
|
|
14390
|
-
);
|
|
14391
|
-
}
|
|
14392
|
-
);
|
|
14393
|
-
}
|
|
14394
|
-
});
|
|
14395
|
-
};
|
|
14396
|
-
|
|
14397
|
-
// src/utils/Api/queries.ts
|
|
14398
|
-
var PAGE_SIZE = 50 * VIEW_LEVELS.length;
|
|
14399
|
-
var useSavedViewsQuery = (props) => {
|
|
14400
|
-
const { projectId, companyId, domain, tableName } = props;
|
|
14401
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
14402
|
-
return (0, import_react_query2.useQuery)({
|
|
14403
|
-
enabled: props.enableSavedViews,
|
|
14404
|
-
queryKey: ["savedViews", domain, tableName],
|
|
14405
|
-
queryFn: async () => {
|
|
14406
|
-
const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
|
|
14407
|
-
const response = await requestJSON(getUrl2);
|
|
14408
|
-
return response.data;
|
|
14409
|
-
}
|
|
14410
|
-
});
|
|
14411
|
-
};
|
|
14412
|
-
var useSavedViewsPermissions = (props) => {
|
|
14413
|
-
const { projectId, companyId, domain } = props;
|
|
14414
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
|
|
14415
|
-
return (0, import_react_query2.useQuery)({
|
|
14416
|
-
enabled: props.enableSavedViews,
|
|
14417
|
-
queryKey: ["savedViewsConfig", domain],
|
|
14418
|
-
queryFn: async () => {
|
|
14419
|
-
const response = await requestJSON(url);
|
|
14420
|
-
return response.data;
|
|
14421
|
-
}
|
|
14422
|
-
});
|
|
14423
|
-
};
|
|
14424
|
-
var useCreateSavedView = (props) => useApiRequest(props, "POST", [
|
|
14425
|
-
"createSavedView",
|
|
14426
|
-
props.domain,
|
|
14427
|
-
props.tableName
|
|
14428
|
-
]);
|
|
14429
|
-
var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
|
|
14430
|
-
"updateSavedView",
|
|
14431
|
-
props.domain,
|
|
14432
|
-
props.tableName
|
|
14433
|
-
]);
|
|
14434
|
-
var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
14435
|
-
"deleteSavedView",
|
|
14436
|
-
props.domain,
|
|
14437
|
-
props.tableName
|
|
14438
|
-
]);
|
|
14439
|
-
var createQueries = (customBackend) => ({
|
|
14440
|
-
useSavedViewsQuery: customBackend?.useSavedViewsQuery ?? useSavedViewsQuery,
|
|
14441
|
-
useSavedViewsPermissions: customBackend?.useSavedViewsPermissions ?? useSavedViewsPermissions,
|
|
14442
|
-
useCreateSavedView: customBackend?.useCreateSavedView ?? useCreateSavedView,
|
|
14443
|
-
useUpdateSavedView: customBackend?.useUpdateSavedView ?? useUpdateSavedView,
|
|
14444
|
-
useDeleteSavedView: customBackend?.useDeleteSavedView ?? useDeleteSavedView
|
|
14445
|
-
});
|
|
14446
|
-
|
|
14447
14419
|
// src/SavedViews/components/SavedViews/SavedViews.tsx
|
|
14448
14420
|
var StyledPanel = styled_components_esm_default.div`
|
|
14449
14421
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
@@ -14458,8 +14430,7 @@ var SavedViewsContent = (props) => {
|
|
|
14458
14430
|
projectId,
|
|
14459
14431
|
companyId
|
|
14460
14432
|
};
|
|
14461
|
-
const
|
|
14462
|
-
const { mutate: deleteSavedView } = backend.useDeleteSavedView(queryInput);
|
|
14433
|
+
const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
|
|
14463
14434
|
const [selectedSavedView, setSelectedSavedView] = (0, import_react13.useState)(() => {
|
|
14464
14435
|
try {
|
|
14465
14436
|
const savedView = JSON.parse(
|
|
@@ -14549,8 +14520,7 @@ var SavedViewsContent = (props) => {
|
|
|
14549
14520
|
defaultView: props.defaultView,
|
|
14550
14521
|
stickyViewsKey: props.stickyViewsKey,
|
|
14551
14522
|
provider: props.provider,
|
|
14552
|
-
userId: props.userId
|
|
14553
|
-
backend
|
|
14523
|
+
userId: props.userId
|
|
14554
14524
|
}
|
|
14555
14525
|
))
|
|
14556
14526
|
), /* @__PURE__ */ import_react13.default.createElement(
|
|
@@ -14566,8 +14536,7 @@ var SavedViewsContent = (props) => {
|
|
|
14566
14536
|
setSelectedSavedView,
|
|
14567
14537
|
onSelect: (view) => handleViewItemSelect({ item: view }),
|
|
14568
14538
|
setOpenEditCreateModal,
|
|
14569
|
-
defaultView: props.defaultView
|
|
14570
|
-
backend
|
|
14539
|
+
defaultView: props.defaultView
|
|
14571
14540
|
}
|
|
14572
14541
|
), selectedSavedView && /* @__PURE__ */ import_react13.default.createElement(
|
|
14573
14542
|
SavedViewsDeleteConfirmationModalShared,
|
|
@@ -14605,13 +14574,11 @@ var SmartGridSavedViews = (props) => {
|
|
|
14605
14574
|
gridApi.refreshCells();
|
|
14606
14575
|
return item;
|
|
14607
14576
|
}
|
|
14608
|
-
const tableConfig2 = item.table_config;
|
|
14609
|
-
const updatedItemConfig = props.transformSettings?.(tableConfig2) ?? tableConfig2;
|
|
14610
14577
|
const updatedView = {
|
|
14611
14578
|
...item,
|
|
14612
14579
|
table_config: customAndConfigSync(
|
|
14613
|
-
|
|
14614
|
-
|
|
14580
|
+
item.table_config,
|
|
14581
|
+
tableConfig
|
|
14615
14582
|
)
|
|
14616
14583
|
};
|
|
14617
14584
|
updateTableConfig(updatedView, gridApi, "smart-grid");
|
|
@@ -14631,8 +14598,7 @@ var SmartGridSavedViews = (props) => {
|
|
|
14631
14598
|
tableName: props.tableName,
|
|
14632
14599
|
tableConfig,
|
|
14633
14600
|
stickyViewsKey: props.stickyViewsKey,
|
|
14634
|
-
enableSavedViews: props.enableSavedViews
|
|
14635
|
-
backend: props.backend
|
|
14601
|
+
enableSavedViews: props.enableSavedViews
|
|
14636
14602
|
}
|
|
14637
14603
|
));
|
|
14638
14604
|
};
|