@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/modern/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
|
if (!props.item) {
|
|
9084
9078
|
return;
|
|
@@ -9102,6 +9096,8 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
9102
9096
|
};
|
|
9103
9097
|
const { showToast } = useToastAlertContext();
|
|
9104
9098
|
const i18n = useI18nContext2();
|
|
9099
|
+
const transport = useOptionalSavedViewsTransport();
|
|
9100
|
+
const canShareViaUrl = transport?.supportsUrlSharing !== false;
|
|
9105
9101
|
const copyShareLink = async (event) => {
|
|
9106
9102
|
event.stopPropagation();
|
|
9107
9103
|
try {
|
|
@@ -9124,18 +9120,18 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
9124
9120
|
label: i18n.t("savedViews.actions.delete")
|
|
9125
9121
|
}
|
|
9126
9122
|
];
|
|
9127
|
-
const preventEventBubbleToNotTriggerViewSelectEvent =
|
|
9123
|
+
const preventEventBubbleToNotTriggerViewSelectEvent = React17.useCallback(
|
|
9128
9124
|
(e) => {
|
|
9129
9125
|
e.stopPropagation();
|
|
9130
9126
|
},
|
|
9131
9127
|
[]
|
|
9132
9128
|
);
|
|
9133
9129
|
const hasUpdateButton = props.item.view_level !== "default" && props.canUpdate;
|
|
9134
|
-
const hasCopyShareLinkButton = props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary";
|
|
9130
|
+
const hasCopyShareLinkButton = canShareViaUrl && props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary";
|
|
9135
9131
|
const hasClearTemporaryButton = props.item.id === "temporary";
|
|
9136
9132
|
const hasOverflowMenu = props.item.view_level !== "default" && props.canEditOrDelete;
|
|
9137
9133
|
const hasActions = hasUpdateButton || hasCopyShareLinkButton || hasClearTemporaryButton || hasOverflowMenu;
|
|
9138
|
-
return /* @__PURE__ */
|
|
9134
|
+
return /* @__PURE__ */ React17.createElement(
|
|
9139
9135
|
Container2,
|
|
9140
9136
|
{
|
|
9141
9137
|
"aria-selected": Boolean(props.selected),
|
|
@@ -9147,7 +9143,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
9147
9143
|
"data-testid": "saved-view-collection-menu-item",
|
|
9148
9144
|
onKeyDown: preventEventBubbleToNotTriggerViewSelectEvent
|
|
9149
9145
|
},
|
|
9150
|
-
/* @__PURE__ */
|
|
9146
|
+
/* @__PURE__ */ React17.createElement(
|
|
9151
9147
|
"span",
|
|
9152
9148
|
{
|
|
9153
9149
|
"data-testid": "saved-view-display-name",
|
|
@@ -9155,7 +9151,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
9155
9151
|
},
|
|
9156
9152
|
props.item.name
|
|
9157
9153
|
),
|
|
9158
|
-
hasActions && /* @__PURE__ */
|
|
9154
|
+
hasActions && /* @__PURE__ */ React17.createElement(RowActionsBox, null, /* @__PURE__ */ React17.createElement(Box, { justifyContent: "space-between" }, hasUpdateButton && /* @__PURE__ */ React17.createElement(
|
|
9159
9155
|
Button,
|
|
9160
9156
|
{
|
|
9161
9157
|
onClick: updateItem,
|
|
@@ -9166,7 +9162,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
9166
9162
|
loading: props.isUpdateProcessing
|
|
9167
9163
|
},
|
|
9168
9164
|
i18n.t("savedViews.actions.update")
|
|
9169
|
-
), hasCopyShareLinkButton && /* @__PURE__ */
|
|
9165
|
+
), hasCopyShareLinkButton && /* @__PURE__ */ React17.createElement(
|
|
9170
9166
|
Button,
|
|
9171
9167
|
{
|
|
9172
9168
|
onClick: copyShareLink,
|
|
@@ -9175,8 +9171,8 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
9175
9171
|
"aria-label": i18n.t("savedViews.actions.copyShareLink"),
|
|
9176
9172
|
"data-testid": "copy-share-link-button"
|
|
9177
9173
|
},
|
|
9178
|
-
/* @__PURE__ */
|
|
9179
|
-
), hasClearTemporaryButton && /* @__PURE__ */
|
|
9174
|
+
/* @__PURE__ */ React17.createElement(IconWrapper, null, /* @__PURE__ */ React17.createElement(Link_default, { size: "sm" }))
|
|
9175
|
+
), hasClearTemporaryButton && /* @__PURE__ */ React17.createElement(
|
|
9180
9176
|
Button,
|
|
9181
9177
|
{
|
|
9182
9178
|
onClick: (e) => {
|
|
@@ -9189,8 +9185,8 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
9189
9185
|
title: i18n.t("savedViews.actions.clearTemporary"),
|
|
9190
9186
|
"data-testid": "clear-temporary-view-button"
|
|
9191
9187
|
},
|
|
9192
|
-
/* @__PURE__ */
|
|
9193
|
-
)), /* @__PURE__ */
|
|
9188
|
+
/* @__PURE__ */ React17.createElement(IconWrapper, null, /* @__PURE__ */ React17.createElement(Clear_default, { size: "sm" }))
|
|
9189
|
+
)), /* @__PURE__ */ React17.createElement(Box, null, hasOverflowMenu && /* @__PURE__ */ React17.createElement(
|
|
9194
9190
|
DropdownFlyout,
|
|
9195
9191
|
{
|
|
9196
9192
|
"data-testid": "saved-view-overflow-button",
|
|
@@ -9216,15 +9212,9 @@ var ExpandedPanel = pt(Panel)`
|
|
|
9216
9212
|
// src/components/panels/PanelContent.tsx
|
|
9217
9213
|
import { Flex as Flex2, MenuImperative as MenuImperative2, useI18nContext as useI18nContext5 } from "@procore/core-react";
|
|
9218
9214
|
import { useToastAlertContext as useToastAlertContext2 } from "@procore/toast-alert";
|
|
9219
|
-
import
|
|
9220
|
-
|
|
9221
|
-
// src/utils/api/queries.ts
|
|
9222
|
-
import { requestJSON as requestJSON2 } from "@procore/core-http";
|
|
9223
|
-
import { useQuery } from "@tanstack/react-query";
|
|
9215
|
+
import React19 from "react";
|
|
9224
9216
|
|
|
9225
9217
|
// src/utils/api/queriesHandler.ts
|
|
9226
|
-
import { requestJSON } from "@procore/core-http";
|
|
9227
|
-
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
9228
9218
|
import { useI18nContext as useI18nContext3 } from "@procore/core-react";
|
|
9229
9219
|
var getBasePath = (companyId, projectId) => {
|
|
9230
9220
|
if (projectId) {
|
|
@@ -9234,22 +9224,39 @@ var getBasePath = (companyId, projectId) => {
|
|
|
9234
9224
|
};
|
|
9235
9225
|
var useApiRequest = (props, method, mutationKey) => {
|
|
9236
9226
|
const { projectId, companyId, domain, tableName } = props;
|
|
9237
|
-
const
|
|
9227
|
+
const transport = useSavedViewsTransport();
|
|
9228
|
+
const http = transport.useHttp();
|
|
9229
|
+
const cacheControl = transport.useCacheControl();
|
|
9238
9230
|
const { locale } = useI18nContext3();
|
|
9239
9231
|
const basePath = getBasePath(companyId, projectId);
|
|
9240
|
-
const queryKey = [
|
|
9241
|
-
|
|
9232
|
+
const queryKey = [
|
|
9233
|
+
"savedViews",
|
|
9234
|
+
domain,
|
|
9235
|
+
tableName,
|
|
9236
|
+
companyId,
|
|
9237
|
+
projectId
|
|
9238
|
+
];
|
|
9239
|
+
return transport.useMutationAdapter({
|
|
9242
9240
|
mutationKey,
|
|
9243
9241
|
mutationFn: async (savedView) => {
|
|
9244
|
-
let url =
|
|
9245
|
-
|
|
9242
|
+
let url = basePath;
|
|
9243
|
+
let body = { ...savedView };
|
|
9244
|
+
if (method === "DELETE") {
|
|
9246
9245
|
url = `${basePath}/${savedView.share_token}?permissions_domain=${domain}`;
|
|
9246
|
+
} else if (method === "PUT") {
|
|
9247
|
+
url = `${basePath}/${savedView.share_token}`;
|
|
9248
|
+
body = { ...savedView, permissions_domain: domain };
|
|
9247
9249
|
} else {
|
|
9248
|
-
|
|
9250
|
+
body = {
|
|
9251
|
+
...savedView,
|
|
9252
|
+
table_name: tableName,
|
|
9253
|
+
permissions_domain: domain
|
|
9254
|
+
};
|
|
9249
9255
|
}
|
|
9250
|
-
const response = await
|
|
9256
|
+
const response = await http({
|
|
9251
9257
|
method,
|
|
9252
|
-
|
|
9258
|
+
url,
|
|
9259
|
+
body: JSON.stringify(body),
|
|
9253
9260
|
headers: {
|
|
9254
9261
|
"Content-Type": "application/json",
|
|
9255
9262
|
"Accept-Language": locale
|
|
@@ -9262,23 +9269,19 @@ var useApiRequest = (props, method, mutationKey) => {
|
|
|
9262
9269
|
},
|
|
9263
9270
|
onSuccess: (savedView) => {
|
|
9264
9271
|
if (method === "DELETE" || method === "POST") {
|
|
9265
|
-
|
|
9266
|
-
queryKey
|
|
9267
|
-
});
|
|
9272
|
+
cacheControl.invalidate(queryKey);
|
|
9268
9273
|
return;
|
|
9269
9274
|
} else {
|
|
9270
|
-
const oldData =
|
|
9275
|
+
const oldData = cacheControl.getData(queryKey);
|
|
9271
9276
|
const oldView = oldData?.find(
|
|
9272
9277
|
(item) => item.share_token === savedView.share_token
|
|
9273
9278
|
);
|
|
9274
9279
|
if (oldView?.name !== savedView.name) {
|
|
9275
|
-
|
|
9276
|
-
queryKey
|
|
9277
|
-
});
|
|
9280
|
+
cacheControl.invalidate(queryKey);
|
|
9278
9281
|
return;
|
|
9279
9282
|
}
|
|
9280
9283
|
}
|
|
9281
|
-
|
|
9284
|
+
cacheControl.setData(queryKey, (oldData) => {
|
|
9282
9285
|
if (!oldData) return [savedView];
|
|
9283
9286
|
return oldData.map(
|
|
9284
9287
|
(item) => item.share_token === savedView.share_token ? savedView : item
|
|
@@ -9307,13 +9310,17 @@ var getBasePath2 = (companyId, projectId) => {
|
|
|
9307
9310
|
};
|
|
9308
9311
|
var useSavedViewsQuery = (props) => {
|
|
9309
9312
|
const { projectId, companyId, domain, tableName } = props;
|
|
9313
|
+
const transport = useSavedViewsTransport();
|
|
9314
|
+
const http = transport.useHttp();
|
|
9310
9315
|
const basePath = getBasePath2(companyId, projectId);
|
|
9311
9316
|
const url = `${basePath}?table_name=${tableName}&permissions_domain=${domain}`;
|
|
9312
|
-
return
|
|
9317
|
+
return transport.useQueryAdapter({
|
|
9313
9318
|
queryKey: ["savedViews", domain, tableName, companyId, projectId],
|
|
9314
9319
|
queryFn: async () => {
|
|
9315
9320
|
const getUrl = `${url}&per_page=${PAGE_SIZE}`;
|
|
9316
|
-
const response = await
|
|
9321
|
+
const response = await http({
|
|
9322
|
+
method: "GET",
|
|
9323
|
+
url: getUrl,
|
|
9317
9324
|
priority: "low"
|
|
9318
9325
|
});
|
|
9319
9326
|
return response.data;
|
|
@@ -9322,12 +9329,16 @@ var useSavedViewsQuery = (props) => {
|
|
|
9322
9329
|
};
|
|
9323
9330
|
var useSavedViewsPermissions = (props) => {
|
|
9324
9331
|
const { projectId, companyId, domain } = props;
|
|
9332
|
+
const transport = useSavedViewsTransport();
|
|
9333
|
+
const http = transport.useHttp();
|
|
9325
9334
|
const basePath = getBasePath2(companyId, projectId);
|
|
9326
9335
|
const url = `${basePath}/permissions?permissions_domain=${domain}`;
|
|
9327
|
-
return
|
|
9336
|
+
return transport.useQueryAdapter({
|
|
9328
9337
|
queryKey: ["savedViewsConfig", domain, companyId, projectId],
|
|
9329
9338
|
queryFn: async () => {
|
|
9330
|
-
const response = await
|
|
9339
|
+
const response = await http({
|
|
9340
|
+
method: "GET",
|
|
9341
|
+
url,
|
|
9331
9342
|
priority: "low"
|
|
9332
9343
|
});
|
|
9333
9344
|
return response.data;
|
|
@@ -9351,13 +9362,17 @@ var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
|
9351
9362
|
]);
|
|
9352
9363
|
var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
9353
9364
|
const { projectId, companyId, domain } = queryInput;
|
|
9365
|
+
const transport = useSavedViewsTransport();
|
|
9366
|
+
const http = transport.useHttp();
|
|
9354
9367
|
const basePath = getBasePath2(companyId, projectId);
|
|
9355
|
-
return
|
|
9368
|
+
return transport.useQueryAdapter({
|
|
9356
9369
|
enabled: enabled && Boolean(savedViewToken),
|
|
9357
9370
|
queryKey: ["savedView", savedViewToken, companyId, projectId],
|
|
9358
9371
|
queryFn: async () => {
|
|
9359
9372
|
const url = `${basePath}/${savedViewToken}?permissions_domain=${domain}`;
|
|
9360
|
-
const response = await
|
|
9373
|
+
const response = await http({
|
|
9374
|
+
method: "GET",
|
|
9375
|
+
url,
|
|
9361
9376
|
priority: "low"
|
|
9362
9377
|
});
|
|
9363
9378
|
return response.data;
|
|
@@ -9597,15 +9612,15 @@ import {
|
|
|
9597
9612
|
Typography,
|
|
9598
9613
|
useI18nContext as useI18nContext4
|
|
9599
9614
|
} from "@procore/core-react";
|
|
9600
|
-
import
|
|
9615
|
+
import React18 from "react";
|
|
9601
9616
|
var groupIcon = (group) => {
|
|
9602
9617
|
switch (group) {
|
|
9603
9618
|
case "personal":
|
|
9604
|
-
return /* @__PURE__ */
|
|
9619
|
+
return /* @__PURE__ */ React18.createElement(Person_default, null);
|
|
9605
9620
|
case "project":
|
|
9606
|
-
return /* @__PURE__ */
|
|
9621
|
+
return /* @__PURE__ */ React18.createElement(Excavator_default, null);
|
|
9607
9622
|
case "company":
|
|
9608
|
-
return /* @__PURE__ */
|
|
9623
|
+
return /* @__PURE__ */ React18.createElement(Building_default, null);
|
|
9609
9624
|
}
|
|
9610
9625
|
};
|
|
9611
9626
|
var StyledButton = pt(Button2)`
|
|
@@ -9615,7 +9630,7 @@ var StyledButton = pt(Button2)`
|
|
|
9615
9630
|
`;
|
|
9616
9631
|
var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
|
|
9617
9632
|
const I18n = useI18nContext4();
|
|
9618
|
-
return /* @__PURE__ */
|
|
9633
|
+
return /* @__PURE__ */ React18.createElement(Box2, { style: { width: "100%" } }, /* @__PURE__ */ React18.createElement(
|
|
9619
9634
|
StyledButton,
|
|
9620
9635
|
{
|
|
9621
9636
|
block: true,
|
|
@@ -9628,10 +9643,10 @@ var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
|
|
|
9628
9643
|
onClick: () => toggleGroup(group),
|
|
9629
9644
|
"aria-controls": `saved-views-collections-${group}`,
|
|
9630
9645
|
"aria-expanded": expanded,
|
|
9631
|
-
icon: expanded ? /* @__PURE__ */
|
|
9646
|
+
icon: expanded ? /* @__PURE__ */ React18.createElement(ChevronDown_default, { size: "sm" }) : /* @__PURE__ */ React18.createElement(ChevronRight_default, { size: "sm" })
|
|
9632
9647
|
},
|
|
9633
9648
|
groupIcon(group),
|
|
9634
|
-
/* @__PURE__ */
|
|
9649
|
+
/* @__PURE__ */ React18.createElement(Typography, { weight: "semibold" }, I18n.t(`savedViews.viewLevel.${group}`))
|
|
9635
9650
|
));
|
|
9636
9651
|
};
|
|
9637
9652
|
var ViewLevelHeader_default = ViewLevelHeader;
|
|
@@ -9685,10 +9700,10 @@ var PanelContent = (props) => {
|
|
|
9685
9700
|
const { data: savedViewsFromQuery, error: savedViewsError } = useSavedViewsQuery(props.queryInput);
|
|
9686
9701
|
const updateMutation = useUpdateSavedView(queryInput);
|
|
9687
9702
|
const { mutate: updateSavedView } = updateMutation;
|
|
9688
|
-
const isUpdateLoading =
|
|
9703
|
+
const isUpdateLoading = updateMutation.isPending;
|
|
9689
9704
|
const savedViews = props.savedViews ?? savedViewsFromQuery;
|
|
9690
|
-
const errorToastRef =
|
|
9691
|
-
|
|
9705
|
+
const errorToastRef = React19.useRef(null);
|
|
9706
|
+
React19.useEffect(() => {
|
|
9692
9707
|
if (savedViewsError && savedViewsError !== errorToastRef.current) {
|
|
9693
9708
|
showToast.error(I18n.t("savedViews.errors.fetch"));
|
|
9694
9709
|
errorToastRef.current = savedViewsError;
|
|
@@ -9718,7 +9733,7 @@ var PanelContent = (props) => {
|
|
|
9718
9733
|
}
|
|
9719
9734
|
});
|
|
9720
9735
|
};
|
|
9721
|
-
return /* @__PURE__ */
|
|
9736
|
+
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(
|
|
9722
9737
|
StyledMenuImperative,
|
|
9723
9738
|
{
|
|
9724
9739
|
role: "listbox",
|
|
@@ -9728,7 +9743,7 @@ var PanelContent = (props) => {
|
|
|
9728
9743
|
}
|
|
9729
9744
|
}
|
|
9730
9745
|
},
|
|
9731
|
-
/* @__PURE__ */
|
|
9746
|
+
/* @__PURE__ */ React19.createElement(MenuImperative2.Options, null, temporaryView && /* @__PURE__ */ React19.createElement(
|
|
9732
9747
|
Row,
|
|
9733
9748
|
{
|
|
9734
9749
|
key: temporaryView.id,
|
|
@@ -9737,7 +9752,7 @@ var PanelContent = (props) => {
|
|
|
9737
9752
|
"aria-current": isTemporarySelected ? "true" : void 0,
|
|
9738
9753
|
ref: isTemporarySelected ? selectedRowRef : null
|
|
9739
9754
|
},
|
|
9740
|
-
/* @__PURE__ */
|
|
9755
|
+
/* @__PURE__ */ React19.createElement(
|
|
9741
9756
|
SavedViewCollectionMenuItem,
|
|
9742
9757
|
{
|
|
9743
9758
|
item: temporaryView,
|
|
@@ -9747,7 +9762,7 @@ var PanelContent = (props) => {
|
|
|
9747
9762
|
)
|
|
9748
9763
|
), presetViews.map((presetView) => {
|
|
9749
9764
|
const isSelected = selectedSavedView?.id === presetView.id;
|
|
9750
|
-
return /* @__PURE__ */
|
|
9765
|
+
return /* @__PURE__ */ React19.createElement(
|
|
9751
9766
|
Row,
|
|
9752
9767
|
{
|
|
9753
9768
|
key: presetView.id,
|
|
@@ -9756,7 +9771,7 @@ var PanelContent = (props) => {
|
|
|
9756
9771
|
"aria-current": isSelected ? "true" : void 0,
|
|
9757
9772
|
ref: isSelected ? selectedRowRef : null
|
|
9758
9773
|
},
|
|
9759
|
-
/* @__PURE__ */
|
|
9774
|
+
/* @__PURE__ */ React19.createElement(
|
|
9760
9775
|
SavedViewCollectionMenuItem,
|
|
9761
9776
|
{
|
|
9762
9777
|
item: presetView,
|
|
@@ -9770,14 +9785,14 @@ var PanelContent = (props) => {
|
|
|
9770
9785
|
const views = isExpanded && savedViews ? savedViews.filter(
|
|
9771
9786
|
(view) => view.view_level === level && view.id !== "temporary"
|
|
9772
9787
|
) : [];
|
|
9773
|
-
return /* @__PURE__ */
|
|
9788
|
+
return /* @__PURE__ */ React19.createElement(React19.Fragment, { key: level }, /* @__PURE__ */ React19.createElement(
|
|
9774
9789
|
ViewLevelHeader_default,
|
|
9775
9790
|
{
|
|
9776
9791
|
group: level,
|
|
9777
9792
|
toggleGroup,
|
|
9778
9793
|
expanded: isExpanded
|
|
9779
9794
|
}
|
|
9780
|
-
), isExpanded && views.length > 0 && /* @__PURE__ */
|
|
9795
|
+
), isExpanded && views.length > 0 && /* @__PURE__ */ React19.createElement(
|
|
9781
9796
|
StyledMenuImperative,
|
|
9782
9797
|
{
|
|
9783
9798
|
id: `saved-views-collections-${level}`,
|
|
@@ -9788,7 +9803,7 @@ var PanelContent = (props) => {
|
|
|
9788
9803
|
}
|
|
9789
9804
|
}
|
|
9790
9805
|
},
|
|
9791
|
-
/* @__PURE__ */
|
|
9806
|
+
/* @__PURE__ */ React19.createElement(MenuImperative2.Options, null, views.map((view) => {
|
|
9792
9807
|
const isSelected = selectedSavedView?.id === view.id;
|
|
9793
9808
|
const canUpdate = isSelected && hasPermissionForViewLevel(
|
|
9794
9809
|
view.view_level,
|
|
@@ -9800,7 +9815,7 @@ var PanelContent = (props) => {
|
|
|
9800
9815
|
props.provider
|
|
9801
9816
|
);
|
|
9802
9817
|
const canEditOrDelete = isSelected && hasPermissionForViewLevel(view.view_level, permissions);
|
|
9803
|
-
return /* @__PURE__ */
|
|
9818
|
+
return /* @__PURE__ */ React19.createElement(
|
|
9804
9819
|
Row,
|
|
9805
9820
|
{
|
|
9806
9821
|
key: view.id,
|
|
@@ -9809,7 +9824,7 @@ var PanelContent = (props) => {
|
|
|
9809
9824
|
"aria-current": isSelected ? "true" : void 0,
|
|
9810
9825
|
ref: isSelected ? selectedRowRef : null
|
|
9811
9826
|
},
|
|
9812
|
-
/* @__PURE__ */
|
|
9827
|
+
/* @__PURE__ */ React19.createElement(
|
|
9813
9828
|
SavedViewCollectionMenuItem,
|
|
9814
9829
|
{
|
|
9815
9830
|
item: view,
|
|
@@ -9839,8 +9854,7 @@ import {
|
|
|
9839
9854
|
Tooltip as Tooltip2,
|
|
9840
9855
|
useI18nContext as useI18nContext12
|
|
9841
9856
|
} from "@procore/core-react";
|
|
9842
|
-
import
|
|
9843
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
9857
|
+
import React25, { useState as useState5, useEffect as useEffect6, useCallback as useCallback5 } from "react";
|
|
9844
9858
|
import { useToastAlertContext as useToastAlertContext3, ToastAlertProvider } from "@procore/toast-alert";
|
|
9845
9859
|
|
|
9846
9860
|
// src/components/modals/DeleteConfirmationModal.tsx
|
|
@@ -9851,14 +9865,14 @@ import {
|
|
|
9851
9865
|
P as P2,
|
|
9852
9866
|
useI18nContext as useI18nContext6
|
|
9853
9867
|
} from "@procore/core-react";
|
|
9854
|
-
import
|
|
9868
|
+
import React20 from "react";
|
|
9855
9869
|
var SavedViewsDeleteConfirmationModalShared = ({
|
|
9856
9870
|
onCancel,
|
|
9857
9871
|
onDelete,
|
|
9858
9872
|
open
|
|
9859
9873
|
}) => {
|
|
9860
9874
|
const i18n = useI18nContext6();
|
|
9861
|
-
return /* @__PURE__ */
|
|
9875
|
+
return /* @__PURE__ */ React20.createElement(
|
|
9862
9876
|
ConfirmModal,
|
|
9863
9877
|
{
|
|
9864
9878
|
"data-testid": "delete-confirmation-modal",
|
|
@@ -9868,13 +9882,13 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
9868
9882
|
onClose: onCancel,
|
|
9869
9883
|
style: { overflowWrap: "anywhere" }
|
|
9870
9884
|
},
|
|
9871
|
-
/* @__PURE__ */
|
|
9872
|
-
/* @__PURE__ */
|
|
9885
|
+
/* @__PURE__ */ React20.createElement(Modal.Body, null, /* @__PURE__ */ React20.createElement(P2, null, i18n.t("savedViews.modal.delete.description"))),
|
|
9886
|
+
/* @__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"))))
|
|
9873
9887
|
);
|
|
9874
9888
|
};
|
|
9875
9889
|
|
|
9876
9890
|
// src/components/modals/form-modal/FormModal.tsx
|
|
9877
|
-
import
|
|
9891
|
+
import React23 from "react";
|
|
9878
9892
|
|
|
9879
9893
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
9880
9894
|
import {
|
|
@@ -9889,7 +9903,7 @@ import {
|
|
|
9889
9903
|
Typography as Typography2,
|
|
9890
9904
|
useI18nContext as useI18nContext8
|
|
9891
9905
|
} from "@procore/core-react";
|
|
9892
|
-
import * as
|
|
9906
|
+
import * as React22 from "react";
|
|
9893
9907
|
import * as yup from "yup";
|
|
9894
9908
|
|
|
9895
9909
|
// src/components/modals/form-modal/FormModalBaseUtils.ts
|
|
@@ -9926,7 +9940,7 @@ function extractMessage(error, I18n) {
|
|
|
9926
9940
|
|
|
9927
9941
|
// src/components/modals/form-modal/NameInputField.tsx
|
|
9928
9942
|
import { Form, useFormContext, useI18nContext as useI18nContext7 } from "@procore/core-react";
|
|
9929
|
-
import * as
|
|
9943
|
+
import * as React21 from "react";
|
|
9930
9944
|
var NAME_INPUT_ID = "saved-view-form-name-input";
|
|
9931
9945
|
var NameInputField = ({
|
|
9932
9946
|
error,
|
|
@@ -9935,12 +9949,12 @@ var NameInputField = ({
|
|
|
9935
9949
|
const I18n = useI18nContext7();
|
|
9936
9950
|
const label = I18n.t("savedViews.modal.fields.name");
|
|
9937
9951
|
const { errors: formErrors, submitCount } = useFormContext();
|
|
9938
|
-
|
|
9952
|
+
React21.useEffect(() => {
|
|
9939
9953
|
if (submitCount > 0 && formErrors?.name) {
|
|
9940
9954
|
document.getElementById(NAME_INPUT_ID)?.focus();
|
|
9941
9955
|
}
|
|
9942
9956
|
}, [formErrors?.name, submitCount]);
|
|
9943
|
-
return /* @__PURE__ */
|
|
9957
|
+
return /* @__PURE__ */ React21.createElement(
|
|
9944
9958
|
Form.Text,
|
|
9945
9959
|
{
|
|
9946
9960
|
id: NAME_INPUT_ID,
|
|
@@ -10032,7 +10046,7 @@ var FormModalBase = ({
|
|
|
10032
10046
|
I18n,
|
|
10033
10047
|
isProjectLevelTool
|
|
10034
10048
|
);
|
|
10035
|
-
return /* @__PURE__ */
|
|
10049
|
+
return /* @__PURE__ */ React22.createElement(
|
|
10036
10050
|
Modal2,
|
|
10037
10051
|
{
|
|
10038
10052
|
howToClose: ["x", "scrim"],
|
|
@@ -10041,7 +10055,7 @@ var FormModalBase = ({
|
|
|
10041
10055
|
width: "md",
|
|
10042
10056
|
"data-testid": "create-update-modal"
|
|
10043
10057
|
},
|
|
10044
|
-
/* @__PURE__ */
|
|
10058
|
+
/* @__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(
|
|
10045
10059
|
Form2,
|
|
10046
10060
|
{
|
|
10047
10061
|
initialValues: {
|
|
@@ -10067,25 +10081,25 @@ var FormModalBase = ({
|
|
|
10067
10081
|
onReset: onCancel,
|
|
10068
10082
|
validateOnChange: true
|
|
10069
10083
|
},
|
|
10070
|
-
/* @__PURE__ */
|
|
10084
|
+
/* @__PURE__ */ React22.createElement(Form2.Form, { name: header }, /* @__PURE__ */ React22.createElement(
|
|
10071
10085
|
Modal2.Body,
|
|
10072
10086
|
{
|
|
10073
10087
|
style: { paddingTop: 0, paddingBottom: 0, marginTop: spacing2.lg }
|
|
10074
10088
|
},
|
|
10075
|
-
errors && /* @__PURE__ */
|
|
10076
|
-
/* @__PURE__ */
|
|
10089
|
+
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?.form || I18n.t(`savedViews.modal.errors.description.${mode}`)))),
|
|
10090
|
+
/* @__PURE__ */ React22.createElement(Form2.Row, null, /* @__PURE__ */ React22.createElement(
|
|
10077
10091
|
NameInputField,
|
|
10078
10092
|
{
|
|
10079
10093
|
error: errors?.name,
|
|
10080
10094
|
onResetMutations: resetMutations
|
|
10081
10095
|
}
|
|
10082
10096
|
)),
|
|
10083
|
-
/* @__PURE__ */
|
|
10097
|
+
/* @__PURE__ */ React22.createElement(
|
|
10084
10098
|
Form2.Row,
|
|
10085
10099
|
{
|
|
10086
10100
|
style: { marginTop: errors?.name ? spacing2.xl : spacing2.none }
|
|
10087
10101
|
},
|
|
10088
|
-
/* @__PURE__ */
|
|
10102
|
+
/* @__PURE__ */ React22.createElement(
|
|
10089
10103
|
Form2.TextArea,
|
|
10090
10104
|
{
|
|
10091
10105
|
name: "description",
|
|
@@ -10096,7 +10110,7 @@ var FormModalBase = ({
|
|
|
10096
10110
|
}
|
|
10097
10111
|
)
|
|
10098
10112
|
),
|
|
10099
|
-
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */
|
|
10113
|
+
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React22.createElement(Form2.Row, null, /* @__PURE__ */ React22.createElement(
|
|
10100
10114
|
Form2.Select,
|
|
10101
10115
|
{
|
|
10102
10116
|
name: "view_level",
|
|
@@ -10106,8 +10120,8 @@ var FormModalBase = ({
|
|
|
10106
10120
|
onSearch: false,
|
|
10107
10121
|
onClear: false
|
|
10108
10122
|
}
|
|
10109
|
-
)) : /* @__PURE__ */
|
|
10110
|
-
), /* @__PURE__ */
|
|
10123
|
+
)) : /* @__PURE__ */ React22.createElement(React22.Fragment, null)
|
|
10124
|
+
), /* @__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(
|
|
10111
10125
|
Button4,
|
|
10112
10126
|
{
|
|
10113
10127
|
"data-testid": "create-update-modal-button",
|
|
@@ -10137,7 +10151,7 @@ var FormModal = ({
|
|
|
10137
10151
|
defaultView
|
|
10138
10152
|
}) => {
|
|
10139
10153
|
const i18n = useI18nContext9();
|
|
10140
|
-
return /* @__PURE__ */
|
|
10154
|
+
return /* @__PURE__ */ React23.createElement(
|
|
10141
10155
|
FormModalBase,
|
|
10142
10156
|
{
|
|
10143
10157
|
open,
|
|
@@ -10171,7 +10185,7 @@ import {
|
|
|
10171
10185
|
Typography as Typography3,
|
|
10172
10186
|
useI18nContext as useI18nContext10
|
|
10173
10187
|
} from "@procore/core-react";
|
|
10174
|
-
import * as
|
|
10188
|
+
import * as React24 from "react";
|
|
10175
10189
|
import * as yup2 from "yup";
|
|
10176
10190
|
var SharedViewFormModal = ({
|
|
10177
10191
|
open,
|
|
@@ -10194,7 +10208,7 @@ var SharedViewFormModal = ({
|
|
|
10194
10208
|
const handleOnSubmit = (data) => {
|
|
10195
10209
|
onCreateView(data.name, data.description);
|
|
10196
10210
|
};
|
|
10197
|
-
return /* @__PURE__ */
|
|
10211
|
+
return /* @__PURE__ */ React24.createElement(
|
|
10198
10212
|
Modal3,
|
|
10199
10213
|
{
|
|
10200
10214
|
"data-testid": "shared-view-form-modal",
|
|
@@ -10203,7 +10217,7 @@ var SharedViewFormModal = ({
|
|
|
10203
10217
|
onClose,
|
|
10204
10218
|
style: { width: "540px" }
|
|
10205
10219
|
},
|
|
10206
|
-
/* @__PURE__ */
|
|
10220
|
+
/* @__PURE__ */ React24.createElement(
|
|
10207
10221
|
Modal3.Header,
|
|
10208
10222
|
{
|
|
10209
10223
|
onClose,
|
|
@@ -10214,9 +10228,9 @@ var SharedViewFormModal = ({
|
|
|
10214
10228
|
paddingRight: spacing3.xl
|
|
10215
10229
|
}
|
|
10216
10230
|
},
|
|
10217
|
-
/* @__PURE__ */
|
|
10231
|
+
/* @__PURE__ */ React24.createElement(Modal3.Heading, null, I18n.t("savedViews.modal.create.title"))
|
|
10218
10232
|
),
|
|
10219
|
-
/* @__PURE__ */
|
|
10233
|
+
/* @__PURE__ */ React24.createElement(
|
|
10220
10234
|
P3,
|
|
10221
10235
|
{
|
|
10222
10236
|
style: {
|
|
@@ -10231,7 +10245,7 @@ var SharedViewFormModal = ({
|
|
|
10231
10245
|
},
|
|
10232
10246
|
I18n.t("savedViews.modal.copyConfirmation.description")
|
|
10233
10247
|
),
|
|
10234
|
-
/* @__PURE__ */
|
|
10248
|
+
/* @__PURE__ */ React24.createElement(
|
|
10235
10249
|
Form3,
|
|
10236
10250
|
{
|
|
10237
10251
|
initialValues: {
|
|
@@ -10250,7 +10264,7 @@ var SharedViewFormModal = ({
|
|
|
10250
10264
|
onSubmit: handleOnSubmit,
|
|
10251
10265
|
validateOnChange: true
|
|
10252
10266
|
},
|
|
10253
|
-
/* @__PURE__ */
|
|
10267
|
+
/* @__PURE__ */ React24.createElement(Form3.Form, { name: "share-view-form" }, /* @__PURE__ */ React24.createElement(
|
|
10254
10268
|
Modal3.Body,
|
|
10255
10269
|
{
|
|
10256
10270
|
style: {
|
|
@@ -10259,22 +10273,22 @@ var SharedViewFormModal = ({
|
|
|
10259
10273
|
borderTop: `1px solid ${colors4.gray85}`
|
|
10260
10274
|
}
|
|
10261
10275
|
},
|
|
10262
|
-
errors && /* @__PURE__ */
|
|
10276
|
+
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", {
|
|
10263
10277
|
mode: "create"
|
|
10264
|
-
})), /* @__PURE__ */
|
|
10265
|
-
/* @__PURE__ */
|
|
10278
|
+
})), /* @__PURE__ */ React24.createElement(Banner2.Body, null, errors?.form || I18n.t("savedViews.modal.errors.description.create")))),
|
|
10279
|
+
/* @__PURE__ */ React24.createElement(Form3.Row, null, /* @__PURE__ */ React24.createElement(
|
|
10266
10280
|
NameInputField,
|
|
10267
10281
|
{
|
|
10268
10282
|
error: errors?.name,
|
|
10269
10283
|
onResetMutations: handleNameChange
|
|
10270
10284
|
}
|
|
10271
10285
|
)),
|
|
10272
|
-
/* @__PURE__ */
|
|
10286
|
+
/* @__PURE__ */ React24.createElement(
|
|
10273
10287
|
Form3.Row,
|
|
10274
10288
|
{
|
|
10275
10289
|
style: { marginTop: errors?.name ? spacing3.xl : spacing3.none }
|
|
10276
10290
|
},
|
|
10277
|
-
/* @__PURE__ */
|
|
10291
|
+
/* @__PURE__ */ React24.createElement(
|
|
10278
10292
|
Form3.TextArea,
|
|
10279
10293
|
{
|
|
10280
10294
|
name: "description",
|
|
@@ -10285,7 +10299,7 @@ var SharedViewFormModal = ({
|
|
|
10285
10299
|
}
|
|
10286
10300
|
)
|
|
10287
10301
|
)
|
|
10288
|
-
), /* @__PURE__ */
|
|
10302
|
+
), /* @__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(
|
|
10289
10303
|
Button5,
|
|
10290
10304
|
{
|
|
10291
10305
|
variant: "secondary",
|
|
@@ -10294,7 +10308,7 @@ var SharedViewFormModal = ({
|
|
|
10294
10308
|
disabled: isCreating
|
|
10295
10309
|
},
|
|
10296
10310
|
I18n.t("savedViews.actions.viewTemporarily")
|
|
10297
|
-
), /* @__PURE__ */
|
|
10311
|
+
), /* @__PURE__ */ React24.createElement(
|
|
10298
10312
|
Button5,
|
|
10299
10313
|
{
|
|
10300
10314
|
type: "submit",
|
|
@@ -10311,7 +10325,6 @@ var SharedViewFormModal = ({
|
|
|
10311
10325
|
|
|
10312
10326
|
// src/utils/hooks/useViewSelection.ts
|
|
10313
10327
|
import { useState as useState4, useCallback as useCallback4, useEffect as useEffect4, useRef as useRef3, useMemo as useMemo3 } from "react";
|
|
10314
|
-
import { useSearchParams } from "react-router-dom";
|
|
10315
10328
|
import { useI18nContext as useI18nContext11 } from "@procore/core-react";
|
|
10316
10329
|
|
|
10317
10330
|
// src/utils/viewStorage.ts
|
|
@@ -10356,42 +10369,24 @@ var areRowGroupStatesEqual = (a2, b2) => {
|
|
|
10356
10369
|
if (a2.length !== b2.length) return false;
|
|
10357
10370
|
return a2.every((val, idx) => val === b2[idx]);
|
|
10358
10371
|
};
|
|
10359
|
-
var
|
|
10360
|
-
if (view.id === "default"
|
|
10361
|
-
|
|
10362
|
-
}
|
|
10372
|
+
var getViewTokenForView = (view) => {
|
|
10373
|
+
if (view.id === "default") return "default";
|
|
10374
|
+
if (view.id === "temporary") return "temporary";
|
|
10363
10375
|
return view.share_token;
|
|
10364
10376
|
};
|
|
10365
|
-
var setSavedViewParam = (token2, setSearchParams) => {
|
|
10366
|
-
setSearchParams(
|
|
10367
|
-
(currentParams) => {
|
|
10368
|
-
const updatedParams = new URLSearchParams(currentParams);
|
|
10369
|
-
updatedParams.set("saved-view", token2);
|
|
10370
|
-
return updatedParams;
|
|
10371
|
-
},
|
|
10372
|
-
{ replace: true }
|
|
10373
|
-
);
|
|
10374
|
-
};
|
|
10375
10377
|
var checkIsViewSelected = (selectedView, viewId) => {
|
|
10376
10378
|
return selectedView?.share_token === viewId || selectedView?.id === viewId;
|
|
10377
10379
|
};
|
|
10378
10380
|
var findViewByToken = (views, token2) => {
|
|
10379
10381
|
return views.find((view) => view.share_token === token2);
|
|
10380
10382
|
};
|
|
10381
|
-
var setViewInUrl = (view, setSearchParams) => {
|
|
10382
|
-
setSavedViewParam(getViewToken(view), setSearchParams);
|
|
10383
|
-
};
|
|
10384
|
-
var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
10385
|
-
if (previousParam && !currentParam) {
|
|
10386
|
-
setSavedViewParam(previousParam, setSearchParams);
|
|
10387
|
-
}
|
|
10388
|
-
};
|
|
10389
10383
|
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, tableConfig) => {
|
|
10390
10384
|
const I18n = useI18nContext11();
|
|
10385
|
+
const transport = useSavedViewsTransport();
|
|
10386
|
+
const urlAdapter = transport.useUrlAdapter();
|
|
10391
10387
|
const projectIdSegment = config.projectId ?? "company";
|
|
10392
10388
|
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${projectIdSegment}_${config.userId}`;
|
|
10393
10389
|
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
10394
|
-
const [searchParams, setSearchParams] = useSearchParams();
|
|
10395
10390
|
const previousSavedViewParamRef = useRef3(null);
|
|
10396
10391
|
const intendedTokenRef = useRef3(null);
|
|
10397
10392
|
const [selectedSavedView, setSelectedSavedView] = useState4(() => {
|
|
@@ -10405,10 +10400,10 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
|
|
|
10405
10400
|
const persistViewToStorageAndUrl = useCallback4(
|
|
10406
10401
|
(view) => {
|
|
10407
10402
|
ViewStorage.save(storageKey, view);
|
|
10408
|
-
intendedTokenRef.current =
|
|
10409
|
-
|
|
10403
|
+
intendedTokenRef.current = getViewTokenForView(view);
|
|
10404
|
+
urlAdapter.setViewToken(getViewTokenForView(view));
|
|
10410
10405
|
},
|
|
10411
|
-
[storageKey,
|
|
10406
|
+
[storageKey, urlAdapter]
|
|
10412
10407
|
);
|
|
10413
10408
|
const baseViews = useMemo3(
|
|
10414
10409
|
() => [...savedViews ?? [], ...presetViews ?? []],
|
|
@@ -10462,28 +10457,26 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, ta
|
|
|
10462
10457
|
openSharedViewModal(viewId);
|
|
10463
10458
|
}
|
|
10464
10459
|
});
|
|
10460
|
+
const savedViewIdFromUrl = urlAdapter.getViewToken();
|
|
10465
10461
|
useEffect4(() => {
|
|
10466
|
-
const savedViewId = searchParams.get("saved-view");
|
|
10467
10462
|
const intendedToken = intendedTokenRef.current;
|
|
10468
|
-
if (intendedToken !== null &&
|
|
10469
|
-
|
|
10463
|
+
if (intendedToken !== null && savedViewIdFromUrl !== intendedToken) {
|
|
10464
|
+
urlAdapter.setViewToken(intendedToken);
|
|
10470
10465
|
return;
|
|
10471
10466
|
}
|
|
10472
|
-
if (intendedToken !== null &&
|
|
10467
|
+
if (intendedToken !== null && savedViewIdFromUrl === intendedToken) {
|
|
10473
10468
|
intendedTokenRef.current = null;
|
|
10474
10469
|
}
|
|
10475
|
-
|
|
10476
|
-
|
|
10477
|
-
|
|
10478
|
-
|
|
10479
|
-
|
|
10480
|
-
if (savedViewId) {
|
|
10481
|
-
previousSavedViewParamRef.current = savedViewId;
|
|
10470
|
+
if (previousSavedViewParamRef.current && !savedViewIdFromUrl) {
|
|
10471
|
+
urlAdapter.setViewToken(previousSavedViewParamRef.current);
|
|
10472
|
+
}
|
|
10473
|
+
if (savedViewIdFromUrl) {
|
|
10474
|
+
previousSavedViewParamRef.current = savedViewIdFromUrl;
|
|
10482
10475
|
}
|
|
10483
|
-
if (
|
|
10484
|
-
handleSavedViewFromUrl(
|
|
10476
|
+
if (savedViewIdFromUrl && savedViews) {
|
|
10477
|
+
handleSavedViewFromUrl(savedViewIdFromUrl);
|
|
10485
10478
|
}
|
|
10486
|
-
}, [
|
|
10479
|
+
}, [savedViewIdFromUrl, handleSavedViewFromUrl, allViews.length, urlAdapter]);
|
|
10487
10480
|
const previousRowGroupStateRef = useRef3(
|
|
10488
10481
|
isSmartGridConfig(tableConfig) ? tableConfig.rowGroupState : void 0
|
|
10489
10482
|
);
|
|
@@ -10578,10 +10571,26 @@ var FocusScopeToggle = ({ isOpen }) => {
|
|
|
10578
10571
|
|
|
10579
10572
|
// src/components/saved-views/SavedViews.tsx
|
|
10580
10573
|
import { FocusScope } from "@react-aria/focus";
|
|
10574
|
+
|
|
10575
|
+
// src/transport/default-lazy.ts
|
|
10576
|
+
var cached;
|
|
10577
|
+
var inFlight;
|
|
10578
|
+
var getCachedDefaultTransport = () => cached;
|
|
10579
|
+
var loadDefaultTransport = () => {
|
|
10580
|
+
if (cached) return Promise.resolve(cached);
|
|
10581
|
+
if (inFlight) return inFlight;
|
|
10582
|
+
inFlight = import("./transport/default.mjs").then((mod) => {
|
|
10583
|
+
cached = mod.defaultTransport;
|
|
10584
|
+
inFlight = void 0;
|
|
10585
|
+
return mod.defaultTransport;
|
|
10586
|
+
});
|
|
10587
|
+
return inFlight;
|
|
10588
|
+
};
|
|
10589
|
+
|
|
10590
|
+
// src/components/saved-views/SavedViews.tsx
|
|
10581
10591
|
var StyledPanel = pt.div`
|
|
10582
10592
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
10583
10593
|
`;
|
|
10584
|
-
var queryClient = new QueryClient();
|
|
10585
10594
|
var SavedViewsContent = (props) => {
|
|
10586
10595
|
const { projectId, companyId } = props;
|
|
10587
10596
|
const queryInput = {
|
|
@@ -10692,19 +10701,19 @@ var SavedViewsContent = (props) => {
|
|
|
10692
10701
|
deleteSelectedView();
|
|
10693
10702
|
closeModal();
|
|
10694
10703
|
};
|
|
10695
|
-
return /* @__PURE__ */
|
|
10704
|
+
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(
|
|
10696
10705
|
ExpandedPanel,
|
|
10697
10706
|
{
|
|
10698
10707
|
"data-testid": "saved-view-expanded-panel",
|
|
10699
10708
|
provider: props.provider
|
|
10700
10709
|
},
|
|
10701
|
-
/* @__PURE__ */
|
|
10710
|
+
/* @__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(
|
|
10702
10711
|
Tooltip2,
|
|
10703
10712
|
{
|
|
10704
10713
|
showDelay: 200,
|
|
10705
|
-
overlay: /* @__PURE__ */
|
|
10714
|
+
overlay: /* @__PURE__ */ React25.createElement(Tooltip2.Content, null, i18n.t("savedViews.tooltip"))
|
|
10706
10715
|
},
|
|
10707
|
-
/* @__PURE__ */
|
|
10716
|
+
/* @__PURE__ */ React25.createElement(
|
|
10708
10717
|
Help_default,
|
|
10709
10718
|
{
|
|
10710
10719
|
tabIndex: 0,
|
|
@@ -10712,16 +10721,16 @@ var SavedViewsContent = (props) => {
|
|
|
10712
10721
|
"aria-label": i18n.t("savedViews.tooltip")
|
|
10713
10722
|
}
|
|
10714
10723
|
)
|
|
10715
|
-
))), /* @__PURE__ */
|
|
10724
|
+
))), /* @__PURE__ */ React25.createElement(
|
|
10716
10725
|
Tooltip2,
|
|
10717
10726
|
{
|
|
10718
10727
|
overlay: i18n.t("savedViews.actions.create"),
|
|
10719
10728
|
showDelay: 1e3
|
|
10720
10729
|
},
|
|
10721
|
-
/* @__PURE__ */
|
|
10730
|
+
/* @__PURE__ */ React25.createElement(
|
|
10722
10731
|
Button6,
|
|
10723
10732
|
{
|
|
10724
|
-
icon: /* @__PURE__ */
|
|
10733
|
+
icon: /* @__PURE__ */ React25.createElement(Plus_default, null),
|
|
10725
10734
|
variant: "secondary",
|
|
10726
10735
|
"data-testid": "expanded-panel-create-button",
|
|
10727
10736
|
onClick: () => openModal("create" /* CREATE */),
|
|
@@ -10730,7 +10739,7 @@ var SavedViewsContent = (props) => {
|
|
|
10730
10739
|
i18n.t("savedViews.actions.create")
|
|
10731
10740
|
)
|
|
10732
10741
|
)),
|
|
10733
|
-
/* @__PURE__ */
|
|
10742
|
+
/* @__PURE__ */ React25.createElement(Panel3.Body, { style: { display: "flex", flexFlow: "column" } }, /* @__PURE__ */ React25.createElement(
|
|
10734
10743
|
PanelContent,
|
|
10735
10744
|
{
|
|
10736
10745
|
onSelect: ({ item }) => selectView(item),
|
|
@@ -10747,7 +10756,7 @@ var SavedViewsContent = (props) => {
|
|
|
10747
10756
|
onClearTemporary: clearTemporaryView
|
|
10748
10757
|
}
|
|
10749
10758
|
))
|
|
10750
|
-
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */
|
|
10759
|
+
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ React25.createElement(
|
|
10751
10760
|
FormModal,
|
|
10752
10761
|
{
|
|
10753
10762
|
open: true,
|
|
@@ -10761,14 +10770,14 @@ var SavedViewsContent = (props) => {
|
|
|
10761
10770
|
setOpenEditCreateModal: closeModal,
|
|
10762
10771
|
defaultView: props.defaultView
|
|
10763
10772
|
}
|
|
10764
|
-
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */
|
|
10773
|
+
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */ React25.createElement(
|
|
10765
10774
|
SavedViewsDeleteConfirmationModalShared,
|
|
10766
10775
|
{
|
|
10767
10776
|
open: true,
|
|
10768
10777
|
onDelete: confirmDeleteAndCloseModal,
|
|
10769
10778
|
onCancel: closeModal
|
|
10770
10779
|
}
|
|
10771
|
-
), fetchedView && isModalOpen("sharedView" /* SHARED_VIEW */) && /* @__PURE__ */
|
|
10780
|
+
), fetchedView && isModalOpen("sharedView" /* SHARED_VIEW */) && /* @__PURE__ */ React25.createElement(
|
|
10772
10781
|
SharedViewFormModal,
|
|
10773
10782
|
{
|
|
10774
10783
|
open: true,
|
|
@@ -10783,11 +10792,31 @@ var SavedViewsContent = (props) => {
|
|
|
10783
10792
|
)));
|
|
10784
10793
|
};
|
|
10785
10794
|
var SavedViews = (props) => {
|
|
10786
|
-
|
|
10795
|
+
const [resolvedDefault, setResolvedDefault] = useState5(() => props.transport ? void 0 : getCachedDefaultTransport());
|
|
10796
|
+
const [transportLoadError, setTransportLoadError] = useState5(void 0);
|
|
10797
|
+
useEffect6(() => {
|
|
10798
|
+
if (props.transport || resolvedDefault) return;
|
|
10799
|
+
let cancelled = false;
|
|
10800
|
+
void loadDefaultTransport().then((transport2) => {
|
|
10801
|
+
if (!cancelled) setResolvedDefault(transport2);
|
|
10802
|
+
}).catch((err) => {
|
|
10803
|
+
if (!cancelled) setTransportLoadError(err);
|
|
10804
|
+
});
|
|
10805
|
+
return () => {
|
|
10806
|
+
cancelled = true;
|
|
10807
|
+
};
|
|
10808
|
+
}, [props.transport, resolvedDefault]);
|
|
10809
|
+
const transport = props.transport ?? resolvedDefault;
|
|
10810
|
+
if (!transport) {
|
|
10811
|
+
if (transportLoadError) throw transportLoadError;
|
|
10812
|
+
return null;
|
|
10813
|
+
}
|
|
10814
|
+
const { CacheProvider } = transport;
|
|
10815
|
+
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 })))));
|
|
10787
10816
|
};
|
|
10788
10817
|
|
|
10789
10818
|
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
10790
|
-
import
|
|
10819
|
+
import React26, { useCallback as useCallback6 } from "react";
|
|
10791
10820
|
|
|
10792
10821
|
// src/components/adapters/smart-grid/SmartGridDefaultSavedView.tsx
|
|
10793
10822
|
import { useMemo as useMemo4 } from "react";
|
|
@@ -10939,7 +10968,7 @@ var SmartGridSavedViews = (props) => {
|
|
|
10939
10968
|
},
|
|
10940
10969
|
[gridApi, tableConfig, setTableConfig]
|
|
10941
10970
|
);
|
|
10942
|
-
return /* @__PURE__ */
|
|
10971
|
+
return /* @__PURE__ */ React26.createElement(
|
|
10943
10972
|
SavedViews,
|
|
10944
10973
|
{
|
|
10945
10974
|
onSelect,
|
|
@@ -10952,13 +10981,14 @@ var SmartGridSavedViews = (props) => {
|
|
|
10952
10981
|
presetViews,
|
|
10953
10982
|
tableName: props.tableName,
|
|
10954
10983
|
tableConfig,
|
|
10955
|
-
isPanelOpen
|
|
10984
|
+
isPanelOpen,
|
|
10985
|
+
transport: props.transport
|
|
10956
10986
|
}
|
|
10957
10987
|
);
|
|
10958
10988
|
};
|
|
10959
10989
|
|
|
10960
10990
|
// src/components/adapters/data-table/DataTableSavedViews.tsx
|
|
10961
|
-
import
|
|
10991
|
+
import React27, {
|
|
10962
10992
|
forwardRef as forwardRef11,
|
|
10963
10993
|
useImperativeHandle,
|
|
10964
10994
|
useState as useState8,
|
|
@@ -11062,7 +11092,7 @@ var DataTableSavedViews = forwardRef11((props, ref) => {
|
|
|
11062
11092
|
if (!internalTableConfig) {
|
|
11063
11093
|
return null;
|
|
11064
11094
|
}
|
|
11065
|
-
return /* @__PURE__ */
|
|
11095
|
+
return /* @__PURE__ */ React27.createElement(
|
|
11066
11096
|
SavedViews,
|
|
11067
11097
|
{
|
|
11068
11098
|
onSelect,
|
|
@@ -11074,7 +11104,8 @@ var DataTableSavedViews = forwardRef11((props, ref) => {
|
|
|
11074
11104
|
defaultView,
|
|
11075
11105
|
presetViews,
|
|
11076
11106
|
tableName: props.tableName,
|
|
11077
|
-
tableConfig: internalTableConfig
|
|
11107
|
+
tableConfig: internalTableConfig,
|
|
11108
|
+
transport: props.transport
|
|
11078
11109
|
}
|
|
11079
11110
|
);
|
|
11080
11111
|
});
|