@griddo/ax 12.10.5-rc.1 → 12.11.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/package.json +2 -2
- package/src/__tests__/components/Fields/ConditionalField/ConditionalField.test.tsx +17 -0
- package/src/__tests__/components/Fields/RadioField/RadioField.test.tsx +66 -0
- package/src/__tests__/components/Fields/RadioGroup/RadioGroup.test.tsx +76 -0
- package/src/__tests__/modules/Redirects/BulkHeader/TableHeader.test.tsx +123 -0
- package/src/__tests__/modules/Redirects/RedirectItem/RedirectItem.test.tsx +163 -0
- package/src/__tests__/modules/Redirects/RedirectPanel/RedirectPanel.test.tsx +134 -0
- package/src/__tests__/modules/Redirects/Redirects/Redirects.create.test.tsx +69 -0
- package/src/__tests__/modules/Redirects/Redirects/Redirects.edit.test.tsx +91 -0
- package/src/__tests__/modules/Redirects/Redirects/Redirects.filter.test.tsx +131 -0
- package/src/components/Fields/ConditionalField/style.tsx +1 -1
- package/src/components/Fields/RadioField/index.tsx +20 -3
- package/src/components/Fields/RadioField/style.tsx +18 -1
- package/src/components/Fields/RadioGroup/index.tsx +1 -0
- package/src/containers/Redirects/actions.tsx +15 -3
- package/src/modules/Redirects/BulkHeader/TableHeader/index.tsx +5 -0
- package/src/modules/Redirects/BulkHeader/TableHeader/style.tsx +5 -1
- package/src/modules/Redirects/RedirectItem/index.tsx +11 -1
- package/src/modules/Redirects/RedirectItem/style.tsx +29 -1
- package/src/modules/Redirects/RedirectPanel/index.tsx +40 -3
- package/src/modules/Redirects/TypeFilter/index.tsx +44 -0
- package/src/modules/Redirects/TypeFilter/style.tsx +27 -0
- package/src/modules/Redirects/hooks.tsx +12 -4
- package/src/modules/Redirects/index.tsx +22 -14
- package/src/modules/Redirects/utils.tsx +10 -1
- package/src/types/index.tsx +3 -0
|
@@ -18,14 +18,17 @@ const useSortedListStatus = () => {
|
|
|
18
18
|
const useFilterQuery = (site: ISite | null) => {
|
|
19
19
|
const initialQueryValues: Record<string, IQueryValue[]> = {
|
|
20
20
|
sites: site ? [{ value: site.id, label: site.name }] : [{ value: "all", label: "All" }],
|
|
21
|
+
type: [],
|
|
21
22
|
order: [],
|
|
22
23
|
};
|
|
23
24
|
|
|
25
|
+
const initialFilterQuery = `&sites=${site?.id || "global"}`;
|
|
26
|
+
|
|
24
27
|
const [query, setQuery] = useState(initialQueryValues);
|
|
25
|
-
const [currentFilterQuery, setCurrentFilterQuery] = useState(
|
|
28
|
+
const [currentFilterQuery, setCurrentFilterQuery] = useState(initialFilterQuery);
|
|
26
29
|
|
|
27
30
|
const setFilterQuery = (filterValues: any) => {
|
|
28
|
-
const { sites, order } = filterValues;
|
|
31
|
+
const { sites, type, order } = filterValues;
|
|
29
32
|
let filterQuery = "";
|
|
30
33
|
|
|
31
34
|
const currentQuery = (pointer: string, values: IQueryValue[]): string => {
|
|
@@ -40,6 +43,10 @@ const useFilterQuery = (site: ISite | null) => {
|
|
|
40
43
|
filterQuery = currentQuery("sites", sites);
|
|
41
44
|
}
|
|
42
45
|
|
|
46
|
+
if (type) {
|
|
47
|
+
filterQuery = currentQuery("type", type);
|
|
48
|
+
}
|
|
49
|
+
|
|
43
50
|
if (order) {
|
|
44
51
|
filterQuery = currentQuery("order", order);
|
|
45
52
|
}
|
|
@@ -48,10 +55,11 @@ const useFilterQuery = (site: ISite | null) => {
|
|
|
48
55
|
};
|
|
49
56
|
|
|
50
57
|
const setFiltersSelection = (pointer: string, filter: IQueryValue[], isAscendent?: boolean) => {
|
|
51
|
-
const { sites, order } = query;
|
|
58
|
+
const { sites, type, order } = query;
|
|
52
59
|
const orderMethod = isAscendent ? "asc" : "desc";
|
|
53
60
|
const filterValues: Record<string, IQueryValue[]> = {
|
|
54
61
|
sites: pointer === "sites" ? filter : sites,
|
|
62
|
+
type: pointer === "type" ? filter : type,
|
|
55
63
|
order: pointer === "order" ? [{ value: `${filter[0].value}-${orderMethod}`, label: filter[0].label }] : order,
|
|
56
64
|
};
|
|
57
65
|
|
|
@@ -61,7 +69,7 @@ const useFilterQuery = (site: ISite | null) => {
|
|
|
61
69
|
|
|
62
70
|
const resetFilterQuery = () => {
|
|
63
71
|
setQuery(initialQueryValues);
|
|
64
|
-
setCurrentFilterQuery(
|
|
72
|
+
setCurrentFilterQuery(initialFilterQuery);
|
|
65
73
|
};
|
|
66
74
|
|
|
67
75
|
return {
|
|
@@ -14,14 +14,14 @@ import {
|
|
|
14
14
|
import { appActions } from "@ax/containers/App";
|
|
15
15
|
import { redirectsActions } from "@ax/containers/Redirects";
|
|
16
16
|
import { useBulkSelection, useModals, useToast } from "@ax/hooks";
|
|
17
|
-
import type { IEmptyStateProps, INavItem, IQueryValue, IRedirect, IRootState, ISite } from "@ax/types";
|
|
17
|
+
import type { IEmptyStateProps, INavItem, IQueryValue, IRedirect, IRootState, ISite, RedirectType } from "@ax/types";
|
|
18
18
|
|
|
19
19
|
import { DeleteModal, ImportCheckModal, ImportModal, OverwriteModal } from "./atoms";
|
|
20
20
|
import BulkHeader from "./BulkHeader";
|
|
21
21
|
import { useFilterQuery, useSortedListStatus } from "./hooks";
|
|
22
22
|
import RedirectItem from "./RedirectItem";
|
|
23
23
|
import RedirectPanel from "./RedirectPanel";
|
|
24
|
-
import { getSortedListStatus } from "./utils";
|
|
24
|
+
import { DEFAULT_REDIRECT_TYPE, getSortedListStatus } from "./utils";
|
|
25
25
|
|
|
26
26
|
import * as S from "./style";
|
|
27
27
|
|
|
@@ -61,12 +61,13 @@ const Redirects = (props: IProps): JSX.Element => {
|
|
|
61
61
|
const [isEmpty, setIsEmpty] = useState(false);
|
|
62
62
|
const [emptyStateProps, setEmptyStateProps] = useState<IEmptyStateProps>({});
|
|
63
63
|
|
|
64
|
-
const initState = {
|
|
64
|
+
const initState: IRedirect = {
|
|
65
65
|
from: "",
|
|
66
66
|
to: {
|
|
67
67
|
pageId: undefined,
|
|
68
68
|
url: "",
|
|
69
69
|
},
|
|
70
|
+
type: DEFAULT_REDIRECT_TYPE,
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
const [formValues, setFormValues] = useState<IRedirect>(initState);
|
|
@@ -202,7 +203,12 @@ const Redirects = (props: IProps): JSX.Element => {
|
|
|
202
203
|
|
|
203
204
|
const handleAddRedirect = async (force?: boolean) => {
|
|
204
205
|
const toPage = formValues.to.pageId ? formValues.to.pageId : formValues.to.url;
|
|
205
|
-
await addRedirect(
|
|
206
|
+
await addRedirect(
|
|
207
|
+
{ from: formValues.from, to: toPage, type: formValues.type },
|
|
208
|
+
() => toggleModal("overwrite"),
|
|
209
|
+
force,
|
|
210
|
+
filterQuery,
|
|
211
|
+
);
|
|
206
212
|
isOpen("edit") && toggleModal("edit");
|
|
207
213
|
};
|
|
208
214
|
|
|
@@ -268,7 +274,8 @@ const Redirects = (props: IProps): JSX.Element => {
|
|
|
268
274
|
<S.TitleWrapper>
|
|
269
275
|
<S.Title>URL Redirects Manager</S.Title>
|
|
270
276
|
<S.Description>
|
|
271
|
-
You can create
|
|
277
|
+
You can create redirects to direct users and search engines from an old URL to a new one, and choose
|
|
278
|
+
whether each one is permanent (301) or temporary (302).
|
|
272
279
|
</S.Description>
|
|
273
280
|
</S.TitleWrapper>
|
|
274
281
|
<S.TableWrapper>
|
|
@@ -282,14 +289,15 @@ const Redirects = (props: IProps): JSX.Element => {
|
|
|
282
289
|
<>
|
|
283
290
|
<S.SearchTags>
|
|
284
291
|
<SearchTagsBar query={searchQuery} setQuery={handleSearch} />
|
|
285
|
-
{
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
292
|
+
{/* El filtro de tipo existe en los dos ámbitos, así que la barra ya no
|
|
293
|
+
depende del ámbito. En el de sitio se etiqueta solo el tipo: el sitio
|
|
294
|
+
lo fija la ruta y ofrecer su tag invitaría a quitar lo que no se puede. */}
|
|
295
|
+
<FilterTagsBar
|
|
296
|
+
filters={filterValues}
|
|
297
|
+
setFilters={setFiltersSelection}
|
|
298
|
+
resetFilters={resetFilterQuery}
|
|
299
|
+
labels={currentSite ? { type: "Type" } : { sites: "Site", type: "Type" }}
|
|
300
|
+
/>
|
|
293
301
|
</S.SearchTags>
|
|
294
302
|
{isEmpty ? (
|
|
295
303
|
<S.EmptyWrapper>
|
|
@@ -399,7 +407,7 @@ interface IDispatchProps {
|
|
|
399
407
|
getRedirects(params: any, filters: string): void;
|
|
400
408
|
deleteRedirect(redirectID: number[]): Promise<boolean>;
|
|
401
409
|
addRedirect(
|
|
402
|
-
redirect: { from: string; to: string | number },
|
|
410
|
+
redirect: { from: string; to: string | number; type?: RedirectType },
|
|
403
411
|
errorAction: () => void,
|
|
404
412
|
force?: boolean,
|
|
405
413
|
filter?: string,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { RedirectType } from "@ax/types";
|
|
2
|
+
|
|
1
3
|
const getSortedListStatus = (
|
|
2
4
|
orderPointer: string,
|
|
3
5
|
isAscending: boolean,
|
|
@@ -10,4 +12,11 @@ const getSortedListStatus = (
|
|
|
10
12
|
return sortedListStatus;
|
|
11
13
|
};
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
const DEFAULT_REDIRECT_TYPE: RedirectType = "301";
|
|
16
|
+
|
|
17
|
+
const REDIRECT_TYPE_COLORS: Record<RedirectType, string> = {
|
|
18
|
+
"301": "#C9EFFF",
|
|
19
|
+
"302": "#DBB9FF",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { getSortedListStatus, DEFAULT_REDIRECT_TYPE, REDIRECT_TYPE_COLORS };
|
package/src/types/index.tsx
CHANGED
|
@@ -914,10 +914,13 @@ export interface IDomainRobot {
|
|
|
914
914
|
computedContent: string;
|
|
915
915
|
}
|
|
916
916
|
|
|
917
|
+
export type RedirectType = "301" | "302";
|
|
918
|
+
|
|
917
919
|
export interface IRedirect {
|
|
918
920
|
id?: number;
|
|
919
921
|
from: string;
|
|
920
922
|
to: { pageId?: number; url: string; linkTo?: number; href?: string };
|
|
923
|
+
type?: RedirectType;
|
|
921
924
|
site?: { siteId: number | null; siteName: string | null; siteUrl: string | null };
|
|
922
925
|
domain?: string;
|
|
923
926
|
date?: string;
|