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