@elementor/editor-site-navigation 0.19.5 → 0.19.7
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/CHANGELOG.md +16 -0
- package/dist/index.js +29 -29
- package/dist/index.mjs +29 -29
- package/package.json +9 -9
- package/src/components/panel/actions-menu/actions/__tests__/delete.test.tsx +1 -1
- package/src/components/panel/actions-menu/actions/__tests__/set-home.test.tsx +1 -1
- package/src/components/panel/actions-menu/actions/delete.tsx +4 -4
- package/src/components/panel/actions-menu/actions/set-home.tsx +2 -2
- package/src/components/panel/posts-list/__tests__/post-list-item.test.tsx +1 -1
- package/src/components/panel/posts-list/__tests__/posts-collapsible-list.test.tsx +2 -2
- package/src/components/panel/posts-list/list-items/list-item-create.tsx +1 -1
- package/src/components/panel/posts-list/list-items/list-item-duplicate.tsx +1 -1
- package/src/components/panel/posts-list/list-items/list-item-rename.tsx +1 -1
- package/src/hooks/use-homepage-actions.ts +5 -5
- package/src/hooks/use-posts-actions.ts +20 -20
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.19.7](https://github.com/elementor/elementor-packages/compare/@elementor/editor-site-navigation@0.19.6...@elementor/editor-site-navigation@0.19.7) (2023-11-02)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @elementor/editor-site-navigation
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.19.6](https://github.com/elementor/elementor-packages/compare/@elementor/editor-site-navigation@0.19.5...@elementor/editor-site-navigation@0.19.6) (2023-10-19)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @elementor/editor-site-navigation
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [0.19.5](https://github.com/elementor/elementor-packages/compare/@elementor/editor-site-navigation@0.19.4...@elementor/editor-site-navigation@0.19.5) (2023-10-19)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @elementor/editor-site-navigation
|
package/dist/index.js
CHANGED
|
@@ -469,22 +469,22 @@ var import_query2 = require("@elementor/query");
|
|
|
469
469
|
function usePostActions(postTypeSlug) {
|
|
470
470
|
const invalidatePosts = useInvalidatePosts(postTypeSlug);
|
|
471
471
|
const onSuccess = () => invalidatePosts({ exact: true });
|
|
472
|
-
const createPost = (0, import_query2.useMutation)(
|
|
473
|
-
(newPost) => createRequest(postTypeSlug, newPost),
|
|
474
|
-
|
|
475
|
-
);
|
|
476
|
-
const updatePost = (0, import_query2.useMutation)(
|
|
477
|
-
(updatedPost) => updateRequest(postTypeSlug, updatedPost),
|
|
478
|
-
|
|
479
|
-
);
|
|
480
|
-
const deletePost = (0, import_query2.useMutation)(
|
|
481
|
-
(postId) => deleteRequest(postTypeSlug, postId),
|
|
482
|
-
|
|
483
|
-
);
|
|
484
|
-
const duplicatePost = (0, import_query2.useMutation)(
|
|
485
|
-
(originalPost) => duplicateRequest(originalPost),
|
|
486
|
-
|
|
487
|
-
);
|
|
472
|
+
const createPost = (0, import_query2.useMutation)({
|
|
473
|
+
mutationFn: (newPost) => createRequest(postTypeSlug, newPost),
|
|
474
|
+
onSuccess
|
|
475
|
+
});
|
|
476
|
+
const updatePost = (0, import_query2.useMutation)({
|
|
477
|
+
mutationFn: (updatedPost) => updateRequest(postTypeSlug, updatedPost),
|
|
478
|
+
onSuccess
|
|
479
|
+
});
|
|
480
|
+
const deletePost = (0, import_query2.useMutation)({
|
|
481
|
+
mutationFn: (postId) => deleteRequest(postTypeSlug, postId),
|
|
482
|
+
onSuccess
|
|
483
|
+
});
|
|
484
|
+
const duplicatePost = (0, import_query2.useMutation)({
|
|
485
|
+
mutationFn: (originalPost) => duplicateRequest(originalPost),
|
|
486
|
+
onSuccess
|
|
487
|
+
});
|
|
488
488
|
return {
|
|
489
489
|
createPost,
|
|
490
490
|
updatePost,
|
|
@@ -496,7 +496,7 @@ function useInvalidatePosts(postTypeSlug) {
|
|
|
496
496
|
const queryClient = (0, import_query2.useQueryClient)();
|
|
497
497
|
return (options = {}) => {
|
|
498
498
|
const queryKey = postsQueryKey(postTypeSlug);
|
|
499
|
-
return queryClient.invalidateQueries(queryKey, options);
|
|
499
|
+
return queryClient.invalidateQueries({ queryKey }, options);
|
|
500
500
|
};
|
|
501
501
|
}
|
|
502
502
|
|
|
@@ -590,7 +590,7 @@ function ListItemRename({ post }) {
|
|
|
590
590
|
}
|
|
591
591
|
});
|
|
592
592
|
};
|
|
593
|
-
return /* @__PURE__ */ React9.createElement(EditModeTemplate, { postTitle: post.title.rendered, isLoading: updatePost.
|
|
593
|
+
return /* @__PURE__ */ React9.createElement(EditModeTemplate, { postTitle: post.title.rendered, isLoading: updatePost.isPending, callback: renamePostCallback });
|
|
594
594
|
}
|
|
595
595
|
|
|
596
596
|
// src/components/panel/posts-list/list-items/list-item-create.tsx
|
|
@@ -612,7 +612,7 @@ function ListItemCreate() {
|
|
|
612
612
|
}
|
|
613
613
|
});
|
|
614
614
|
};
|
|
615
|
-
return /* @__PURE__ */ React10.createElement(EditModeTemplate, { postTitle: (0, import_i18n5.__)("New Page", "elementor"), isLoading: createPost.
|
|
615
|
+
return /* @__PURE__ */ React10.createElement(EditModeTemplate, { postTitle: (0, import_i18n5.__)("New Page", "elementor"), isLoading: createPost.isPending, callback: createPostCallback });
|
|
616
616
|
}
|
|
617
617
|
|
|
618
618
|
// src/components/panel/posts-list/list-items/list-item-duplicate.tsx
|
|
@@ -637,7 +637,7 @@ function ListItemDuplicate() {
|
|
|
637
637
|
}
|
|
638
638
|
});
|
|
639
639
|
};
|
|
640
|
-
return /* @__PURE__ */ React11.createElement(EditModeTemplate, { postTitle: `${editMode.details.title} ${(0, import_i18n6.__)("copy", "elementor")}`, isLoading: duplicatePost.
|
|
640
|
+
return /* @__PURE__ */ React11.createElement(EditModeTemplate, { postTitle: `${editMode.details.title} ${(0, import_i18n6.__)("copy", "elementor")}`, isLoading: duplicatePost.isPending, callback: duplicatePostCallback });
|
|
641
641
|
}
|
|
642
642
|
|
|
643
643
|
// src/components/panel/posts-list/list-items/list-item-view.tsx
|
|
@@ -790,7 +790,7 @@ function DeleteDialog({ post, setIsDialogOpen }) {
|
|
|
790
790
|
await deletePost.mutateAsync(post.id);
|
|
791
791
|
};
|
|
792
792
|
const handleCancel = () => {
|
|
793
|
-
if (deletePost.
|
|
793
|
+
if (deletePost.isPending) {
|
|
794
794
|
return;
|
|
795
795
|
}
|
|
796
796
|
setIsDialogOpen(false);
|
|
@@ -805,7 +805,7 @@ function DeleteDialog({ post, setIsDialogOpen }) {
|
|
|
805
805
|
/* @__PURE__ */ React16.createElement(import_ui10.DialogTitle, { noWrap: true }, dialogTitle),
|
|
806
806
|
/* @__PURE__ */ React16.createElement(import_ui10.Divider, null),
|
|
807
807
|
/* @__PURE__ */ React16.createElement(import_ui10.DialogContent, null, /* @__PURE__ */ React16.createElement(import_ui10.DialogContentText, null, (0, import_i18n9.__)("The page and its content will be deleted forever and we won\u2019t be able to recover them.", "elementor"))),
|
|
808
|
-
/* @__PURE__ */ React16.createElement(import_ui10.DialogActions, null, /* @__PURE__ */ React16.createElement(import_ui10.Button, { variant: "contained", color: "secondary", onClick: handleCancel, disabled: deletePost.
|
|
808
|
+
/* @__PURE__ */ React16.createElement(import_ui10.DialogActions, null, /* @__PURE__ */ React16.createElement(import_ui10.Button, { variant: "contained", color: "secondary", onClick: handleCancel, disabled: deletePost.isPending }, (0, import_i18n9.__)("Cancel", "elementor")), /* @__PURE__ */ React16.createElement(import_ui10.Button, { variant: "contained", color: "error", onClick: deletePage, disabled: deletePost.isPending }, !deletePost.isPending ? (0, import_i18n9.__)("Delete", "elementor") : /* @__PURE__ */ React16.createElement(import_ui10.CircularProgress, null)))
|
|
809
809
|
);
|
|
810
810
|
}
|
|
811
811
|
|
|
@@ -869,17 +869,17 @@ function useHomepage() {
|
|
|
869
869
|
function useHomepageActions() {
|
|
870
870
|
const invalidateSettings = useInvalidateSettings();
|
|
871
871
|
const onSuccess = async () => invalidateSettings({ exact: true });
|
|
872
|
-
const updateSettingsMutation = (0, import_query4.useMutation)(
|
|
873
|
-
(settings) => updateSettings(settings),
|
|
874
|
-
|
|
875
|
-
);
|
|
872
|
+
const updateSettingsMutation = (0, import_query4.useMutation)({
|
|
873
|
+
mutationFn: (settings) => updateSettings(settings),
|
|
874
|
+
onSuccess
|
|
875
|
+
});
|
|
876
876
|
return { updateSettingsMutation };
|
|
877
877
|
}
|
|
878
878
|
function useInvalidateSettings() {
|
|
879
879
|
const queryClient = (0, import_query4.useQueryClient)();
|
|
880
880
|
return (options = {}) => {
|
|
881
881
|
const queryKey = settingsQueryKey();
|
|
882
|
-
return queryClient.invalidateQueries(queryKey, options);
|
|
882
|
+
return queryClient.invalidateQueries({ queryKey }, options);
|
|
883
883
|
};
|
|
884
884
|
}
|
|
885
885
|
|
|
@@ -894,9 +894,9 @@ function SetHome({ post }) {
|
|
|
894
894
|
ActionMenuItem,
|
|
895
895
|
{
|
|
896
896
|
title: (0, import_i18n11.__)("Set as homepage", "elementor"),
|
|
897
|
-
icon: !updateSettingsMutation.
|
|
897
|
+
icon: !updateSettingsMutation.isPending ? import_icons11.HomeIcon : import_ui11.CircularProgress,
|
|
898
898
|
ListItemButtonProps: {
|
|
899
|
-
disabled: !!post.isHome || post.status !== "publish" || updateSettingsMutation.
|
|
899
|
+
disabled: !!post.isHome || post.status !== "publish" || updateSettingsMutation.isPending,
|
|
900
900
|
onClick: handleClick
|
|
901
901
|
}
|
|
902
902
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -451,22 +451,22 @@ import { useQueryClient, useMutation } from "@elementor/query";
|
|
|
451
451
|
function usePostActions(postTypeSlug) {
|
|
452
452
|
const invalidatePosts = useInvalidatePosts(postTypeSlug);
|
|
453
453
|
const onSuccess = () => invalidatePosts({ exact: true });
|
|
454
|
-
const createPost = useMutation(
|
|
455
|
-
(newPost) => createRequest(postTypeSlug, newPost),
|
|
456
|
-
|
|
457
|
-
);
|
|
458
|
-
const updatePost = useMutation(
|
|
459
|
-
(updatedPost) => updateRequest(postTypeSlug, updatedPost),
|
|
460
|
-
|
|
461
|
-
);
|
|
462
|
-
const deletePost = useMutation(
|
|
463
|
-
(postId) => deleteRequest(postTypeSlug, postId),
|
|
464
|
-
|
|
465
|
-
);
|
|
466
|
-
const duplicatePost = useMutation(
|
|
467
|
-
(originalPost) => duplicateRequest(originalPost),
|
|
468
|
-
|
|
469
|
-
);
|
|
454
|
+
const createPost = useMutation({
|
|
455
|
+
mutationFn: (newPost) => createRequest(postTypeSlug, newPost),
|
|
456
|
+
onSuccess
|
|
457
|
+
});
|
|
458
|
+
const updatePost = useMutation({
|
|
459
|
+
mutationFn: (updatedPost) => updateRequest(postTypeSlug, updatedPost),
|
|
460
|
+
onSuccess
|
|
461
|
+
});
|
|
462
|
+
const deletePost = useMutation({
|
|
463
|
+
mutationFn: (postId) => deleteRequest(postTypeSlug, postId),
|
|
464
|
+
onSuccess
|
|
465
|
+
});
|
|
466
|
+
const duplicatePost = useMutation({
|
|
467
|
+
mutationFn: (originalPost) => duplicateRequest(originalPost),
|
|
468
|
+
onSuccess
|
|
469
|
+
});
|
|
470
470
|
return {
|
|
471
471
|
createPost,
|
|
472
472
|
updatePost,
|
|
@@ -478,7 +478,7 @@ function useInvalidatePosts(postTypeSlug) {
|
|
|
478
478
|
const queryClient = useQueryClient();
|
|
479
479
|
return (options = {}) => {
|
|
480
480
|
const queryKey = postsQueryKey(postTypeSlug);
|
|
481
|
-
return queryClient.invalidateQueries(queryKey, options);
|
|
481
|
+
return queryClient.invalidateQueries({ queryKey }, options);
|
|
482
482
|
};
|
|
483
483
|
}
|
|
484
484
|
|
|
@@ -578,7 +578,7 @@ function ListItemRename({ post }) {
|
|
|
578
578
|
}
|
|
579
579
|
});
|
|
580
580
|
};
|
|
581
|
-
return /* @__PURE__ */ React9.createElement(EditModeTemplate, { postTitle: post.title.rendered, isLoading: updatePost.
|
|
581
|
+
return /* @__PURE__ */ React9.createElement(EditModeTemplate, { postTitle: post.title.rendered, isLoading: updatePost.isPending, callback: renamePostCallback });
|
|
582
582
|
}
|
|
583
583
|
|
|
584
584
|
// src/components/panel/posts-list/list-items/list-item-create.tsx
|
|
@@ -600,7 +600,7 @@ function ListItemCreate() {
|
|
|
600
600
|
}
|
|
601
601
|
});
|
|
602
602
|
};
|
|
603
|
-
return /* @__PURE__ */ React10.createElement(EditModeTemplate, { postTitle: __5("New Page", "elementor"), isLoading: createPost.
|
|
603
|
+
return /* @__PURE__ */ React10.createElement(EditModeTemplate, { postTitle: __5("New Page", "elementor"), isLoading: createPost.isPending, callback: createPostCallback });
|
|
604
604
|
}
|
|
605
605
|
|
|
606
606
|
// src/components/panel/posts-list/list-items/list-item-duplicate.tsx
|
|
@@ -625,7 +625,7 @@ function ListItemDuplicate() {
|
|
|
625
625
|
}
|
|
626
626
|
});
|
|
627
627
|
};
|
|
628
|
-
return /* @__PURE__ */ React11.createElement(EditModeTemplate, { postTitle: `${editMode.details.title} ${__6("copy", "elementor")}`, isLoading: duplicatePost.
|
|
628
|
+
return /* @__PURE__ */ React11.createElement(EditModeTemplate, { postTitle: `${editMode.details.title} ${__6("copy", "elementor")}`, isLoading: duplicatePost.isPending, callback: duplicatePostCallback });
|
|
629
629
|
}
|
|
630
630
|
|
|
631
631
|
// src/components/panel/posts-list/list-items/list-item-view.tsx
|
|
@@ -803,7 +803,7 @@ function DeleteDialog({ post, setIsDialogOpen }) {
|
|
|
803
803
|
await deletePost.mutateAsync(post.id);
|
|
804
804
|
};
|
|
805
805
|
const handleCancel = () => {
|
|
806
|
-
if (deletePost.
|
|
806
|
+
if (deletePost.isPending) {
|
|
807
807
|
return;
|
|
808
808
|
}
|
|
809
809
|
setIsDialogOpen(false);
|
|
@@ -818,7 +818,7 @@ function DeleteDialog({ post, setIsDialogOpen }) {
|
|
|
818
818
|
/* @__PURE__ */ React16.createElement(DialogTitle, { noWrap: true }, dialogTitle),
|
|
819
819
|
/* @__PURE__ */ React16.createElement(Divider3, null),
|
|
820
820
|
/* @__PURE__ */ React16.createElement(DialogContent, null, /* @__PURE__ */ React16.createElement(DialogContentText, null, __9("The page and its content will be deleted forever and we won\u2019t be able to recover them.", "elementor"))),
|
|
821
|
-
/* @__PURE__ */ React16.createElement(DialogActions, null, /* @__PURE__ */ React16.createElement(Button2, { variant: "contained", color: "secondary", onClick: handleCancel, disabled: deletePost.
|
|
821
|
+
/* @__PURE__ */ React16.createElement(DialogActions, null, /* @__PURE__ */ React16.createElement(Button2, { variant: "contained", color: "secondary", onClick: handleCancel, disabled: deletePost.isPending }, __9("Cancel", "elementor")), /* @__PURE__ */ React16.createElement(Button2, { variant: "contained", color: "error", onClick: deletePage, disabled: deletePost.isPending }, !deletePost.isPending ? __9("Delete", "elementor") : /* @__PURE__ */ React16.createElement(CircularProgress3, null)))
|
|
822
822
|
);
|
|
823
823
|
}
|
|
824
824
|
|
|
@@ -882,17 +882,17 @@ function useHomepage() {
|
|
|
882
882
|
function useHomepageActions() {
|
|
883
883
|
const invalidateSettings = useInvalidateSettings();
|
|
884
884
|
const onSuccess = async () => invalidateSettings({ exact: true });
|
|
885
|
-
const updateSettingsMutation = useMutation2(
|
|
886
|
-
(settings) => updateSettings(settings),
|
|
887
|
-
|
|
888
|
-
);
|
|
885
|
+
const updateSettingsMutation = useMutation2({
|
|
886
|
+
mutationFn: (settings) => updateSettings(settings),
|
|
887
|
+
onSuccess
|
|
888
|
+
});
|
|
889
889
|
return { updateSettingsMutation };
|
|
890
890
|
}
|
|
891
891
|
function useInvalidateSettings() {
|
|
892
892
|
const queryClient = useQueryClient2();
|
|
893
893
|
return (options = {}) => {
|
|
894
894
|
const queryKey = settingsQueryKey();
|
|
895
|
-
return queryClient.invalidateQueries(queryKey, options);
|
|
895
|
+
return queryClient.invalidateQueries({ queryKey }, options);
|
|
896
896
|
};
|
|
897
897
|
}
|
|
898
898
|
|
|
@@ -907,9 +907,9 @@ function SetHome({ post }) {
|
|
|
907
907
|
ActionMenuItem,
|
|
908
908
|
{
|
|
909
909
|
title: __11("Set as homepage", "elementor"),
|
|
910
|
-
icon: !updateSettingsMutation.
|
|
910
|
+
icon: !updateSettingsMutation.isPending ? HomeIcon : CircularProgress4,
|
|
911
911
|
ListItemButtonProps: {
|
|
912
|
-
disabled: !!post.isHome || post.status !== "publish" || updateSettingsMutation.
|
|
912
|
+
disabled: !!post.isHome || post.status !== "publish" || updateSettingsMutation.isPending,
|
|
913
913
|
onClick: handleClick
|
|
914
914
|
}
|
|
915
915
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-site-navigation",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@elementor/editor-app-bar": "^0.9.
|
|
36
|
-
"@elementor/editor-documents": "^0.10.
|
|
37
|
-
"@elementor/editor-panels": "^0.4.
|
|
35
|
+
"@elementor/editor-app-bar": "^0.9.6",
|
|
36
|
+
"@elementor/editor-documents": "^0.10.1",
|
|
37
|
+
"@elementor/editor-panels": "^0.4.4",
|
|
38
38
|
"@elementor/env": "^0.3.2",
|
|
39
39
|
"@elementor/icons": "^0.7.1",
|
|
40
|
-
"@elementor/query": "^0.1.
|
|
40
|
+
"@elementor/query": "^0.1.5",
|
|
41
41
|
"@elementor/ui": "^1.4.60",
|
|
42
|
-
"@wordpress/api-fetch": "^6.
|
|
43
|
-
"@wordpress/i18n": "^4.
|
|
44
|
-
"@wordpress/url": "^3.
|
|
42
|
+
"@wordpress/api-fetch": "^6.41.0",
|
|
43
|
+
"@wordpress/i18n": "^4.44.0",
|
|
44
|
+
"@wordpress/url": "^3.45.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "18.x"
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"elementor": {
|
|
50
50
|
"type": "extension"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "cbfffae2a0d21655d4e3b524095aaf3a0430ae76"
|
|
53
53
|
}
|
|
@@ -59,7 +59,7 @@ function DeleteDialog( { post, setIsDialogOpen }: { post: Post, setIsDialogOpen:
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
const handleCancel = () => {
|
|
62
|
-
if ( deletePost.
|
|
62
|
+
if ( deletePost.isPending ) {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -82,11 +82,11 @@ function DeleteDialog( { post, setIsDialogOpen }: { post: Post, setIsDialogOpen:
|
|
|
82
82
|
</DialogContentText>
|
|
83
83
|
</DialogContent>
|
|
84
84
|
<DialogActions>
|
|
85
|
-
<Button variant="contained" color="secondary" onClick={ handleCancel } disabled={ deletePost.
|
|
85
|
+
<Button variant="contained" color="secondary" onClick={ handleCancel } disabled={ deletePost.isPending }>
|
|
86
86
|
{ __( 'Cancel', 'elementor' ) }
|
|
87
87
|
</Button>
|
|
88
|
-
<Button variant="contained" color="error" onClick={ deletePage } disabled={ deletePost.
|
|
89
|
-
{ ! deletePost.
|
|
88
|
+
<Button variant="contained" color="error" onClick={ deletePage } disabled={ deletePost.isPending } >
|
|
89
|
+
{ ! deletePost.isPending ? __( 'Delete', 'elementor' ) : <CircularProgress /> }
|
|
90
90
|
</Button>
|
|
91
91
|
</DialogActions>
|
|
92
92
|
</Dialog>
|
|
@@ -16,10 +16,10 @@ export default function SetHome( { post }: { post: Post } ) {
|
|
|
16
16
|
return (
|
|
17
17
|
<ActionMenuItem
|
|
18
18
|
title={ __( 'Set as homepage', 'elementor' ) }
|
|
19
|
-
icon={ ! updateSettingsMutation.
|
|
19
|
+
icon={ ! updateSettingsMutation.isPending ? HomeIcon : CircularProgress }
|
|
20
20
|
ListItemButtonProps={
|
|
21
21
|
{
|
|
22
|
-
disabled: !! post.isHome || post.status !== 'publish' || updateSettingsMutation.
|
|
22
|
+
disabled: !! post.isHome || post.status !== 'publish' || updateSettingsMutation.isPending,
|
|
23
23
|
onClick: handleClick,
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -10,11 +10,11 @@ jest.mock( '../../../../hooks/use-posts-actions', () => ( {
|
|
|
10
10
|
usePostActions: () => ( {
|
|
11
11
|
createPost: {
|
|
12
12
|
mutateAsync: mockMutateAsync,
|
|
13
|
-
|
|
13
|
+
isPending: false,
|
|
14
14
|
},
|
|
15
15
|
duplicatePost: {
|
|
16
16
|
mutateAsync: mockMutateAsync,
|
|
17
|
-
|
|
17
|
+
isPending: false,
|
|
18
18
|
},
|
|
19
19
|
} ),
|
|
20
20
|
} ) );
|
|
@@ -24,6 +24,6 @@ export default function ListItemCreate() {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
return (
|
|
27
|
-
<EditModeTemplate postTitle={ __( 'New Page', 'elementor' ) } isLoading={ createPost.
|
|
27
|
+
<EditModeTemplate postTitle={ __( 'New Page', 'elementor' ) } isLoading={ createPost.isPending } callback={ createPostCallback } />
|
|
28
28
|
);
|
|
29
29
|
}
|
|
@@ -28,6 +28,6 @@ export default function ListItemDuplicate() {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
return (
|
|
31
|
-
<EditModeTemplate postTitle={ `${ editMode.details.title } ${ __( 'copy', 'elementor' ) }` } isLoading={ duplicatePost.
|
|
31
|
+
<EditModeTemplate postTitle={ `${ editMode.details.title } ${ __( 'copy', 'elementor' ) }` } isLoading={ duplicatePost.isPending } callback={ duplicatePostCallback } />
|
|
32
32
|
);
|
|
33
33
|
}
|
|
@@ -28,6 +28,6 @@ export default function ListItemRename( { post }: Props ) {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
return (
|
|
31
|
-
<EditModeTemplate postTitle={ post.title.rendered } isLoading={ updatePost.
|
|
31
|
+
<EditModeTemplate postTitle={ post.title.rendered } isLoading={ updatePost.isPending } callback={ renamePostCallback } />
|
|
32
32
|
);
|
|
33
33
|
}
|
|
@@ -7,10 +7,10 @@ export function useHomepageActions() {
|
|
|
7
7
|
|
|
8
8
|
const onSuccess = async () => invalidateSettings( { exact: true } );
|
|
9
9
|
|
|
10
|
-
const updateSettingsMutation = useMutation(
|
|
11
|
-
( settings: Settings ) => updateSettings( settings ),
|
|
12
|
-
|
|
13
|
-
);
|
|
10
|
+
const updateSettingsMutation = useMutation( {
|
|
11
|
+
mutationFn: ( settings: Settings ) => updateSettings( settings ),
|
|
12
|
+
onSuccess,
|
|
13
|
+
} );
|
|
14
14
|
|
|
15
15
|
return { updateSettingsMutation };
|
|
16
16
|
}
|
|
@@ -21,6 +21,6 @@ function useInvalidateSettings() {
|
|
|
21
21
|
return ( options = {} ) => {
|
|
22
22
|
const queryKey = settingsQueryKey();
|
|
23
23
|
|
|
24
|
-
return queryClient.invalidateQueries( queryKey, options );
|
|
24
|
+
return queryClient.invalidateQueries( { queryKey }, options );
|
|
25
25
|
};
|
|
26
26
|
}
|
|
@@ -7,25 +7,25 @@ export function usePostActions( postTypeSlug: Slug ) {
|
|
|
7
7
|
|
|
8
8
|
const onSuccess = () => invalidatePosts( { exact: true } );
|
|
9
9
|
|
|
10
|
-
const createPost = useMutation(
|
|
11
|
-
( newPost: NewPost ) => createRequest( postTypeSlug, newPost ),
|
|
12
|
-
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
const updatePost = useMutation(
|
|
16
|
-
( updatedPost: UpdatePost ) => updateRequest( postTypeSlug, updatedPost ),
|
|
17
|
-
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const deletePost = useMutation(
|
|
21
|
-
( postId: number ) => deleteRequest( postTypeSlug, postId ),
|
|
22
|
-
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const duplicatePost = useMutation(
|
|
26
|
-
( originalPost: UpdatePost ) => duplicateRequest( originalPost ),
|
|
27
|
-
|
|
28
|
-
);
|
|
10
|
+
const createPost = useMutation( {
|
|
11
|
+
mutationFn: ( newPost: NewPost ) => createRequest( postTypeSlug, newPost ),
|
|
12
|
+
onSuccess,
|
|
13
|
+
} );
|
|
14
|
+
|
|
15
|
+
const updatePost = useMutation( {
|
|
16
|
+
mutationFn: ( updatedPost: UpdatePost ) => updateRequest( postTypeSlug, updatedPost ),
|
|
17
|
+
onSuccess,
|
|
18
|
+
} );
|
|
19
|
+
|
|
20
|
+
const deletePost = useMutation( {
|
|
21
|
+
mutationFn: ( postId: number ) => deleteRequest( postTypeSlug, postId ),
|
|
22
|
+
onSuccess,
|
|
23
|
+
} );
|
|
24
|
+
|
|
25
|
+
const duplicatePost = useMutation( {
|
|
26
|
+
mutationFn: ( originalPost: UpdatePost ) => duplicateRequest( originalPost ),
|
|
27
|
+
onSuccess,
|
|
28
|
+
} );
|
|
29
29
|
|
|
30
30
|
return {
|
|
31
31
|
createPost,
|
|
@@ -41,6 +41,6 @@ function useInvalidatePosts( postTypeSlug: string ) {
|
|
|
41
41
|
return ( options = {} ) => {
|
|
42
42
|
const queryKey = postsQueryKey( postTypeSlug );
|
|
43
43
|
|
|
44
|
-
return queryClient.invalidateQueries( queryKey, options );
|
|
44
|
+
return queryClient.invalidateQueries( { queryKey }, options );
|
|
45
45
|
};
|
|
46
46
|
}
|