@procore/saved-views 1.0.0 → 1.0.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/legacy/index.d.mts +25 -7
- package/dist/legacy/index.d.ts +25 -7
- package/dist/legacy/index.js +305 -261
- package/dist/legacy/index.mjs +252 -208
- package/dist/modern/index.d.mts +25 -7
- package/dist/modern/index.d.ts +25 -7
- package/dist/modern/index.js +305 -261
- package/dist/modern/index.mjs +252 -208
- package/package.json +1 -1
package/dist/modern/index.js
CHANGED
|
@@ -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,
|
|
@@ -12003,16 +11842,16 @@ var import_react_query3 = require("@tanstack/react-query");
|
|
|
12003
11842
|
var import_toast_alert3 = require("@procore/toast-alert");
|
|
12004
11843
|
|
|
12005
11844
|
// src/components/modals/DeleteConfirmationModal.tsx
|
|
12006
|
-
var
|
|
11845
|
+
var import_core_react8 = require("@procore/core-react");
|
|
12007
11846
|
var import_react10 = __toESM(require("react"));
|
|
12008
11847
|
var SavedViewsDeleteConfirmationModalShared = ({
|
|
12009
11848
|
onCancel,
|
|
12010
11849
|
onDelete,
|
|
12011
11850
|
open
|
|
12012
11851
|
}) => {
|
|
12013
|
-
const i18n = (0,
|
|
11852
|
+
const i18n = (0, import_core_react8.useI18nContext)();
|
|
12014
11853
|
return /* @__PURE__ */ import_react10.default.createElement(
|
|
12015
|
-
|
|
11854
|
+
import_core_react8.ConfirmModal,
|
|
12016
11855
|
{
|
|
12017
11856
|
"data-testid": "delete-confirmation-modal",
|
|
12018
11857
|
open,
|
|
@@ -12021,8 +11860,8 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
12021
11860
|
onClose: onCancel,
|
|
12022
11861
|
style: { overflowWrap: "anywhere" }
|
|
12023
11862
|
},
|
|
12024
|
-
/* @__PURE__ */ import_react10.default.createElement(
|
|
12025
|
-
/* @__PURE__ */ import_react10.default.createElement(
|
|
11863
|
+
/* @__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"))),
|
|
11864
|
+
/* @__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
11865
|
);
|
|
12027
11866
|
};
|
|
12028
11867
|
|
|
@@ -12030,7 +11869,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
12030
11869
|
var import_react11 = __toESM(require("react"));
|
|
12031
11870
|
|
|
12032
11871
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
12033
|
-
var
|
|
11872
|
+
var import_core_react9 = require("@procore/core-react");
|
|
12034
11873
|
var React19 = __toESM(require("react"));
|
|
12035
11874
|
|
|
12036
11875
|
// ../../node_modules/yup/index.esm.js
|
|
@@ -14359,6 +14198,7 @@ function extractMessage(error, I18n) {
|
|
|
14359
14198
|
}
|
|
14360
14199
|
|
|
14361
14200
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
14201
|
+
var { useEffect: useEffect2, useRef: useRef2 } = React19;
|
|
14362
14202
|
var ScrollContainer = styled_components_esm_default("div")`
|
|
14363
14203
|
overflow: auto;
|
|
14364
14204
|
`;
|
|
@@ -14375,22 +14215,38 @@ var FormModalBase = ({
|
|
|
14375
14215
|
defaultView,
|
|
14376
14216
|
selectedSavedView,
|
|
14377
14217
|
setOpenEditCreateModal,
|
|
14378
|
-
onSelect
|
|
14218
|
+
onSelect,
|
|
14219
|
+
backend
|
|
14379
14220
|
}) => {
|
|
14380
|
-
const I18n = (0,
|
|
14221
|
+
const I18n = (0, import_core_react9.useI18nContext)();
|
|
14381
14222
|
const NAME_MAX_LENGTH = 150;
|
|
14223
|
+
const originalBodyWidth = useRef2("");
|
|
14224
|
+
useEffect2(() => {
|
|
14225
|
+
if (open) {
|
|
14226
|
+
originalBodyWidth.current = document.body.style.width || "";
|
|
14227
|
+
document.body.style.width = "100%";
|
|
14228
|
+
} else {
|
|
14229
|
+
document.body.style.width = originalBodyWidth.current;
|
|
14230
|
+
}
|
|
14231
|
+
return () => {
|
|
14232
|
+
if (originalBodyWidth.current !== void 0) {
|
|
14233
|
+
document.body.style.width = originalBodyWidth.current;
|
|
14234
|
+
}
|
|
14235
|
+
};
|
|
14236
|
+
}, [open]);
|
|
14237
|
+
const { useCreateSavedView: useCreateSavedView2, useUpdateSavedView: useUpdateSavedView2, useSavedViewsPermissions: useSavedViewsPermissions2 } = backend;
|
|
14382
14238
|
const {
|
|
14383
14239
|
mutate: createSavedView,
|
|
14384
14240
|
isPending: isCreating,
|
|
14385
14241
|
error: createError,
|
|
14386
14242
|
reset: resetCreateMutation
|
|
14387
|
-
} =
|
|
14243
|
+
} = useCreateSavedView2(queryInput);
|
|
14388
14244
|
const {
|
|
14389
14245
|
mutate: updateSavedView,
|
|
14390
14246
|
isPending: isUpdating,
|
|
14391
14247
|
error: updateError,
|
|
14392
14248
|
reset: resetUpdateMutation
|
|
14393
|
-
} =
|
|
14249
|
+
} = useUpdateSavedView2(queryInput);
|
|
14394
14250
|
const resetMutations = () => {
|
|
14395
14251
|
resetCreateMutation();
|
|
14396
14252
|
resetUpdateMutation();
|
|
@@ -14399,7 +14255,7 @@ var FormModalBase = ({
|
|
|
14399
14255
|
resetMutations();
|
|
14400
14256
|
onCancel();
|
|
14401
14257
|
};
|
|
14402
|
-
const { data: permissions } =
|
|
14258
|
+
const { data: permissions } = useSavedViewsPermissions2(queryInput);
|
|
14403
14259
|
const isLoading = isCreating || isUpdating;
|
|
14404
14260
|
const errors = extractMessage(createError || updateError, I18n);
|
|
14405
14261
|
const handleOnSubmit = (data) => {
|
|
@@ -14432,7 +14288,7 @@ var FormModalBase = ({
|
|
|
14432
14288
|
};
|
|
14433
14289
|
const viewLevelOptions = getViewLevelOptions(permissions, I18n);
|
|
14434
14290
|
return /* @__PURE__ */ React19.createElement(
|
|
14435
|
-
|
|
14291
|
+
import_core_react9.Modal,
|
|
14436
14292
|
{
|
|
14437
14293
|
"aria-label": I18n.t("savedViews.ariaLabels.modal"),
|
|
14438
14294
|
onClickOverlay: onClose,
|
|
@@ -14441,14 +14297,14 @@ var FormModalBase = ({
|
|
|
14441
14297
|
"data-testid": "create-update-modal"
|
|
14442
14298
|
},
|
|
14443
14299
|
/* @__PURE__ */ React19.createElement(ScrollContainer, null, /* @__PURE__ */ React19.createElement(
|
|
14444
|
-
|
|
14300
|
+
import_core_react9.Modal.Header,
|
|
14445
14301
|
{
|
|
14446
14302
|
onClose,
|
|
14447
|
-
style: { borderBottom: `1px solid ${
|
|
14303
|
+
style: { borderBottom: `1px solid ${import_core_react9.colors.gray85}` }
|
|
14448
14304
|
},
|
|
14449
|
-
/* @__PURE__ */ React19.createElement(
|
|
14305
|
+
/* @__PURE__ */ React19.createElement(import_core_react9.H2, null, header)
|
|
14450
14306
|
), /* @__PURE__ */ React19.createElement(
|
|
14451
|
-
|
|
14307
|
+
import_core_react9.Form,
|
|
14452
14308
|
{
|
|
14453
14309
|
initialValues: {
|
|
14454
14310
|
name: initialName,
|
|
@@ -14473,14 +14329,14 @@ var FormModalBase = ({
|
|
|
14473
14329
|
onReset: onCancel,
|
|
14474
14330
|
validateOnChange: true
|
|
14475
14331
|
},
|
|
14476
|
-
/* @__PURE__ */ React19.createElement(
|
|
14477
|
-
|
|
14332
|
+
/* @__PURE__ */ React19.createElement(import_core_react9.Form.Form, { name: header }, /* @__PURE__ */ React19.createElement(
|
|
14333
|
+
import_core_react9.Modal.Body,
|
|
14478
14334
|
{
|
|
14479
|
-
style: { paddingTop: 0, paddingBottom: 0, marginTop:
|
|
14335
|
+
style: { paddingTop: 0, paddingBottom: 0, marginTop: import_core_react9.spacing.lg }
|
|
14480
14336
|
},
|
|
14481
|
-
errors && /* @__PURE__ */ React19.createElement(
|
|
14482
|
-
/* @__PURE__ */ React19.createElement(
|
|
14483
|
-
|
|
14337
|
+
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}`)))),
|
|
14338
|
+
/* @__PURE__ */ React19.createElement(import_core_react9.Form.Row, null, /* @__PURE__ */ React19.createElement(
|
|
14339
|
+
import_core_react9.Form.Text,
|
|
14484
14340
|
{
|
|
14485
14341
|
name: "name",
|
|
14486
14342
|
error: errors?.name,
|
|
@@ -14491,12 +14347,12 @@ var FormModalBase = ({
|
|
|
14491
14347
|
}
|
|
14492
14348
|
)),
|
|
14493
14349
|
/* @__PURE__ */ React19.createElement(
|
|
14494
|
-
|
|
14350
|
+
import_core_react9.Form.Row,
|
|
14495
14351
|
{
|
|
14496
|
-
style: { marginTop: errors?.name ?
|
|
14352
|
+
style: { marginTop: errors?.name ? import_core_react9.spacing.xl : import_core_react9.spacing.none }
|
|
14497
14353
|
},
|
|
14498
14354
|
/* @__PURE__ */ React19.createElement(
|
|
14499
|
-
|
|
14355
|
+
import_core_react9.Form.TextArea,
|
|
14500
14356
|
{
|
|
14501
14357
|
name: "description",
|
|
14502
14358
|
placeholder: I18n.t("savedViews.modal.fields.description"),
|
|
@@ -14506,10 +14362,11 @@ var FormModalBase = ({
|
|
|
14506
14362
|
}
|
|
14507
14363
|
)
|
|
14508
14364
|
),
|
|
14509
|
-
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React19.createElement(
|
|
14510
|
-
|
|
14365
|
+
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React19.createElement(import_core_react9.Form.Row, null, /* @__PURE__ */ React19.createElement(
|
|
14366
|
+
import_core_react9.Form.Select,
|
|
14511
14367
|
{
|
|
14512
14368
|
name: "view_level",
|
|
14369
|
+
qa: { label: "view-level" },
|
|
14513
14370
|
options: viewLevelOptions,
|
|
14514
14371
|
label: I18n.t("savedViews.modal.fields.viewLevel"),
|
|
14515
14372
|
colWidth: 12,
|
|
@@ -14517,8 +14374,8 @@ var FormModalBase = ({
|
|
|
14517
14374
|
onClear: false
|
|
14518
14375
|
}
|
|
14519
14376
|
)) : /* @__PURE__ */ React19.createElement(React19.Fragment, null)
|
|
14520
|
-
), /* @__PURE__ */ React19.createElement(
|
|
14521
|
-
|
|
14377
|
+
), /* @__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(
|
|
14378
|
+
import_core_react9.Button,
|
|
14522
14379
|
{
|
|
14523
14380
|
"data-testid": "create-update-modal-button",
|
|
14524
14381
|
type: "submit",
|
|
@@ -14533,7 +14390,7 @@ var FormModalBase = ({
|
|
|
14533
14390
|
};
|
|
14534
14391
|
|
|
14535
14392
|
// src/components/modals/form-modal/FormModal.tsx
|
|
14536
|
-
var
|
|
14393
|
+
var import_core_react10 = require("@procore/core-react");
|
|
14537
14394
|
var FormModal = ({
|
|
14538
14395
|
open,
|
|
14539
14396
|
mode,
|
|
@@ -14544,9 +14401,10 @@ var FormModal = ({
|
|
|
14544
14401
|
selectedSavedView,
|
|
14545
14402
|
setOpenEditCreateModal,
|
|
14546
14403
|
onSelect,
|
|
14547
|
-
defaultView
|
|
14404
|
+
defaultView,
|
|
14405
|
+
backend
|
|
14548
14406
|
}) => {
|
|
14549
|
-
const i18n = (0,
|
|
14407
|
+
const i18n = (0, import_core_react10.useI18nContext)();
|
|
14550
14408
|
return /* @__PURE__ */ import_react11.default.createElement(
|
|
14551
14409
|
FormModalBase,
|
|
14552
14410
|
{
|
|
@@ -14562,13 +14420,14 @@ var FormModal = ({
|
|
|
14562
14420
|
selectedSavedView,
|
|
14563
14421
|
setOpenEditCreateModal,
|
|
14564
14422
|
onSelect,
|
|
14565
|
-
defaultView
|
|
14423
|
+
defaultView,
|
|
14424
|
+
backend
|
|
14566
14425
|
}
|
|
14567
14426
|
);
|
|
14568
14427
|
};
|
|
14569
14428
|
|
|
14570
14429
|
// src/components/modals/form-modal/SharedViewFormModal.tsx
|
|
14571
|
-
var
|
|
14430
|
+
var import_core_react11 = require("@procore/core-react");
|
|
14572
14431
|
var React21 = __toESM(require("react"));
|
|
14573
14432
|
var SharedViewFormModal = ({
|
|
14574
14433
|
open,
|
|
@@ -14580,7 +14439,7 @@ var SharedViewFormModal = ({
|
|
|
14580
14439
|
isCreating,
|
|
14581
14440
|
resetCreateError
|
|
14582
14441
|
}) => {
|
|
14583
|
-
const I18n = (0,
|
|
14442
|
+
const I18n = (0, import_core_react11.useI18nContext)();
|
|
14584
14443
|
const NAME_MAX_LENGTH = 150;
|
|
14585
14444
|
const errors = extractMessage(createError, I18n);
|
|
14586
14445
|
const handleNameChange = () => {
|
|
@@ -14592,7 +14451,7 @@ var SharedViewFormModal = ({
|
|
|
14592
14451
|
onCreateView(data.name, data.description);
|
|
14593
14452
|
};
|
|
14594
14453
|
return /* @__PURE__ */ React21.createElement(
|
|
14595
|
-
|
|
14454
|
+
import_core_react11.Modal,
|
|
14596
14455
|
{
|
|
14597
14456
|
"data-testid": "shared-view-form-modal",
|
|
14598
14457
|
open,
|
|
@@ -14600,35 +14459,35 @@ var SharedViewFormModal = ({
|
|
|
14600
14459
|
style: { width: "540px" }
|
|
14601
14460
|
},
|
|
14602
14461
|
/* @__PURE__ */ React21.createElement(
|
|
14603
|
-
|
|
14462
|
+
import_core_react11.Modal.Header,
|
|
14604
14463
|
{
|
|
14605
14464
|
onClose,
|
|
14606
14465
|
style: {
|
|
14607
|
-
paddingTop:
|
|
14608
|
-
paddingBottom:
|
|
14609
|
-
paddingLeft:
|
|
14610
|
-
paddingRight:
|
|
14466
|
+
paddingTop: import_core_react11.spacing.lg,
|
|
14467
|
+
paddingBottom: import_core_react11.spacing.xs,
|
|
14468
|
+
paddingLeft: import_core_react11.spacing.xl,
|
|
14469
|
+
paddingRight: import_core_react11.spacing.xl
|
|
14611
14470
|
}
|
|
14612
14471
|
},
|
|
14613
14472
|
I18n.t("savedViews.modal.create.title")
|
|
14614
14473
|
),
|
|
14615
14474
|
/* @__PURE__ */ React21.createElement(
|
|
14616
|
-
|
|
14475
|
+
import_core_react11.P,
|
|
14617
14476
|
{
|
|
14618
14477
|
style: {
|
|
14619
|
-
paddingLeft:
|
|
14620
|
-
paddingRight:
|
|
14621
|
-
paddingBottom:
|
|
14622
|
-
paddingTop:
|
|
14478
|
+
paddingLeft: import_core_react11.spacing.xl,
|
|
14479
|
+
paddingRight: import_core_react11.spacing.xl,
|
|
14480
|
+
paddingBottom: import_core_react11.spacing.lg,
|
|
14481
|
+
paddingTop: import_core_react11.spacing.none,
|
|
14623
14482
|
margin: 0,
|
|
14624
|
-
color:
|
|
14483
|
+
color: import_core_react11.colors.gray45,
|
|
14625
14484
|
whiteSpace: "pre-line"
|
|
14626
14485
|
}
|
|
14627
14486
|
},
|
|
14628
14487
|
I18n.t("savedViews.modal.copyConfirmation.description")
|
|
14629
14488
|
),
|
|
14630
14489
|
/* @__PURE__ */ React21.createElement(
|
|
14631
|
-
|
|
14490
|
+
import_core_react11.Form,
|
|
14632
14491
|
{
|
|
14633
14492
|
initialValues: {
|
|
14634
14493
|
name: fetchedView.name,
|
|
@@ -14646,20 +14505,20 @@ var SharedViewFormModal = ({
|
|
|
14646
14505
|
onSubmit: handleOnSubmit,
|
|
14647
14506
|
validateOnChange: true
|
|
14648
14507
|
},
|
|
14649
|
-
/* @__PURE__ */ React21.createElement(
|
|
14650
|
-
|
|
14508
|
+
/* @__PURE__ */ React21.createElement(import_core_react11.Form.Form, { name: "share-view-form" }, /* @__PURE__ */ React21.createElement(
|
|
14509
|
+
import_core_react11.Modal.Body,
|
|
14651
14510
|
{
|
|
14652
14511
|
style: {
|
|
14653
|
-
paddingTop:
|
|
14512
|
+
paddingTop: import_core_react11.spacing.lg,
|
|
14654
14513
|
paddingBottom: 0,
|
|
14655
|
-
borderTop: `1px solid ${
|
|
14514
|
+
borderTop: `1px solid ${import_core_react11.colors.gray85}`
|
|
14656
14515
|
}
|
|
14657
14516
|
},
|
|
14658
|
-
errors && /* @__PURE__ */ React21.createElement(
|
|
14517
|
+
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
14518
|
mode: "create"
|
|
14660
|
-
})), /* @__PURE__ */ React21.createElement(
|
|
14661
|
-
/* @__PURE__ */ React21.createElement(
|
|
14662
|
-
|
|
14519
|
+
})), /* @__PURE__ */ React21.createElement(import_core_react11.Banner.Body, null, errors?.form || I18n.t("savedViews.modal.errors.description.create")))),
|
|
14520
|
+
/* @__PURE__ */ React21.createElement(import_core_react11.Form.Row, null, /* @__PURE__ */ React21.createElement(
|
|
14521
|
+
import_core_react11.Form.Text,
|
|
14663
14522
|
{
|
|
14664
14523
|
name: "name",
|
|
14665
14524
|
error: errors?.name,
|
|
@@ -14670,12 +14529,12 @@ var SharedViewFormModal = ({
|
|
|
14670
14529
|
}
|
|
14671
14530
|
)),
|
|
14672
14531
|
/* @__PURE__ */ React21.createElement(
|
|
14673
|
-
|
|
14532
|
+
import_core_react11.Form.Row,
|
|
14674
14533
|
{
|
|
14675
|
-
style: { marginTop: errors?.name ?
|
|
14534
|
+
style: { marginTop: errors?.name ? import_core_react11.spacing.xl : import_core_react11.spacing.none }
|
|
14676
14535
|
},
|
|
14677
14536
|
/* @__PURE__ */ React21.createElement(
|
|
14678
|
-
|
|
14537
|
+
import_core_react11.Form.TextArea,
|
|
14679
14538
|
{
|
|
14680
14539
|
name: "description",
|
|
14681
14540
|
placeholder: I18n.t("savedViews.modal.fields.description"),
|
|
@@ -14685,8 +14544,8 @@ var SharedViewFormModal = ({
|
|
|
14685
14544
|
}
|
|
14686
14545
|
)
|
|
14687
14546
|
)
|
|
14688
|
-
), /* @__PURE__ */ React21.createElement(
|
|
14689
|
-
|
|
14547
|
+
), /* @__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(
|
|
14548
|
+
import_core_react11.Button,
|
|
14690
14549
|
{
|
|
14691
14550
|
variant: "secondary",
|
|
14692
14551
|
onClick: onCreateTemporaryView,
|
|
@@ -14695,7 +14554,7 @@ var SharedViewFormModal = ({
|
|
|
14695
14554
|
},
|
|
14696
14555
|
I18n.t("savedViews.actions.viewTemporarily")
|
|
14697
14556
|
), /* @__PURE__ */ React21.createElement(
|
|
14698
|
-
|
|
14557
|
+
import_core_react11.Button,
|
|
14699
14558
|
{
|
|
14700
14559
|
type: "submit",
|
|
14701
14560
|
variant: "primary",
|
|
@@ -14712,7 +14571,7 @@ var SharedViewFormModal = ({
|
|
|
14712
14571
|
// src/utils/hooks/useViewSelection.ts
|
|
14713
14572
|
var import_react12 = require("react");
|
|
14714
14573
|
var import_react_router_dom = require("react-router-dom");
|
|
14715
|
-
var
|
|
14574
|
+
var import_core_react12 = require("@procore/core-react");
|
|
14716
14575
|
|
|
14717
14576
|
// src/utils/viewStorage.ts
|
|
14718
14577
|
var ViewStorage = {
|
|
@@ -14775,7 +14634,7 @@ var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
|
14775
14634
|
}
|
|
14776
14635
|
};
|
|
14777
14636
|
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) => {
|
|
14778
|
-
const I18n = (0,
|
|
14637
|
+
const I18n = (0, import_core_react12.useI18nContext)();
|
|
14779
14638
|
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${config.projectId}_${config.userId}`;
|
|
14780
14639
|
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
14781
14640
|
const [searchParams, setSearchParams] = (0, import_react_router_dom.useSearchParams)();
|
|
@@ -14874,6 +14733,177 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) =>
|
|
|
14874
14733
|
};
|
|
14875
14734
|
};
|
|
14876
14735
|
|
|
14736
|
+
// node_modules/@procore/core-http/dist/modern/index.js
|
|
14737
|
+
function getCSRFToken() {
|
|
14738
|
+
const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
|
|
14739
|
+
return token ? decodeURIComponent(token.pop() || "") : "";
|
|
14740
|
+
}
|
|
14741
|
+
function getCSRFHeader() {
|
|
14742
|
+
const csrfToken = getCSRFToken();
|
|
14743
|
+
return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
|
|
14744
|
+
}
|
|
14745
|
+
function removeLeadingSlash(url) {
|
|
14746
|
+
return url.startsWith("/") ? url.substring(1, url.length) : url;
|
|
14747
|
+
}
|
|
14748
|
+
function removeTrailingSlash(url) {
|
|
14749
|
+
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
14750
|
+
}
|
|
14751
|
+
function applyBaseUrl(url, baseUrl) {
|
|
14752
|
+
return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
|
|
14753
|
+
}
|
|
14754
|
+
function getOptions({ headers, ...options }) {
|
|
14755
|
+
const opts = {
|
|
14756
|
+
credentials: "same-origin",
|
|
14757
|
+
headers: {
|
|
14758
|
+
...getCSRFHeader(),
|
|
14759
|
+
...headers
|
|
14760
|
+
},
|
|
14761
|
+
mode: "same-origin",
|
|
14762
|
+
...options
|
|
14763
|
+
};
|
|
14764
|
+
return opts;
|
|
14765
|
+
}
|
|
14766
|
+
function getUrl(url, baseUrl) {
|
|
14767
|
+
return baseUrl ? applyBaseUrl(url, baseUrl) : url;
|
|
14768
|
+
}
|
|
14769
|
+
function request(url, { baseUrl, ...options } = {}) {
|
|
14770
|
+
return fetch(getUrl(url, baseUrl), getOptions(options));
|
|
14771
|
+
}
|
|
14772
|
+
function requestJSON(url, requestParams = {}) {
|
|
14773
|
+
return request(url, requestParams).then(
|
|
14774
|
+
(response) => response.json()
|
|
14775
|
+
);
|
|
14776
|
+
}
|
|
14777
|
+
|
|
14778
|
+
// src/utils/api/queries.ts
|
|
14779
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
14780
|
+
|
|
14781
|
+
// src/utils/api/queriesHandler.ts
|
|
14782
|
+
var import_react_query = require("@tanstack/react-query");
|
|
14783
|
+
var import_core_react13 = require("@procore/core-react");
|
|
14784
|
+
var useApiRequest = (props, method, mutationKey) => {
|
|
14785
|
+
const { projectId, companyId, domain, tableName } = props;
|
|
14786
|
+
const queryClient2 = (0, import_react_query.useQueryClient)();
|
|
14787
|
+
const { locale: locale2 } = (0, import_core_react13.useI18nContext)();
|
|
14788
|
+
return (0, import_react_query.useMutation)({
|
|
14789
|
+
mutationKey,
|
|
14790
|
+
mutationFn: async (savedView) => {
|
|
14791
|
+
let url = "";
|
|
14792
|
+
if (method === "DELETE" || method === "PUT") {
|
|
14793
|
+
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.share_token}?permissions_domain=${domain}`;
|
|
14794
|
+
} else {
|
|
14795
|
+
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
14796
|
+
}
|
|
14797
|
+
const response = await requestJSON(url, {
|
|
14798
|
+
method,
|
|
14799
|
+
body: JSON.stringify(savedView),
|
|
14800
|
+
headers: {
|
|
14801
|
+
"Content-Type": "application/json",
|
|
14802
|
+
"Accept-Language": locale2
|
|
14803
|
+
}
|
|
14804
|
+
});
|
|
14805
|
+
if (response.error) {
|
|
14806
|
+
throw response.error;
|
|
14807
|
+
}
|
|
14808
|
+
return response.data;
|
|
14809
|
+
},
|
|
14810
|
+
onSuccess: (savedView) => {
|
|
14811
|
+
if (method === "DELETE" || method === "POST") {
|
|
14812
|
+
queryClient2.invalidateQueries({
|
|
14813
|
+
queryKey: ["savedViews", domain, tableName]
|
|
14814
|
+
});
|
|
14815
|
+
return;
|
|
14816
|
+
} else {
|
|
14817
|
+
const oldData = queryClient2.getQueryData([
|
|
14818
|
+
"savedViews",
|
|
14819
|
+
domain,
|
|
14820
|
+
tableName
|
|
14821
|
+
]);
|
|
14822
|
+
const oldView = oldData?.find(
|
|
14823
|
+
(item) => item.share_token === savedView.share_token
|
|
14824
|
+
);
|
|
14825
|
+
if (oldView?.name !== savedView.name) {
|
|
14826
|
+
queryClient2.invalidateQueries({
|
|
14827
|
+
queryKey: ["savedViews", domain, tableName]
|
|
14828
|
+
});
|
|
14829
|
+
return;
|
|
14830
|
+
}
|
|
14831
|
+
}
|
|
14832
|
+
queryClient2.setQueryData(
|
|
14833
|
+
["savedViews", domain, tableName],
|
|
14834
|
+
(oldData) => {
|
|
14835
|
+
if (!oldData)
|
|
14836
|
+
return [savedView];
|
|
14837
|
+
return oldData.map(
|
|
14838
|
+
(item) => item.share_token === savedView.share_token ? savedView : item
|
|
14839
|
+
);
|
|
14840
|
+
}
|
|
14841
|
+
);
|
|
14842
|
+
}
|
|
14843
|
+
});
|
|
14844
|
+
};
|
|
14845
|
+
|
|
14846
|
+
// src/utils/api/queries.ts
|
|
14847
|
+
var PAGE_SIZE = 50 * VIEW_LEVELS.length;
|
|
14848
|
+
var useSavedViewsQuery = (props) => {
|
|
14849
|
+
const { projectId, companyId, domain, tableName } = props;
|
|
14850
|
+
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
14851
|
+
return (0, import_react_query2.useQuery)({
|
|
14852
|
+
queryKey: ["savedViews", domain, tableName],
|
|
14853
|
+
queryFn: async () => {
|
|
14854
|
+
const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
|
|
14855
|
+
const response = await requestJSON(getUrl2);
|
|
14856
|
+
return response.data;
|
|
14857
|
+
}
|
|
14858
|
+
});
|
|
14859
|
+
};
|
|
14860
|
+
var useSavedViewsPermissions = (props) => {
|
|
14861
|
+
const { projectId, companyId, domain } = props;
|
|
14862
|
+
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
|
|
14863
|
+
return (0, import_react_query2.useQuery)({
|
|
14864
|
+
queryKey: ["savedViewsConfig", domain],
|
|
14865
|
+
queryFn: async () => {
|
|
14866
|
+
const response = await requestJSON(url);
|
|
14867
|
+
return response.data;
|
|
14868
|
+
}
|
|
14869
|
+
});
|
|
14870
|
+
};
|
|
14871
|
+
var useCreateSavedView = (props) => useApiRequest(props, "POST", [
|
|
14872
|
+
"createSavedView",
|
|
14873
|
+
props.domain,
|
|
14874
|
+
props.tableName
|
|
14875
|
+
]);
|
|
14876
|
+
var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
|
|
14877
|
+
"updateSavedView",
|
|
14878
|
+
props.domain,
|
|
14879
|
+
props.tableName
|
|
14880
|
+
]);
|
|
14881
|
+
var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
14882
|
+
"deleteSavedView",
|
|
14883
|
+
props.domain,
|
|
14884
|
+
props.tableName
|
|
14885
|
+
]);
|
|
14886
|
+
var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
14887
|
+
const { projectId, companyId } = queryInput;
|
|
14888
|
+
return (0, import_react_query2.useQuery)({
|
|
14889
|
+
enabled: enabled && Boolean(savedViewToken),
|
|
14890
|
+
queryKey: ["savedView", savedViewToken],
|
|
14891
|
+
queryFn: async () => {
|
|
14892
|
+
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedViewToken}`;
|
|
14893
|
+
const response = await requestJSON(url);
|
|
14894
|
+
return response.data;
|
|
14895
|
+
}
|
|
14896
|
+
});
|
|
14897
|
+
};
|
|
14898
|
+
var createQueries = (customBackend) => ({
|
|
14899
|
+
useSavedViewsQuery: customBackend?.useSavedViewsQuery ?? useSavedViewsQuery,
|
|
14900
|
+
useSavedViewsPermissions: customBackend?.useSavedViewsPermissions ?? useSavedViewsPermissions,
|
|
14901
|
+
useCreateSavedView: customBackend?.useCreateSavedView ?? useCreateSavedView,
|
|
14902
|
+
useUpdateSavedView: customBackend?.useUpdateSavedView ?? useUpdateSavedView,
|
|
14903
|
+
useDeleteSavedView: customBackend?.useDeleteSavedView ?? useDeleteSavedView,
|
|
14904
|
+
useFetchSavedViewById: customBackend?.useFetchSavedViewById ?? useFetchSavedViewById
|
|
14905
|
+
});
|
|
14906
|
+
|
|
14877
14907
|
// src/components/saved-views/SavedViews.tsx
|
|
14878
14908
|
var StyledPanel = styled_components_esm_default.div`
|
|
14879
14909
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
@@ -14881,14 +14911,15 @@ var StyledPanel = styled_components_esm_default.div`
|
|
|
14881
14911
|
var queryClient = new import_react_query3.QueryClient();
|
|
14882
14912
|
var SavedViewsContent = (props) => {
|
|
14883
14913
|
const { projectId, companyId } = props;
|
|
14914
|
+
const backend = createQueries(props.backend);
|
|
14884
14915
|
const queryInput = {
|
|
14885
14916
|
domain: props.domain,
|
|
14886
14917
|
tableName: props.tableName,
|
|
14887
14918
|
projectId,
|
|
14888
14919
|
companyId
|
|
14889
14920
|
};
|
|
14890
|
-
const { data: savedViews } = useSavedViewsQuery(queryInput);
|
|
14891
|
-
const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
|
|
14921
|
+
const { data: savedViews } = backend.useSavedViewsQuery(queryInput);
|
|
14922
|
+
const { mutate: deleteSavedView } = backend.useDeleteSavedView(queryInput);
|
|
14892
14923
|
const { showToast } = (0, import_toast_alert3.useToastAlertContext)();
|
|
14893
14924
|
const i18n = (0, import_core_react14.useI18nContext)();
|
|
14894
14925
|
const [activeModal, setActiveModal] = (0, import_react13.useState)(null);
|
|
@@ -14925,7 +14956,7 @@ var SavedViewsContent = (props) => {
|
|
|
14925
14956
|
props.presetViews,
|
|
14926
14957
|
openSharedViewModal
|
|
14927
14958
|
);
|
|
14928
|
-
const { data: fetchedView, isError: fetchError } = useFetchSavedViewById(
|
|
14959
|
+
const { data: fetchedView, isError: fetchError } = backend.useFetchSavedViewById(
|
|
14929
14960
|
modalData?.viewId ?? null,
|
|
14930
14961
|
queryInput,
|
|
14931
14962
|
Boolean(modalData?.viewId)
|
|
@@ -14935,7 +14966,7 @@ var SavedViewsContent = (props) => {
|
|
|
14935
14966
|
isPending: isCreating,
|
|
14936
14967
|
error: createError,
|
|
14937
14968
|
reset: resetCreateError
|
|
14938
|
-
} = useCreateSavedView(queryInput);
|
|
14969
|
+
} = backend.useCreateSavedView(queryInput);
|
|
14939
14970
|
(0, import_react13.useEffect)(() => {
|
|
14940
14971
|
if (fetchError) {
|
|
14941
14972
|
showToast.error(i18n.t("savedViews.errors.notFound"));
|
|
@@ -15022,7 +15053,8 @@ var SavedViewsContent = (props) => {
|
|
|
15022
15053
|
savedViews: allViews,
|
|
15023
15054
|
provider: props.provider,
|
|
15024
15055
|
userId: props.userId,
|
|
15025
|
-
onClearTemporary: clearTemporaryView
|
|
15056
|
+
onClearTemporary: clearTemporaryView,
|
|
15057
|
+
backend
|
|
15026
15058
|
}
|
|
15027
15059
|
))
|
|
15028
15060
|
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ import_react13.default.createElement(
|
|
@@ -15037,7 +15069,8 @@ var SavedViewsContent = (props) => {
|
|
|
15037
15069
|
selectedSavedView: selectedView,
|
|
15038
15070
|
onSelect: selectView,
|
|
15039
15071
|
setOpenEditCreateModal: closeModal,
|
|
15040
|
-
defaultView: props.defaultView
|
|
15072
|
+
defaultView: props.defaultView,
|
|
15073
|
+
backend
|
|
15041
15074
|
}
|
|
15042
15075
|
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */ import_react13.default.createElement(
|
|
15043
15076
|
SavedViewsDeleteConfirmationModalShared,
|
|
@@ -15147,10 +15180,14 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15147
15180
|
const [config, setConfig] = (0, import_react15.useState)(
|
|
15148
15181
|
() => getSmartGridConfig(gridApi)
|
|
15149
15182
|
);
|
|
15183
|
+
const eventListenersDisabledRef = (0, import_react15.useRef)(false);
|
|
15150
15184
|
(0, import_react15.useEffect)(() => {
|
|
15151
15185
|
if (!gridApi)
|
|
15152
15186
|
return;
|
|
15153
15187
|
const updateConfig = () => {
|
|
15188
|
+
if (eventListenersDisabledRef.current) {
|
|
15189
|
+
return;
|
|
15190
|
+
}
|
|
15154
15191
|
setConfig(getSmartGridConfig(gridApi));
|
|
15155
15192
|
};
|
|
15156
15193
|
GRID_STATE_EVENTS.forEach((event) => {
|
|
@@ -15162,7 +15199,13 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15162
15199
|
});
|
|
15163
15200
|
};
|
|
15164
15201
|
}, [gridApi]);
|
|
15165
|
-
|
|
15202
|
+
const disableEventListeners = () => {
|
|
15203
|
+
eventListenersDisabledRef.current = true;
|
|
15204
|
+
};
|
|
15205
|
+
const enableEventListeners = () => {
|
|
15206
|
+
eventListenersDisabledRef.current = false;
|
|
15207
|
+
};
|
|
15208
|
+
return { config, setConfig, disableEventListeners, enableEventListeners };
|
|
15166
15209
|
};
|
|
15167
15210
|
|
|
15168
15211
|
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
@@ -15206,7 +15249,8 @@ var SmartGridSavedViews = (props) => {
|
|
|
15206
15249
|
defaultView,
|
|
15207
15250
|
presetViews,
|
|
15208
15251
|
tableName: props.tableName,
|
|
15209
|
-
tableConfig
|
|
15252
|
+
tableConfig,
|
|
15253
|
+
backend: props.backend
|
|
15210
15254
|
}
|
|
15211
15255
|
);
|
|
15212
15256
|
};
|