@procore/saved-views 6.1.0 → 6.2.0
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/adapters/hub-data-loader.d.mts +22 -0
- package/dist/legacy/adapters/hub-data-loader.d.ts +22 -0
- package/dist/legacy/adapters/hub-data-loader.js +273 -0
- package/dist/legacy/adapters/hub-data-loader.mjs +273 -0
- package/dist/legacy/chunk-6DZX6EAA.mjs +37 -0
- package/dist/legacy/chunk-QGM4M3NI.js +37 -0
- package/dist/legacy/index.d.mts +13 -2
- package/dist/legacy/index.d.ts +13 -2
- package/dist/legacy/index.js +549 -471
- package/dist/legacy/index.mjs +223 -192
- package/dist/legacy/transport/default.d.mts +15 -0
- package/dist/legacy/transport/default.d.ts +15 -0
- package/dist/legacy/transport/default.js +104 -0
- package/dist/legacy/transport/default.mjs +104 -0
- package/dist/legacy/types-BWhJ-on3.d.mts +109 -0
- package/dist/legacy/types-BWhJ-on3.d.ts +109 -0
- package/dist/modern/adapters/hub-data-loader.d.mts +22 -0
- package/dist/modern/adapters/hub-data-loader.d.ts +22 -0
- package/dist/modern/adapters/hub-data-loader.js +270 -0
- package/dist/modern/adapters/hub-data-loader.mjs +270 -0
- package/dist/modern/chunk-6DZX6EAA.mjs +37 -0
- package/dist/modern/chunk-QGM4M3NI.js +37 -0
- package/dist/modern/index.d.mts +13 -2
- package/dist/modern/index.d.ts +13 -2
- package/dist/modern/index.js +606 -528
- package/dist/modern/index.mjs +223 -192
- package/dist/modern/transport/default.d.mts +15 -0
- package/dist/modern/transport/default.d.ts +15 -0
- package/dist/modern/transport/default.js +104 -0
- package/dist/modern/transport/default.mjs +104 -0
- package/dist/modern/types-BWhJ-on3.d.mts +109 -0
- package/dist/modern/types-BWhJ-on3.d.ts +109 -0
- package/package.json +35 -2
package/dist/legacy/index.mjs
CHANGED
|
@@ -1,34 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
|
|
8
|
-
get: (a2, b2) => (typeof require !== "undefined" ? require : a2)[b2]
|
|
9
|
-
}) : x2)(function(x2) {
|
|
10
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
-
throw Error('Dynamic require of "' + x2 + '" is not supported');
|
|
12
|
-
});
|
|
13
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
-
};
|
|
16
|
-
var __copyProps = (to, from2, except, desc) => {
|
|
17
|
-
if (from2 && typeof from2 === "object" || typeof from2 === "function") {
|
|
18
|
-
for (let key of __getOwnPropNames(from2))
|
|
19
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
-
__defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
-
mod
|
|
31
|
-
));
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__require,
|
|
4
|
+
__toESM
|
|
5
|
+
} from "./chunk-6DZX6EAA.mjs";
|
|
32
6
|
|
|
33
7
|
// node_modules/lodash/lodash.js
|
|
34
8
|
var require_lodash = __commonJS({
|
|
@@ -738,7 +712,7 @@ var require_lodash = __commonJS({
|
|
|
738
712
|
var reIsNative = RegExp2(
|
|
739
713
|
"^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
740
714
|
);
|
|
741
|
-
var
|
|
715
|
+
var Buffer = moduleExports ? context.Buffer : undefined2, Symbol2 = context.Symbol, Uint8Array = context.Uint8Array, allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined2, getPrototype = overArg(Object2.getPrototypeOf, Object2), objectCreate = Object2.create, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, spreadableSymbol = Symbol2 ? Symbol2.isConcatSpreadable : undefined2, symIterator = Symbol2 ? Symbol2.iterator : undefined2, symToStringTag = Symbol2 ? Symbol2.toStringTag : undefined2;
|
|
742
716
|
var defineProperty = (function() {
|
|
743
717
|
try {
|
|
744
718
|
var func = getNative(Object2, "defineProperty");
|
|
@@ -748,7 +722,7 @@ var require_lodash = __commonJS({
|
|
|
748
722
|
}
|
|
749
723
|
})();
|
|
750
724
|
var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date && Date.now !== root.Date.now && Date.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
|
|
751
|
-
var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer =
|
|
725
|
+
var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined2, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
|
|
752
726
|
var DataView = getNative(context, "DataView"), Map2 = getNative(context, "Map"), Promise2 = getNative(context, "Promise"), Set2 = getNative(context, "Set"), WeakMap2 = getNative(context, "WeakMap"), nativeCreate = getNative(Object2, "create");
|
|
753
727
|
var metaMap = WeakMap2 && new WeakMap2();
|
|
754
728
|
var realNames = {};
|
|
@@ -2060,7 +2034,7 @@ var require_lodash = __commonJS({
|
|
|
2060
2034
|
}
|
|
2061
2035
|
function cloneArrayBuffer(arrayBuffer) {
|
|
2062
2036
|
var result2 = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
|
2063
|
-
new
|
|
2037
|
+
new Uint8Array(result2).set(new Uint8Array(arrayBuffer));
|
|
2064
2038
|
return result2;
|
|
2065
2039
|
}
|
|
2066
2040
|
function cloneDataView(dataView, isDeep) {
|
|
@@ -2664,7 +2638,7 @@ var require_lodash = __commonJS({
|
|
|
2664
2638
|
object3 = object3.buffer;
|
|
2665
2639
|
other = other.buffer;
|
|
2666
2640
|
case arrayBufferTag:
|
|
2667
|
-
if (object3.byteLength != other.byteLength || !equalFunc(new
|
|
2641
|
+
if (object3.byteLength != other.byteLength || !equalFunc(new Uint8Array(object3), new Uint8Array(other))) {
|
|
2668
2642
|
return false;
|
|
2669
2643
|
}
|
|
2670
2644
|
return true;
|
|
@@ -9056,8 +9030,28 @@ import {
|
|
|
9056
9030
|
Flex,
|
|
9057
9031
|
useI18nContext as useI18nContext2
|
|
9058
9032
|
} from "@procore/core-react";
|
|
9059
|
-
import * as
|
|
9033
|
+
import * as React17 from "react";
|
|
9060
9034
|
import { useToastAlertContext } from "@procore/toast-alert";
|
|
9035
|
+
|
|
9036
|
+
// src/transport/context.tsx
|
|
9037
|
+
import React16, { createContext as createContext2, useContext as useContext2 } from "react";
|
|
9038
|
+
var SavedViewsTransportContext = createContext2(void 0);
|
|
9039
|
+
var SavedViewsTransportProvider = ({
|
|
9040
|
+
transport,
|
|
9041
|
+
children
|
|
9042
|
+
}) => /* @__PURE__ */ React16.createElement(SavedViewsTransportContext.Provider, { value: transport }, children);
|
|
9043
|
+
var useSavedViewsTransport = () => {
|
|
9044
|
+
const transport = useContext2(SavedViewsTransportContext);
|
|
9045
|
+
if (!transport) {
|
|
9046
|
+
throw new Error(
|
|
9047
|
+
"useSavedViewsTransport must be used inside <SavedViews> (or a SavedViewsTransportProvider). This usually means a hook is being called outside the saved-views component tree."
|
|
9048
|
+
);
|
|
9049
|
+
}
|
|
9050
|
+
return transport;
|
|
9051
|
+
};
|
|
9052
|
+
var useOptionalSavedViewsTransport = () => useContext2(SavedViewsTransportContext);
|
|
9053
|
+
|
|
9054
|
+
// src/components/menu-items/SavedViewsCollectionsMenuItem.tsx
|
|
9061
9055
|
var RowActionsBox = pt(Flex)`
|
|
9062
9056
|
justify-content: center;
|
|
9063
9057
|
align-items: center;
|
|
@@ -9078,7 +9072,7 @@ var IconWrapper = pt.span`
|
|
|
9078
9072
|
justify-content: center;
|
|
9079
9073
|
`;
|
|
9080
9074
|
var SavedViewCollectionMenuItem = (props) => {
|
|
9081
|
-
const onClick =
|
|
9075
|
+
const onClick = React17.useCallback(
|
|
9082
9076
|
(a2) => {
|
|
9083
9077
|
var _a, _b;
|
|
9084
9078
|
if (!props.item) {
|
|
@@ -9104,6 +9098,8 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
9104
9098
|
};
|
|
9105
9099
|
const { showToast } = useToastAlertContext();
|
|
9106
9100
|
const i18n = useI18nContext2();
|
|
9101
|
+
const transport = useOptionalSavedViewsTransport();
|
|
9102
|
+
const canShareViaUrl = (transport == null ? void 0 : transport.supportsUrlSharing) !== false;
|
|
9107
9103
|
const copyShareLink = async (event) => {
|
|
9108
9104
|
event.stopPropagation();
|
|
9109
9105
|
try {
|
|
@@ -9126,18 +9122,18 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
9126
9122
|
label: i18n.t("savedViews.actions.delete")
|
|
9127
9123
|
}
|
|
9128
9124
|
];
|
|
9129
|
-
const preventEventBubbleToNotTriggerViewSelectEvent =
|
|
9125
|
+
const preventEventBubbleToNotTriggerViewSelectEvent = React17.useCallback(
|
|
9130
9126
|
(e) => {
|
|
9131
9127
|
e.stopPropagation();
|
|
9132
9128
|
},
|
|
9133
9129
|
[]
|
|
9134
9130
|
);
|
|
9135
9131
|
const hasUpdateButton = props.item.view_level !== "default" && props.canUpdate;
|
|
9136
|
-
const hasCopyShareLinkButton = props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary";
|
|
9132
|
+
const hasCopyShareLinkButton = canShareViaUrl && props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary";
|
|
9137
9133
|
const hasClearTemporaryButton = props.item.id === "temporary";
|
|
9138
9134
|
const hasOverflowMenu = props.item.view_level !== "default" && props.canEditOrDelete;
|
|
9139
9135
|
const hasActions = hasUpdateButton || hasCopyShareLinkButton || hasClearTemporaryButton || hasOverflowMenu;
|
|
9140
|
-
return /* @__PURE__ */
|
|
9136
|
+
return /* @__PURE__ */ React17.createElement(
|
|
9141
9137
|
Container2,
|
|
9142
9138
|
{
|
|
9143
9139
|
"aria-selected": Boolean(props.selected),
|
|
@@ -9149,7 +9145,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
9149
9145
|
"data-testid": "saved-view-collection-menu-item",
|
|
9150
9146
|
onKeyDown: preventEventBubbleToNotTriggerViewSelectEvent
|
|
9151
9147
|
},
|
|
9152
|
-
/* @__PURE__ */
|
|
9148
|
+
/* @__PURE__ */ React17.createElement(
|
|
9153
9149
|
"span",
|
|
9154
9150
|
{
|
|
9155
9151
|
"data-testid": "saved-view-display-name",
|
|
@@ -9157,7 +9153,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
9157
9153
|
},
|
|
9158
9154
|
props.item.name
|
|
9159
9155
|
),
|
|
9160
|
-
hasActions && /* @__PURE__ */
|
|
9156
|
+
hasActions && /* @__PURE__ */ React17.createElement(RowActionsBox, null, /* @__PURE__ */ React17.createElement(Box, { justifyContent: "space-between" }, hasUpdateButton && /* @__PURE__ */ React17.createElement(
|
|
9161
9157
|
Button,
|
|
9162
9158
|
{
|
|
9163
9159
|
onClick: updateItem,
|
|
@@ -9168,7 +9164,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
9168
9164
|
loading: props.isUpdateProcessing
|
|
9169
9165
|
},
|
|
9170
9166
|
i18n.t("savedViews.actions.update")
|
|
9171
|
-
), hasCopyShareLinkButton && /* @__PURE__ */
|
|
9167
|
+
), hasCopyShareLinkButton && /* @__PURE__ */ React17.createElement(
|
|
9172
9168
|
Button,
|
|
9173
9169
|
{
|
|
9174
9170
|
onClick: copyShareLink,
|
|
@@ -9177,8 +9173,8 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
9177
9173
|
"aria-label": i18n.t("savedViews.actions.copyShareLink"),
|
|
9178
9174
|
"data-testid": "copy-share-link-button"
|
|
9179
9175
|
},
|
|
9180
|
-
/* @__PURE__ */
|
|
9181
|
-
), hasClearTemporaryButton && /* @__PURE__ */
|
|
9176
|
+
/* @__PURE__ */ React17.createElement(IconWrapper, null, /* @__PURE__ */ React17.createElement(Link_default, { size: "sm" }))
|
|
9177
|
+
), hasClearTemporaryButton && /* @__PURE__ */ React17.createElement(
|
|
9182
9178
|
Button,
|
|
9183
9179
|
{
|
|
9184
9180
|
onClick: (e) => {
|
|
@@ -9192,8 +9188,8 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
9192
9188
|
title: i18n.t("savedViews.actions.clearTemporary"),
|
|
9193
9189
|
"data-testid": "clear-temporary-view-button"
|
|
9194
9190
|
},
|
|
9195
|
-
/* @__PURE__ */
|
|
9196
|
-
)), /* @__PURE__ */
|
|
9191
|
+
/* @__PURE__ */ React17.createElement(IconWrapper, null, /* @__PURE__ */ React17.createElement(Clear_default, { size: "sm" }))
|
|
9192
|
+
)), /* @__PURE__ */ React17.createElement(Box, null, hasOverflowMenu && /* @__PURE__ */ React17.createElement(
|
|
9197
9193
|
DropdownFlyout,
|
|
9198
9194
|
{
|
|
9199
9195
|
"data-testid": "saved-view-overflow-button",
|
|
@@ -9219,15 +9215,9 @@ var ExpandedPanel = pt(Panel)`
|
|
|
9219
9215
|
// src/components/panels/PanelContent.tsx
|
|
9220
9216
|
import { Flex as Flex2, MenuImperative as MenuImperative2, useI18nContext as useI18nContext5 } from "@procore/core-react";
|
|
9221
9217
|
import { useToastAlertContext as useToastAlertContext2 } from "@procore/toast-alert";
|
|
9222
|
-
import
|
|
9223
|
-
|
|
9224
|
-
// src/utils/api/queries.ts
|
|
9225
|
-
import { requestJSON as requestJSON2 } from "@procore/core-http";
|
|
9226
|
-
import { useQuery } from "@tanstack/react-query";
|
|
9218
|
+
import React19 from "react";
|
|
9227
9219
|
|
|
9228
9220
|
// src/utils/api/queriesHandler.ts
|
|
9229
|
-
import { requestJSON } from "@procore/core-http";
|
|
9230
|
-
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
9231
9221
|
import { useI18nContext as useI18nContext3 } from "@procore/core-react";
|
|
9232
9222
|
var getBasePath = (companyId, projectId) => {
|
|
9233
9223
|
if (projectId) {
|
|
@@ -9237,22 +9227,39 @@ var getBasePath = (companyId, projectId) => {
|
|
|
9237
9227
|
};
|
|
9238
9228
|
var useApiRequest = (props, method, mutationKey) => {
|
|
9239
9229
|
const { projectId, companyId, domain, tableName } = props;
|
|
9240
|
-
const
|
|
9230
|
+
const transport = useSavedViewsTransport();
|
|
9231
|
+
const http = transport.useHttp();
|
|
9232
|
+
const cacheControl = transport.useCacheControl();
|
|
9241
9233
|
const { locale } = useI18nContext3();
|
|
9242
9234
|
const basePath = getBasePath(companyId, projectId);
|
|
9243
|
-
const queryKey = [
|
|
9244
|
-
|
|
9235
|
+
const queryKey = [
|
|
9236
|
+
"savedViews",
|
|
9237
|
+
domain,
|
|
9238
|
+
tableName,
|
|
9239
|
+
companyId,
|
|
9240
|
+
projectId
|
|
9241
|
+
];
|
|
9242
|
+
return transport.useMutationAdapter({
|
|
9245
9243
|
mutationKey,
|
|
9246
9244
|
mutationFn: async (savedView) => {
|
|
9247
|
-
let url =
|
|
9248
|
-
|
|
9245
|
+
let url = basePath;
|
|
9246
|
+
let body = { ...savedView };
|
|
9247
|
+
if (method === "DELETE") {
|
|
9249
9248
|
url = `${basePath}/${savedView.share_token}?permissions_domain=${domain}`;
|
|
9249
|
+
} else if (method === "PUT") {
|
|
9250
|
+
url = `${basePath}/${savedView.share_token}`;
|
|
9251
|
+
body = { ...savedView, permissions_domain: domain };
|
|
9250
9252
|
} else {
|
|
9251
|
-
|
|
9253
|
+
body = {
|
|
9254
|
+
...savedView,
|
|
9255
|
+
table_name: tableName,
|
|
9256
|
+
permissions_domain: domain
|
|
9257
|
+
};
|
|
9252
9258
|
}
|
|
9253
|
-
const response = await
|
|
9259
|
+
const response = await http({
|
|
9254
9260
|
method,
|
|
9255
|
-
|
|
9261
|
+
url,
|
|
9262
|
+
body: JSON.stringify(body),
|
|
9256
9263
|
headers: {
|
|
9257
9264
|
"Content-Type": "application/json",
|
|
9258
9265
|
"Accept-Language": locale
|
|
@@ -9265,23 +9272,19 @@ var useApiRequest = (props, method, mutationKey) => {
|
|
|
9265
9272
|
},
|
|
9266
9273
|
onSuccess: (savedView) => {
|
|
9267
9274
|
if (method === "DELETE" || method === "POST") {
|
|
9268
|
-
|
|
9269
|
-
queryKey
|
|
9270
|
-
});
|
|
9275
|
+
cacheControl.invalidate(queryKey);
|
|
9271
9276
|
return;
|
|
9272
9277
|
} else {
|
|
9273
|
-
const oldData =
|
|
9278
|
+
const oldData = cacheControl.getData(queryKey);
|
|
9274
9279
|
const oldView = oldData == null ? void 0 : oldData.find(
|
|
9275
9280
|
(item) => item.share_token === savedView.share_token
|
|
9276
9281
|
);
|
|
9277
9282
|
if ((oldView == null ? void 0 : oldView.name) !== savedView.name) {
|
|
9278
|
-
|
|
9279
|
-
queryKey
|
|
9280
|
-
});
|
|
9283
|
+
cacheControl.invalidate(queryKey);
|
|
9281
9284
|
return;
|
|
9282
9285
|
}
|
|
9283
9286
|
}
|
|
9284
|
-
|
|
9287
|
+
cacheControl.setData(queryKey, (oldData) => {
|
|
9285
9288
|
if (!oldData) return [savedView];
|
|
9286
9289
|
return oldData.map(
|
|
9287
9290
|
(item) => item.share_token === savedView.share_token ? savedView : item
|
|
@@ -9310,13 +9313,17 @@ var getBasePath2 = (companyId, projectId) => {
|
|
|
9310
9313
|
};
|
|
9311
9314
|
var useSavedViewsQuery = (props) => {
|
|
9312
9315
|
const { projectId, companyId, domain, tableName } = props;
|
|
9316
|
+
const transport = useSavedViewsTransport();
|
|
9317
|
+
const http = transport.useHttp();
|
|
9313
9318
|
const basePath = getBasePath2(companyId, projectId);
|
|
9314
9319
|
const url = `${basePath}?table_name=${tableName}&permissions_domain=${domain}`;
|
|
9315
|
-
return
|
|
9320
|
+
return transport.useQueryAdapter({
|
|
9316
9321
|
queryKey: ["savedViews", domain, tableName, companyId, projectId],
|
|
9317
9322
|
queryFn: async () => {
|
|
9318
9323
|
const getUrl = `${url}&per_page=${PAGE_SIZE}`;
|
|
9319
|
-
const response = await
|
|
9324
|
+
const response = await http({
|
|
9325
|
+
method: "GET",
|
|
9326
|
+
url: getUrl,
|
|
9320
9327
|
priority: "low"
|
|
9321
9328
|
});
|
|
9322
9329
|
return response.data;
|
|
@@ -9325,12 +9332,16 @@ var useSavedViewsQuery = (props) => {
|
|
|
9325
9332
|
};
|
|
9326
9333
|
var useSavedViewsPermissions = (props) => {
|
|
9327
9334
|
const { projectId, companyId, domain } = props;
|
|
9335
|
+
const transport = useSavedViewsTransport();
|
|
9336
|
+
const http = transport.useHttp();
|
|
9328
9337
|
const basePath = getBasePath2(companyId, projectId);
|
|
9329
9338
|
const url = `${basePath}/permissions?permissions_domain=${domain}`;
|
|
9330
|
-
return
|
|
9339
|
+
return transport.useQueryAdapter({
|
|
9331
9340
|
queryKey: ["savedViewsConfig", domain, companyId, projectId],
|
|
9332
9341
|
queryFn: async () => {
|
|
9333
|
-
const response = await
|
|
9342
|
+
const response = await http({
|
|
9343
|
+
method: "GET",
|
|
9344
|
+
url,
|
|
9334
9345
|
priority: "low"
|
|
9335
9346
|
});
|
|
9336
9347
|
return response.data;
|
|
@@ -9354,13 +9365,17 @@ var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
|
9354
9365
|
]);
|
|
9355
9366
|
var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
9356
9367
|
const { projectId, companyId, domain } = queryInput;
|
|
9368
|
+
const transport = useSavedViewsTransport();
|
|
9369
|
+
const http = transport.useHttp();
|
|
9357
9370
|
const basePath = getBasePath2(companyId, projectId);
|
|
9358
|
-
return
|
|
9371
|
+
return transport.useQueryAdapter({
|
|
9359
9372
|
enabled: enabled && Boolean(savedViewToken),
|
|
9360
9373
|
queryKey: ["savedView", savedViewToken, companyId, projectId],
|
|
9361
9374
|
queryFn: async () => {
|
|
9362
9375
|
const url = `${basePath}/${savedViewToken}?permissions_domain=${domain}`;
|
|
9363
|
-
const response = await
|
|
9376
|
+
const response = await http({
|
|
9377
|
+
method: "GET",
|
|
9378
|
+
url,
|
|
9364
9379
|
priority: "low"
|
|
9365
9380
|
});
|
|
9366
9381
|
return response.data;
|
|
@@ -9601,15 +9616,15 @@ import {
|
|
|
9601
9616
|
Typography,
|
|
9602
9617
|
useI18nContext as useI18nContext4
|
|
9603
9618
|
} from "@procore/core-react";
|
|
9604
|
-
import
|
|
9619
|
+
import React18 from "react";
|
|
9605
9620
|
var groupIcon = (group) => {
|
|
9606
9621
|
switch (group) {
|
|
9607
9622
|
case "personal":
|
|
9608
|
-
return /* @__PURE__ */
|
|
9623
|
+
return /* @__PURE__ */ React18.createElement(Person_default, null);
|
|
9609
9624
|
case "project":
|
|
9610
|
-
return /* @__PURE__ */
|
|
9625
|
+
return /* @__PURE__ */ React18.createElement(Excavator_default, null);
|
|
9611
9626
|
case "company":
|
|
9612
|
-
return /* @__PURE__ */
|
|
9627
|
+
return /* @__PURE__ */ React18.createElement(Building_default, null);
|
|
9613
9628
|
}
|
|
9614
9629
|
};
|
|
9615
9630
|
var StyledButton = pt(Button2)`
|
|
@@ -9619,7 +9634,7 @@ var StyledButton = pt(Button2)`
|
|
|
9619
9634
|
`;
|
|
9620
9635
|
var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
|
|
9621
9636
|
const I18n = useI18nContext4();
|
|
9622
|
-
return /* @__PURE__ */
|
|
9637
|
+
return /* @__PURE__ */ React18.createElement(Box2, { style: { width: "100%" } }, /* @__PURE__ */ React18.createElement(
|
|
9623
9638
|
StyledButton,
|
|
9624
9639
|
{
|
|
9625
9640
|
block: true,
|
|
@@ -9632,10 +9647,10 @@ var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
|
|
|
9632
9647
|
onClick: () => toggleGroup(group),
|
|
9633
9648
|
"aria-controls": `saved-views-collections-${group}`,
|
|
9634
9649
|
"aria-expanded": expanded,
|
|
9635
|
-
icon: expanded ? /* @__PURE__ */
|
|
9650
|
+
icon: expanded ? /* @__PURE__ */ React18.createElement(ChevronDown_default, { size: "sm" }) : /* @__PURE__ */ React18.createElement(ChevronRight_default, { size: "sm" })
|
|
9636
9651
|
},
|
|
9637
9652
|
groupIcon(group),
|
|
9638
|
-
/* @__PURE__ */
|
|
9653
|
+
/* @__PURE__ */ React18.createElement(Typography, { weight: "semibold" }, I18n.t(`savedViews.viewLevel.${group}`))
|
|
9639
9654
|
));
|
|
9640
9655
|
};
|
|
9641
9656
|
var ViewLevelHeader_default = ViewLevelHeader;
|
|
@@ -9689,10 +9704,10 @@ var PanelContent = (props) => {
|
|
|
9689
9704
|
const { data: savedViewsFromQuery, error: savedViewsError } = useSavedViewsQuery(props.queryInput);
|
|
9690
9705
|
const updateMutation = useUpdateSavedView(queryInput);
|
|
9691
9706
|
const { mutate: updateSavedView } = updateMutation;
|
|
9692
|
-
const isUpdateLoading =
|
|
9707
|
+
const isUpdateLoading = updateMutation.isPending;
|
|
9693
9708
|
const savedViews = props.savedViews ?? savedViewsFromQuery;
|
|
9694
|
-
const errorToastRef =
|
|
9695
|
-
|
|
9709
|
+
const errorToastRef = React19.useRef(null);
|
|
9710
|
+
React19.useEffect(() => {
|
|
9696
9711
|
if (savedViewsError && savedViewsError !== errorToastRef.current) {
|
|
9697
9712
|
showToast.error(I18n.t("savedViews.errors.fetch"));
|
|
9698
9713
|
errorToastRef.current = savedViewsError;
|
|
@@ -9722,7 +9737,7 @@ var PanelContent = (props) => {
|
|
|
9722
9737
|
}
|
|
9723
9738
|
});
|
|
9724
9739
|
};
|
|
9725
|
-
return /* @__PURE__ */
|
|
9740
|
+
return /* @__PURE__ */ React19.createElement(Panel2, { "data-testid": "inner-panel" }, /* @__PURE__ */ React19.createElement(Flex2, { direction: "column", style: { height: "100%", width: "100%" } }, (temporaryView || presetViews) && /* @__PURE__ */ React19.createElement(
|
|
9726
9741
|
StyledMenuImperative,
|
|
9727
9742
|
{
|
|
9728
9743
|
role: "listbox",
|
|
@@ -9732,7 +9747,7 @@ var PanelContent = (props) => {
|
|
|
9732
9747
|
}
|
|
9733
9748
|
}
|
|
9734
9749
|
},
|
|
9735
|
-
/* @__PURE__ */
|
|
9750
|
+
/* @__PURE__ */ React19.createElement(MenuImperative2.Options, null, temporaryView && /* @__PURE__ */ React19.createElement(
|
|
9736
9751
|
Row,
|
|
9737
9752
|
{
|
|
9738
9753
|
key: temporaryView.id,
|
|
@@ -9741,7 +9756,7 @@ var PanelContent = (props) => {
|
|
|
9741
9756
|
"aria-current": isTemporarySelected ? "true" : void 0,
|
|
9742
9757
|
ref: isTemporarySelected ? selectedRowRef : null
|
|
9743
9758
|
},
|
|
9744
|
-
/* @__PURE__ */
|
|
9759
|
+
/* @__PURE__ */ React19.createElement(
|
|
9745
9760
|
SavedViewCollectionMenuItem,
|
|
9746
9761
|
{
|
|
9747
9762
|
item: temporaryView,
|
|
@@ -9751,7 +9766,7 @@ var PanelContent = (props) => {
|
|
|
9751
9766
|
)
|
|
9752
9767
|
), presetViews.map((presetView) => {
|
|
9753
9768
|
const isSelected = (selectedSavedView == null ? void 0 : selectedSavedView.id) === presetView.id;
|
|
9754
|
-
return /* @__PURE__ */
|
|
9769
|
+
return /* @__PURE__ */ React19.createElement(
|
|
9755
9770
|
Row,
|
|
9756
9771
|
{
|
|
9757
9772
|
key: presetView.id,
|
|
@@ -9760,7 +9775,7 @@ var PanelContent = (props) => {
|
|
|
9760
9775
|
"aria-current": isSelected ? "true" : void 0,
|
|
9761
9776
|
ref: isSelected ? selectedRowRef : null
|
|
9762
9777
|
},
|
|
9763
|
-
/* @__PURE__ */
|
|
9778
|
+
/* @__PURE__ */ React19.createElement(
|
|
9764
9779
|
SavedViewCollectionMenuItem,
|
|
9765
9780
|
{
|
|
9766
9781
|
item: presetView,
|
|
@@ -9774,14 +9789,14 @@ var PanelContent = (props) => {
|
|
|
9774
9789
|
const views = isExpanded && savedViews ? savedViews.filter(
|
|
9775
9790
|
(view) => view.view_level === level && view.id !== "temporary"
|
|
9776
9791
|
) : [];
|
|
9777
|
-
return /* @__PURE__ */
|
|
9792
|
+
return /* @__PURE__ */ React19.createElement(React19.Fragment, { key: level }, /* @__PURE__ */ React19.createElement(
|
|
9778
9793
|
ViewLevelHeader_default,
|
|
9779
9794
|
{
|
|
9780
9795
|
group: level,
|
|
9781
9796
|
toggleGroup,
|
|
9782
9797
|
expanded: isExpanded
|
|
9783
9798
|
}
|
|
9784
|
-
), isExpanded && views.length > 0 && /* @__PURE__ */
|
|
9799
|
+
), isExpanded && views.length > 0 && /* @__PURE__ */ React19.createElement(
|
|
9785
9800
|
StyledMenuImperative,
|
|
9786
9801
|
{
|
|
9787
9802
|
id: `saved-views-collections-${level}`,
|
|
@@ -9792,7 +9807,7 @@ var PanelContent = (props) => {
|
|
|
9792
9807
|
}
|
|
9793
9808
|
}
|
|
9794
9809
|
},
|
|
9795
|
-
/* @__PURE__ */
|
|
9810
|
+
/* @__PURE__ */ React19.createElement(MenuImperative2.Options, null, views.map((view) => {
|
|
9796
9811
|
const isSelected = (selectedSavedView == null ? void 0 : selectedSavedView.id) === view.id;
|
|
9797
9812
|
const canUpdate = isSelected && hasPermissionForViewLevel(
|
|
9798
9813
|
view.view_level,
|
|
@@ -9804,7 +9819,7 @@ var PanelContent = (props) => {
|
|
|
9804
9819
|
props.provider
|
|
9805
9820
|
);
|
|
9806
9821
|
const canEditOrDelete = isSelected && hasPermissionForViewLevel(view.view_level, permissions);
|
|
9807
|
-
return /* @__PURE__ */
|
|
9822
|
+
return /* @__PURE__ */ React19.createElement(
|
|
9808
9823
|
Row,
|
|
9809
9824
|
{
|
|
9810
9825
|
key: view.id,
|
|
@@ -9813,7 +9828,7 @@ var PanelContent = (props) => {
|
|
|
9813
9828
|
"aria-current": isSelected ? "true" : void 0,
|
|
9814
9829
|
ref: isSelected ? selectedRowRef : null
|
|
9815
9830
|
},
|
|
9816
|
-
/* @__PURE__ */
|
|
9831
|
+
/* @__PURE__ */ React19.createElement(
|
|
9817
9832
|
SavedViewCollectionMenuItem,
|
|
9818
9833
|
{
|
|
9819
9834
|
item: view,
|
|
@@ -9843,8 +9858,7 @@ import {
|
|
|
9843
9858
|
Tooltip as Tooltip2,
|
|
9844
9859
|
useI18nContext as useI18nContext12
|
|
9845
9860
|
} from "@procore/core-react";
|
|
9846
|
-
import
|
|
9847
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
9861
|
+
import React25, { useState as useState5, useEffect as useEffect6, useCallback as useCallback5 } from "react";
|
|
9848
9862
|
import { useToastAlertContext as useToastAlertContext3, ToastAlertProvider } from "@procore/toast-alert";
|
|
9849
9863
|
|
|
9850
9864
|
// src/components/modals/DeleteConfirmationModal.tsx
|
|
@@ -9855,14 +9869,14 @@ import {
|
|
|
9855
9869
|
P as P2,
|
|
9856
9870
|
useI18nContext as useI18nContext6
|
|
9857
9871
|
} from "@procore/core-react";
|
|
9858
|
-
import
|
|
9872
|
+
import React20 from "react";
|
|
9859
9873
|
var SavedViewsDeleteConfirmationModalShared = ({
|
|
9860
9874
|
onCancel,
|
|
9861
9875
|
onDelete,
|
|
9862
9876
|
open
|
|
9863
9877
|
}) => {
|
|
9864
9878
|
const i18n = useI18nContext6();
|
|
9865
|
-
return /* @__PURE__ */
|
|
9879
|
+
return /* @__PURE__ */ React20.createElement(
|
|
9866
9880
|
ConfirmModal,
|
|
9867
9881
|
{
|
|
9868
9882
|
"data-testid": "delete-confirmation-modal",
|
|
@@ -9872,13 +9886,13 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
9872
9886
|
onClose: onCancel,
|
|
9873
9887
|
style: { overflowWrap: "anywhere" }
|
|
9874
9888
|
},
|
|
9875
|
-
/* @__PURE__ */
|
|
9876
|
-
/* @__PURE__ */
|
|
9889
|
+
/* @__PURE__ */ React20.createElement(Modal.Body, null, /* @__PURE__ */ React20.createElement(P2, null, i18n.t("savedViews.modal.delete.description"))),
|
|
9890
|
+
/* @__PURE__ */ React20.createElement(Modal.Footer, null, /* @__PURE__ */ React20.createElement(Modal.FooterButtons, null, /* @__PURE__ */ React20.createElement(Button3, { variant: "secondary", onClick: onCancel }, i18n.t("savedViews.actions.cancel")), /* @__PURE__ */ React20.createElement(Button3, { variant: "primary", onClick: onDelete }, i18n.t("savedViews.actions.delete"))))
|
|
9877
9891
|
);
|
|
9878
9892
|
};
|
|
9879
9893
|
|
|
9880
9894
|
// src/components/modals/form-modal/FormModal.tsx
|
|
9881
|
-
import
|
|
9895
|
+
import React23 from "react";
|
|
9882
9896
|
|
|
9883
9897
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
9884
9898
|
import {
|
|
@@ -9893,7 +9907,7 @@ import {
|
|
|
9893
9907
|
Typography as Typography2,
|
|
9894
9908
|
useI18nContext as useI18nContext8
|
|
9895
9909
|
} from "@procore/core-react";
|
|
9896
|
-
import * as
|
|
9910
|
+
import * as React22 from "react";
|
|
9897
9911
|
import * as yup from "yup";
|
|
9898
9912
|
|
|
9899
9913
|
// src/components/modals/form-modal/FormModalBaseUtils.ts
|
|
@@ -9930,7 +9944,7 @@ function extractMessage(error, I18n) {
|
|
|
9930
9944
|
|
|
9931
9945
|
// src/components/modals/form-modal/NameInputField.tsx
|
|
9932
9946
|
import { Form, useFormContext, useI18nContext as useI18nContext7 } from "@procore/core-react";
|
|
9933
|
-
import * as
|
|
9947
|
+
import * as React21 from "react";
|
|
9934
9948
|
var NAME_INPUT_ID = "saved-view-form-name-input";
|
|
9935
9949
|
var NameInputField = ({
|
|
9936
9950
|
error,
|
|
@@ -9939,13 +9953,13 @@ var NameInputField = ({
|
|
|
9939
9953
|
const I18n = useI18nContext7();
|
|
9940
9954
|
const label = I18n.t("savedViews.modal.fields.name");
|
|
9941
9955
|
const { errors: formErrors, submitCount } = useFormContext();
|
|
9942
|
-
|
|
9956
|
+
React21.useEffect(() => {
|
|
9943
9957
|
var _a;
|
|
9944
9958
|
if (submitCount > 0 && (formErrors == null ? void 0 : formErrors.name)) {
|
|
9945
9959
|
(_a = document.getElementById(NAME_INPUT_ID)) == null ? void 0 : _a.focus();
|
|
9946
9960
|
}
|
|
9947
9961
|
}, [formErrors == null ? void 0 : formErrors.name, submitCount]);
|
|
9948
|
-
return /* @__PURE__ */
|
|
9962
|
+
return /* @__PURE__ */ React21.createElement(
|
|
9949
9963
|
Form.Text,
|
|
9950
9964
|
{
|
|
9951
9965
|
id: NAME_INPUT_ID,
|
|
@@ -10037,7 +10051,7 @@ var FormModalBase = ({
|
|
|
10037
10051
|
I18n,
|
|
10038
10052
|
isProjectLevelTool
|
|
10039
10053
|
);
|
|
10040
|
-
return /* @__PURE__ */
|
|
10054
|
+
return /* @__PURE__ */ React22.createElement(
|
|
10041
10055
|
Modal2,
|
|
10042
10056
|
{
|
|
10043
10057
|
howToClose: ["x", "scrim"],
|
|
@@ -10046,7 +10060,7 @@ var FormModalBase = ({
|
|
|
10046
10060
|
width: "md",
|
|
10047
10061
|
"data-testid": "create-update-modal"
|
|
10048
10062
|
},
|
|
10049
|
-
/* @__PURE__ */
|
|
10063
|
+
/* @__PURE__ */ React22.createElement(ScrollContainer, null, /* @__PURE__ */ React22.createElement(Modal2.Header, { style: { borderBottom: `1px solid ${colors3.gray85}` } }, /* @__PURE__ */ React22.createElement(Modal2.Heading, null, header)), /* @__PURE__ */ React22.createElement(
|
|
10050
10064
|
Form2,
|
|
10051
10065
|
{
|
|
10052
10066
|
initialValues: {
|
|
@@ -10072,25 +10086,25 @@ var FormModalBase = ({
|
|
|
10072
10086
|
onReset: onCancel,
|
|
10073
10087
|
validateOnChange: true
|
|
10074
10088
|
},
|
|
10075
|
-
/* @__PURE__ */
|
|
10089
|
+
/* @__PURE__ */ React22.createElement(Form2.Form, { name: header }, /* @__PURE__ */ React22.createElement(
|
|
10076
10090
|
Modal2.Body,
|
|
10077
10091
|
{
|
|
10078
10092
|
style: { paddingTop: 0, paddingBottom: 0, marginTop: spacing2.lg }
|
|
10079
10093
|
},
|
|
10080
|
-
errors && /* @__PURE__ */
|
|
10081
|
-
/* @__PURE__ */
|
|
10094
|
+
errors && /* @__PURE__ */ React22.createElement(ErrorBanner, { style: { marginBottom: spacing2.xl } }, /* @__PURE__ */ React22.createElement(Banner.Content, null, /* @__PURE__ */ React22.createElement(Banner.Title, null, I18n.t("savedViews.modal.errors.title", { mode })), /* @__PURE__ */ React22.createElement(Banner.Body, null, (errors == null ? void 0 : errors.form) || I18n.t(`savedViews.modal.errors.description.${mode}`)))),
|
|
10095
|
+
/* @__PURE__ */ React22.createElement(Form2.Row, null, /* @__PURE__ */ React22.createElement(
|
|
10082
10096
|
NameInputField,
|
|
10083
10097
|
{
|
|
10084
10098
|
error: errors == null ? void 0 : errors.name,
|
|
10085
10099
|
onResetMutations: resetMutations
|
|
10086
10100
|
}
|
|
10087
10101
|
)),
|
|
10088
|
-
/* @__PURE__ */
|
|
10102
|
+
/* @__PURE__ */ React22.createElement(
|
|
10089
10103
|
Form2.Row,
|
|
10090
10104
|
{
|
|
10091
10105
|
style: { marginTop: (errors == null ? void 0 : errors.name) ? spacing2.xl : spacing2.none }
|
|
10092
10106
|
},
|
|
10093
|
-
/* @__PURE__ */
|
|
10107
|
+
/* @__PURE__ */ React22.createElement(
|
|
10094
10108
|
Form2.TextArea,
|
|
10095
10109
|
{
|
|
10096
10110
|
name: "description",
|
|
@@ -10101,7 +10115,7 @@ var FormModalBase = ({
|
|
|
10101
10115
|
}
|
|
10102
10116
|
)
|
|
10103
10117
|
),
|
|
10104
|
-
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */
|
|
10118
|
+
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React22.createElement(Form2.Row, null, /* @__PURE__ */ React22.createElement(
|
|
10105
10119
|
Form2.Select,
|
|
10106
10120
|
{
|
|
10107
10121
|
name: "view_level",
|
|
@@ -10111,8 +10125,8 @@ var FormModalBase = ({
|
|
|
10111
10125
|
onSearch: false,
|
|
10112
10126
|
onClear: false
|
|
10113
10127
|
}
|
|
10114
|
-
)) : /* @__PURE__ */
|
|
10115
|
-
), /* @__PURE__ */
|
|
10128
|
+
)) : /* @__PURE__ */ React22.createElement(React22.Fragment, null)
|
|
10129
|
+
), /* @__PURE__ */ React22.createElement(Modal2.Footer, { style: { borderTop: `1px solid ${colors3.gray85}` } }, /* @__PURE__ */ React22.createElement(Flex3, { grow: "1", justifyContent: "space-between", alignItems: "center" }, /* @__PURE__ */ React22.createElement(Typography2, { color: "gray45", italic: true }, /* @__PURE__ */ React22.createElement(Typography2, { color: "red45" }, "*"), " ", I18n.t("savedViews.modal.info.required_fields")), /* @__PURE__ */ React22.createElement(Modal2.FooterButtons, null, /* @__PURE__ */ React22.createElement(Button4, { type: "reset", variant: "tertiary", disabled: isLoading }, I18n.t("savedViews.actions.cancel")), /* @__PURE__ */ React22.createElement(
|
|
10116
10130
|
Button4,
|
|
10117
10131
|
{
|
|
10118
10132
|
"data-testid": "create-update-modal-button",
|
|
@@ -10142,7 +10156,7 @@ var FormModal = ({
|
|
|
10142
10156
|
defaultView
|
|
10143
10157
|
}) => {
|
|
10144
10158
|
const i18n = useI18nContext9();
|
|
10145
|
-
return /* @__PURE__ */
|
|
10159
|
+
return /* @__PURE__ */ React23.createElement(
|
|
10146
10160
|
FormModalBase,
|
|
10147
10161
|
{
|
|
10148
10162
|
open,
|
|
@@ -10176,7 +10190,7 @@ import {
|
|
|
10176
10190
|
Typography as Typography3,
|
|
10177
10191
|
useI18nContext as useI18nContext10
|
|
10178
10192
|
} from "@procore/core-react";
|
|
10179
|
-
import * as
|
|
10193
|
+
import * as React24 from "react";
|
|
10180
10194
|
import * as yup2 from "yup";
|
|
10181
10195
|
var SharedViewFormModal = ({
|
|
10182
10196
|
open,
|
|
@@ -10199,7 +10213,7 @@ var SharedViewFormModal = ({
|
|
|
10199
10213
|
const handleOnSubmit = (data) => {
|
|
10200
10214
|
onCreateView(data.name, data.description);
|
|
10201
10215
|
};
|
|
10202
|
-
return /* @__PURE__ */
|
|
10216
|
+
return /* @__PURE__ */ React24.createElement(
|
|
10203
10217
|
Modal3,
|
|
10204
10218
|
{
|
|
10205
10219
|
"data-testid": "shared-view-form-modal",
|
|
@@ -10208,7 +10222,7 @@ var SharedViewFormModal = ({
|
|
|
10208
10222
|
onClose,
|
|
10209
10223
|
style: { width: "540px" }
|
|
10210
10224
|
},
|
|
10211
|
-
/* @__PURE__ */
|
|
10225
|
+
/* @__PURE__ */ React24.createElement(
|
|
10212
10226
|
Modal3.Header,
|
|
10213
10227
|
{
|
|
10214
10228
|
onClose,
|
|
@@ -10219,9 +10233,9 @@ var SharedViewFormModal = ({
|
|
|
10219
10233
|
paddingRight: spacing3.xl
|
|
10220
10234
|
}
|
|
10221
10235
|
},
|
|
10222
|
-
/* @__PURE__ */
|
|
10236
|
+
/* @__PURE__ */ React24.createElement(Modal3.Heading, null, I18n.t("savedViews.modal.create.title"))
|
|
10223
10237
|
),
|
|
10224
|
-
/* @__PURE__ */
|
|
10238
|
+
/* @__PURE__ */ React24.createElement(
|
|
10225
10239
|
P3,
|
|
10226
10240
|
{
|
|
10227
10241
|
style: {
|
|
@@ -10236,7 +10250,7 @@ var SharedViewFormModal = ({
|
|
|
10236
10250
|
},
|
|
10237
10251
|
I18n.t("savedViews.modal.copyConfirmation.description")
|
|
10238
10252
|
),
|
|
10239
|
-
/* @__PURE__ */
|
|
10253
|
+
/* @__PURE__ */ React24.createElement(
|
|
10240
10254
|
Form3,
|
|
10241
10255
|
{
|
|
10242
10256
|
initialValues: {
|
|
@@ -10255,7 +10269,7 @@ var SharedViewFormModal = ({
|
|
|
10255
10269
|
onSubmit: handleOnSubmit,
|
|
10256
10270
|
validateOnChange: true
|
|
10257
10271
|
},
|
|
10258
|
-
/* @__PURE__ */
|
|
10272
|
+
/* @__PURE__ */ React24.createElement(Form3.Form, { name: "share-view-form" }, /* @__PURE__ */ React24.createElement(
|
|
10259
10273
|
Modal3.Body,
|
|
10260
10274
|
{
|
|
10261
10275
|
style: {
|
|
@@ -10264,22 +10278,22 @@ var SharedViewFormModal = ({
|
|
|
10264
10278
|
borderTop: `1px solid ${colors4.gray85}`
|
|
10265
10279
|
}
|
|
10266
10280
|
},
|
|
10267
|
-
errors && /* @__PURE__ */
|
|
10281
|
+
errors && /* @__PURE__ */ React24.createElement(ErrorBanner2, { style: { marginBottom: spacing3.xl } }, /* @__PURE__ */ React24.createElement(Banner2.Content, null, /* @__PURE__ */ React24.createElement(Banner2.Title, null, I18n.t("savedViews.modal.errors.title", {
|
|
10268
10282
|
mode: "create"
|
|
10269
|
-
})), /* @__PURE__ */
|
|
10270
|
-
/* @__PURE__ */
|
|
10283
|
+
})), /* @__PURE__ */ React24.createElement(Banner2.Body, null, (errors == null ? void 0 : errors.form) || I18n.t("savedViews.modal.errors.description.create")))),
|
|
10284
|
+
/* @__PURE__ */ React24.createElement(Form3.Row, null, /* @__PURE__ */ React24.createElement(
|
|
10271
10285
|
NameInputField,
|
|
10272
10286
|
{
|
|
10273
10287
|
error: errors == null ? void 0 : errors.name,
|
|
10274
10288
|
onResetMutations: handleNameChange
|
|
10275
10289
|
}
|
|
10276
10290
|
)),
|
|
10277
|
-
/* @__PURE__ */
|
|
10291
|
+
/* @__PURE__ */ React24.createElement(
|
|
10278
10292
|
Form3.Row,
|
|
10279
10293
|
{
|
|
10280
10294
|
style: { marginTop: (errors == null ? void 0 : errors.name) ? spacing3.xl : spacing3.none }
|
|
10281
10295
|
},
|
|
10282
|
-
/* @__PURE__ */
|
|
10296
|
+
/* @__PURE__ */ React24.createElement(
|
|
10283
10297
|
Form3.TextArea,
|
|
10284
10298
|
{
|
|
10285
10299
|
name: "description",
|
|
@@ -10290,7 +10304,7 @@ var SharedViewFormModal = ({
|
|
|
10290
10304
|
}
|
|
10291
10305
|
)
|
|
10292
10306
|
)
|
|
10293
|
-
), /* @__PURE__ */
|
|
10307
|
+
), /* @__PURE__ */ React24.createElement(Modal3.Footer, { style: { borderTop: `1px solid ${colors4.gray85}` } }, /* @__PURE__ */ React24.createElement(Flex4, { grow: "1", justifyContent: "space-between", alignItems: "center" }, /* @__PURE__ */ React24.createElement(Typography3, { color: "gray45", italic: true }, /* @__PURE__ */ React24.createElement(Typography3, { color: "red45" }, "*"), " ", I18n.t("savedViews.modal.info.required_fields")), /* @__PURE__ */ React24.createElement(Modal3.FooterButtons, null, /* @__PURE__ */ React24.createElement(
|
|
10294
10308
|
Button5,
|
|
10295
10309
|
{
|
|
10296
10310
|
variant: "secondary",
|
|
@@ -10299,7 +10313,7 @@ var SharedViewFormModal = ({
|
|
|
10299
10313
|
disabled: isCreating
|
|
10300
10314
|
},
|
|
10301
10315
|
I18n.t("savedViews.actions.viewTemporarily")
|
|
10302
|
-
), /* @__PURE__ */
|
|
10316
|
+
), /* @__PURE__ */ React24.createElement(
|
|
10303
10317
|
Button5,
|
|
10304
10318
|
{
|
|
10305
10319
|
type: "submit",
|
|
@@ -10316,7 +10330,6 @@ var SharedViewFormModal = ({
|
|
|
10316
10330
|
|
|
10317
10331
|
// src/utils/hooks/useViewSelection.ts
|
|
10318
10332
|
import { useState as useState4, useCallback as useCallback4, useEffect as useEffect4, useRef as useRef3, useMemo as useMemo3 } from "react";
|
|
10319
|
-
import { useSearchParams } from "react-router-dom";
|
|
10320
10333
|
import { useI18nContext as useI18nContext11 } from "@procore/core-react";
|
|
10321
10334
|
|
|
10322
10335
|
// src/utils/viewStorage.ts
|
|
@@ -10361,42 +10374,24 @@ var areRowGroupStatesEqual = (a2, b2) => {
|
|
|
10361
10374
|
if (a2.length !== b2.length) return false;
|
|
10362
10375
|
return a2.every((val, idx) => val === b2[idx]);
|
|
10363
10376
|
};
|
|
10364
|
-
var
|
|
10365
|
-
if (view.id === "default"
|
|
10366
|
-
|
|
10367
|
-
}
|
|
10377
|
+
var getViewTokenForView = (view) => {
|
|
10378
|
+
if (view.id === "default") return "default";
|
|
10379
|
+
if (view.id === "temporary") return "temporary";
|
|
10368
10380
|
return view.share_token;
|
|
10369
10381
|
};
|
|
10370
|
-
var setSavedViewParam = (token2, setSearchParams) => {
|
|
10371
|
-
setSearchParams(
|
|
10372
|
-
(currentParams) => {
|
|
10373
|
-
const updatedParams = new URLSearchParams(currentParams);
|
|
10374
|
-
updatedParams.set("saved-view", token2);
|
|
10375
|
-
return updatedParams;
|
|
10376
|
-
},
|
|
10377
|
-
{ replace: true }
|
|
10378
|
-
);
|
|
10379
|
-
};
|
|
10380
10382
|
var checkIsViewSelected = (selectedView, viewId) => {
|
|
10381
10383
|
return (selectedView == null ? void 0 : selectedView.share_token) === viewId || (selectedView == null ? void 0 : selectedView.id) === viewId;
|
|
10382
10384
|
};
|
|
10383
10385
|
var findViewByToken = (views, token2) => {
|
|
10384
10386
|
return views.find((view) => view.share_token === token2);
|
|
10385
10387
|
};
|
|
10386
|
-
var setViewInUrl = (view, setSearchParams) => {
|
|
10387
|
-
setSavedViewParam(getViewToken(view), setSearchParams);
|
|
10388
|
-
};
|
|
10389
|
-
var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
10390
|
-
if (previousParam && !currentParam) {
|
|
10391
|
-
setSavedViewParam(previousParam, setSearchParams);
|
|
10392
|
-
}
|
|
10393
|
-
};
|
|
10394
10388
|
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, tableConfig) => {
|
|
10395
10389
|
const I18n = useI18nContext11();
|
|
10390
|
+
const transport = useSavedViewsTransport();
|
|
10391
|
+
const urlAdapter = transport.useUrlAdapter();
|
|
10396
10392
|
const projectIdSegment = config.projectId ?? "company";
|
|
10397
10393
|
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${projectIdSegment}_${config.userId}`;
|
|
10398
10394
|
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
10399
|
-
const [searchParams, setSearchParams] = useSearchParams();
|
|
10400
10395
|
const previousSavedViewParamRef = useRef3(null);
|
|
10401
10396
|
const intendedTokenRef = useRef3(null);
|
|
10402
10397
|
const [selectedSavedView, setSelectedSavedView] = useState4(() => {
|
|
@@ -10410,10 +10405,10 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
|
|
|
10410
10405
|
const persistViewToStorageAndUrl = useCallback4(
|
|
10411
10406
|
(view) => {
|
|
10412
10407
|
ViewStorage.save(storageKey, view);
|
|
10413
|
-
intendedTokenRef.current =
|
|
10414
|
-
|
|
10408
|
+
intendedTokenRef.current = getViewTokenForView(view);
|
|
10409
|
+
urlAdapter.setViewToken(getViewTokenForView(view));
|
|
10415
10410
|
},
|
|
10416
|
-
[storageKey,
|
|
10411
|
+
[storageKey, urlAdapter]
|
|
10417
10412
|
);
|
|
10418
10413
|
const baseViews = useMemo3(
|
|
10419
10414
|
() => [...savedViews ?? [], ...presetViews ?? []],
|
|
@@ -10467,28 +10462,26 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
|
|
|
10467
10462
|
openSharedViewModal(viewId);
|
|
10468
10463
|
}
|
|
10469
10464
|
});
|
|
10465
|
+
const savedViewIdFromUrl = urlAdapter.getViewToken();
|
|
10470
10466
|
useEffect4(() => {
|
|
10471
|
-
const savedViewId = searchParams.get("saved-view");
|
|
10472
10467
|
const intendedToken = intendedTokenRef.current;
|
|
10473
|
-
if (intendedToken !== null &&
|
|
10474
|
-
|
|
10468
|
+
if (intendedToken !== null && savedViewIdFromUrl !== intendedToken) {
|
|
10469
|
+
urlAdapter.setViewToken(intendedToken);
|
|
10475
10470
|
return;
|
|
10476
10471
|
}
|
|
10477
|
-
if (intendedToken !== null &&
|
|
10472
|
+
if (intendedToken !== null && savedViewIdFromUrl === intendedToken) {
|
|
10478
10473
|
intendedTokenRef.current = null;
|
|
10479
10474
|
}
|
|
10480
|
-
|
|
10481
|
-
|
|
10482
|
-
|
|
10483
|
-
|
|
10484
|
-
|
|
10485
|
-
if (savedViewId) {
|
|
10486
|
-
previousSavedViewParamRef.current = savedViewId;
|
|
10475
|
+
if (previousSavedViewParamRef.current && !savedViewIdFromUrl) {
|
|
10476
|
+
urlAdapter.setViewToken(previousSavedViewParamRef.current);
|
|
10477
|
+
}
|
|
10478
|
+
if (savedViewIdFromUrl) {
|
|
10479
|
+
previousSavedViewParamRef.current = savedViewIdFromUrl;
|
|
10487
10480
|
}
|
|
10488
|
-
if (
|
|
10489
|
-
handleSavedViewFromUrl(
|
|
10481
|
+
if (savedViewIdFromUrl && savedViews) {
|
|
10482
|
+
handleSavedViewFromUrl(savedViewIdFromUrl);
|
|
10490
10483
|
}
|
|
10491
|
-
}, [
|
|
10484
|
+
}, [savedViewIdFromUrl, handleSavedViewFromUrl, allViews.length, urlAdapter]);
|
|
10492
10485
|
const previousRowGroupStateRef = useRef3(
|
|
10493
10486
|
isSmartGridConfig(tableConfig) ? tableConfig.rowGroupState : void 0
|
|
10494
10487
|
);
|
|
@@ -10587,10 +10580,26 @@ var FocusScopeToggle = ({ isOpen }) => {
|
|
|
10587
10580
|
|
|
10588
10581
|
// src/components/saved-views/SavedViews.tsx
|
|
10589
10582
|
import { FocusScope } from "@react-aria/focus";
|
|
10583
|
+
|
|
10584
|
+
// src/transport/default-lazy.ts
|
|
10585
|
+
var cached;
|
|
10586
|
+
var inFlight;
|
|
10587
|
+
var getCachedDefaultTransport = () => cached;
|
|
10588
|
+
var loadDefaultTransport = () => {
|
|
10589
|
+
if (cached) return Promise.resolve(cached);
|
|
10590
|
+
if (inFlight) return inFlight;
|
|
10591
|
+
inFlight = import("./transport/default.mjs").then((mod) => {
|
|
10592
|
+
cached = mod.defaultTransport;
|
|
10593
|
+
inFlight = void 0;
|
|
10594
|
+
return mod.defaultTransport;
|
|
10595
|
+
});
|
|
10596
|
+
return inFlight;
|
|
10597
|
+
};
|
|
10598
|
+
|
|
10599
|
+
// src/components/saved-views/SavedViews.tsx
|
|
10590
10600
|
var StyledPanel = pt.div`
|
|
10591
10601
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
10592
10602
|
`;
|
|
10593
|
-
var queryClient = new QueryClient();
|
|
10594
10603
|
var SavedViewsContent = (props) => {
|
|
10595
10604
|
var _a;
|
|
10596
10605
|
const { projectId, companyId } = props;
|
|
@@ -10702,19 +10711,19 @@ var SavedViewsContent = (props) => {
|
|
|
10702
10711
|
deleteSelectedView();
|
|
10703
10712
|
closeModal();
|
|
10704
10713
|
};
|
|
10705
|
-
return /* @__PURE__ */
|
|
10714
|
+
return /* @__PURE__ */ React25.createElement(FocusScope, { contain: false }, /* @__PURE__ */ React25.createElement(StyledPanel, { id: "saved-views-panel", provider: props.provider }, /* @__PURE__ */ React25.createElement(FocusScopeToggle, { isOpen: props.isPanelOpen ?? true }), /* @__PURE__ */ React25.createElement(
|
|
10706
10715
|
ExpandedPanel,
|
|
10707
10716
|
{
|
|
10708
10717
|
"data-testid": "saved-view-expanded-panel",
|
|
10709
10718
|
provider: props.provider
|
|
10710
10719
|
},
|
|
10711
|
-
/* @__PURE__ */
|
|
10720
|
+
/* @__PURE__ */ React25.createElement(Panel3.Header, { id: "saved-views-collections-panel-header" }, /* @__PURE__ */ React25.createElement(Panel3.Title, null, /* @__PURE__ */ React25.createElement(Flex5, { alignItems: "center" }, /* @__PURE__ */ React25.createElement(Box3, { paddingRight: "sm" }, i18n.t("savedViews.title")), /* @__PURE__ */ React25.createElement(
|
|
10712
10721
|
Tooltip2,
|
|
10713
10722
|
{
|
|
10714
10723
|
showDelay: 200,
|
|
10715
|
-
overlay: /* @__PURE__ */
|
|
10724
|
+
overlay: /* @__PURE__ */ React25.createElement(Tooltip2.Content, null, i18n.t("savedViews.tooltip"))
|
|
10716
10725
|
},
|
|
10717
|
-
/* @__PURE__ */
|
|
10726
|
+
/* @__PURE__ */ React25.createElement(
|
|
10718
10727
|
Help_default,
|
|
10719
10728
|
{
|
|
10720
10729
|
tabIndex: 0,
|
|
@@ -10722,16 +10731,16 @@ var SavedViewsContent = (props) => {
|
|
|
10722
10731
|
"aria-label": i18n.t("savedViews.tooltip")
|
|
10723
10732
|
}
|
|
10724
10733
|
)
|
|
10725
|
-
))), /* @__PURE__ */
|
|
10734
|
+
))), /* @__PURE__ */ React25.createElement(
|
|
10726
10735
|
Tooltip2,
|
|
10727
10736
|
{
|
|
10728
10737
|
overlay: i18n.t("savedViews.actions.create"),
|
|
10729
10738
|
showDelay: 1e3
|
|
10730
10739
|
},
|
|
10731
|
-
/* @__PURE__ */
|
|
10740
|
+
/* @__PURE__ */ React25.createElement(
|
|
10732
10741
|
Button6,
|
|
10733
10742
|
{
|
|
10734
|
-
icon: /* @__PURE__ */
|
|
10743
|
+
icon: /* @__PURE__ */ React25.createElement(Plus_default, null),
|
|
10735
10744
|
variant: "secondary",
|
|
10736
10745
|
"data-testid": "expanded-panel-create-button",
|
|
10737
10746
|
onClick: () => openModal("create" /* CREATE */),
|
|
@@ -10740,7 +10749,7 @@ var SavedViewsContent = (props) => {
|
|
|
10740
10749
|
i18n.t("savedViews.actions.create")
|
|
10741
10750
|
)
|
|
10742
10751
|
)),
|
|
10743
|
-
/* @__PURE__ */
|
|
10752
|
+
/* @__PURE__ */ React25.createElement(Panel3.Body, { style: { display: "flex", flexFlow: "column" } }, /* @__PURE__ */ React25.createElement(
|
|
10744
10753
|
PanelContent,
|
|
10745
10754
|
{
|
|
10746
10755
|
onSelect: ({ item }) => selectView(item),
|
|
@@ -10757,7 +10766,7 @@ var SavedViewsContent = (props) => {
|
|
|
10757
10766
|
onClearTemporary: clearTemporaryView
|
|
10758
10767
|
}
|
|
10759
10768
|
))
|
|
10760
|
-
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */
|
|
10769
|
+
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ React25.createElement(
|
|
10761
10770
|
FormModal,
|
|
10762
10771
|
{
|
|
10763
10772
|
open: true,
|
|
@@ -10771,14 +10780,14 @@ var SavedViewsContent = (props) => {
|
|
|
10771
10780
|
setOpenEditCreateModal: closeModal,
|
|
10772
10781
|
defaultView: props.defaultView
|
|
10773
10782
|
}
|
|
10774
|
-
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */
|
|
10783
|
+
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */ React25.createElement(
|
|
10775
10784
|
SavedViewsDeleteConfirmationModalShared,
|
|
10776
10785
|
{
|
|
10777
10786
|
open: true,
|
|
10778
10787
|
onDelete: confirmDeleteAndCloseModal,
|
|
10779
10788
|
onCancel: closeModal
|
|
10780
10789
|
}
|
|
10781
|
-
), fetchedView && isModalOpen("sharedView" /* SHARED_VIEW */) && /* @__PURE__ */
|
|
10790
|
+
), fetchedView && isModalOpen("sharedView" /* SHARED_VIEW */) && /* @__PURE__ */ React25.createElement(
|
|
10782
10791
|
SharedViewFormModal,
|
|
10783
10792
|
{
|
|
10784
10793
|
open: true,
|
|
@@ -10793,11 +10802,31 @@ var SavedViewsContent = (props) => {
|
|
|
10793
10802
|
)));
|
|
10794
10803
|
};
|
|
10795
10804
|
var SavedViews = (props) => {
|
|
10796
|
-
|
|
10805
|
+
const [resolvedDefault, setResolvedDefault] = useState5(() => props.transport ? void 0 : getCachedDefaultTransport());
|
|
10806
|
+
const [transportLoadError, setTransportLoadError] = useState5(void 0);
|
|
10807
|
+
useEffect6(() => {
|
|
10808
|
+
if (props.transport || resolvedDefault) return;
|
|
10809
|
+
let cancelled = false;
|
|
10810
|
+
void loadDefaultTransport().then((transport2) => {
|
|
10811
|
+
if (!cancelled) setResolvedDefault(transport2);
|
|
10812
|
+
}).catch((err) => {
|
|
10813
|
+
if (!cancelled) setTransportLoadError(err);
|
|
10814
|
+
});
|
|
10815
|
+
return () => {
|
|
10816
|
+
cancelled = true;
|
|
10817
|
+
};
|
|
10818
|
+
}, [props.transport, resolvedDefault]);
|
|
10819
|
+
const transport = props.transport ?? resolvedDefault;
|
|
10820
|
+
if (!transport) {
|
|
10821
|
+
if (transportLoadError) throw transportLoadError;
|
|
10822
|
+
return null;
|
|
10823
|
+
}
|
|
10824
|
+
const { CacheProvider } = transport;
|
|
10825
|
+
return /* @__PURE__ */ React25.createElement(EnvironmentI18nProvider, null, /* @__PURE__ */ React25.createElement(SavedViewsTransportProvider, { transport }, /* @__PURE__ */ React25.createElement(CacheProvider, null, /* @__PURE__ */ React25.createElement(ToastAlertProvider, null, /* @__PURE__ */ React25.createElement(SavedViewsContent, { ...props })))));
|
|
10797
10826
|
};
|
|
10798
10827
|
|
|
10799
10828
|
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
10800
|
-
import
|
|
10829
|
+
import React26, { useCallback as useCallback6 } from "react";
|
|
10801
10830
|
|
|
10802
10831
|
// src/components/adapters/smart-grid/SmartGridDefaultSavedView.tsx
|
|
10803
10832
|
import { useMemo as useMemo4 } from "react";
|
|
@@ -10955,7 +10984,7 @@ var SmartGridSavedViews = (props) => {
|
|
|
10955
10984
|
},
|
|
10956
10985
|
[gridApi, tableConfig, setTableConfig]
|
|
10957
10986
|
);
|
|
10958
|
-
return /* @__PURE__ */
|
|
10987
|
+
return /* @__PURE__ */ React26.createElement(
|
|
10959
10988
|
SavedViews,
|
|
10960
10989
|
{
|
|
10961
10990
|
onSelect,
|
|
@@ -10968,13 +10997,14 @@ var SmartGridSavedViews = (props) => {
|
|
|
10968
10997
|
presetViews,
|
|
10969
10998
|
tableName: props.tableName,
|
|
10970
10999
|
tableConfig,
|
|
10971
|
-
isPanelOpen
|
|
11000
|
+
isPanelOpen,
|
|
11001
|
+
transport: props.transport
|
|
10972
11002
|
}
|
|
10973
11003
|
);
|
|
10974
11004
|
};
|
|
10975
11005
|
|
|
10976
11006
|
// src/components/adapters/data-table/DataTableSavedViews.tsx
|
|
10977
|
-
import
|
|
11007
|
+
import React27, {
|
|
10978
11008
|
forwardRef as forwardRef11,
|
|
10979
11009
|
useImperativeHandle,
|
|
10980
11010
|
useState as useState8,
|
|
@@ -11080,7 +11110,7 @@ var DataTableSavedViews = forwardRef11((props, ref) => {
|
|
|
11080
11110
|
if (!internalTableConfig) {
|
|
11081
11111
|
return null;
|
|
11082
11112
|
}
|
|
11083
|
-
return /* @__PURE__ */
|
|
11113
|
+
return /* @__PURE__ */ React27.createElement(
|
|
11084
11114
|
SavedViews,
|
|
11085
11115
|
{
|
|
11086
11116
|
onSelect,
|
|
@@ -11092,7 +11122,8 @@ var DataTableSavedViews = forwardRef11((props, ref) => {
|
|
|
11092
11122
|
defaultView,
|
|
11093
11123
|
presetViews,
|
|
11094
11124
|
tableName: props.tableName,
|
|
11095
|
-
tableConfig: internalTableConfig
|
|
11125
|
+
tableConfig: internalTableConfig,
|
|
11126
|
+
transport: props.transport
|
|
11096
11127
|
}
|
|
11097
11128
|
);
|
|
11098
11129
|
});
|