@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/legacy/index.js
CHANGED
|
@@ -11440,176 +11440,13 @@ var ExpandedPanel = styled_components_esm_default(import_core_react4.Panel)`
|
|
|
11440
11440
|
`;
|
|
11441
11441
|
|
|
11442
11442
|
// src/components/panels/PanelContent.tsx
|
|
11443
|
-
var
|
|
11443
|
+
var import_core_react7 = require("@procore/core-react");
|
|
11444
11444
|
var import_toast_alert2 = require("@procore/toast-alert");
|
|
11445
11445
|
var import_react9 = __toESM(require("react"));
|
|
11446
11446
|
|
|
11447
|
-
// node_modules/@procore/core-http/dist/modern/index.js
|
|
11448
|
-
function getCSRFToken() {
|
|
11449
|
-
const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
|
|
11450
|
-
return token ? decodeURIComponent(token.pop() || "") : "";
|
|
11451
|
-
}
|
|
11452
|
-
function getCSRFHeader() {
|
|
11453
|
-
const csrfToken = getCSRFToken();
|
|
11454
|
-
return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
|
|
11455
|
-
}
|
|
11456
|
-
function removeLeadingSlash(url) {
|
|
11457
|
-
return url.startsWith("/") ? url.substring(1, url.length) : url;
|
|
11458
|
-
}
|
|
11459
|
-
function removeTrailingSlash(url) {
|
|
11460
|
-
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
11461
|
-
}
|
|
11462
|
-
function applyBaseUrl(url, baseUrl) {
|
|
11463
|
-
return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
|
|
11464
|
-
}
|
|
11465
|
-
function getOptions({ headers, ...options }) {
|
|
11466
|
-
const opts = {
|
|
11467
|
-
credentials: "same-origin",
|
|
11468
|
-
headers: {
|
|
11469
|
-
...getCSRFHeader(),
|
|
11470
|
-
...headers
|
|
11471
|
-
},
|
|
11472
|
-
mode: "same-origin",
|
|
11473
|
-
...options
|
|
11474
|
-
};
|
|
11475
|
-
return opts;
|
|
11476
|
-
}
|
|
11477
|
-
function getUrl(url, baseUrl) {
|
|
11478
|
-
return baseUrl ? applyBaseUrl(url, baseUrl) : url;
|
|
11479
|
-
}
|
|
11480
|
-
function request(url, { baseUrl, ...options } = {}) {
|
|
11481
|
-
return fetch(getUrl(url, baseUrl), getOptions(options));
|
|
11482
|
-
}
|
|
11483
|
-
function requestJSON(url, requestParams = {}) {
|
|
11484
|
-
return request(url, requestParams).then(
|
|
11485
|
-
(response) => response.json()
|
|
11486
|
-
);
|
|
11487
|
-
}
|
|
11488
|
-
|
|
11489
|
-
// src/utils/api/queries.ts
|
|
11490
|
-
var import_react_query2 = require("@tanstack/react-query");
|
|
11491
|
-
|
|
11492
|
-
// src/utils/api/queriesHandler.ts
|
|
11493
|
-
var import_react_query = require("@tanstack/react-query");
|
|
11494
|
-
var import_core_react5 = require("@procore/core-react");
|
|
11495
|
-
var useApiRequest = (props, method, mutationKey) => {
|
|
11496
|
-
const { projectId, companyId, domain, tableName } = props;
|
|
11497
|
-
const queryClient2 = (0, import_react_query.useQueryClient)();
|
|
11498
|
-
const { locale: locale2 } = (0, import_core_react5.useI18nContext)();
|
|
11499
|
-
return (0, import_react_query.useMutation)({
|
|
11500
|
-
mutationKey,
|
|
11501
|
-
mutationFn: async (savedView) => {
|
|
11502
|
-
let url = "";
|
|
11503
|
-
if (method === "DELETE" || method === "PUT") {
|
|
11504
|
-
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.share_token}?permissions_domain=${domain}`;
|
|
11505
|
-
} else {
|
|
11506
|
-
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
11507
|
-
}
|
|
11508
|
-
const response = await requestJSON(url, {
|
|
11509
|
-
method,
|
|
11510
|
-
body: JSON.stringify(savedView),
|
|
11511
|
-
headers: {
|
|
11512
|
-
"Content-Type": "application/json",
|
|
11513
|
-
"Accept-Language": locale2
|
|
11514
|
-
}
|
|
11515
|
-
});
|
|
11516
|
-
if (response.error) {
|
|
11517
|
-
throw response.error;
|
|
11518
|
-
}
|
|
11519
|
-
return response.data;
|
|
11520
|
-
},
|
|
11521
|
-
onSuccess: (savedView) => {
|
|
11522
|
-
if (method === "DELETE" || method === "POST") {
|
|
11523
|
-
queryClient2.invalidateQueries({
|
|
11524
|
-
queryKey: ["savedViews", domain, tableName]
|
|
11525
|
-
});
|
|
11526
|
-
return;
|
|
11527
|
-
} else {
|
|
11528
|
-
const oldData = queryClient2.getQueryData([
|
|
11529
|
-
"savedViews",
|
|
11530
|
-
domain,
|
|
11531
|
-
tableName
|
|
11532
|
-
]);
|
|
11533
|
-
const oldView = oldData == null ? void 0 : oldData.find(
|
|
11534
|
-
(item) => item.share_token === savedView.share_token
|
|
11535
|
-
);
|
|
11536
|
-
if ((oldView == null ? void 0 : oldView.name) !== savedView.name) {
|
|
11537
|
-
queryClient2.invalidateQueries({
|
|
11538
|
-
queryKey: ["savedViews", domain, tableName]
|
|
11539
|
-
});
|
|
11540
|
-
return;
|
|
11541
|
-
}
|
|
11542
|
-
}
|
|
11543
|
-
queryClient2.setQueryData(
|
|
11544
|
-
["savedViews", domain, tableName],
|
|
11545
|
-
(oldData) => {
|
|
11546
|
-
if (!oldData)
|
|
11547
|
-
return [savedView];
|
|
11548
|
-
return oldData.map(
|
|
11549
|
-
(item) => item.share_token === savedView.share_token ? savedView : item
|
|
11550
|
-
);
|
|
11551
|
-
}
|
|
11552
|
-
);
|
|
11553
|
-
}
|
|
11554
|
-
});
|
|
11555
|
-
};
|
|
11556
|
-
|
|
11557
11447
|
// src/utils/constants/viewLevels.ts
|
|
11558
11448
|
var VIEW_LEVELS = ["company", "project", "personal"];
|
|
11559
11449
|
|
|
11560
|
-
// src/utils/api/queries.ts
|
|
11561
|
-
var PAGE_SIZE = 50 * VIEW_LEVELS.length;
|
|
11562
|
-
var useSavedViewsQuery = (props) => {
|
|
11563
|
-
const { projectId, companyId, domain, tableName } = props;
|
|
11564
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
11565
|
-
return (0, import_react_query2.useQuery)({
|
|
11566
|
-
queryKey: ["savedViews", domain, tableName],
|
|
11567
|
-
queryFn: async () => {
|
|
11568
|
-
const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
|
|
11569
|
-
const response = await requestJSON(getUrl2);
|
|
11570
|
-
return response.data;
|
|
11571
|
-
}
|
|
11572
|
-
});
|
|
11573
|
-
};
|
|
11574
|
-
var useSavedViewsPermissions = (props) => {
|
|
11575
|
-
const { projectId, companyId, domain } = props;
|
|
11576
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
|
|
11577
|
-
return (0, import_react_query2.useQuery)({
|
|
11578
|
-
queryKey: ["savedViewsConfig", domain],
|
|
11579
|
-
queryFn: async () => {
|
|
11580
|
-
const response = await requestJSON(url);
|
|
11581
|
-
return response.data;
|
|
11582
|
-
}
|
|
11583
|
-
});
|
|
11584
|
-
};
|
|
11585
|
-
var useCreateSavedView = (props) => useApiRequest(props, "POST", [
|
|
11586
|
-
"createSavedView",
|
|
11587
|
-
props.domain,
|
|
11588
|
-
props.tableName
|
|
11589
|
-
]);
|
|
11590
|
-
var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
|
|
11591
|
-
"updateSavedView",
|
|
11592
|
-
props.domain,
|
|
11593
|
-
props.tableName
|
|
11594
|
-
]);
|
|
11595
|
-
var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
11596
|
-
"deleteSavedView",
|
|
11597
|
-
props.domain,
|
|
11598
|
-
props.tableName
|
|
11599
|
-
]);
|
|
11600
|
-
var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
11601
|
-
const { projectId, companyId } = queryInput;
|
|
11602
|
-
return (0, import_react_query2.useQuery)({
|
|
11603
|
-
enabled: enabled && Boolean(savedViewToken),
|
|
11604
|
-
queryKey: ["savedView", savedViewToken],
|
|
11605
|
-
queryFn: async () => {
|
|
11606
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedViewToken}`;
|
|
11607
|
-
const response = await requestJSON(url);
|
|
11608
|
-
return response.data;
|
|
11609
|
-
}
|
|
11610
|
-
});
|
|
11611
|
-
};
|
|
11612
|
-
|
|
11613
11450
|
// src/components/panels/PanelContentUtils.ts
|
|
11614
11451
|
var import_lodash = __toESM(require_lodash());
|
|
11615
11452
|
|
|
@@ -11759,12 +11596,13 @@ var normalizeForComparison = (config) => {
|
|
|
11759
11596
|
if (!(config == null ? void 0 : config.columnState))
|
|
11760
11597
|
return config;
|
|
11761
11598
|
return {
|
|
11762
|
-
...config,
|
|
11599
|
+
...import_lodash.default.omit(config, ["enableRowGrouping", "enableColumnGrouping"]),
|
|
11763
11600
|
columnState: config.columnState.map((col) => {
|
|
11601
|
+
const res = import_lodash.default.omit(col, ["aggFunc"]);
|
|
11764
11602
|
if (col.flex) {
|
|
11765
|
-
return import_lodash.default.omit(
|
|
11603
|
+
return import_lodash.default.omit(res, ["width", "flex"]);
|
|
11766
11604
|
}
|
|
11767
|
-
return
|
|
11605
|
+
return res;
|
|
11768
11606
|
})
|
|
11769
11607
|
};
|
|
11770
11608
|
};
|
|
@@ -11777,10 +11615,9 @@ var isEqual = (viewTableConfig, tableConfig, defaultViewConfig, provider) => {
|
|
|
11777
11615
|
);
|
|
11778
11616
|
const normalizedViewConfig = normalizeForComparison(syncedViewTableConfig);
|
|
11779
11617
|
const normalizedCurrentConfig = normalizeForComparison(tableConfig);
|
|
11780
|
-
|
|
11781
|
-
|
|
11782
|
-
|
|
11783
|
-
);
|
|
11618
|
+
const cleanedViewConfig = cleanObject(normalizedViewConfig, provider);
|
|
11619
|
+
const cleanedCurrentConfig = cleanObject(normalizedCurrentConfig, provider);
|
|
11620
|
+
return import_lodash.default.isEqual(cleanedViewConfig, cleanedCurrentConfig);
|
|
11784
11621
|
};
|
|
11785
11622
|
var hasPermissionForViewLevel = (viewLevel, permissions) => {
|
|
11786
11623
|
switch (viewLevel) {
|
|
@@ -11808,7 +11645,7 @@ var useGroups = () => {
|
|
|
11808
11645
|
};
|
|
11809
11646
|
|
|
11810
11647
|
// src/components/panels/ViewLevelHeader.tsx
|
|
11811
|
-
var
|
|
11648
|
+
var import_core_react5 = require("@procore/core-react");
|
|
11812
11649
|
var import_react7 = __toESM(require("react"));
|
|
11813
11650
|
var groupIcon = (group) => {
|
|
11814
11651
|
switch (group) {
|
|
@@ -11820,26 +11657,26 @@ var groupIcon = (group) => {
|
|
|
11820
11657
|
return /* @__PURE__ */ import_react7.default.createElement(Building_default, null);
|
|
11821
11658
|
}
|
|
11822
11659
|
};
|
|
11823
|
-
var Header = styled_components_esm_default(
|
|
11660
|
+
var Header = styled_components_esm_default(import_core_react5.Flex)`
|
|
11824
11661
|
width: 100%;
|
|
11825
11662
|
&:hover {
|
|
11826
|
-
background-color: ${
|
|
11663
|
+
background-color: ${import_core_react5.colors.gray98};
|
|
11827
11664
|
}
|
|
11828
11665
|
`;
|
|
11829
11666
|
var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
|
|
11830
|
-
const I18n = (0,
|
|
11667
|
+
const I18n = (0, import_core_react5.useI18nContext)();
|
|
11831
11668
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
11832
11669
|
Header,
|
|
11833
11670
|
{
|
|
11834
11671
|
alignItems: "center",
|
|
11835
|
-
padding: `${
|
|
11836
|
-
gap: `${
|
|
11672
|
+
padding: `${import_core_react5.spacing.sm}px`,
|
|
11673
|
+
gap: `${import_core_react5.spacing.sm}px`,
|
|
11837
11674
|
style: { cursor: "pointer" },
|
|
11838
11675
|
onClick: () => toggleGroup(group)
|
|
11839
11676
|
},
|
|
11840
11677
|
expanded ? /* @__PURE__ */ import_react7.default.createElement(ChevronDown_default, { size: "sm" }) : /* @__PURE__ */ import_react7.default.createElement(ChevronRight_default, { size: "sm" }),
|
|
11841
11678
|
groupIcon(group),
|
|
11842
|
-
/* @__PURE__ */ import_react7.default.createElement(
|
|
11679
|
+
/* @__PURE__ */ import_react7.default.createElement(import_core_react5.Typography, { weight: "semibold" }, I18n.t(`savedViews.viewLevel.${group}`))
|
|
11843
11680
|
);
|
|
11844
11681
|
};
|
|
11845
11682
|
var ViewLevelHeader_default = ViewLevelHeader;
|
|
@@ -11857,21 +11694,21 @@ var useScrollToRef = (dependency) => {
|
|
|
11857
11694
|
};
|
|
11858
11695
|
|
|
11859
11696
|
// src/components/panels/PanelContent.styles.ts
|
|
11860
|
-
var
|
|
11861
|
-
var Row = styled_components_esm_default(
|
|
11697
|
+
var import_core_react6 = require("@procore/core-react");
|
|
11698
|
+
var Row = styled_components_esm_default(import_core_react6.UNSAFE_Menu.Item)`
|
|
11862
11699
|
width: 100%;
|
|
11863
11700
|
padding-left: 35px;
|
|
11864
11701
|
padding-right: 4px;
|
|
11865
|
-
background-color: ${({ selected }) => selected ?
|
|
11702
|
+
background-color: ${({ selected }) => selected ? import_core_react6.colors.blue96 : "transparent"};
|
|
11866
11703
|
|
|
11867
11704
|
&:hover {
|
|
11868
|
-
background-color: ${({ selected }) => selected ?
|
|
11705
|
+
background-color: ${({ selected }) => selected ? import_core_react6.colors.blue96 : import_core_react6.colors.gray98};
|
|
11869
11706
|
}
|
|
11870
11707
|
`;
|
|
11871
|
-
var Panel2 = styled_components_esm_default(
|
|
11708
|
+
var Panel2 = styled_components_esm_default(import_core_react6.DetailPage.Card)`
|
|
11872
11709
|
margin: 0;
|
|
11873
11710
|
height: 100%;
|
|
11874
|
-
padding-top: ${
|
|
11711
|
+
padding-top: ${import_core_react6.spacing.sm}px;
|
|
11875
11712
|
box-shadow: none;
|
|
11876
11713
|
`;
|
|
11877
11714
|
|
|
@@ -11879,9 +11716,9 @@ var Panel2 = styled_components_esm_default(import_core_react7.DetailPage.Card)`
|
|
|
11879
11716
|
var PanelContent = (props) => {
|
|
11880
11717
|
const { queryInput, selectedSavedView, tableConfig } = props;
|
|
11881
11718
|
const { showToast } = (0, import_toast_alert2.useToastAlertContext)();
|
|
11882
|
-
const I18n = (0,
|
|
11883
|
-
const { data: savedViewsFromQuery, error: savedViewsError } = useSavedViewsQuery(props.queryInput);
|
|
11884
|
-
const updateMutation = useUpdateSavedView(queryInput);
|
|
11719
|
+
const I18n = (0, import_core_react7.useI18nContext)();
|
|
11720
|
+
const { data: savedViewsFromQuery, error: savedViewsError } = props.backend.useSavedViewsQuery(props.queryInput);
|
|
11721
|
+
const updateMutation = props.backend.useUpdateSavedView(queryInput);
|
|
11885
11722
|
const { mutate: updateSavedView } = updateMutation;
|
|
11886
11723
|
const isUpdateLoading = "isPending" in updateMutation ? updateMutation.isPending : updateMutation.isLoading ?? false;
|
|
11887
11724
|
const savedViews = props.savedViews ?? savedViewsFromQuery;
|
|
@@ -11892,7 +11729,9 @@ var PanelContent = (props) => {
|
|
|
11892
11729
|
errorToastRef.current = savedViewsError;
|
|
11893
11730
|
}
|
|
11894
11731
|
}, [savedViewsError, showToast, I18n]);
|
|
11895
|
-
const { data: permissions } = useSavedViewsPermissions(
|
|
11732
|
+
const { data: permissions } = props.backend.useSavedViewsPermissions(
|
|
11733
|
+
props.queryInput
|
|
11734
|
+
);
|
|
11896
11735
|
const selectedRowRef = useScrollToRef(savedViews);
|
|
11897
11736
|
const { groups, toggleGroup } = useGroups();
|
|
11898
11737
|
const isTemporarySelected = (selectedSavedView == null ? void 0 : selectedSavedView.id) === "temporary";
|
|
@@ -11914,7 +11753,7 @@ var PanelContent = (props) => {
|
|
|
11914
11753
|
}
|
|
11915
11754
|
});
|
|
11916
11755
|
};
|
|
11917
|
-
return /* @__PURE__ */ import_react9.default.createElement(Panel2, { "data-testid": "inner-panel" }, /* @__PURE__ */ import_react9.default.createElement(
|
|
11756
|
+
return /* @__PURE__ */ import_react9.default.createElement(Panel2, { "data-testid": "inner-panel" }, /* @__PURE__ */ import_react9.default.createElement(import_core_react7.Flex, { direction: "column", style: { height: "100%", width: "100%" } }, temporaryView && /* @__PURE__ */ import_react9.default.createElement(
|
|
11918
11757
|
Row,
|
|
11919
11758
|
{
|
|
11920
11759
|
selected: isTemporarySelected,
|
|
@@ -12006,16 +11845,16 @@ var import_react_query3 = require("@tanstack/react-query");
|
|
|
12006
11845
|
var import_toast_alert3 = require("@procore/toast-alert");
|
|
12007
11846
|
|
|
12008
11847
|
// src/components/modals/DeleteConfirmationModal.tsx
|
|
12009
|
-
var
|
|
11848
|
+
var import_core_react8 = require("@procore/core-react");
|
|
12010
11849
|
var import_react10 = __toESM(require("react"));
|
|
12011
11850
|
var SavedViewsDeleteConfirmationModalShared = ({
|
|
12012
11851
|
onCancel,
|
|
12013
11852
|
onDelete,
|
|
12014
11853
|
open
|
|
12015
11854
|
}) => {
|
|
12016
|
-
const i18n = (0,
|
|
11855
|
+
const i18n = (0, import_core_react8.useI18nContext)();
|
|
12017
11856
|
return /* @__PURE__ */ import_react10.default.createElement(
|
|
12018
|
-
|
|
11857
|
+
import_core_react8.ConfirmModal,
|
|
12019
11858
|
{
|
|
12020
11859
|
"data-testid": "delete-confirmation-modal",
|
|
12021
11860
|
open,
|
|
@@ -12024,8 +11863,8 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
12024
11863
|
onClose: onCancel,
|
|
12025
11864
|
style: { overflowWrap: "anywhere" }
|
|
12026
11865
|
},
|
|
12027
|
-
/* @__PURE__ */ import_react10.default.createElement(
|
|
12028
|
-
/* @__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"))))
|
|
12029
11868
|
);
|
|
12030
11869
|
};
|
|
12031
11870
|
|
|
@@ -12033,7 +11872,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
12033
11872
|
var import_react11 = __toESM(require("react"));
|
|
12034
11873
|
|
|
12035
11874
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
12036
|
-
var
|
|
11875
|
+
var import_core_react9 = require("@procore/core-react");
|
|
12037
11876
|
var React19 = __toESM(require("react"));
|
|
12038
11877
|
|
|
12039
11878
|
// ../../node_modules/yup/index.esm.js
|
|
@@ -14362,6 +14201,7 @@ function extractMessage(error, I18n) {
|
|
|
14362
14201
|
}
|
|
14363
14202
|
|
|
14364
14203
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
14204
|
+
var { useEffect: useEffect2, useRef: useRef2 } = React19;
|
|
14365
14205
|
var ScrollContainer = styled_components_esm_default("div")`
|
|
14366
14206
|
overflow: auto;
|
|
14367
14207
|
`;
|
|
@@ -14378,22 +14218,38 @@ var FormModalBase = ({
|
|
|
14378
14218
|
defaultView,
|
|
14379
14219
|
selectedSavedView,
|
|
14380
14220
|
setOpenEditCreateModal,
|
|
14381
|
-
onSelect
|
|
14221
|
+
onSelect,
|
|
14222
|
+
backend
|
|
14382
14223
|
}) => {
|
|
14383
|
-
const I18n = (0,
|
|
14224
|
+
const I18n = (0, import_core_react9.useI18nContext)();
|
|
14384
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;
|
|
14385
14241
|
const {
|
|
14386
14242
|
mutate: createSavedView,
|
|
14387
14243
|
isPending: isCreating,
|
|
14388
14244
|
error: createError,
|
|
14389
14245
|
reset: resetCreateMutation
|
|
14390
|
-
} =
|
|
14246
|
+
} = useCreateSavedView2(queryInput);
|
|
14391
14247
|
const {
|
|
14392
14248
|
mutate: updateSavedView,
|
|
14393
14249
|
isPending: isUpdating,
|
|
14394
14250
|
error: updateError,
|
|
14395
14251
|
reset: resetUpdateMutation
|
|
14396
|
-
} =
|
|
14252
|
+
} = useUpdateSavedView2(queryInput);
|
|
14397
14253
|
const resetMutations = () => {
|
|
14398
14254
|
resetCreateMutation();
|
|
14399
14255
|
resetUpdateMutation();
|
|
@@ -14402,7 +14258,7 @@ var FormModalBase = ({
|
|
|
14402
14258
|
resetMutations();
|
|
14403
14259
|
onCancel();
|
|
14404
14260
|
};
|
|
14405
|
-
const { data: permissions } =
|
|
14261
|
+
const { data: permissions } = useSavedViewsPermissions2(queryInput);
|
|
14406
14262
|
const isLoading = isCreating || isUpdating;
|
|
14407
14263
|
const errors = extractMessage(createError || updateError, I18n);
|
|
14408
14264
|
const handleOnSubmit = (data) => {
|
|
@@ -14435,7 +14291,7 @@ var FormModalBase = ({
|
|
|
14435
14291
|
};
|
|
14436
14292
|
const viewLevelOptions = getViewLevelOptions(permissions, I18n);
|
|
14437
14293
|
return /* @__PURE__ */ React19.createElement(
|
|
14438
|
-
|
|
14294
|
+
import_core_react9.Modal,
|
|
14439
14295
|
{
|
|
14440
14296
|
"aria-label": I18n.t("savedViews.ariaLabels.modal"),
|
|
14441
14297
|
onClickOverlay: onClose,
|
|
@@ -14444,14 +14300,14 @@ var FormModalBase = ({
|
|
|
14444
14300
|
"data-testid": "create-update-modal"
|
|
14445
14301
|
},
|
|
14446
14302
|
/* @__PURE__ */ React19.createElement(ScrollContainer, null, /* @__PURE__ */ React19.createElement(
|
|
14447
|
-
|
|
14303
|
+
import_core_react9.Modal.Header,
|
|
14448
14304
|
{
|
|
14449
14305
|
onClose,
|
|
14450
|
-
style: { borderBottom: `1px solid ${
|
|
14306
|
+
style: { borderBottom: `1px solid ${import_core_react9.colors.gray85}` }
|
|
14451
14307
|
},
|
|
14452
|
-
/* @__PURE__ */ React19.createElement(
|
|
14308
|
+
/* @__PURE__ */ React19.createElement(import_core_react9.H2, null, header)
|
|
14453
14309
|
), /* @__PURE__ */ React19.createElement(
|
|
14454
|
-
|
|
14310
|
+
import_core_react9.Form,
|
|
14455
14311
|
{
|
|
14456
14312
|
initialValues: {
|
|
14457
14313
|
name: initialName,
|
|
@@ -14476,14 +14332,14 @@ var FormModalBase = ({
|
|
|
14476
14332
|
onReset: onCancel,
|
|
14477
14333
|
validateOnChange: true
|
|
14478
14334
|
},
|
|
14479
|
-
/* @__PURE__ */ React19.createElement(
|
|
14480
|
-
|
|
14335
|
+
/* @__PURE__ */ React19.createElement(import_core_react9.Form.Form, { name: header }, /* @__PURE__ */ React19.createElement(
|
|
14336
|
+
import_core_react9.Modal.Body,
|
|
14481
14337
|
{
|
|
14482
|
-
style: { paddingTop: 0, paddingBottom: 0, marginTop:
|
|
14338
|
+
style: { paddingTop: 0, paddingBottom: 0, marginTop: import_core_react9.spacing.lg }
|
|
14483
14339
|
},
|
|
14484
|
-
errors && /* @__PURE__ */ React19.createElement(
|
|
14485
|
-
/* @__PURE__ */ React19.createElement(
|
|
14486
|
-
|
|
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 == null ? void 0 : 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,
|
|
14487
14343
|
{
|
|
14488
14344
|
name: "name",
|
|
14489
14345
|
error: errors == null ? void 0 : errors.name,
|
|
@@ -14494,12 +14350,12 @@ var FormModalBase = ({
|
|
|
14494
14350
|
}
|
|
14495
14351
|
)),
|
|
14496
14352
|
/* @__PURE__ */ React19.createElement(
|
|
14497
|
-
|
|
14353
|
+
import_core_react9.Form.Row,
|
|
14498
14354
|
{
|
|
14499
|
-
style: { marginTop: (errors == null ? void 0 : errors.name) ?
|
|
14355
|
+
style: { marginTop: (errors == null ? void 0 : errors.name) ? import_core_react9.spacing.xl : import_core_react9.spacing.none }
|
|
14500
14356
|
},
|
|
14501
14357
|
/* @__PURE__ */ React19.createElement(
|
|
14502
|
-
|
|
14358
|
+
import_core_react9.Form.TextArea,
|
|
14503
14359
|
{
|
|
14504
14360
|
name: "description",
|
|
14505
14361
|
placeholder: I18n.t("savedViews.modal.fields.description"),
|
|
@@ -14509,10 +14365,11 @@ var FormModalBase = ({
|
|
|
14509
14365
|
}
|
|
14510
14366
|
)
|
|
14511
14367
|
),
|
|
14512
|
-
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React19.createElement(
|
|
14513
|
-
|
|
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,
|
|
14514
14370
|
{
|
|
14515
14371
|
name: "view_level",
|
|
14372
|
+
qa: { label: "view-level" },
|
|
14516
14373
|
options: viewLevelOptions,
|
|
14517
14374
|
label: I18n.t("savedViews.modal.fields.viewLevel"),
|
|
14518
14375
|
colWidth: 12,
|
|
@@ -14520,8 +14377,8 @@ var FormModalBase = ({
|
|
|
14520
14377
|
onClear: false
|
|
14521
14378
|
}
|
|
14522
14379
|
)) : /* @__PURE__ */ React19.createElement(React19.Fragment, null)
|
|
14523
|
-
), /* @__PURE__ */ React19.createElement(
|
|
14524
|
-
|
|
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,
|
|
14525
14382
|
{
|
|
14526
14383
|
"data-testid": "create-update-modal-button",
|
|
14527
14384
|
type: "submit",
|
|
@@ -14536,7 +14393,7 @@ var FormModalBase = ({
|
|
|
14536
14393
|
};
|
|
14537
14394
|
|
|
14538
14395
|
// src/components/modals/form-modal/FormModal.tsx
|
|
14539
|
-
var
|
|
14396
|
+
var import_core_react10 = require("@procore/core-react");
|
|
14540
14397
|
var FormModal = ({
|
|
14541
14398
|
open,
|
|
14542
14399
|
mode,
|
|
@@ -14547,9 +14404,10 @@ var FormModal = ({
|
|
|
14547
14404
|
selectedSavedView,
|
|
14548
14405
|
setOpenEditCreateModal,
|
|
14549
14406
|
onSelect,
|
|
14550
|
-
defaultView
|
|
14407
|
+
defaultView,
|
|
14408
|
+
backend
|
|
14551
14409
|
}) => {
|
|
14552
|
-
const i18n = (0,
|
|
14410
|
+
const i18n = (0, import_core_react10.useI18nContext)();
|
|
14553
14411
|
return /* @__PURE__ */ import_react11.default.createElement(
|
|
14554
14412
|
FormModalBase,
|
|
14555
14413
|
{
|
|
@@ -14565,13 +14423,14 @@ var FormModal = ({
|
|
|
14565
14423
|
selectedSavedView,
|
|
14566
14424
|
setOpenEditCreateModal,
|
|
14567
14425
|
onSelect,
|
|
14568
|
-
defaultView
|
|
14426
|
+
defaultView,
|
|
14427
|
+
backend
|
|
14569
14428
|
}
|
|
14570
14429
|
);
|
|
14571
14430
|
};
|
|
14572
14431
|
|
|
14573
14432
|
// src/components/modals/form-modal/SharedViewFormModal.tsx
|
|
14574
|
-
var
|
|
14433
|
+
var import_core_react11 = require("@procore/core-react");
|
|
14575
14434
|
var React21 = __toESM(require("react"));
|
|
14576
14435
|
var SharedViewFormModal = ({
|
|
14577
14436
|
open,
|
|
@@ -14583,7 +14442,7 @@ var SharedViewFormModal = ({
|
|
|
14583
14442
|
isCreating,
|
|
14584
14443
|
resetCreateError
|
|
14585
14444
|
}) => {
|
|
14586
|
-
const I18n = (0,
|
|
14445
|
+
const I18n = (0, import_core_react11.useI18nContext)();
|
|
14587
14446
|
const NAME_MAX_LENGTH = 150;
|
|
14588
14447
|
const errors = extractMessage(createError, I18n);
|
|
14589
14448
|
const handleNameChange = () => {
|
|
@@ -14595,7 +14454,7 @@ var SharedViewFormModal = ({
|
|
|
14595
14454
|
onCreateView(data.name, data.description);
|
|
14596
14455
|
};
|
|
14597
14456
|
return /* @__PURE__ */ React21.createElement(
|
|
14598
|
-
|
|
14457
|
+
import_core_react11.Modal,
|
|
14599
14458
|
{
|
|
14600
14459
|
"data-testid": "shared-view-form-modal",
|
|
14601
14460
|
open,
|
|
@@ -14603,35 +14462,35 @@ var SharedViewFormModal = ({
|
|
|
14603
14462
|
style: { width: "540px" }
|
|
14604
14463
|
},
|
|
14605
14464
|
/* @__PURE__ */ React21.createElement(
|
|
14606
|
-
|
|
14465
|
+
import_core_react11.Modal.Header,
|
|
14607
14466
|
{
|
|
14608
14467
|
onClose,
|
|
14609
14468
|
style: {
|
|
14610
|
-
paddingTop:
|
|
14611
|
-
paddingBottom:
|
|
14612
|
-
paddingLeft:
|
|
14613
|
-
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
|
|
14614
14473
|
}
|
|
14615
14474
|
},
|
|
14616
14475
|
I18n.t("savedViews.modal.create.title")
|
|
14617
14476
|
),
|
|
14618
14477
|
/* @__PURE__ */ React21.createElement(
|
|
14619
|
-
|
|
14478
|
+
import_core_react11.P,
|
|
14620
14479
|
{
|
|
14621
14480
|
style: {
|
|
14622
|
-
paddingLeft:
|
|
14623
|
-
paddingRight:
|
|
14624
|
-
paddingBottom:
|
|
14625
|
-
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,
|
|
14626
14485
|
margin: 0,
|
|
14627
|
-
color:
|
|
14486
|
+
color: import_core_react11.colors.gray45,
|
|
14628
14487
|
whiteSpace: "pre-line"
|
|
14629
14488
|
}
|
|
14630
14489
|
},
|
|
14631
14490
|
I18n.t("savedViews.modal.copyConfirmation.description")
|
|
14632
14491
|
),
|
|
14633
14492
|
/* @__PURE__ */ React21.createElement(
|
|
14634
|
-
|
|
14493
|
+
import_core_react11.Form,
|
|
14635
14494
|
{
|
|
14636
14495
|
initialValues: {
|
|
14637
14496
|
name: fetchedView.name,
|
|
@@ -14649,20 +14508,20 @@ var SharedViewFormModal = ({
|
|
|
14649
14508
|
onSubmit: handleOnSubmit,
|
|
14650
14509
|
validateOnChange: true
|
|
14651
14510
|
},
|
|
14652
|
-
/* @__PURE__ */ React21.createElement(
|
|
14653
|
-
|
|
14511
|
+
/* @__PURE__ */ React21.createElement(import_core_react11.Form.Form, { name: "share-view-form" }, /* @__PURE__ */ React21.createElement(
|
|
14512
|
+
import_core_react11.Modal.Body,
|
|
14654
14513
|
{
|
|
14655
14514
|
style: {
|
|
14656
|
-
paddingTop:
|
|
14515
|
+
paddingTop: import_core_react11.spacing.lg,
|
|
14657
14516
|
paddingBottom: 0,
|
|
14658
|
-
borderTop: `1px solid ${
|
|
14517
|
+
borderTop: `1px solid ${import_core_react11.colors.gray85}`
|
|
14659
14518
|
}
|
|
14660
14519
|
},
|
|
14661
|
-
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", {
|
|
14662
14521
|
mode: "create"
|
|
14663
|
-
})), /* @__PURE__ */ React21.createElement(
|
|
14664
|
-
/* @__PURE__ */ React21.createElement(
|
|
14665
|
-
|
|
14522
|
+
})), /* @__PURE__ */ React21.createElement(import_core_react11.Banner.Body, null, (errors == null ? void 0 : 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,
|
|
14666
14525
|
{
|
|
14667
14526
|
name: "name",
|
|
14668
14527
|
error: errors == null ? void 0 : errors.name,
|
|
@@ -14673,12 +14532,12 @@ var SharedViewFormModal = ({
|
|
|
14673
14532
|
}
|
|
14674
14533
|
)),
|
|
14675
14534
|
/* @__PURE__ */ React21.createElement(
|
|
14676
|
-
|
|
14535
|
+
import_core_react11.Form.Row,
|
|
14677
14536
|
{
|
|
14678
|
-
style: { marginTop: (errors == null ? void 0 : errors.name) ?
|
|
14537
|
+
style: { marginTop: (errors == null ? void 0 : errors.name) ? import_core_react11.spacing.xl : import_core_react11.spacing.none }
|
|
14679
14538
|
},
|
|
14680
14539
|
/* @__PURE__ */ React21.createElement(
|
|
14681
|
-
|
|
14540
|
+
import_core_react11.Form.TextArea,
|
|
14682
14541
|
{
|
|
14683
14542
|
name: "description",
|
|
14684
14543
|
placeholder: I18n.t("savedViews.modal.fields.description"),
|
|
@@ -14688,8 +14547,8 @@ var SharedViewFormModal = ({
|
|
|
14688
14547
|
}
|
|
14689
14548
|
)
|
|
14690
14549
|
)
|
|
14691
|
-
), /* @__PURE__ */ React21.createElement(
|
|
14692
|
-
|
|
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,
|
|
14693
14552
|
{
|
|
14694
14553
|
variant: "secondary",
|
|
14695
14554
|
onClick: onCreateTemporaryView,
|
|
@@ -14698,7 +14557,7 @@ var SharedViewFormModal = ({
|
|
|
14698
14557
|
},
|
|
14699
14558
|
I18n.t("savedViews.actions.viewTemporarily")
|
|
14700
14559
|
), /* @__PURE__ */ React21.createElement(
|
|
14701
|
-
|
|
14560
|
+
import_core_react11.Button,
|
|
14702
14561
|
{
|
|
14703
14562
|
type: "submit",
|
|
14704
14563
|
variant: "primary",
|
|
@@ -14715,7 +14574,7 @@ var SharedViewFormModal = ({
|
|
|
14715
14574
|
// src/utils/hooks/useViewSelection.ts
|
|
14716
14575
|
var import_react12 = require("react");
|
|
14717
14576
|
var import_react_router_dom = require("react-router-dom");
|
|
14718
|
-
var
|
|
14577
|
+
var import_core_react12 = require("@procore/core-react");
|
|
14719
14578
|
|
|
14720
14579
|
// src/utils/viewStorage.ts
|
|
14721
14580
|
var ViewStorage = {
|
|
@@ -14778,7 +14637,7 @@ var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
|
14778
14637
|
}
|
|
14779
14638
|
};
|
|
14780
14639
|
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) => {
|
|
14781
|
-
const I18n = (0,
|
|
14640
|
+
const I18n = (0, import_core_react12.useI18nContext)();
|
|
14782
14641
|
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${config.projectId}_${config.userId}`;
|
|
14783
14642
|
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
14784
14643
|
const [searchParams, setSearchParams] = (0, import_react_router_dom.useSearchParams)();
|
|
@@ -14877,6 +14736,177 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) =>
|
|
|
14877
14736
|
};
|
|
14878
14737
|
};
|
|
14879
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 == null ? void 0 : oldData.find(
|
|
14826
|
+
(item) => item.share_token === savedView.share_token
|
|
14827
|
+
);
|
|
14828
|
+
if ((oldView == null ? void 0 : 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 == null ? void 0 : customBackend.useSavedViewsQuery) ?? useSavedViewsQuery,
|
|
14903
|
+
useSavedViewsPermissions: (customBackend == null ? void 0 : customBackend.useSavedViewsPermissions) ?? useSavedViewsPermissions,
|
|
14904
|
+
useCreateSavedView: (customBackend == null ? void 0 : customBackend.useCreateSavedView) ?? useCreateSavedView,
|
|
14905
|
+
useUpdateSavedView: (customBackend == null ? void 0 : customBackend.useUpdateSavedView) ?? useUpdateSavedView,
|
|
14906
|
+
useDeleteSavedView: (customBackend == null ? void 0 : customBackend.useDeleteSavedView) ?? useDeleteSavedView,
|
|
14907
|
+
useFetchSavedViewById: (customBackend == null ? void 0 : customBackend.useFetchSavedViewById) ?? useFetchSavedViewById
|
|
14908
|
+
});
|
|
14909
|
+
|
|
14880
14910
|
// src/components/saved-views/SavedViews.tsx
|
|
14881
14911
|
var StyledPanel = styled_components_esm_default.div`
|
|
14882
14912
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
@@ -14884,14 +14914,15 @@ var StyledPanel = styled_components_esm_default.div`
|
|
|
14884
14914
|
var queryClient = new import_react_query3.QueryClient();
|
|
14885
14915
|
var SavedViewsContent = (props) => {
|
|
14886
14916
|
const { projectId, companyId } = props;
|
|
14917
|
+
const backend = createQueries(props.backend);
|
|
14887
14918
|
const queryInput = {
|
|
14888
14919
|
domain: props.domain,
|
|
14889
14920
|
tableName: props.tableName,
|
|
14890
14921
|
projectId,
|
|
14891
14922
|
companyId
|
|
14892
14923
|
};
|
|
14893
|
-
const { data: savedViews } = useSavedViewsQuery(queryInput);
|
|
14894
|
-
const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
|
|
14924
|
+
const { data: savedViews } = backend.useSavedViewsQuery(queryInput);
|
|
14925
|
+
const { mutate: deleteSavedView } = backend.useDeleteSavedView(queryInput);
|
|
14895
14926
|
const { showToast } = (0, import_toast_alert3.useToastAlertContext)();
|
|
14896
14927
|
const i18n = (0, import_core_react14.useI18nContext)();
|
|
14897
14928
|
const [activeModal, setActiveModal] = (0, import_react13.useState)(null);
|
|
@@ -14928,7 +14959,7 @@ var SavedViewsContent = (props) => {
|
|
|
14928
14959
|
props.presetViews,
|
|
14929
14960
|
openSharedViewModal
|
|
14930
14961
|
);
|
|
14931
|
-
const { data: fetchedView, isError: fetchError } = useFetchSavedViewById(
|
|
14962
|
+
const { data: fetchedView, isError: fetchError } = backend.useFetchSavedViewById(
|
|
14932
14963
|
(modalData == null ? void 0 : modalData.viewId) ?? null,
|
|
14933
14964
|
queryInput,
|
|
14934
14965
|
Boolean(modalData == null ? void 0 : modalData.viewId)
|
|
@@ -14938,7 +14969,7 @@ var SavedViewsContent = (props) => {
|
|
|
14938
14969
|
isPending: isCreating,
|
|
14939
14970
|
error: createError,
|
|
14940
14971
|
reset: resetCreateError
|
|
14941
|
-
} = useCreateSavedView(queryInput);
|
|
14972
|
+
} = backend.useCreateSavedView(queryInput);
|
|
14942
14973
|
(0, import_react13.useEffect)(() => {
|
|
14943
14974
|
if (fetchError) {
|
|
14944
14975
|
showToast.error(i18n.t("savedViews.errors.notFound"));
|
|
@@ -15025,7 +15056,8 @@ var SavedViewsContent = (props) => {
|
|
|
15025
15056
|
savedViews: allViews,
|
|
15026
15057
|
provider: props.provider,
|
|
15027
15058
|
userId: props.userId,
|
|
15028
|
-
onClearTemporary: clearTemporaryView
|
|
15059
|
+
onClearTemporary: clearTemporaryView,
|
|
15060
|
+
backend
|
|
15029
15061
|
}
|
|
15030
15062
|
))
|
|
15031
15063
|
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ import_react13.default.createElement(
|
|
@@ -15040,7 +15072,8 @@ var SavedViewsContent = (props) => {
|
|
|
15040
15072
|
selectedSavedView: selectedView,
|
|
15041
15073
|
onSelect: selectView,
|
|
15042
15074
|
setOpenEditCreateModal: closeModal,
|
|
15043
|
-
defaultView: props.defaultView
|
|
15075
|
+
defaultView: props.defaultView,
|
|
15076
|
+
backend
|
|
15044
15077
|
}
|
|
15045
15078
|
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */ import_react13.default.createElement(
|
|
15046
15079
|
SavedViewsDeleteConfirmationModalShared,
|
|
@@ -15151,10 +15184,14 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15151
15184
|
const [config, setConfig] = (0, import_react15.useState)(
|
|
15152
15185
|
() => getSmartGridConfig(gridApi)
|
|
15153
15186
|
);
|
|
15187
|
+
const eventListenersDisabledRef = (0, import_react15.useRef)(false);
|
|
15154
15188
|
(0, import_react15.useEffect)(() => {
|
|
15155
15189
|
if (!gridApi)
|
|
15156
15190
|
return;
|
|
15157
15191
|
const updateConfig = () => {
|
|
15192
|
+
if (eventListenersDisabledRef.current) {
|
|
15193
|
+
return;
|
|
15194
|
+
}
|
|
15158
15195
|
setConfig(getSmartGridConfig(gridApi));
|
|
15159
15196
|
};
|
|
15160
15197
|
GRID_STATE_EVENTS.forEach((event) => {
|
|
@@ -15166,7 +15203,13 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15166
15203
|
});
|
|
15167
15204
|
};
|
|
15168
15205
|
}, [gridApi]);
|
|
15169
|
-
|
|
15206
|
+
const disableEventListeners = () => {
|
|
15207
|
+
eventListenersDisabledRef.current = true;
|
|
15208
|
+
};
|
|
15209
|
+
const enableEventListeners = () => {
|
|
15210
|
+
eventListenersDisabledRef.current = false;
|
|
15211
|
+
};
|
|
15212
|
+
return { config, setConfig, disableEventListeners, enableEventListeners };
|
|
15170
15213
|
};
|
|
15171
15214
|
|
|
15172
15215
|
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
@@ -15210,7 +15253,8 @@ var SmartGridSavedViews = (props) => {
|
|
|
15210
15253
|
defaultView,
|
|
15211
15254
|
presetViews,
|
|
15212
15255
|
tableName: props.tableName,
|
|
15213
|
-
tableConfig
|
|
15256
|
+
tableConfig,
|
|
15257
|
+
backend: props.backend
|
|
15214
15258
|
}
|
|
15215
15259
|
);
|
|
15216
15260
|
};
|