@procore/saved-views 1.0.0 → 1.0.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/legacy/index.d.mts +26 -7
- package/dist/legacy/index.d.ts +26 -7
- package/dist/legacy/index.js +342 -284
- package/dist/legacy/index.mjs +289 -231
- package/dist/modern/index.d.mts +26 -7
- package/dist/modern/index.d.ts +26 -7
- package/dist/modern/index.js +342 -284
- package/dist/modern/index.mjs +289 -231
- package/package.json +1 -1
package/dist/legacy/index.js
CHANGED
|
@@ -11391,7 +11391,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
11391
11391
|
loading: props.isUpdateProcessing
|
|
11392
11392
|
},
|
|
11393
11393
|
i18n.t("savedViews.actions.update")
|
|
11394
|
-
)), props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
|
|
11394
|
+
)), (props.enableSharingViews ?? true) && props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
|
|
11395
11395
|
import_core_react3.Button,
|
|
11396
11396
|
{
|
|
11397
11397
|
onClick: copyShareLink,
|
|
@@ -11440,176 +11440,13 @@ var ExpandedPanel = styled_components_esm_default(import_core_react4.Panel)`
|
|
|
11440
11440
|
`;
|
|
11441
11441
|
|
|
11442
11442
|
// src/components/panels/PanelContent.tsx
|
|
11443
|
-
var
|
|
11443
|
+
var import_core_react7 = require("@procore/core-react");
|
|
11444
11444
|
var import_toast_alert2 = require("@procore/toast-alert");
|
|
11445
11445
|
var import_react9 = __toESM(require("react"));
|
|
11446
11446
|
|
|
11447
|
-
// node_modules/@procore/core-http/dist/modern/index.js
|
|
11448
|
-
function getCSRFToken() {
|
|
11449
|
-
const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
|
|
11450
|
-
return token ? decodeURIComponent(token.pop() || "") : "";
|
|
11451
|
-
}
|
|
11452
|
-
function getCSRFHeader() {
|
|
11453
|
-
const csrfToken = getCSRFToken();
|
|
11454
|
-
return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
|
|
11455
|
-
}
|
|
11456
|
-
function removeLeadingSlash(url) {
|
|
11457
|
-
return url.startsWith("/") ? url.substring(1, url.length) : url;
|
|
11458
|
-
}
|
|
11459
|
-
function removeTrailingSlash(url) {
|
|
11460
|
-
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
11461
|
-
}
|
|
11462
|
-
function applyBaseUrl(url, baseUrl) {
|
|
11463
|
-
return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
|
|
11464
|
-
}
|
|
11465
|
-
function getOptions({ headers, ...options }) {
|
|
11466
|
-
const opts = {
|
|
11467
|
-
credentials: "same-origin",
|
|
11468
|
-
headers: {
|
|
11469
|
-
...getCSRFHeader(),
|
|
11470
|
-
...headers
|
|
11471
|
-
},
|
|
11472
|
-
mode: "same-origin",
|
|
11473
|
-
...options
|
|
11474
|
-
};
|
|
11475
|
-
return opts;
|
|
11476
|
-
}
|
|
11477
|
-
function getUrl(url, baseUrl) {
|
|
11478
|
-
return baseUrl ? applyBaseUrl(url, baseUrl) : url;
|
|
11479
|
-
}
|
|
11480
|
-
function request(url, { baseUrl, ...options } = {}) {
|
|
11481
|
-
return fetch(getUrl(url, baseUrl), getOptions(options));
|
|
11482
|
-
}
|
|
11483
|
-
function requestJSON(url, requestParams = {}) {
|
|
11484
|
-
return request(url, requestParams).then(
|
|
11485
|
-
(response) => response.json()
|
|
11486
|
-
);
|
|
11487
|
-
}
|
|
11488
|
-
|
|
11489
|
-
// src/utils/api/queries.ts
|
|
11490
|
-
var import_react_query2 = require("@tanstack/react-query");
|
|
11491
|
-
|
|
11492
|
-
// src/utils/api/queriesHandler.ts
|
|
11493
|
-
var import_react_query = require("@tanstack/react-query");
|
|
11494
|
-
var import_core_react5 = require("@procore/core-react");
|
|
11495
|
-
var useApiRequest = (props, method, mutationKey) => {
|
|
11496
|
-
const { projectId, companyId, domain, tableName } = props;
|
|
11497
|
-
const queryClient2 = (0, import_react_query.useQueryClient)();
|
|
11498
|
-
const { locale: locale2 } = (0, import_core_react5.useI18nContext)();
|
|
11499
|
-
return (0, import_react_query.useMutation)({
|
|
11500
|
-
mutationKey,
|
|
11501
|
-
mutationFn: async (savedView) => {
|
|
11502
|
-
let url = "";
|
|
11503
|
-
if (method === "DELETE" || method === "PUT") {
|
|
11504
|
-
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.share_token}?permissions_domain=${domain}`;
|
|
11505
|
-
} else {
|
|
11506
|
-
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
11507
|
-
}
|
|
11508
|
-
const response = await requestJSON(url, {
|
|
11509
|
-
method,
|
|
11510
|
-
body: JSON.stringify(savedView),
|
|
11511
|
-
headers: {
|
|
11512
|
-
"Content-Type": "application/json",
|
|
11513
|
-
"Accept-Language": locale2
|
|
11514
|
-
}
|
|
11515
|
-
});
|
|
11516
|
-
if (response.error) {
|
|
11517
|
-
throw response.error;
|
|
11518
|
-
}
|
|
11519
|
-
return response.data;
|
|
11520
|
-
},
|
|
11521
|
-
onSuccess: (savedView) => {
|
|
11522
|
-
if (method === "DELETE" || method === "POST") {
|
|
11523
|
-
queryClient2.invalidateQueries({
|
|
11524
|
-
queryKey: ["savedViews", domain, tableName]
|
|
11525
|
-
});
|
|
11526
|
-
return;
|
|
11527
|
-
} else {
|
|
11528
|
-
const oldData = queryClient2.getQueryData([
|
|
11529
|
-
"savedViews",
|
|
11530
|
-
domain,
|
|
11531
|
-
tableName
|
|
11532
|
-
]);
|
|
11533
|
-
const oldView = oldData == null ? void 0 : oldData.find(
|
|
11534
|
-
(item) => item.share_token === savedView.share_token
|
|
11535
|
-
);
|
|
11536
|
-
if ((oldView == null ? void 0 : oldView.name) !== savedView.name) {
|
|
11537
|
-
queryClient2.invalidateQueries({
|
|
11538
|
-
queryKey: ["savedViews", domain, tableName]
|
|
11539
|
-
});
|
|
11540
|
-
return;
|
|
11541
|
-
}
|
|
11542
|
-
}
|
|
11543
|
-
queryClient2.setQueryData(
|
|
11544
|
-
["savedViews", domain, tableName],
|
|
11545
|
-
(oldData) => {
|
|
11546
|
-
if (!oldData)
|
|
11547
|
-
return [savedView];
|
|
11548
|
-
return oldData.map(
|
|
11549
|
-
(item) => item.share_token === savedView.share_token ? savedView : item
|
|
11550
|
-
);
|
|
11551
|
-
}
|
|
11552
|
-
);
|
|
11553
|
-
}
|
|
11554
|
-
});
|
|
11555
|
-
};
|
|
11556
|
-
|
|
11557
11447
|
// src/utils/constants/viewLevels.ts
|
|
11558
11448
|
var VIEW_LEVELS = ["company", "project", "personal"];
|
|
11559
11449
|
|
|
11560
|
-
// src/utils/api/queries.ts
|
|
11561
|
-
var PAGE_SIZE = 50 * VIEW_LEVELS.length;
|
|
11562
|
-
var useSavedViewsQuery = (props) => {
|
|
11563
|
-
const { projectId, companyId, domain, tableName } = props;
|
|
11564
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
11565
|
-
return (0, import_react_query2.useQuery)({
|
|
11566
|
-
queryKey: ["savedViews", domain, tableName],
|
|
11567
|
-
queryFn: async () => {
|
|
11568
|
-
const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
|
|
11569
|
-
const response = await requestJSON(getUrl2);
|
|
11570
|
-
return response.data;
|
|
11571
|
-
}
|
|
11572
|
-
});
|
|
11573
|
-
};
|
|
11574
|
-
var useSavedViewsPermissions = (props) => {
|
|
11575
|
-
const { projectId, companyId, domain } = props;
|
|
11576
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
|
|
11577
|
-
return (0, import_react_query2.useQuery)({
|
|
11578
|
-
queryKey: ["savedViewsConfig", domain],
|
|
11579
|
-
queryFn: async () => {
|
|
11580
|
-
const response = await requestJSON(url);
|
|
11581
|
-
return response.data;
|
|
11582
|
-
}
|
|
11583
|
-
});
|
|
11584
|
-
};
|
|
11585
|
-
var useCreateSavedView = (props) => useApiRequest(props, "POST", [
|
|
11586
|
-
"createSavedView",
|
|
11587
|
-
props.domain,
|
|
11588
|
-
props.tableName
|
|
11589
|
-
]);
|
|
11590
|
-
var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
|
|
11591
|
-
"updateSavedView",
|
|
11592
|
-
props.domain,
|
|
11593
|
-
props.tableName
|
|
11594
|
-
]);
|
|
11595
|
-
var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
11596
|
-
"deleteSavedView",
|
|
11597
|
-
props.domain,
|
|
11598
|
-
props.tableName
|
|
11599
|
-
]);
|
|
11600
|
-
var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
11601
|
-
const { projectId, companyId } = queryInput;
|
|
11602
|
-
return (0, import_react_query2.useQuery)({
|
|
11603
|
-
enabled: enabled && Boolean(savedViewToken),
|
|
11604
|
-
queryKey: ["savedView", savedViewToken],
|
|
11605
|
-
queryFn: async () => {
|
|
11606
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedViewToken}`;
|
|
11607
|
-
const response = await requestJSON(url);
|
|
11608
|
-
return response.data;
|
|
11609
|
-
}
|
|
11610
|
-
});
|
|
11611
|
-
};
|
|
11612
|
-
|
|
11613
11450
|
// src/components/panels/PanelContentUtils.ts
|
|
11614
11451
|
var import_lodash = __toESM(require_lodash());
|
|
11615
11452
|
|
|
@@ -11759,12 +11596,13 @@ var normalizeForComparison = (config) => {
|
|
|
11759
11596
|
if (!(config == null ? void 0 : config.columnState))
|
|
11760
11597
|
return config;
|
|
11761
11598
|
return {
|
|
11762
|
-
...config,
|
|
11599
|
+
...import_lodash.default.omit(config, ["enableRowGrouping", "enableColumnGrouping"]),
|
|
11763
11600
|
columnState: config.columnState.map((col) => {
|
|
11601
|
+
const res = import_lodash.default.omit(col, ["aggFunc"]);
|
|
11764
11602
|
if (col.flex) {
|
|
11765
|
-
return import_lodash.default.omit(
|
|
11603
|
+
return import_lodash.default.omit(res, ["width", "flex"]);
|
|
11766
11604
|
}
|
|
11767
|
-
return
|
|
11605
|
+
return res;
|
|
11768
11606
|
})
|
|
11769
11607
|
};
|
|
11770
11608
|
};
|
|
@@ -11777,10 +11615,9 @@ var isEqual = (viewTableConfig, tableConfig, defaultViewConfig, provider) => {
|
|
|
11777
11615
|
);
|
|
11778
11616
|
const normalizedViewConfig = normalizeForComparison(syncedViewTableConfig);
|
|
11779
11617
|
const normalizedCurrentConfig = normalizeForComparison(tableConfig);
|
|
11780
|
-
|
|
11781
|
-
|
|
11782
|
-
|
|
11783
|
-
);
|
|
11618
|
+
const cleanedViewConfig = cleanObject(normalizedViewConfig, provider);
|
|
11619
|
+
const cleanedCurrentConfig = cleanObject(normalizedCurrentConfig, provider);
|
|
11620
|
+
return import_lodash.default.isEqual(cleanedViewConfig, cleanedCurrentConfig);
|
|
11784
11621
|
};
|
|
11785
11622
|
var hasPermissionForViewLevel = (viewLevel, permissions) => {
|
|
11786
11623
|
switch (viewLevel) {
|
|
@@ -11808,7 +11645,7 @@ var useGroups = () => {
|
|
|
11808
11645
|
};
|
|
11809
11646
|
|
|
11810
11647
|
// src/components/panels/ViewLevelHeader.tsx
|
|
11811
|
-
var
|
|
11648
|
+
var import_core_react5 = require("@procore/core-react");
|
|
11812
11649
|
var import_react7 = __toESM(require("react"));
|
|
11813
11650
|
var groupIcon = (group) => {
|
|
11814
11651
|
switch (group) {
|
|
@@ -11820,26 +11657,26 @@ var groupIcon = (group) => {
|
|
|
11820
11657
|
return /* @__PURE__ */ import_react7.default.createElement(Building_default, null);
|
|
11821
11658
|
}
|
|
11822
11659
|
};
|
|
11823
|
-
var Header = styled_components_esm_default(
|
|
11660
|
+
var Header = styled_components_esm_default(import_core_react5.Flex)`
|
|
11824
11661
|
width: 100%;
|
|
11825
11662
|
&:hover {
|
|
11826
|
-
background-color: ${
|
|
11663
|
+
background-color: ${import_core_react5.colors.gray98};
|
|
11827
11664
|
}
|
|
11828
11665
|
`;
|
|
11829
11666
|
var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
|
|
11830
|
-
const I18n = (0,
|
|
11667
|
+
const I18n = (0, import_core_react5.useI18nContext)();
|
|
11831
11668
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
11832
11669
|
Header,
|
|
11833
11670
|
{
|
|
11834
11671
|
alignItems: "center",
|
|
11835
|
-
padding: `${
|
|
11836
|
-
gap: `${
|
|
11672
|
+
padding: `${import_core_react5.spacing.sm}px`,
|
|
11673
|
+
gap: `${import_core_react5.spacing.sm}px`,
|
|
11837
11674
|
style: { cursor: "pointer" },
|
|
11838
11675
|
onClick: () => toggleGroup(group)
|
|
11839
11676
|
},
|
|
11840
11677
|
expanded ? /* @__PURE__ */ import_react7.default.createElement(ChevronDown_default, { size: "sm" }) : /* @__PURE__ */ import_react7.default.createElement(ChevronRight_default, { size: "sm" }),
|
|
11841
11678
|
groupIcon(group),
|
|
11842
|
-
/* @__PURE__ */ import_react7.default.createElement(
|
|
11679
|
+
/* @__PURE__ */ import_react7.default.createElement(import_core_react5.Typography, { weight: "semibold" }, I18n.t(`savedViews.viewLevel.${group}`))
|
|
11843
11680
|
);
|
|
11844
11681
|
};
|
|
11845
11682
|
var ViewLevelHeader_default = ViewLevelHeader;
|
|
@@ -11857,21 +11694,21 @@ var useScrollToRef = (dependency) => {
|
|
|
11857
11694
|
};
|
|
11858
11695
|
|
|
11859
11696
|
// src/components/panels/PanelContent.styles.ts
|
|
11860
|
-
var
|
|
11861
|
-
var Row = styled_components_esm_default(
|
|
11697
|
+
var import_core_react6 = require("@procore/core-react");
|
|
11698
|
+
var Row = styled_components_esm_default(import_core_react6.UNSAFE_Menu.Item)`
|
|
11862
11699
|
width: 100%;
|
|
11863
11700
|
padding-left: 35px;
|
|
11864
11701
|
padding-right: 4px;
|
|
11865
|
-
background-color: ${({ selected }) => selected ?
|
|
11702
|
+
background-color: ${({ selected }) => selected ? import_core_react6.colors.blue96 : "transparent"};
|
|
11866
11703
|
|
|
11867
11704
|
&:hover {
|
|
11868
|
-
background-color: ${({ selected }) => selected ?
|
|
11705
|
+
background-color: ${({ selected }) => selected ? import_core_react6.colors.blue96 : import_core_react6.colors.gray98};
|
|
11869
11706
|
}
|
|
11870
11707
|
`;
|
|
11871
|
-
var Panel2 = styled_components_esm_default(
|
|
11708
|
+
var Panel2 = styled_components_esm_default(import_core_react6.DetailPage.Card)`
|
|
11872
11709
|
margin: 0;
|
|
11873
11710
|
height: 100%;
|
|
11874
|
-
padding-top: ${
|
|
11711
|
+
padding-top: ${import_core_react6.spacing.sm}px;
|
|
11875
11712
|
box-shadow: none;
|
|
11876
11713
|
`;
|
|
11877
11714
|
|
|
@@ -11879,9 +11716,9 @@ var Panel2 = styled_components_esm_default(import_core_react7.DetailPage.Card)`
|
|
|
11879
11716
|
var PanelContent = (props) => {
|
|
11880
11717
|
const { queryInput, selectedSavedView, tableConfig } = props;
|
|
11881
11718
|
const { showToast } = (0, import_toast_alert2.useToastAlertContext)();
|
|
11882
|
-
const I18n = (0,
|
|
11883
|
-
const { data: savedViewsFromQuery, error: savedViewsError } = useSavedViewsQuery(props.queryInput);
|
|
11884
|
-
const updateMutation = useUpdateSavedView(queryInput);
|
|
11719
|
+
const I18n = (0, import_core_react7.useI18nContext)();
|
|
11720
|
+
const { data: savedViewsFromQuery, error: savedViewsError } = props.backend.useSavedViewsQuery(props.queryInput);
|
|
11721
|
+
const updateMutation = props.backend.useUpdateSavedView(queryInput);
|
|
11885
11722
|
const { mutate: updateSavedView } = updateMutation;
|
|
11886
11723
|
const isUpdateLoading = "isPending" in updateMutation ? updateMutation.isPending : updateMutation.isLoading ?? false;
|
|
11887
11724
|
const savedViews = props.savedViews ?? savedViewsFromQuery;
|
|
@@ -11892,7 +11729,9 @@ var PanelContent = (props) => {
|
|
|
11892
11729
|
errorToastRef.current = savedViewsError;
|
|
11893
11730
|
}
|
|
11894
11731
|
}, [savedViewsError, showToast, I18n]);
|
|
11895
|
-
const { data: permissions } = useSavedViewsPermissions(
|
|
11732
|
+
const { data: permissions } = props.backend.useSavedViewsPermissions(
|
|
11733
|
+
props.queryInput
|
|
11734
|
+
);
|
|
11896
11735
|
const selectedRowRef = useScrollToRef(savedViews);
|
|
11897
11736
|
const { groups, toggleGroup } = useGroups();
|
|
11898
11737
|
const isTemporarySelected = (selectedSavedView == null ? void 0 : selectedSavedView.id) === "temporary";
|
|
@@ -11914,7 +11753,7 @@ var PanelContent = (props) => {
|
|
|
11914
11753
|
}
|
|
11915
11754
|
});
|
|
11916
11755
|
};
|
|
11917
|
-
return /* @__PURE__ */ import_react9.default.createElement(Panel2, { "data-testid": "inner-panel" }, /* @__PURE__ */ import_react9.default.createElement(
|
|
11756
|
+
return /* @__PURE__ */ import_react9.default.createElement(Panel2, { "data-testid": "inner-panel" }, /* @__PURE__ */ import_react9.default.createElement(import_core_react7.Flex, { direction: "column", style: { height: "100%", width: "100%" } }, temporaryView && /* @__PURE__ */ import_react9.default.createElement(
|
|
11918
11757
|
Row,
|
|
11919
11758
|
{
|
|
11920
11759
|
selected: isTemporarySelected,
|
|
@@ -11926,7 +11765,8 @@ var PanelContent = (props) => {
|
|
|
11926
11765
|
{
|
|
11927
11766
|
item: temporaryView,
|
|
11928
11767
|
selected: isTemporarySelected,
|
|
11929
|
-
onClearTemporary: props.onClearTemporary
|
|
11768
|
+
onClearTemporary: props.onClearTemporary,
|
|
11769
|
+
enableSharingViews: false
|
|
11930
11770
|
}
|
|
11931
11771
|
)
|
|
11932
11772
|
), presetViews.map((presetView) => {
|
|
@@ -11943,7 +11783,8 @@ var PanelContent = (props) => {
|
|
|
11943
11783
|
SavedViewCollectionMenuItem,
|
|
11944
11784
|
{
|
|
11945
11785
|
item: presetView,
|
|
11946
|
-
selected: isSelected
|
|
11786
|
+
selected: isSelected,
|
|
11787
|
+
enableSharingViews: false
|
|
11947
11788
|
}
|
|
11948
11789
|
)
|
|
11949
11790
|
);
|
|
@@ -11991,7 +11832,8 @@ var PanelContent = (props) => {
|
|
|
11991
11832
|
isUpdateProcessing: isUpdateLoading,
|
|
11992
11833
|
onEdit: () => props.openModal("update" /* UPDATE */),
|
|
11993
11834
|
onDelete: props.onDelete,
|
|
11994
|
-
permissions
|
|
11835
|
+
permissions,
|
|
11836
|
+
enableSharingViews: false
|
|
11995
11837
|
}
|
|
11996
11838
|
)
|
|
11997
11839
|
);
|
|
@@ -12006,16 +11848,16 @@ var import_react_query3 = require("@tanstack/react-query");
|
|
|
12006
11848
|
var import_toast_alert3 = require("@procore/toast-alert");
|
|
12007
11849
|
|
|
12008
11850
|
// src/components/modals/DeleteConfirmationModal.tsx
|
|
12009
|
-
var
|
|
11851
|
+
var import_core_react8 = require("@procore/core-react");
|
|
12010
11852
|
var import_react10 = __toESM(require("react"));
|
|
12011
11853
|
var SavedViewsDeleteConfirmationModalShared = ({
|
|
12012
11854
|
onCancel,
|
|
12013
11855
|
onDelete,
|
|
12014
11856
|
open
|
|
12015
11857
|
}) => {
|
|
12016
|
-
const i18n = (0,
|
|
11858
|
+
const i18n = (0, import_core_react8.useI18nContext)();
|
|
12017
11859
|
return /* @__PURE__ */ import_react10.default.createElement(
|
|
12018
|
-
|
|
11860
|
+
import_core_react8.ConfirmModal,
|
|
12019
11861
|
{
|
|
12020
11862
|
"data-testid": "delete-confirmation-modal",
|
|
12021
11863
|
open,
|
|
@@ -12024,8 +11866,8 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
12024
11866
|
onClose: onCancel,
|
|
12025
11867
|
style: { overflowWrap: "anywhere" }
|
|
12026
11868
|
},
|
|
12027
|
-
/* @__PURE__ */ import_react10.default.createElement(
|
|
12028
|
-
/* @__PURE__ */ import_react10.default.createElement(
|
|
11869
|
+
/* @__PURE__ */ import_react10.default.createElement(import_core_react8.Modal.Body, null, /* @__PURE__ */ import_react10.default.createElement(import_core_react8.P, null, i18n.t("savedViews.modal.delete.description"))),
|
|
11870
|
+
/* @__PURE__ */ import_react10.default.createElement(import_core_react8.Modal.Footer, null, /* @__PURE__ */ import_react10.default.createElement(import_core_react8.Modal.FooterButtons, null, /* @__PURE__ */ import_react10.default.createElement(import_core_react8.Button, { variant: "secondary", onClick: onCancel }, i18n.t("savedViews.actions.cancel")), /* @__PURE__ */ import_react10.default.createElement(import_core_react8.Button, { variant: "primary", onClick: onDelete }, i18n.t("savedViews.actions.delete"))))
|
|
12029
11871
|
);
|
|
12030
11872
|
};
|
|
12031
11873
|
|
|
@@ -12033,7 +11875,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
12033
11875
|
var import_react11 = __toESM(require("react"));
|
|
12034
11876
|
|
|
12035
11877
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
12036
|
-
var
|
|
11878
|
+
var import_core_react9 = require("@procore/core-react");
|
|
12037
11879
|
var React19 = __toESM(require("react"));
|
|
12038
11880
|
|
|
12039
11881
|
// ../../node_modules/yup/index.esm.js
|
|
@@ -14362,6 +14204,7 @@ function extractMessage(error, I18n) {
|
|
|
14362
14204
|
}
|
|
14363
14205
|
|
|
14364
14206
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
14207
|
+
var { useEffect: useEffect2, useRef: useRef2 } = React19;
|
|
14365
14208
|
var ScrollContainer = styled_components_esm_default("div")`
|
|
14366
14209
|
overflow: auto;
|
|
14367
14210
|
`;
|
|
@@ -14378,22 +14221,38 @@ var FormModalBase = ({
|
|
|
14378
14221
|
defaultView,
|
|
14379
14222
|
selectedSavedView,
|
|
14380
14223
|
setOpenEditCreateModal,
|
|
14381
|
-
onSelect
|
|
14224
|
+
onSelect,
|
|
14225
|
+
backend
|
|
14382
14226
|
}) => {
|
|
14383
|
-
const I18n = (0,
|
|
14227
|
+
const I18n = (0, import_core_react9.useI18nContext)();
|
|
14384
14228
|
const NAME_MAX_LENGTH = 150;
|
|
14229
|
+
const originalBodyWidth = useRef2("");
|
|
14230
|
+
useEffect2(() => {
|
|
14231
|
+
if (open) {
|
|
14232
|
+
originalBodyWidth.current = document.body.style.width || "";
|
|
14233
|
+
document.body.style.width = "100%";
|
|
14234
|
+
} else {
|
|
14235
|
+
document.body.style.width = originalBodyWidth.current;
|
|
14236
|
+
}
|
|
14237
|
+
return () => {
|
|
14238
|
+
if (originalBodyWidth.current !== void 0) {
|
|
14239
|
+
document.body.style.width = originalBodyWidth.current;
|
|
14240
|
+
}
|
|
14241
|
+
};
|
|
14242
|
+
}, [open]);
|
|
14243
|
+
const { useCreateSavedView: useCreateSavedView2, useUpdateSavedView: useUpdateSavedView2, useSavedViewsPermissions: useSavedViewsPermissions2 } = backend;
|
|
14385
14244
|
const {
|
|
14386
14245
|
mutate: createSavedView,
|
|
14387
14246
|
isPending: isCreating,
|
|
14388
14247
|
error: createError,
|
|
14389
14248
|
reset: resetCreateMutation
|
|
14390
|
-
} =
|
|
14249
|
+
} = useCreateSavedView2(queryInput);
|
|
14391
14250
|
const {
|
|
14392
14251
|
mutate: updateSavedView,
|
|
14393
14252
|
isPending: isUpdating,
|
|
14394
14253
|
error: updateError,
|
|
14395
14254
|
reset: resetUpdateMutation
|
|
14396
|
-
} =
|
|
14255
|
+
} = useUpdateSavedView2(queryInput);
|
|
14397
14256
|
const resetMutations = () => {
|
|
14398
14257
|
resetCreateMutation();
|
|
14399
14258
|
resetUpdateMutation();
|
|
@@ -14402,7 +14261,7 @@ var FormModalBase = ({
|
|
|
14402
14261
|
resetMutations();
|
|
14403
14262
|
onCancel();
|
|
14404
14263
|
};
|
|
14405
|
-
const { data: permissions } =
|
|
14264
|
+
const { data: permissions } = useSavedViewsPermissions2(queryInput);
|
|
14406
14265
|
const isLoading = isCreating || isUpdating;
|
|
14407
14266
|
const errors = extractMessage(createError || updateError, I18n);
|
|
14408
14267
|
const handleOnSubmit = (data) => {
|
|
@@ -14435,7 +14294,7 @@ var FormModalBase = ({
|
|
|
14435
14294
|
};
|
|
14436
14295
|
const viewLevelOptions = getViewLevelOptions(permissions, I18n);
|
|
14437
14296
|
return /* @__PURE__ */ React19.createElement(
|
|
14438
|
-
|
|
14297
|
+
import_core_react9.Modal,
|
|
14439
14298
|
{
|
|
14440
14299
|
"aria-label": I18n.t("savedViews.ariaLabels.modal"),
|
|
14441
14300
|
onClickOverlay: onClose,
|
|
@@ -14444,14 +14303,14 @@ var FormModalBase = ({
|
|
|
14444
14303
|
"data-testid": "create-update-modal"
|
|
14445
14304
|
},
|
|
14446
14305
|
/* @__PURE__ */ React19.createElement(ScrollContainer, null, /* @__PURE__ */ React19.createElement(
|
|
14447
|
-
|
|
14306
|
+
import_core_react9.Modal.Header,
|
|
14448
14307
|
{
|
|
14449
14308
|
onClose,
|
|
14450
|
-
style: { borderBottom: `1px solid ${
|
|
14309
|
+
style: { borderBottom: `1px solid ${import_core_react9.colors.gray85}` }
|
|
14451
14310
|
},
|
|
14452
|
-
/* @__PURE__ */ React19.createElement(
|
|
14311
|
+
/* @__PURE__ */ React19.createElement(import_core_react9.H2, null, header)
|
|
14453
14312
|
), /* @__PURE__ */ React19.createElement(
|
|
14454
|
-
|
|
14313
|
+
import_core_react9.Form,
|
|
14455
14314
|
{
|
|
14456
14315
|
initialValues: {
|
|
14457
14316
|
name: initialName,
|
|
@@ -14476,14 +14335,14 @@ var FormModalBase = ({
|
|
|
14476
14335
|
onReset: onCancel,
|
|
14477
14336
|
validateOnChange: true
|
|
14478
14337
|
},
|
|
14479
|
-
/* @__PURE__ */ React19.createElement(
|
|
14480
|
-
|
|
14338
|
+
/* @__PURE__ */ React19.createElement(import_core_react9.Form.Form, { name: header }, /* @__PURE__ */ React19.createElement(
|
|
14339
|
+
import_core_react9.Modal.Body,
|
|
14481
14340
|
{
|
|
14482
|
-
style: { paddingTop: 0, paddingBottom: 0, marginTop:
|
|
14341
|
+
style: { paddingTop: 0, paddingBottom: 0, marginTop: import_core_react9.spacing.lg }
|
|
14483
14342
|
},
|
|
14484
|
-
errors && /* @__PURE__ */ React19.createElement(
|
|
14485
|
-
/* @__PURE__ */ React19.createElement(
|
|
14486
|
-
|
|
14343
|
+
errors && /* @__PURE__ */ React19.createElement(import_core_react9.ErrorBanner, { style: { marginBottom: import_core_react9.spacing.xl } }, /* @__PURE__ */ React19.createElement(import_core_react9.Banner.Content, null, /* @__PURE__ */ React19.createElement(import_core_react9.Banner.Title, null, I18n.t("savedViews.modal.errors.title", { mode })), /* @__PURE__ */ React19.createElement(import_core_react9.Banner.Body, null, (errors == null ? void 0 : errors.form) || I18n.t(`savedViews.modal.errors.description.${mode}`)))),
|
|
14344
|
+
/* @__PURE__ */ React19.createElement(import_core_react9.Form.Row, null, /* @__PURE__ */ React19.createElement(
|
|
14345
|
+
import_core_react9.Form.Text,
|
|
14487
14346
|
{
|
|
14488
14347
|
name: "name",
|
|
14489
14348
|
error: errors == null ? void 0 : errors.name,
|
|
@@ -14494,12 +14353,12 @@ var FormModalBase = ({
|
|
|
14494
14353
|
}
|
|
14495
14354
|
)),
|
|
14496
14355
|
/* @__PURE__ */ React19.createElement(
|
|
14497
|
-
|
|
14356
|
+
import_core_react9.Form.Row,
|
|
14498
14357
|
{
|
|
14499
|
-
style: { marginTop: (errors == null ? void 0 : errors.name) ?
|
|
14358
|
+
style: { marginTop: (errors == null ? void 0 : errors.name) ? import_core_react9.spacing.xl : import_core_react9.spacing.none }
|
|
14500
14359
|
},
|
|
14501
14360
|
/* @__PURE__ */ React19.createElement(
|
|
14502
|
-
|
|
14361
|
+
import_core_react9.Form.TextArea,
|
|
14503
14362
|
{
|
|
14504
14363
|
name: "description",
|
|
14505
14364
|
placeholder: I18n.t("savedViews.modal.fields.description"),
|
|
@@ -14509,10 +14368,11 @@ var FormModalBase = ({
|
|
|
14509
14368
|
}
|
|
14510
14369
|
)
|
|
14511
14370
|
),
|
|
14512
|
-
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React19.createElement(
|
|
14513
|
-
|
|
14371
|
+
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React19.createElement(import_core_react9.Form.Row, null, /* @__PURE__ */ React19.createElement(
|
|
14372
|
+
import_core_react9.Form.Select,
|
|
14514
14373
|
{
|
|
14515
14374
|
name: "view_level",
|
|
14375
|
+
qa: { label: "view-level" },
|
|
14516
14376
|
options: viewLevelOptions,
|
|
14517
14377
|
label: I18n.t("savedViews.modal.fields.viewLevel"),
|
|
14518
14378
|
colWidth: 12,
|
|
@@ -14520,8 +14380,8 @@ var FormModalBase = ({
|
|
|
14520
14380
|
onClear: false
|
|
14521
14381
|
}
|
|
14522
14382
|
)) : /* @__PURE__ */ React19.createElement(React19.Fragment, null)
|
|
14523
|
-
), /* @__PURE__ */ React19.createElement(
|
|
14524
|
-
|
|
14383
|
+
), /* @__PURE__ */ React19.createElement(import_core_react9.Modal.Footer, { style: { borderTop: `1px solid ${import_core_react9.colors.gray85}` } }, /* @__PURE__ */ React19.createElement(import_core_react9.Flex, { grow: "1", justifyContent: "space-between", alignItems: "center" }, /* @__PURE__ */ React19.createElement(import_core_react9.Typography, { color: "gray45", italic: true }, /* @__PURE__ */ React19.createElement(import_core_react9.Typography, { color: "red45" }, "*"), " ", I18n.t("savedViews.modal.info.required_fields")), /* @__PURE__ */ React19.createElement(import_core_react9.Modal.FooterButtons, null, /* @__PURE__ */ React19.createElement(import_core_react9.Button, { type: "reset", variant: "tertiary", disabled: isLoading }, I18n.t("savedViews.actions.cancel")), /* @__PURE__ */ React19.createElement(
|
|
14384
|
+
import_core_react9.Button,
|
|
14525
14385
|
{
|
|
14526
14386
|
"data-testid": "create-update-modal-button",
|
|
14527
14387
|
type: "submit",
|
|
@@ -14536,7 +14396,7 @@ var FormModalBase = ({
|
|
|
14536
14396
|
};
|
|
14537
14397
|
|
|
14538
14398
|
// src/components/modals/form-modal/FormModal.tsx
|
|
14539
|
-
var
|
|
14399
|
+
var import_core_react10 = require("@procore/core-react");
|
|
14540
14400
|
var FormModal = ({
|
|
14541
14401
|
open,
|
|
14542
14402
|
mode,
|
|
@@ -14547,9 +14407,10 @@ var FormModal = ({
|
|
|
14547
14407
|
selectedSavedView,
|
|
14548
14408
|
setOpenEditCreateModal,
|
|
14549
14409
|
onSelect,
|
|
14550
|
-
defaultView
|
|
14410
|
+
defaultView,
|
|
14411
|
+
backend
|
|
14551
14412
|
}) => {
|
|
14552
|
-
const i18n = (0,
|
|
14413
|
+
const i18n = (0, import_core_react10.useI18nContext)();
|
|
14553
14414
|
return /* @__PURE__ */ import_react11.default.createElement(
|
|
14554
14415
|
FormModalBase,
|
|
14555
14416
|
{
|
|
@@ -14565,13 +14426,14 @@ var FormModal = ({
|
|
|
14565
14426
|
selectedSavedView,
|
|
14566
14427
|
setOpenEditCreateModal,
|
|
14567
14428
|
onSelect,
|
|
14568
|
-
defaultView
|
|
14429
|
+
defaultView,
|
|
14430
|
+
backend
|
|
14569
14431
|
}
|
|
14570
14432
|
);
|
|
14571
14433
|
};
|
|
14572
14434
|
|
|
14573
14435
|
// src/components/modals/form-modal/SharedViewFormModal.tsx
|
|
14574
|
-
var
|
|
14436
|
+
var import_core_react11 = require("@procore/core-react");
|
|
14575
14437
|
var React21 = __toESM(require("react"));
|
|
14576
14438
|
var SharedViewFormModal = ({
|
|
14577
14439
|
open,
|
|
@@ -14583,7 +14445,7 @@ var SharedViewFormModal = ({
|
|
|
14583
14445
|
isCreating,
|
|
14584
14446
|
resetCreateError
|
|
14585
14447
|
}) => {
|
|
14586
|
-
const I18n = (0,
|
|
14448
|
+
const I18n = (0, import_core_react11.useI18nContext)();
|
|
14587
14449
|
const NAME_MAX_LENGTH = 150;
|
|
14588
14450
|
const errors = extractMessage(createError, I18n);
|
|
14589
14451
|
const handleNameChange = () => {
|
|
@@ -14595,7 +14457,7 @@ var SharedViewFormModal = ({
|
|
|
14595
14457
|
onCreateView(data.name, data.description);
|
|
14596
14458
|
};
|
|
14597
14459
|
return /* @__PURE__ */ React21.createElement(
|
|
14598
|
-
|
|
14460
|
+
import_core_react11.Modal,
|
|
14599
14461
|
{
|
|
14600
14462
|
"data-testid": "shared-view-form-modal",
|
|
14601
14463
|
open,
|
|
@@ -14603,35 +14465,35 @@ var SharedViewFormModal = ({
|
|
|
14603
14465
|
style: { width: "540px" }
|
|
14604
14466
|
},
|
|
14605
14467
|
/* @__PURE__ */ React21.createElement(
|
|
14606
|
-
|
|
14468
|
+
import_core_react11.Modal.Header,
|
|
14607
14469
|
{
|
|
14608
14470
|
onClose,
|
|
14609
14471
|
style: {
|
|
14610
|
-
paddingTop:
|
|
14611
|
-
paddingBottom:
|
|
14612
|
-
paddingLeft:
|
|
14613
|
-
paddingRight:
|
|
14472
|
+
paddingTop: import_core_react11.spacing.lg,
|
|
14473
|
+
paddingBottom: import_core_react11.spacing.xs,
|
|
14474
|
+
paddingLeft: import_core_react11.spacing.xl,
|
|
14475
|
+
paddingRight: import_core_react11.spacing.xl
|
|
14614
14476
|
}
|
|
14615
14477
|
},
|
|
14616
14478
|
I18n.t("savedViews.modal.create.title")
|
|
14617
14479
|
),
|
|
14618
14480
|
/* @__PURE__ */ React21.createElement(
|
|
14619
|
-
|
|
14481
|
+
import_core_react11.P,
|
|
14620
14482
|
{
|
|
14621
14483
|
style: {
|
|
14622
|
-
paddingLeft:
|
|
14623
|
-
paddingRight:
|
|
14624
|
-
paddingBottom:
|
|
14625
|
-
paddingTop:
|
|
14484
|
+
paddingLeft: import_core_react11.spacing.xl,
|
|
14485
|
+
paddingRight: import_core_react11.spacing.xl,
|
|
14486
|
+
paddingBottom: import_core_react11.spacing.lg,
|
|
14487
|
+
paddingTop: import_core_react11.spacing.none,
|
|
14626
14488
|
margin: 0,
|
|
14627
|
-
color:
|
|
14489
|
+
color: import_core_react11.colors.gray45,
|
|
14628
14490
|
whiteSpace: "pre-line"
|
|
14629
14491
|
}
|
|
14630
14492
|
},
|
|
14631
14493
|
I18n.t("savedViews.modal.copyConfirmation.description")
|
|
14632
14494
|
),
|
|
14633
14495
|
/* @__PURE__ */ React21.createElement(
|
|
14634
|
-
|
|
14496
|
+
import_core_react11.Form,
|
|
14635
14497
|
{
|
|
14636
14498
|
initialValues: {
|
|
14637
14499
|
name: fetchedView.name,
|
|
@@ -14649,20 +14511,20 @@ var SharedViewFormModal = ({
|
|
|
14649
14511
|
onSubmit: handleOnSubmit,
|
|
14650
14512
|
validateOnChange: true
|
|
14651
14513
|
},
|
|
14652
|
-
/* @__PURE__ */ React21.createElement(
|
|
14653
|
-
|
|
14514
|
+
/* @__PURE__ */ React21.createElement(import_core_react11.Form.Form, { name: "share-view-form" }, /* @__PURE__ */ React21.createElement(
|
|
14515
|
+
import_core_react11.Modal.Body,
|
|
14654
14516
|
{
|
|
14655
14517
|
style: {
|
|
14656
|
-
paddingTop:
|
|
14518
|
+
paddingTop: import_core_react11.spacing.lg,
|
|
14657
14519
|
paddingBottom: 0,
|
|
14658
|
-
borderTop: `1px solid ${
|
|
14520
|
+
borderTop: `1px solid ${import_core_react11.colors.gray85}`
|
|
14659
14521
|
}
|
|
14660
14522
|
},
|
|
14661
|
-
errors && /* @__PURE__ */ React21.createElement(
|
|
14523
|
+
errors && /* @__PURE__ */ React21.createElement(import_core_react11.ErrorBanner, { style: { marginBottom: import_core_react11.spacing.xl } }, /* @__PURE__ */ React21.createElement(import_core_react11.Banner.Content, null, /* @__PURE__ */ React21.createElement(import_core_react11.Banner.Title, null, I18n.t("savedViews.modal.errors.title", {
|
|
14662
14524
|
mode: "create"
|
|
14663
|
-
})), /* @__PURE__ */ React21.createElement(
|
|
14664
|
-
/* @__PURE__ */ React21.createElement(
|
|
14665
|
-
|
|
14525
|
+
})), /* @__PURE__ */ React21.createElement(import_core_react11.Banner.Body, null, (errors == null ? void 0 : errors.form) || I18n.t("savedViews.modal.errors.description.create")))),
|
|
14526
|
+
/* @__PURE__ */ React21.createElement(import_core_react11.Form.Row, null, /* @__PURE__ */ React21.createElement(
|
|
14527
|
+
import_core_react11.Form.Text,
|
|
14666
14528
|
{
|
|
14667
14529
|
name: "name",
|
|
14668
14530
|
error: errors == null ? void 0 : errors.name,
|
|
@@ -14673,12 +14535,12 @@ var SharedViewFormModal = ({
|
|
|
14673
14535
|
}
|
|
14674
14536
|
)),
|
|
14675
14537
|
/* @__PURE__ */ React21.createElement(
|
|
14676
|
-
|
|
14538
|
+
import_core_react11.Form.Row,
|
|
14677
14539
|
{
|
|
14678
|
-
style: { marginTop: (errors == null ? void 0 : errors.name) ?
|
|
14540
|
+
style: { marginTop: (errors == null ? void 0 : errors.name) ? import_core_react11.spacing.xl : import_core_react11.spacing.none }
|
|
14679
14541
|
},
|
|
14680
14542
|
/* @__PURE__ */ React21.createElement(
|
|
14681
|
-
|
|
14543
|
+
import_core_react11.Form.TextArea,
|
|
14682
14544
|
{
|
|
14683
14545
|
name: "description",
|
|
14684
14546
|
placeholder: I18n.t("savedViews.modal.fields.description"),
|
|
@@ -14688,8 +14550,8 @@ var SharedViewFormModal = ({
|
|
|
14688
14550
|
}
|
|
14689
14551
|
)
|
|
14690
14552
|
)
|
|
14691
|
-
), /* @__PURE__ */ React21.createElement(
|
|
14692
|
-
|
|
14553
|
+
), /* @__PURE__ */ React21.createElement(import_core_react11.Modal.Footer, { style: { borderTop: `1px solid ${import_core_react11.colors.gray85}` } }, /* @__PURE__ */ React21.createElement(import_core_react11.Flex, { grow: "1", justifyContent: "space-between", alignItems: "center" }, /* @__PURE__ */ React21.createElement(import_core_react11.Typography, { color: "gray45", italic: true }, /* @__PURE__ */ React21.createElement(import_core_react11.Typography, { color: "red45" }, "*"), " ", I18n.t("savedViews.modal.info.required_fields")), /* @__PURE__ */ React21.createElement(import_core_react11.Modal.FooterButtons, null, /* @__PURE__ */ React21.createElement(
|
|
14554
|
+
import_core_react11.Button,
|
|
14693
14555
|
{
|
|
14694
14556
|
variant: "secondary",
|
|
14695
14557
|
onClick: onCreateTemporaryView,
|
|
@@ -14698,7 +14560,7 @@ var SharedViewFormModal = ({
|
|
|
14698
14560
|
},
|
|
14699
14561
|
I18n.t("savedViews.actions.viewTemporarily")
|
|
14700
14562
|
), /* @__PURE__ */ React21.createElement(
|
|
14701
|
-
|
|
14563
|
+
import_core_react11.Button,
|
|
14702
14564
|
{
|
|
14703
14565
|
type: "submit",
|
|
14704
14566
|
variant: "primary",
|
|
@@ -14715,7 +14577,7 @@ var SharedViewFormModal = ({
|
|
|
14715
14577
|
// src/utils/hooks/useViewSelection.ts
|
|
14716
14578
|
var import_react12 = require("react");
|
|
14717
14579
|
var import_react_router_dom = require("react-router-dom");
|
|
14718
|
-
var
|
|
14580
|
+
var import_core_react12 = require("@procore/core-react");
|
|
14719
14581
|
|
|
14720
14582
|
// src/utils/viewStorage.ts
|
|
14721
14583
|
var ViewStorage = {
|
|
@@ -14778,7 +14640,7 @@ var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
|
14778
14640
|
}
|
|
14779
14641
|
};
|
|
14780
14642
|
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) => {
|
|
14781
|
-
const I18n = (0,
|
|
14643
|
+
const I18n = (0, import_core_react12.useI18nContext)();
|
|
14782
14644
|
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${config.projectId}_${config.userId}`;
|
|
14783
14645
|
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
14784
14646
|
const [searchParams, setSearchParams] = (0, import_react_router_dom.useSearchParams)();
|
|
@@ -14877,6 +14739,177 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) =>
|
|
|
14877
14739
|
};
|
|
14878
14740
|
};
|
|
14879
14741
|
|
|
14742
|
+
// node_modules/@procore/core-http/dist/modern/index.js
|
|
14743
|
+
function getCSRFToken() {
|
|
14744
|
+
const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
|
|
14745
|
+
return token ? decodeURIComponent(token.pop() || "") : "";
|
|
14746
|
+
}
|
|
14747
|
+
function getCSRFHeader() {
|
|
14748
|
+
const csrfToken = getCSRFToken();
|
|
14749
|
+
return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
|
|
14750
|
+
}
|
|
14751
|
+
function removeLeadingSlash(url) {
|
|
14752
|
+
return url.startsWith("/") ? url.substring(1, url.length) : url;
|
|
14753
|
+
}
|
|
14754
|
+
function removeTrailingSlash(url) {
|
|
14755
|
+
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
14756
|
+
}
|
|
14757
|
+
function applyBaseUrl(url, baseUrl) {
|
|
14758
|
+
return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
|
|
14759
|
+
}
|
|
14760
|
+
function getOptions({ headers, ...options }) {
|
|
14761
|
+
const opts = {
|
|
14762
|
+
credentials: "same-origin",
|
|
14763
|
+
headers: {
|
|
14764
|
+
...getCSRFHeader(),
|
|
14765
|
+
...headers
|
|
14766
|
+
},
|
|
14767
|
+
mode: "same-origin",
|
|
14768
|
+
...options
|
|
14769
|
+
};
|
|
14770
|
+
return opts;
|
|
14771
|
+
}
|
|
14772
|
+
function getUrl(url, baseUrl) {
|
|
14773
|
+
return baseUrl ? applyBaseUrl(url, baseUrl) : url;
|
|
14774
|
+
}
|
|
14775
|
+
function request(url, { baseUrl, ...options } = {}) {
|
|
14776
|
+
return fetch(getUrl(url, baseUrl), getOptions(options));
|
|
14777
|
+
}
|
|
14778
|
+
function requestJSON(url, requestParams = {}) {
|
|
14779
|
+
return request(url, requestParams).then(
|
|
14780
|
+
(response) => response.json()
|
|
14781
|
+
);
|
|
14782
|
+
}
|
|
14783
|
+
|
|
14784
|
+
// src/utils/api/queries.ts
|
|
14785
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
14786
|
+
|
|
14787
|
+
// src/utils/api/queriesHandler.ts
|
|
14788
|
+
var import_react_query = require("@tanstack/react-query");
|
|
14789
|
+
var import_core_react13 = require("@procore/core-react");
|
|
14790
|
+
var useApiRequest = (props, method, mutationKey) => {
|
|
14791
|
+
const { projectId, companyId, domain, tableName } = props;
|
|
14792
|
+
const queryClient2 = (0, import_react_query.useQueryClient)();
|
|
14793
|
+
const { locale: locale2 } = (0, import_core_react13.useI18nContext)();
|
|
14794
|
+
return (0, import_react_query.useMutation)({
|
|
14795
|
+
mutationKey,
|
|
14796
|
+
mutationFn: async (savedView) => {
|
|
14797
|
+
let url = "";
|
|
14798
|
+
if (method === "DELETE" || method === "PUT") {
|
|
14799
|
+
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.share_token}?permissions_domain=${domain}`;
|
|
14800
|
+
} else {
|
|
14801
|
+
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
14802
|
+
}
|
|
14803
|
+
const response = await requestJSON(url, {
|
|
14804
|
+
method,
|
|
14805
|
+
body: JSON.stringify(savedView),
|
|
14806
|
+
headers: {
|
|
14807
|
+
"Content-Type": "application/json",
|
|
14808
|
+
"Accept-Language": locale2
|
|
14809
|
+
}
|
|
14810
|
+
});
|
|
14811
|
+
if (response.error) {
|
|
14812
|
+
throw response.error;
|
|
14813
|
+
}
|
|
14814
|
+
return response.data;
|
|
14815
|
+
},
|
|
14816
|
+
onSuccess: (savedView) => {
|
|
14817
|
+
if (method === "DELETE" || method === "POST") {
|
|
14818
|
+
queryClient2.invalidateQueries({
|
|
14819
|
+
queryKey: ["savedViews", domain, tableName]
|
|
14820
|
+
});
|
|
14821
|
+
return;
|
|
14822
|
+
} else {
|
|
14823
|
+
const oldData = queryClient2.getQueryData([
|
|
14824
|
+
"savedViews",
|
|
14825
|
+
domain,
|
|
14826
|
+
tableName
|
|
14827
|
+
]);
|
|
14828
|
+
const oldView = oldData == null ? void 0 : oldData.find(
|
|
14829
|
+
(item) => item.share_token === savedView.share_token
|
|
14830
|
+
);
|
|
14831
|
+
if ((oldView == null ? void 0 : oldView.name) !== savedView.name) {
|
|
14832
|
+
queryClient2.invalidateQueries({
|
|
14833
|
+
queryKey: ["savedViews", domain, tableName]
|
|
14834
|
+
});
|
|
14835
|
+
return;
|
|
14836
|
+
}
|
|
14837
|
+
}
|
|
14838
|
+
queryClient2.setQueryData(
|
|
14839
|
+
["savedViews", domain, tableName],
|
|
14840
|
+
(oldData) => {
|
|
14841
|
+
if (!oldData)
|
|
14842
|
+
return [savedView];
|
|
14843
|
+
return oldData.map(
|
|
14844
|
+
(item) => item.share_token === savedView.share_token ? savedView : item
|
|
14845
|
+
);
|
|
14846
|
+
}
|
|
14847
|
+
);
|
|
14848
|
+
}
|
|
14849
|
+
});
|
|
14850
|
+
};
|
|
14851
|
+
|
|
14852
|
+
// src/utils/api/queries.ts
|
|
14853
|
+
var PAGE_SIZE = 50 * VIEW_LEVELS.length;
|
|
14854
|
+
var useSavedViewsQuery = (props) => {
|
|
14855
|
+
const { projectId, companyId, domain, tableName } = props;
|
|
14856
|
+
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
14857
|
+
return (0, import_react_query2.useQuery)({
|
|
14858
|
+
queryKey: ["savedViews", domain, tableName],
|
|
14859
|
+
queryFn: async () => {
|
|
14860
|
+
const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
|
|
14861
|
+
const response = await requestJSON(getUrl2);
|
|
14862
|
+
return response.data;
|
|
14863
|
+
}
|
|
14864
|
+
});
|
|
14865
|
+
};
|
|
14866
|
+
var useSavedViewsPermissions = (props) => {
|
|
14867
|
+
const { projectId, companyId, domain } = props;
|
|
14868
|
+
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
|
|
14869
|
+
return (0, import_react_query2.useQuery)({
|
|
14870
|
+
queryKey: ["savedViewsConfig", domain],
|
|
14871
|
+
queryFn: async () => {
|
|
14872
|
+
const response = await requestJSON(url);
|
|
14873
|
+
return response.data;
|
|
14874
|
+
}
|
|
14875
|
+
});
|
|
14876
|
+
};
|
|
14877
|
+
var useCreateSavedView = (props) => useApiRequest(props, "POST", [
|
|
14878
|
+
"createSavedView",
|
|
14879
|
+
props.domain,
|
|
14880
|
+
props.tableName
|
|
14881
|
+
]);
|
|
14882
|
+
var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
|
|
14883
|
+
"updateSavedView",
|
|
14884
|
+
props.domain,
|
|
14885
|
+
props.tableName
|
|
14886
|
+
]);
|
|
14887
|
+
var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
14888
|
+
"deleteSavedView",
|
|
14889
|
+
props.domain,
|
|
14890
|
+
props.tableName
|
|
14891
|
+
]);
|
|
14892
|
+
var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
14893
|
+
const { projectId, companyId } = queryInput;
|
|
14894
|
+
return (0, import_react_query2.useQuery)({
|
|
14895
|
+
enabled: enabled && Boolean(savedViewToken),
|
|
14896
|
+
queryKey: ["savedView", savedViewToken],
|
|
14897
|
+
queryFn: async () => {
|
|
14898
|
+
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedViewToken}`;
|
|
14899
|
+
const response = await requestJSON(url);
|
|
14900
|
+
return response.data;
|
|
14901
|
+
}
|
|
14902
|
+
});
|
|
14903
|
+
};
|
|
14904
|
+
var createQueries = (customBackend) => ({
|
|
14905
|
+
useSavedViewsQuery: (customBackend == null ? void 0 : customBackend.useSavedViewsQuery) ?? useSavedViewsQuery,
|
|
14906
|
+
useSavedViewsPermissions: (customBackend == null ? void 0 : customBackend.useSavedViewsPermissions) ?? useSavedViewsPermissions,
|
|
14907
|
+
useCreateSavedView: (customBackend == null ? void 0 : customBackend.useCreateSavedView) ?? useCreateSavedView,
|
|
14908
|
+
useUpdateSavedView: (customBackend == null ? void 0 : customBackend.useUpdateSavedView) ?? useUpdateSavedView,
|
|
14909
|
+
useDeleteSavedView: (customBackend == null ? void 0 : customBackend.useDeleteSavedView) ?? useDeleteSavedView,
|
|
14910
|
+
useFetchSavedViewById: (customBackend == null ? void 0 : customBackend.useFetchSavedViewById) ?? useFetchSavedViewById
|
|
14911
|
+
});
|
|
14912
|
+
|
|
14880
14913
|
// src/components/saved-views/SavedViews.tsx
|
|
14881
14914
|
var StyledPanel = styled_components_esm_default.div`
|
|
14882
14915
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
@@ -14884,14 +14917,15 @@ var StyledPanel = styled_components_esm_default.div`
|
|
|
14884
14917
|
var queryClient = new import_react_query3.QueryClient();
|
|
14885
14918
|
var SavedViewsContent = (props) => {
|
|
14886
14919
|
const { projectId, companyId } = props;
|
|
14920
|
+
const backend = createQueries(props.backend);
|
|
14887
14921
|
const queryInput = {
|
|
14888
14922
|
domain: props.domain,
|
|
14889
14923
|
tableName: props.tableName,
|
|
14890
14924
|
projectId,
|
|
14891
14925
|
companyId
|
|
14892
14926
|
};
|
|
14893
|
-
const { data: savedViews } = useSavedViewsQuery(queryInput);
|
|
14894
|
-
const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
|
|
14927
|
+
const { data: savedViews } = backend.useSavedViewsQuery(queryInput);
|
|
14928
|
+
const { mutate: deleteSavedView } = backend.useDeleteSavedView(queryInput);
|
|
14895
14929
|
const { showToast } = (0, import_toast_alert3.useToastAlertContext)();
|
|
14896
14930
|
const i18n = (0, import_core_react14.useI18nContext)();
|
|
14897
14931
|
const [activeModal, setActiveModal] = (0, import_react13.useState)(null);
|
|
@@ -14928,7 +14962,7 @@ var SavedViewsContent = (props) => {
|
|
|
14928
14962
|
props.presetViews,
|
|
14929
14963
|
openSharedViewModal
|
|
14930
14964
|
);
|
|
14931
|
-
const { data: fetchedView, isError: fetchError } = useFetchSavedViewById(
|
|
14965
|
+
const { data: fetchedView, isError: fetchError } = backend.useFetchSavedViewById(
|
|
14932
14966
|
(modalData == null ? void 0 : modalData.viewId) ?? null,
|
|
14933
14967
|
queryInput,
|
|
14934
14968
|
Boolean(modalData == null ? void 0 : modalData.viewId)
|
|
@@ -14938,7 +14972,7 @@ var SavedViewsContent = (props) => {
|
|
|
14938
14972
|
isPending: isCreating,
|
|
14939
14973
|
error: createError,
|
|
14940
14974
|
reset: resetCreateError
|
|
14941
|
-
} = useCreateSavedView(queryInput);
|
|
14975
|
+
} = backend.useCreateSavedView(queryInput);
|
|
14942
14976
|
(0, import_react13.useEffect)(() => {
|
|
14943
14977
|
if (fetchError) {
|
|
14944
14978
|
showToast.error(i18n.t("savedViews.errors.notFound"));
|
|
@@ -15025,7 +15059,8 @@ var SavedViewsContent = (props) => {
|
|
|
15025
15059
|
savedViews: allViews,
|
|
15026
15060
|
provider: props.provider,
|
|
15027
15061
|
userId: props.userId,
|
|
15028
|
-
onClearTemporary: clearTemporaryView
|
|
15062
|
+
onClearTemporary: clearTemporaryView,
|
|
15063
|
+
backend
|
|
15029
15064
|
}
|
|
15030
15065
|
))
|
|
15031
15066
|
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ import_react13.default.createElement(
|
|
@@ -15040,7 +15075,8 @@ var SavedViewsContent = (props) => {
|
|
|
15040
15075
|
selectedSavedView: selectedView,
|
|
15041
15076
|
onSelect: selectView,
|
|
15042
15077
|
setOpenEditCreateModal: closeModal,
|
|
15043
|
-
defaultView: props.defaultView
|
|
15078
|
+
defaultView: props.defaultView,
|
|
15079
|
+
backend
|
|
15044
15080
|
}
|
|
15045
15081
|
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */ import_react13.default.createElement(
|
|
15046
15082
|
SavedViewsDeleteConfirmationModalShared,
|
|
@@ -15085,26 +15121,37 @@ var DEFAULT_COLUMN_STATE = {
|
|
|
15085
15121
|
rowGroupIndex: null,
|
|
15086
15122
|
flex: null
|
|
15087
15123
|
};
|
|
15124
|
+
var isColGroupDef = (colDef) => {
|
|
15125
|
+
return "children" in colDef && Array.isArray(colDef.children);
|
|
15126
|
+
};
|
|
15088
15127
|
var getColumnStateFromDefs = (columnDefs) => {
|
|
15089
|
-
return columnDefs.
|
|
15090
|
-
|
|
15091
|
-
|
|
15092
|
-
|
|
15093
|
-
return
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
|
|
15097
|
-
|
|
15098
|
-
|
|
15099
|
-
|
|
15100
|
-
|
|
15101
|
-
|
|
15102
|
-
|
|
15103
|
-
|
|
15104
|
-
|
|
15105
|
-
|
|
15106
|
-
|
|
15107
|
-
|
|
15128
|
+
return columnDefs.flatMap((colDef) => {
|
|
15129
|
+
if (isColGroupDef(colDef)) {
|
|
15130
|
+
return getColumnStateFromDefs(colDef.children);
|
|
15131
|
+
}
|
|
15132
|
+
return getColumnStateFromSingleDef(colDef);
|
|
15133
|
+
}).filter(
|
|
15134
|
+
(col) => col !== null
|
|
15135
|
+
);
|
|
15136
|
+
};
|
|
15137
|
+
var getColumnStateFromSingleDef = (colDef) => {
|
|
15138
|
+
const field = colDef.field ?? colDef.colId;
|
|
15139
|
+
if (!field)
|
|
15140
|
+
return null;
|
|
15141
|
+
return {
|
|
15142
|
+
colId: field,
|
|
15143
|
+
hide: colDef.hide ?? false,
|
|
15144
|
+
pinned: colDef.pinned ?? null,
|
|
15145
|
+
width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
|
|
15146
|
+
sort: null,
|
|
15147
|
+
sortIndex: null,
|
|
15148
|
+
pivot: false,
|
|
15149
|
+
pivotIndex: null,
|
|
15150
|
+
aggFunc: null,
|
|
15151
|
+
rowGroup: false,
|
|
15152
|
+
rowGroupIndex: null,
|
|
15153
|
+
flex: colDef.flex ?? null
|
|
15154
|
+
};
|
|
15108
15155
|
};
|
|
15109
15156
|
var extractDefaultView = (gridApi, receivedConfig) => {
|
|
15110
15157
|
var _a, _b;
|
|
@@ -15151,10 +15198,14 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15151
15198
|
const [config, setConfig] = (0, import_react15.useState)(
|
|
15152
15199
|
() => getSmartGridConfig(gridApi)
|
|
15153
15200
|
);
|
|
15201
|
+
const eventListenersDisabledRef = (0, import_react15.useRef)(false);
|
|
15154
15202
|
(0, import_react15.useEffect)(() => {
|
|
15155
15203
|
if (!gridApi)
|
|
15156
15204
|
return;
|
|
15157
15205
|
const updateConfig = () => {
|
|
15206
|
+
if (eventListenersDisabledRef.current) {
|
|
15207
|
+
return;
|
|
15208
|
+
}
|
|
15158
15209
|
setConfig(getSmartGridConfig(gridApi));
|
|
15159
15210
|
};
|
|
15160
15211
|
GRID_STATE_EVENTS.forEach((event) => {
|
|
@@ -15166,7 +15217,13 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15166
15217
|
});
|
|
15167
15218
|
};
|
|
15168
15219
|
}, [gridApi]);
|
|
15169
|
-
|
|
15220
|
+
const disableEventListeners = () => {
|
|
15221
|
+
eventListenersDisabledRef.current = true;
|
|
15222
|
+
};
|
|
15223
|
+
const enableEventListeners = () => {
|
|
15224
|
+
eventListenersDisabledRef.current = false;
|
|
15225
|
+
};
|
|
15226
|
+
return { config, setConfig, disableEventListeners, enableEventListeners };
|
|
15170
15227
|
};
|
|
15171
15228
|
|
|
15172
15229
|
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
@@ -15210,7 +15267,8 @@ var SmartGridSavedViews = (props) => {
|
|
|
15210
15267
|
defaultView,
|
|
15211
15268
|
presetViews,
|
|
15212
15269
|
tableName: props.tableName,
|
|
15213
|
-
tableConfig
|
|
15270
|
+
tableConfig,
|
|
15271
|
+
backend: props.backend
|
|
15214
15272
|
}
|
|
15215
15273
|
);
|
|
15216
15274
|
};
|