@elementor/editor-site-navigation 4.5.0-1223 → 4.5.0-1225
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/index.js +96 -28
- package/dist/index.mjs +88 -20
- package/package.json +11 -11
- package/src/api/settings.ts +4 -2
- package/src/components/panel/actions-menu/actions/set-home.tsx +97 -8
- package/src/components/panel/posts-list/list-items/list-item-view.tsx +12 -2
- package/src/hooks/use-homepage-actions.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -64,7 +64,7 @@ var import_editor_panels2 = require("@elementor/editor-panels");
|
|
|
64
64
|
|
|
65
65
|
// src/components/panel/shell.tsx
|
|
66
66
|
var React36 = __toESM(require("react"));
|
|
67
|
-
var
|
|
67
|
+
var import_react12 = require("react");
|
|
68
68
|
var import_editor_panels = require("@elementor/editor-panels");
|
|
69
69
|
var import_editor_sidebar = require("@elementor/editor-sidebar");
|
|
70
70
|
var import_ui25 = require("@elementor/ui");
|
|
@@ -948,7 +948,7 @@ function usePostListContext() {
|
|
|
948
948
|
|
|
949
949
|
// src/components/panel/posts-list/posts-collapsible-list.tsx
|
|
950
950
|
var React33 = __toESM(require("react"));
|
|
951
|
-
var
|
|
951
|
+
var import_react11 = require("react");
|
|
952
952
|
var import_ui22 = require("@elementor/ui");
|
|
953
953
|
var import_i18n24 = require("@wordpress/i18n");
|
|
954
954
|
|
|
@@ -1577,6 +1577,7 @@ function ListItemRename({ post }) {
|
|
|
1577
1577
|
|
|
1578
1578
|
// src/components/panel/posts-list/list-items/list-item-view.tsx
|
|
1579
1579
|
var React30 = __toESM(require("react"));
|
|
1580
|
+
var import_react10 = require("react");
|
|
1580
1581
|
var import_editor_documents5 = require("@elementor/editor-documents");
|
|
1581
1582
|
var import_icons19 = require("@elementor/icons");
|
|
1582
1583
|
var import_ui20 = require("@elementor/ui");
|
|
@@ -1928,6 +1929,7 @@ function Restore({ post }) {
|
|
|
1928
1929
|
|
|
1929
1930
|
// src/components/panel/actions-menu/actions/set-home.tsx
|
|
1930
1931
|
var React28 = __toESM(require("react"));
|
|
1932
|
+
var import_editor_ui4 = require("@elementor/editor-ui");
|
|
1931
1933
|
var import_icons17 = require("@elementor/icons");
|
|
1932
1934
|
var import_ui19 = require("@elementor/ui");
|
|
1933
1935
|
var import_i18n20 = require("@wordpress/i18n");
|
|
@@ -1952,11 +1954,12 @@ function useInvalidateSettings() {
|
|
|
1952
1954
|
}
|
|
1953
1955
|
|
|
1954
1956
|
// src/components/panel/actions-menu/actions/set-home.tsx
|
|
1955
|
-
function SetHome({ post, closeMenu }) {
|
|
1957
|
+
function SetHome({ post, closeMenu, onRequestRemoveHomepage }) {
|
|
1956
1958
|
const { updateSettingsMutation } = useHomepageActions();
|
|
1957
1959
|
const { setError } = usePostListContext();
|
|
1958
1960
|
const { data: user } = useUser();
|
|
1959
|
-
const
|
|
1961
|
+
const isPostHomepage = !!post.isHome;
|
|
1962
|
+
const handleSetHomepage = async () => {
|
|
1960
1963
|
try {
|
|
1961
1964
|
await updateSettingsMutation.mutateAsync({ show_on_front: "page", page_on_front: post.id });
|
|
1962
1965
|
} catch {
|
|
@@ -1965,22 +1968,73 @@ function SetHome({ post, closeMenu }) {
|
|
|
1965
1968
|
closeMenu();
|
|
1966
1969
|
}
|
|
1967
1970
|
};
|
|
1971
|
+
const handleMenuClick = () => {
|
|
1972
|
+
if (isPostHomepage) {
|
|
1973
|
+
onRequestRemoveHomepage?.();
|
|
1974
|
+
closeMenu();
|
|
1975
|
+
return;
|
|
1976
|
+
}
|
|
1977
|
+
void handleSetHomepage();
|
|
1978
|
+
};
|
|
1968
1979
|
const canManageOptions = !!user?.capabilities?.manage_options;
|
|
1969
1980
|
const isPostPublished = post.status === "publish";
|
|
1970
|
-
const
|
|
1971
|
-
const
|
|
1981
|
+
const isSetHomeDisabled = !canManageOptions || !isPostPublished || updateSettingsMutation.isPending;
|
|
1982
|
+
const isRemoveHomeDisabled = !canManageOptions || updateSettingsMutation.isPending;
|
|
1983
|
+
const isDisabled = isPostHomepage ? isRemoveHomeDisabled : isSetHomeDisabled;
|
|
1984
|
+
const title = isPostHomepage ? (0, import_i18n20.__)("Remove as homepage", "elementor") : (0, import_i18n20.__)("Set as homepage", "elementor");
|
|
1972
1985
|
return /* @__PURE__ */ React28.createElement(
|
|
1973
1986
|
ActionMenuItem,
|
|
1974
1987
|
{
|
|
1975
|
-
title
|
|
1988
|
+
title,
|
|
1976
1989
|
icon: !updateSettingsMutation.isPending ? import_icons17.HomeIcon : import_ui19.CircularProgress,
|
|
1977
1990
|
MenuItemProps: {
|
|
1978
1991
|
disabled: isDisabled,
|
|
1979
|
-
onClick:
|
|
1992
|
+
onClick: handleMenuClick
|
|
1980
1993
|
}
|
|
1981
1994
|
}
|
|
1982
1995
|
);
|
|
1983
1996
|
}
|
|
1997
|
+
function RemoveHomepageDialog({ open, onClose }) {
|
|
1998
|
+
const { updateSettingsMutation } = useHomepageActions();
|
|
1999
|
+
const { setError } = usePostListContext();
|
|
2000
|
+
if (!open) {
|
|
2001
|
+
return null;
|
|
2002
|
+
}
|
|
2003
|
+
const handleCancel = () => {
|
|
2004
|
+
if (updateSettingsMutation.isPending) {
|
|
2005
|
+
return;
|
|
2006
|
+
}
|
|
2007
|
+
onClose();
|
|
2008
|
+
};
|
|
2009
|
+
const handleConfirm = async () => {
|
|
2010
|
+
if (updateSettingsMutation.isPending) {
|
|
2011
|
+
return;
|
|
2012
|
+
}
|
|
2013
|
+
try {
|
|
2014
|
+
await updateSettingsMutation.mutateAsync({ show_on_front: "posts" });
|
|
2015
|
+
onClose();
|
|
2016
|
+
} catch {
|
|
2017
|
+
setError();
|
|
2018
|
+
onClose();
|
|
2019
|
+
}
|
|
2020
|
+
};
|
|
2021
|
+
const isPending = updateSettingsMutation.isPending;
|
|
2022
|
+
const removeHomepageLabel = (0, import_i18n20.__)("Remove as homepage", "elementor");
|
|
2023
|
+
return /* @__PURE__ */ React28.createElement(import_editor_ui4.ConfirmationDialog, { open: true, onClose: handleCancel }, /* @__PURE__ */ React28.createElement(import_editor_ui4.ConfirmationDialog.Title, { iconColor: "secondary" }, (0, import_i18n20.__)("Remove this page as your homepage?", "elementor")), /* @__PURE__ */ React28.createElement(import_editor_ui4.ConfirmationDialog.Content, null, /* @__PURE__ */ React28.createElement(import_editor_ui4.ConfirmationDialog.ContentText, null, (0, import_i18n20.__)(
|
|
2024
|
+
"Your homepage will go back to showing your latest posts. You can set a page as your homepage again at any time.",
|
|
2025
|
+
"elementor"
|
|
2026
|
+
))), /* @__PURE__ */ React28.createElement(import_ui19.DialogActions, null, /* @__PURE__ */ React28.createElement(import_ui19.Button, { color: "secondary", disabled: isPending, onClick: handleCancel }, (0, import_i18n20.__)("Not now", "elementor")), /* @__PURE__ */ React28.createElement(
|
|
2027
|
+
import_ui19.Button,
|
|
2028
|
+
{
|
|
2029
|
+
color: "secondary",
|
|
2030
|
+
disabled: isPending,
|
|
2031
|
+
onClick: () => void handleConfirm(),
|
|
2032
|
+
sx: { ml: 1 },
|
|
2033
|
+
variant: "contained"
|
|
2034
|
+
},
|
|
2035
|
+
!isPending ? removeHomepageLabel : /* @__PURE__ */ React28.createElement(import_ui19.CircularProgress, null)
|
|
2036
|
+
)));
|
|
2037
|
+
}
|
|
1984
2038
|
|
|
1985
2039
|
// src/components/panel/actions-menu/actions/view.tsx
|
|
1986
2040
|
var React29 = __toESM(require("react"));
|
|
@@ -2023,6 +2077,7 @@ var DisabledPostTooltip = ({
|
|
|
2023
2077
|
};
|
|
2024
2078
|
function ListItemView({ post }) {
|
|
2025
2079
|
const { type } = usePostListContext();
|
|
2080
|
+
const [isRemoveHomeDialogOpen, setIsRemoveHomeDialogOpen] = (0, import_react10.useState)(false);
|
|
2026
2081
|
const activeDocument = (0, import_editor_documents5.__useActiveDocument)();
|
|
2027
2082
|
const navigateToDocument = (0, import_editor_documents5.__useNavigateToDocument)();
|
|
2028
2083
|
const popupState = (0, import_ui20.usePopupState)({
|
|
@@ -2085,7 +2140,20 @@ function ListItemView({ post }) {
|
|
|
2085
2140
|
MenuListProps: { dense: true },
|
|
2086
2141
|
...(0, import_ui20.bindMenu)(popupState)
|
|
2087
2142
|
},
|
|
2088
|
-
isTrashed ? /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(Restore, { post }), /* @__PURE__ */ React30.createElement(ForceDelete, { post })) : /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(Rename, { post }), /* @__PURE__ */ React30.createElement(Duplicate, { post, popupState }), /* @__PURE__ */ React30.createElement(Delete, { post }), /* @__PURE__ */ React30.createElement(View, { post }), type === "page" && /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(import_ui20.Divider, null), /* @__PURE__ */ React30.createElement(
|
|
2143
|
+
isTrashed ? /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(Restore, { post }), /* @__PURE__ */ React30.createElement(ForceDelete, { post })) : /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(Rename, { post }), /* @__PURE__ */ React30.createElement(Duplicate, { post, popupState }), /* @__PURE__ */ React30.createElement(Delete, { post }), /* @__PURE__ */ React30.createElement(View, { post }), type === "page" && /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(import_ui20.Divider, null), /* @__PURE__ */ React30.createElement(
|
|
2144
|
+
SetHome,
|
|
2145
|
+
{
|
|
2146
|
+
post,
|
|
2147
|
+
closeMenu: () => popupState.close(),
|
|
2148
|
+
onRequestRemoveHomepage: () => setIsRemoveHomeDialogOpen(true)
|
|
2149
|
+
}
|
|
2150
|
+
)))
|
|
2151
|
+
), /* @__PURE__ */ React30.createElement(
|
|
2152
|
+
RemoveHomepageDialog,
|
|
2153
|
+
{
|
|
2154
|
+
open: isRemoveHomeDialogOpen,
|
|
2155
|
+
onClose: () => setIsRemoveHomeDialogOpen(false)
|
|
2156
|
+
}
|
|
2089
2157
|
));
|
|
2090
2158
|
}
|
|
2091
2159
|
|
|
@@ -2109,7 +2177,7 @@ function PostListItem({ post }) {
|
|
|
2109
2177
|
|
|
2110
2178
|
// src/components/panel/posts-list/post-list-pagination-actions.tsx
|
|
2111
2179
|
var React32 = __toESM(require("react"));
|
|
2112
|
-
var
|
|
2180
|
+
var import_editor_ui5 = require("@elementor/editor-ui");
|
|
2113
2181
|
var import_ui21 = require("@elementor/ui");
|
|
2114
2182
|
var import_i18n23 = require("@wordpress/i18n");
|
|
2115
2183
|
var listPaginationButtonProps = {
|
|
@@ -2137,7 +2205,7 @@ function PostListPaginationActions({
|
|
|
2137
2205
|
ref: loadMoreButtonRef,
|
|
2138
2206
|
"aria-label": loadMoreLabel,
|
|
2139
2207
|
disabled: isLoadingMore,
|
|
2140
|
-
endIcon: isLoadingMore ? void 0 : /* @__PURE__ */ React32.createElement(
|
|
2208
|
+
endIcon: isLoadingMore ? void 0 : /* @__PURE__ */ React32.createElement(import_editor_ui5.CollapseIcon, { open: false }),
|
|
2141
2209
|
fullWidth: true,
|
|
2142
2210
|
onClick: onLoadMore,
|
|
2143
2211
|
sx: { flex: 1, my: 0.5 }
|
|
@@ -2149,7 +2217,7 @@ function PostListPaginationActions({
|
|
|
2149
2217
|
{
|
|
2150
2218
|
...listPaginationButtonProps,
|
|
2151
2219
|
"aria-label": showLessLabel,
|
|
2152
|
-
endIcon: /* @__PURE__ */ React32.createElement(
|
|
2220
|
+
endIcon: /* @__PURE__ */ React32.createElement(import_editor_ui5.CollapseIcon, { open: true }),
|
|
2153
2221
|
fullWidth: true,
|
|
2154
2222
|
onClick: onShowLess,
|
|
2155
2223
|
sx: { flex: 1, my: 0.5 }
|
|
@@ -2167,14 +2235,14 @@ var SEARCH_DEBOUNCE_MS = 300;
|
|
|
2167
2235
|
function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
2168
2236
|
const { type, editMode, resetEditMode, setEditMode } = usePostListContext();
|
|
2169
2237
|
const { registerSection, searchQuery, siteContentSort, statusFilters, unregisterSection } = useContentPanelCoordinator();
|
|
2170
|
-
const [isOpen, setIsOpen] = (0,
|
|
2238
|
+
const [isOpen, setIsOpen] = (0, import_react11.useState)(isOpenByDefault);
|
|
2171
2239
|
const trimmedSearch = searchQuery.trim();
|
|
2172
|
-
const [debouncedSearch, setDebouncedSearch] = (0,
|
|
2173
|
-
const focusAfterShowLessRef = (0,
|
|
2174
|
-
const listTopRef = (0,
|
|
2175
|
-
const loadMoreButtonRef = (0,
|
|
2176
|
-
const sectionHeaderRef = (0,
|
|
2177
|
-
(0,
|
|
2240
|
+
const [debouncedSearch, setDebouncedSearch] = (0, import_react11.useState)(trimmedSearch);
|
|
2241
|
+
const focusAfterShowLessRef = (0, import_react11.useRef)(false);
|
|
2242
|
+
const listTopRef = (0, import_react11.useRef)(null);
|
|
2243
|
+
const loadMoreButtonRef = (0, import_react11.useRef)(null);
|
|
2244
|
+
const sectionHeaderRef = (0, import_react11.useRef)(null);
|
|
2245
|
+
(0, import_react11.useEffect)(() => {
|
|
2178
2246
|
const handle = window.setTimeout(() => setDebouncedSearch(trimmedSearch), SEARCH_DEBOUNCE_MS);
|
|
2179
2247
|
return () => window.clearTimeout(handle);
|
|
2180
2248
|
}, [trimmedSearch]);
|
|
@@ -2193,19 +2261,19 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
|
2193
2261
|
const { data: homepageId } = useHomepage();
|
|
2194
2262
|
const isPageType = type === "page";
|
|
2195
2263
|
const statusFiltersKey = serializeSiteContentStatusFilters(statusFilters);
|
|
2196
|
-
(0,
|
|
2264
|
+
(0, import_react11.useEffect)(() => {
|
|
2197
2265
|
if (isTrashFilter) {
|
|
2198
2266
|
resetEditMode();
|
|
2199
2267
|
}
|
|
2200
2268
|
}, [isTrashFilter, resetEditMode]);
|
|
2201
|
-
(0,
|
|
2269
|
+
(0, import_react11.useEffect)(() => {
|
|
2202
2270
|
registerSection(type, {
|
|
2203
2271
|
setExpanded: setIsOpen,
|
|
2204
2272
|
startCreate: () => setEditMode({ mode: "create", details: {} })
|
|
2205
2273
|
});
|
|
2206
2274
|
return () => unregisterSection(type);
|
|
2207
2275
|
}, [registerSection, unregisterSection, type, setEditMode]);
|
|
2208
|
-
const filteredPosts = (0,
|
|
2276
|
+
const filteredPosts = (0, import_react11.useMemo)(() => {
|
|
2209
2277
|
if (!posts) {
|
|
2210
2278
|
return [];
|
|
2211
2279
|
}
|
|
@@ -2230,7 +2298,7 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
|
2230
2298
|
resetKey: `${type}:${debouncedSearch}:${statusFiltersKey}:${siteContentSort}`,
|
|
2231
2299
|
totalCount: total
|
|
2232
2300
|
});
|
|
2233
|
-
const displayedPosts = (0,
|
|
2301
|
+
const displayedPosts = (0, import_react11.useMemo)(
|
|
2234
2302
|
() => filteredPosts.slice(0, pagination.visibleCount),
|
|
2235
2303
|
[filteredPosts, pagination.visibleCount]
|
|
2236
2304
|
);
|
|
@@ -2242,7 +2310,7 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
|
2242
2310
|
listTop.scrollIntoView({ block: "nearest" });
|
|
2243
2311
|
}
|
|
2244
2312
|
};
|
|
2245
|
-
(0,
|
|
2313
|
+
(0, import_react11.useEffect)(() => {
|
|
2246
2314
|
if (!focusAfterShowLessRef.current) {
|
|
2247
2315
|
return;
|
|
2248
2316
|
}
|
|
@@ -2254,7 +2322,7 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
|
2254
2322
|
}
|
|
2255
2323
|
sectionHeaderRef.current?.focus();
|
|
2256
2324
|
}, [pagination.canLoadMore, pagination.visibleCount]);
|
|
2257
|
-
(0,
|
|
2325
|
+
(0, import_react11.useEffect)(() => {
|
|
2258
2326
|
if ((debouncedSearch || hasActiveSiteContentStatusFilters(statusFilters)) && filteredPosts.length > 0) {
|
|
2259
2327
|
setIsOpen(true);
|
|
2260
2328
|
}
|
|
@@ -2330,7 +2398,7 @@ function ShellPanelBodyContent({
|
|
|
2330
2398
|
// src/components/panel/shell.tsx
|
|
2331
2399
|
var Shell = () => {
|
|
2332
2400
|
const sidebarPanelChrome = (0, import_editor_sidebar.isSidebarEnabled)();
|
|
2333
|
-
const [isErrorSnackbarOpen, setIsErrorSnackbarOpen] = (0,
|
|
2401
|
+
const [isErrorSnackbarOpen, setIsErrorSnackbarOpen] = (0, import_react12.useState)(false);
|
|
2334
2402
|
const { accessiblePostTypes, isUserPending, showUserLoadError } = useAccessiblePanelPostTypes();
|
|
2335
2403
|
return /* @__PURE__ */ React36.createElement(ContentPanelCoordinatorProvider, null, /* @__PURE__ */ React36.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React36.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React36.createElement(
|
|
2336
2404
|
import_ui25.Stack,
|
|
@@ -2379,11 +2447,11 @@ var import_ui26 = require("@elementor/ui");
|
|
|
2379
2447
|
var import_i18n27 = require("@wordpress/i18n");
|
|
2380
2448
|
|
|
2381
2449
|
// src/hooks/use-create-page.ts
|
|
2382
|
-
var
|
|
2450
|
+
var import_react13 = require("react");
|
|
2383
2451
|
var import_api_fetch5 = __toESM(require("@wordpress/api-fetch"));
|
|
2384
2452
|
var endpointPath = "/elementor/v1/site-navigation/add-new-post";
|
|
2385
2453
|
function useCreatePage() {
|
|
2386
|
-
const [isLoading, setIsLoading] = (0,
|
|
2454
|
+
const [isLoading, setIsLoading] = (0, import_react13.useState)(false);
|
|
2387
2455
|
return {
|
|
2388
2456
|
create: () => {
|
|
2389
2457
|
setIsLoading(true);
|
package/dist/index.mjs
CHANGED
|
@@ -31,7 +31,7 @@ import { createPanel } from "@elementor/editor-panels";
|
|
|
31
31
|
|
|
32
32
|
// src/components/panel/shell.tsx
|
|
33
33
|
import * as React36 from "react";
|
|
34
|
-
import { useState as
|
|
34
|
+
import { useState as useState9 } from "react";
|
|
35
35
|
import { Panel, PanelBody, PanelHeader, PanelHeaderTitle } from "@elementor/editor-panels";
|
|
36
36
|
import { isSidebarEnabled } from "@elementor/editor-sidebar";
|
|
37
37
|
import { Divider as Divider7, Stack as Stack9 } from "@elementor/ui";
|
|
@@ -915,7 +915,7 @@ function usePostListContext() {
|
|
|
915
915
|
|
|
916
916
|
// src/components/panel/posts-list/posts-collapsible-list.tsx
|
|
917
917
|
import * as React33 from "react";
|
|
918
|
-
import { useEffect as useEffect2, useMemo as useMemo4, useRef as useRef4, useState as
|
|
918
|
+
import { useEffect as useEffect2, useMemo as useMemo4, useRef as useRef4, useState as useState8 } from "react";
|
|
919
919
|
import { Box as Box9, Skeleton, Typography as Typography7 } from "@elementor/ui";
|
|
920
920
|
import { __ as __24 } from "@wordpress/i18n";
|
|
921
921
|
|
|
@@ -1544,6 +1544,7 @@ function ListItemRename({ post }) {
|
|
|
1544
1544
|
|
|
1545
1545
|
// src/components/panel/posts-list/list-items/list-item-view.tsx
|
|
1546
1546
|
import * as React30 from "react";
|
|
1547
|
+
import { useState as useState7 } from "react";
|
|
1547
1548
|
import {
|
|
1548
1549
|
__useActiveDocument as useActiveDocument3,
|
|
1549
1550
|
__useNavigateToDocument as useNavigateToDocument3
|
|
@@ -1929,8 +1930,9 @@ function Restore({ post }) {
|
|
|
1929
1930
|
|
|
1930
1931
|
// src/components/panel/actions-menu/actions/set-home.tsx
|
|
1931
1932
|
import * as React28 from "react";
|
|
1933
|
+
import { ConfirmationDialog } from "@elementor/editor-ui";
|
|
1932
1934
|
import { HomeIcon } from "@elementor/icons";
|
|
1933
|
-
import { CircularProgress as CircularProgress4 } from "@elementor/ui";
|
|
1935
|
+
import { Button as Button3, CircularProgress as CircularProgress4, DialogActions as DialogActions3 } from "@elementor/ui";
|
|
1934
1936
|
import { __ as __20 } from "@wordpress/i18n";
|
|
1935
1937
|
|
|
1936
1938
|
// src/hooks/use-homepage-actions.ts
|
|
@@ -1953,11 +1955,12 @@ function useInvalidateSettings() {
|
|
|
1953
1955
|
}
|
|
1954
1956
|
|
|
1955
1957
|
// src/components/panel/actions-menu/actions/set-home.tsx
|
|
1956
|
-
function SetHome({ post, closeMenu }) {
|
|
1958
|
+
function SetHome({ post, closeMenu, onRequestRemoveHomepage }) {
|
|
1957
1959
|
const { updateSettingsMutation } = useHomepageActions();
|
|
1958
1960
|
const { setError } = usePostListContext();
|
|
1959
1961
|
const { data: user } = useUser();
|
|
1960
|
-
const
|
|
1962
|
+
const isPostHomepage = !!post.isHome;
|
|
1963
|
+
const handleSetHomepage = async () => {
|
|
1961
1964
|
try {
|
|
1962
1965
|
await updateSettingsMutation.mutateAsync({ show_on_front: "page", page_on_front: post.id });
|
|
1963
1966
|
} catch {
|
|
@@ -1966,22 +1969,73 @@ function SetHome({ post, closeMenu }) {
|
|
|
1966
1969
|
closeMenu();
|
|
1967
1970
|
}
|
|
1968
1971
|
};
|
|
1972
|
+
const handleMenuClick = () => {
|
|
1973
|
+
if (isPostHomepage) {
|
|
1974
|
+
onRequestRemoveHomepage?.();
|
|
1975
|
+
closeMenu();
|
|
1976
|
+
return;
|
|
1977
|
+
}
|
|
1978
|
+
void handleSetHomepage();
|
|
1979
|
+
};
|
|
1969
1980
|
const canManageOptions = !!user?.capabilities?.manage_options;
|
|
1970
1981
|
const isPostPublished = post.status === "publish";
|
|
1971
|
-
const
|
|
1972
|
-
const
|
|
1982
|
+
const isSetHomeDisabled = !canManageOptions || !isPostPublished || updateSettingsMutation.isPending;
|
|
1983
|
+
const isRemoveHomeDisabled = !canManageOptions || updateSettingsMutation.isPending;
|
|
1984
|
+
const isDisabled = isPostHomepage ? isRemoveHomeDisabled : isSetHomeDisabled;
|
|
1985
|
+
const title = isPostHomepage ? __20("Remove as homepage", "elementor") : __20("Set as homepage", "elementor");
|
|
1973
1986
|
return /* @__PURE__ */ React28.createElement(
|
|
1974
1987
|
ActionMenuItem,
|
|
1975
1988
|
{
|
|
1976
|
-
title
|
|
1989
|
+
title,
|
|
1977
1990
|
icon: !updateSettingsMutation.isPending ? HomeIcon : CircularProgress4,
|
|
1978
1991
|
MenuItemProps: {
|
|
1979
1992
|
disabled: isDisabled,
|
|
1980
|
-
onClick:
|
|
1993
|
+
onClick: handleMenuClick
|
|
1981
1994
|
}
|
|
1982
1995
|
}
|
|
1983
1996
|
);
|
|
1984
1997
|
}
|
|
1998
|
+
function RemoveHomepageDialog({ open, onClose }) {
|
|
1999
|
+
const { updateSettingsMutation } = useHomepageActions();
|
|
2000
|
+
const { setError } = usePostListContext();
|
|
2001
|
+
if (!open) {
|
|
2002
|
+
return null;
|
|
2003
|
+
}
|
|
2004
|
+
const handleCancel = () => {
|
|
2005
|
+
if (updateSettingsMutation.isPending) {
|
|
2006
|
+
return;
|
|
2007
|
+
}
|
|
2008
|
+
onClose();
|
|
2009
|
+
};
|
|
2010
|
+
const handleConfirm = async () => {
|
|
2011
|
+
if (updateSettingsMutation.isPending) {
|
|
2012
|
+
return;
|
|
2013
|
+
}
|
|
2014
|
+
try {
|
|
2015
|
+
await updateSettingsMutation.mutateAsync({ show_on_front: "posts" });
|
|
2016
|
+
onClose();
|
|
2017
|
+
} catch {
|
|
2018
|
+
setError();
|
|
2019
|
+
onClose();
|
|
2020
|
+
}
|
|
2021
|
+
};
|
|
2022
|
+
const isPending = updateSettingsMutation.isPending;
|
|
2023
|
+
const removeHomepageLabel = __20("Remove as homepage", "elementor");
|
|
2024
|
+
return /* @__PURE__ */ React28.createElement(ConfirmationDialog, { open: true, onClose: handleCancel }, /* @__PURE__ */ React28.createElement(ConfirmationDialog.Title, { iconColor: "secondary" }, __20("Remove this page as your homepage?", "elementor")), /* @__PURE__ */ React28.createElement(ConfirmationDialog.Content, null, /* @__PURE__ */ React28.createElement(ConfirmationDialog.ContentText, null, __20(
|
|
2025
|
+
"Your homepage will go back to showing your latest posts. You can set a page as your homepage again at any time.",
|
|
2026
|
+
"elementor"
|
|
2027
|
+
))), /* @__PURE__ */ React28.createElement(DialogActions3, null, /* @__PURE__ */ React28.createElement(Button3, { color: "secondary", disabled: isPending, onClick: handleCancel }, __20("Not now", "elementor")), /* @__PURE__ */ React28.createElement(
|
|
2028
|
+
Button3,
|
|
2029
|
+
{
|
|
2030
|
+
color: "secondary",
|
|
2031
|
+
disabled: isPending,
|
|
2032
|
+
onClick: () => void handleConfirm(),
|
|
2033
|
+
sx: { ml: 1 },
|
|
2034
|
+
variant: "contained"
|
|
2035
|
+
},
|
|
2036
|
+
!isPending ? removeHomepageLabel : /* @__PURE__ */ React28.createElement(CircularProgress4, null)
|
|
2037
|
+
)));
|
|
2038
|
+
}
|
|
1985
2039
|
|
|
1986
2040
|
// src/components/panel/actions-menu/actions/view.tsx
|
|
1987
2041
|
import * as React29 from "react";
|
|
@@ -2024,6 +2078,7 @@ var DisabledPostTooltip = ({
|
|
|
2024
2078
|
};
|
|
2025
2079
|
function ListItemView({ post }) {
|
|
2026
2080
|
const { type } = usePostListContext();
|
|
2081
|
+
const [isRemoveHomeDialogOpen, setIsRemoveHomeDialogOpen] = useState7(false);
|
|
2027
2082
|
const activeDocument = useActiveDocument3();
|
|
2028
2083
|
const navigateToDocument = useNavigateToDocument3();
|
|
2029
2084
|
const popupState = usePopupState4({
|
|
@@ -2086,7 +2141,20 @@ function ListItemView({ post }) {
|
|
|
2086
2141
|
MenuListProps: { dense: true },
|
|
2087
2142
|
...bindMenu2(popupState)
|
|
2088
2143
|
},
|
|
2089
|
-
isTrashed ? /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(Restore, { post }), /* @__PURE__ */ React30.createElement(ForceDelete, { post })) : /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(Rename, { post }), /* @__PURE__ */ React30.createElement(Duplicate, { post, popupState }), /* @__PURE__ */ React30.createElement(Delete, { post }), /* @__PURE__ */ React30.createElement(View, { post }), type === "page" && /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(Divider6, null), /* @__PURE__ */ React30.createElement(
|
|
2144
|
+
isTrashed ? /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(Restore, { post }), /* @__PURE__ */ React30.createElement(ForceDelete, { post })) : /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(Rename, { post }), /* @__PURE__ */ React30.createElement(Duplicate, { post, popupState }), /* @__PURE__ */ React30.createElement(Delete, { post }), /* @__PURE__ */ React30.createElement(View, { post }), type === "page" && /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(Divider6, null), /* @__PURE__ */ React30.createElement(
|
|
2145
|
+
SetHome,
|
|
2146
|
+
{
|
|
2147
|
+
post,
|
|
2148
|
+
closeMenu: () => popupState.close(),
|
|
2149
|
+
onRequestRemoveHomepage: () => setIsRemoveHomeDialogOpen(true)
|
|
2150
|
+
}
|
|
2151
|
+
)))
|
|
2152
|
+
), /* @__PURE__ */ React30.createElement(
|
|
2153
|
+
RemoveHomepageDialog,
|
|
2154
|
+
{
|
|
2155
|
+
open: isRemoveHomeDialogOpen,
|
|
2156
|
+
onClose: () => setIsRemoveHomeDialogOpen(false)
|
|
2157
|
+
}
|
|
2090
2158
|
));
|
|
2091
2159
|
}
|
|
2092
2160
|
|
|
@@ -2111,7 +2179,7 @@ function PostListItem({ post }) {
|
|
|
2111
2179
|
// src/components/panel/posts-list/post-list-pagination-actions.tsx
|
|
2112
2180
|
import * as React32 from "react";
|
|
2113
2181
|
import { CollapseIcon as CollapseIcon2 } from "@elementor/editor-ui";
|
|
2114
|
-
import { Box as Box8, Button as
|
|
2182
|
+
import { Box as Box8, Button as Button4, CircularProgress as CircularProgress5, Stack as Stack7 } from "@elementor/ui";
|
|
2115
2183
|
import { __ as __23 } from "@wordpress/i18n";
|
|
2116
2184
|
var listPaginationButtonProps = {
|
|
2117
2185
|
color: "secondary",
|
|
@@ -2132,7 +2200,7 @@ function PostListPaginationActions({
|
|
|
2132
2200
|
const loadMoreLabel = __23("Load more", "elementor");
|
|
2133
2201
|
const showLessLabel = __23("Show less", "elementor");
|
|
2134
2202
|
const loadMoreButton = /* @__PURE__ */ React32.createElement(
|
|
2135
|
-
|
|
2203
|
+
Button4,
|
|
2136
2204
|
{
|
|
2137
2205
|
...listPaginationButtonProps,
|
|
2138
2206
|
ref: loadMoreButtonRef,
|
|
@@ -2146,7 +2214,7 @@ function PostListPaginationActions({
|
|
|
2146
2214
|
isLoadingMore ? /* @__PURE__ */ React32.createElement(CircularProgress5, { size: 20 }) : loadMoreLabel
|
|
2147
2215
|
);
|
|
2148
2216
|
const showLessButton = /* @__PURE__ */ React32.createElement(
|
|
2149
|
-
|
|
2217
|
+
Button4,
|
|
2150
2218
|
{
|
|
2151
2219
|
...listPaginationButtonProps,
|
|
2152
2220
|
"aria-label": showLessLabel,
|
|
@@ -2168,9 +2236,9 @@ var SEARCH_DEBOUNCE_MS = 300;
|
|
|
2168
2236
|
function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
2169
2237
|
const { type, editMode, resetEditMode, setEditMode } = usePostListContext();
|
|
2170
2238
|
const { registerSection, searchQuery, siteContentSort, statusFilters, unregisterSection } = useContentPanelCoordinator();
|
|
2171
|
-
const [isOpen, setIsOpen] =
|
|
2239
|
+
const [isOpen, setIsOpen] = useState8(isOpenByDefault);
|
|
2172
2240
|
const trimmedSearch = searchQuery.trim();
|
|
2173
|
-
const [debouncedSearch, setDebouncedSearch] =
|
|
2241
|
+
const [debouncedSearch, setDebouncedSearch] = useState8(trimmedSearch);
|
|
2174
2242
|
const focusAfterShowLessRef = useRef4(false);
|
|
2175
2243
|
const listTopRef = useRef4(null);
|
|
2176
2244
|
const loadMoreButtonRef = useRef4(null);
|
|
@@ -2331,7 +2399,7 @@ function ShellPanelBodyContent({
|
|
|
2331
2399
|
// src/components/panel/shell.tsx
|
|
2332
2400
|
var Shell = () => {
|
|
2333
2401
|
const sidebarPanelChrome = isSidebarEnabled();
|
|
2334
|
-
const [isErrorSnackbarOpen, setIsErrorSnackbarOpen] =
|
|
2402
|
+
const [isErrorSnackbarOpen, setIsErrorSnackbarOpen] = useState9(false);
|
|
2335
2403
|
const { accessiblePostTypes, isUserPending, showUserLoadError } = useAccessiblePanelPostTypes();
|
|
2336
2404
|
return /* @__PURE__ */ React36.createElement(ContentPanelCoordinatorProvider, null, /* @__PURE__ */ React36.createElement(Panel, null, /* @__PURE__ */ React36.createElement(PanelHeader, null, /* @__PURE__ */ React36.createElement(
|
|
2337
2405
|
Stack9,
|
|
@@ -2374,7 +2442,7 @@ import { ChevronDownIcon } from "@elementor/icons";
|
|
|
2374
2442
|
import {
|
|
2375
2443
|
bindMenu as bindMenu3,
|
|
2376
2444
|
bindTrigger as bindTrigger3,
|
|
2377
|
-
Button as
|
|
2445
|
+
Button as Button5,
|
|
2378
2446
|
Divider as Divider8,
|
|
2379
2447
|
ListItemText as ListItemText8,
|
|
2380
2448
|
ListSubheader,
|
|
@@ -2393,11 +2461,11 @@ import { CircularProgress as CircularProgress6, ListItemIcon as ListItemIcon3, L
|
|
|
2393
2461
|
import { __ as __27 } from "@wordpress/i18n";
|
|
2394
2462
|
|
|
2395
2463
|
// src/hooks/use-create-page.ts
|
|
2396
|
-
import { useState as
|
|
2464
|
+
import { useState as useState10 } from "react";
|
|
2397
2465
|
import apiFetch5 from "@wordpress/api-fetch";
|
|
2398
2466
|
var endpointPath = "/elementor/v1/site-navigation/add-new-post";
|
|
2399
2467
|
function useCreatePage() {
|
|
2400
|
-
const [isLoading, setIsLoading] =
|
|
2468
|
+
const [isLoading, setIsLoading] = useState10(false);
|
|
2401
2469
|
return {
|
|
2402
2470
|
create: () => {
|
|
2403
2471
|
setIsLoading(true);
|
|
@@ -2569,7 +2637,7 @@ function RecentlyEdited() {
|
|
|
2569
2637
|
}
|
|
2570
2638
|
const buttonProps = bindTrigger3(popupState);
|
|
2571
2639
|
return /* @__PURE__ */ React41.createElement(React41.Fragment, null, /* @__PURE__ */ React41.createElement(
|
|
2572
|
-
|
|
2640
|
+
Button5,
|
|
2573
2641
|
{
|
|
2574
2642
|
color: "inherit",
|
|
2575
2643
|
size: "small",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-site-navigation",
|
|
3
|
-
"version": "4.5.0-
|
|
3
|
+
"version": "4.5.0-1225",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,17 +39,17 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor-app-bar": "4.5.0-
|
|
43
|
-
"@elementor/editor-documents": "4.5.0-
|
|
44
|
-
"@elementor/editor-panels": "4.5.0-
|
|
45
|
-
"@elementor/editor-sidebar": "4.5.0-
|
|
46
|
-
"@elementor/editor-ui": "4.5.0-
|
|
47
|
-
"@elementor/editor-v1-adapters": "4.5.0-
|
|
48
|
-
"@elementor/env": "4.5.0-
|
|
49
|
-
"@elementor/events": "4.5.0-
|
|
42
|
+
"@elementor/editor-app-bar": "4.5.0-1225",
|
|
43
|
+
"@elementor/editor-documents": "4.5.0-1225",
|
|
44
|
+
"@elementor/editor-panels": "4.5.0-1225",
|
|
45
|
+
"@elementor/editor-sidebar": "4.5.0-1225",
|
|
46
|
+
"@elementor/editor-ui": "4.5.0-1225",
|
|
47
|
+
"@elementor/editor-v1-adapters": "4.5.0-1225",
|
|
48
|
+
"@elementor/env": "4.5.0-1225",
|
|
49
|
+
"@elementor/events": "4.5.0-1225",
|
|
50
50
|
"@elementor/icons": "~1.78.1",
|
|
51
|
-
"@elementor/locations": "4.5.0-
|
|
52
|
-
"@elementor/query": "4.5.0-
|
|
51
|
+
"@elementor/locations": "4.5.0-1225",
|
|
52
|
+
"@elementor/query": "4.5.0-1225",
|
|
53
53
|
"@elementor/ui": "1.41.4",
|
|
54
54
|
"@wordpress/api-fetch": "^6.42.0",
|
|
55
55
|
"@wordpress/i18n": "^5.13.0"
|
package/src/api/settings.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import apiFetch from '@wordpress/api-fetch';
|
|
2
2
|
|
|
3
3
|
export type Settings = {
|
|
4
|
-
show_on_front: 'page' | '';
|
|
5
4
|
page_on_front: number;
|
|
5
|
+
show_on_front: 'page' | 'posts';
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
export type UpdateReadingSettings = { show_on_front: 'posts' } | { show_on_front: 'page'; page_on_front: number };
|
|
9
|
+
|
|
8
10
|
type Homepage = number;
|
|
9
11
|
|
|
10
12
|
export const getSettings = () => {
|
|
@@ -15,7 +17,7 @@ export const getSettings = () => {
|
|
|
15
17
|
return apiFetch< Homepage >( { path: uri } );
|
|
16
18
|
};
|
|
17
19
|
|
|
18
|
-
export const updateSettings = ( settings:
|
|
20
|
+
export const updateSettings = ( settings: UpdateReadingSettings ) => {
|
|
19
21
|
return apiFetch( {
|
|
20
22
|
path: '/wp/v2/settings',
|
|
21
23
|
method: 'POST',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { ConfirmationDialog } from '@elementor/editor-ui';
|
|
2
3
|
import { HomeIcon } from '@elementor/icons';
|
|
3
|
-
import { CircularProgress } from '@elementor/ui';
|
|
4
|
+
import { Button, CircularProgress, DialogActions } from '@elementor/ui';
|
|
4
5
|
import { __ } from '@wordpress/i18n';
|
|
5
6
|
|
|
6
7
|
import { usePostListContext } from '../../../../contexts/post-list-context';
|
|
@@ -9,12 +10,20 @@ import useUser from '../../../../hooks/use-user';
|
|
|
9
10
|
import { type Post } from '../../../../types';
|
|
10
11
|
import ActionMenuItem from '../action-menu-item';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
type SetHomeProps = {
|
|
14
|
+
post: Post;
|
|
15
|
+
closeMenu: () => void;
|
|
16
|
+
onRequestRemoveHomepage?: () => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default function SetHome( { post, closeMenu, onRequestRemoveHomepage }: SetHomeProps ) {
|
|
13
20
|
const { updateSettingsMutation } = useHomepageActions();
|
|
14
21
|
const { setError } = usePostListContext();
|
|
15
22
|
const { data: user } = useUser();
|
|
16
23
|
|
|
17
|
-
const
|
|
24
|
+
const isPostHomepage = !! post.isHome;
|
|
25
|
+
|
|
26
|
+
const handleSetHomepage = async () => {
|
|
18
27
|
try {
|
|
19
28
|
await updateSettingsMutation.mutateAsync( { show_on_front: 'page', page_on_front: post.id } );
|
|
20
29
|
} catch {
|
|
@@ -24,20 +33,100 @@ export default function SetHome( { post, closeMenu }: { post: Post; closeMenu: (
|
|
|
24
33
|
}
|
|
25
34
|
};
|
|
26
35
|
|
|
36
|
+
const handleMenuClick = () => {
|
|
37
|
+
if ( isPostHomepage ) {
|
|
38
|
+
onRequestRemoveHomepage?.();
|
|
39
|
+
closeMenu();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void handleSetHomepage();
|
|
44
|
+
};
|
|
45
|
+
|
|
27
46
|
const canManageOptions = !! user?.capabilities?.manage_options;
|
|
28
47
|
const isPostPublished = post.status === 'publish';
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const isDisabled =
|
|
48
|
+
const isSetHomeDisabled = ! canManageOptions || ! isPostPublished || updateSettingsMutation.isPending;
|
|
49
|
+
const isRemoveHomeDisabled = ! canManageOptions || updateSettingsMutation.isPending;
|
|
50
|
+
const isDisabled = isPostHomepage ? isRemoveHomeDisabled : isSetHomeDisabled;
|
|
51
|
+
const title = isPostHomepage ? __( 'Remove as homepage', 'elementor' ) : __( 'Set as homepage', 'elementor' );
|
|
32
52
|
|
|
33
53
|
return (
|
|
34
54
|
<ActionMenuItem
|
|
35
|
-
title={
|
|
55
|
+
title={ title }
|
|
36
56
|
icon={ ! updateSettingsMutation.isPending ? HomeIcon : CircularProgress }
|
|
37
57
|
MenuItemProps={ {
|
|
38
58
|
disabled: isDisabled,
|
|
39
|
-
onClick:
|
|
59
|
+
onClick: handleMenuClick,
|
|
40
60
|
} }
|
|
41
61
|
/>
|
|
42
62
|
);
|
|
43
63
|
}
|
|
64
|
+
|
|
65
|
+
type RemoveHomepageDialogProps = {
|
|
66
|
+
open: boolean;
|
|
67
|
+
onClose: () => void;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export function RemoveHomepageDialog( { open, onClose }: RemoveHomepageDialogProps ) {
|
|
71
|
+
const { updateSettingsMutation } = useHomepageActions();
|
|
72
|
+
const { setError } = usePostListContext();
|
|
73
|
+
|
|
74
|
+
if ( ! open ) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const handleCancel = () => {
|
|
79
|
+
if ( updateSettingsMutation.isPending ) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
onClose();
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const handleConfirm = async () => {
|
|
87
|
+
if ( updateSettingsMutation.isPending ) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
await updateSettingsMutation.mutateAsync( { show_on_front: 'posts' } );
|
|
93
|
+
onClose();
|
|
94
|
+
} catch {
|
|
95
|
+
setError();
|
|
96
|
+
onClose();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const isPending = updateSettingsMutation.isPending;
|
|
101
|
+
const removeHomepageLabel = __( 'Remove as homepage', 'elementor' );
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<ConfirmationDialog open onClose={ handleCancel }>
|
|
105
|
+
<ConfirmationDialog.Title iconColor="secondary">
|
|
106
|
+
{ __( 'Remove this page as your homepage?', 'elementor' ) }
|
|
107
|
+
</ConfirmationDialog.Title>
|
|
108
|
+
<ConfirmationDialog.Content>
|
|
109
|
+
<ConfirmationDialog.ContentText>
|
|
110
|
+
{ __(
|
|
111
|
+
'Your homepage will go back to showing your latest posts. You can set a page as your homepage again at any time.',
|
|
112
|
+
'elementor'
|
|
113
|
+
) }
|
|
114
|
+
</ConfirmationDialog.ContentText>
|
|
115
|
+
</ConfirmationDialog.Content>
|
|
116
|
+
<DialogActions>
|
|
117
|
+
<Button color="secondary" disabled={ isPending } onClick={ handleCancel }>
|
|
118
|
+
{ __( 'Not now', 'elementor' ) }
|
|
119
|
+
</Button>
|
|
120
|
+
<Button
|
|
121
|
+
color="secondary"
|
|
122
|
+
disabled={ isPending }
|
|
123
|
+
onClick={ () => void handleConfirm() }
|
|
124
|
+
sx={ { ml: 1 } }
|
|
125
|
+
variant="contained"
|
|
126
|
+
>
|
|
127
|
+
{ ! isPending ? removeHomepageLabel : <CircularProgress /> }
|
|
128
|
+
</Button>
|
|
129
|
+
</DialogActions>
|
|
130
|
+
</ConfirmationDialog>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import {
|
|
3
4
|
__useActiveDocument as useActiveDocument,
|
|
4
5
|
__useNavigateToDocument as useNavigateToDocument,
|
|
@@ -29,7 +30,7 @@ import Duplicate from '../../actions-menu/actions/duplicate';
|
|
|
29
30
|
import ForceDelete from '../../actions-menu/actions/force-delete';
|
|
30
31
|
import Rename from '../../actions-menu/actions/rename';
|
|
31
32
|
import Restore from '../../actions-menu/actions/restore';
|
|
32
|
-
import SetHome from '../../actions-menu/actions/set-home';
|
|
33
|
+
import SetHome, { RemoveHomepageDialog } from '../../actions-menu/actions/set-home';
|
|
33
34
|
import View from '../../actions-menu/actions/view';
|
|
34
35
|
import { contentPanelListItemButtonSx, getContentPanelListItemSx } from '../../content-panel-chrome';
|
|
35
36
|
import {
|
|
@@ -68,6 +69,7 @@ const DisabledPostTooltip = ( {
|
|
|
68
69
|
|
|
69
70
|
export default function ListItemView( { post }: { post: Post } ) {
|
|
70
71
|
const { type } = usePostListContext();
|
|
72
|
+
const [ isRemoveHomeDialogOpen, setIsRemoveHomeDialogOpen ] = useState( false );
|
|
71
73
|
const activeDocument = useActiveDocument();
|
|
72
74
|
const navigateToDocument = useNavigateToDocument();
|
|
73
75
|
|
|
@@ -159,12 +161,20 @@ export default function ListItemView( { post }: { post: Post } ) {
|
|
|
159
161
|
{ type === 'page' && (
|
|
160
162
|
<>
|
|
161
163
|
<Divider />
|
|
162
|
-
<SetHome
|
|
164
|
+
<SetHome
|
|
165
|
+
post={ post }
|
|
166
|
+
closeMenu={ () => popupState.close() }
|
|
167
|
+
onRequestRemoveHomepage={ () => setIsRemoveHomeDialogOpen( true ) }
|
|
168
|
+
/>
|
|
163
169
|
</>
|
|
164
170
|
) }
|
|
165
171
|
</>
|
|
166
172
|
) }
|
|
167
173
|
</Menu>
|
|
174
|
+
<RemoveHomepageDialog
|
|
175
|
+
open={ isRemoveHomeDialogOpen }
|
|
176
|
+
onClose={ () => setIsRemoveHomeDialogOpen( false ) }
|
|
177
|
+
/>
|
|
168
178
|
</>
|
|
169
179
|
);
|
|
170
180
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMutation, useQueryClient } from '@elementor/query';
|
|
2
2
|
|
|
3
|
-
import { type
|
|
3
|
+
import { type UpdateReadingSettings, updateSettings } from '../api/settings';
|
|
4
4
|
import { settingsQueryKey } from './use-homepage';
|
|
5
5
|
|
|
6
6
|
export function useHomepageActions() {
|
|
@@ -9,7 +9,7 @@ export function useHomepageActions() {
|
|
|
9
9
|
const onSuccess = async () => invalidateSettings( { exact: true } );
|
|
10
10
|
|
|
11
11
|
const updateSettingsMutation = useMutation( {
|
|
12
|
-
mutationFn: ( settings:
|
|
12
|
+
mutationFn: ( settings: UpdateReadingSettings ) => updateSettings( settings ),
|
|
13
13
|
onSuccess,
|
|
14
14
|
} );
|
|
15
15
|
|