@griddo/ax 10.3.23 → 10.3.25
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/Gallery/GalleryFilters/Orientation/Orientation.test.tsx +5 -2
- package/src/__tests__/components/Gallery/GalleryFilters/SortBy/SortBy.test.tsx +5 -4
- package/src/__tests__/components/Gallery/GalleryFilters/Type/Type.test.tsx +5 -2
- package/src/__tests__/components/TableFilters/CategoryFilter/CategoryFilter.test.tsx +12 -11
- package/src/__tests__/components/TableFilters/DateFilter/DateFilter.test.tsx +17 -16
- package/src/__tests__/components/TableFilters/LiveFilter/LiveFilter.test.tsx +14 -13
- package/src/__tests__/components/TableFilters/NameFilter/NameFilter.test.tsx +21 -20
- package/src/__tests__/components/TableFilters/RoleFilter/RoleFilter.test.tsx +6 -5
- package/src/__tests__/components/TableFilters/SiteFilter/SiteFilter.test.tsx +8 -7
- package/src/__tests__/components/TableFilters/StatusFilter/StatusFilter.test.tsx +21 -20
- package/src/__tests__/components/TableFilters/TranslationsFilter/TranslationsFilter.test.tsx +24 -23
- package/src/__tests__/components/TableFilters/TypeFilter/TypeFilter.test.tsx +6 -5
- package/src/__tests__/components/TableFilters/UsersFilter/UsersFilter.test.tsx +17 -16
- package/src/api/sites.tsx +5 -9
- package/src/components/Button/index.tsx +3 -1
- package/src/components/Button/style.tsx +6 -0
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/TemplateManager/index.tsx +2 -2
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/index.tsx +1 -1
- package/src/components/Fields/ArrayFieldGroup/ArrayFieldInline/index.tsx +3 -2
- package/src/components/Fields/ArrayFieldGroup/ArrayFieldItem/index.tsx +3 -1
- package/src/components/Fields/ArrayFieldGroup/index.tsx +5 -2
- package/src/components/Fields/CheckField/style.tsx +2 -2
- package/src/components/Fields/ColorPicker/index.tsx +4 -2
- package/src/components/Fields/ColorPicker/style.tsx +4 -0
- package/src/components/Fields/DateField/DatePickerInput/index.tsx +1 -1
- package/src/components/Fields/FileField/index.tsx +3 -1
- package/src/components/Fields/FileField/style.tsx +9 -4
- package/src/components/Fields/SliderField/index.tsx +4 -2
- package/src/components/Fields/SliderField/style.tsx +53 -4
- package/src/components/Fields/TimeField/style.tsx +6 -5
- package/src/components/FileGallery/index.tsx +26 -16
- package/src/components/FileGallery/style.tsx +12 -1
- package/src/components/FilterTagsBar/index.tsx +61 -0
- package/src/components/FilterTagsBar/style.tsx +30 -0
- package/src/components/FloatingMenu/index.tsx +5 -1
- package/src/components/Gallery/GalleryFilters/Orientation/index.tsx +14 -6
- package/src/components/Gallery/GalleryFilters/SortBy/index.tsx +24 -8
- package/src/components/Gallery/GalleryFilters/Type/index.tsx +22 -9
- package/src/components/Gallery/GalleryPanel/GalleryDragAndDrop/style.tsx +2 -1
- package/src/components/Gallery/hooks.tsx +37 -23
- package/src/components/Gallery/index.tsx +38 -20
- package/src/components/Gallery/style.tsx +15 -2
- package/src/components/MainWrapper/AppBar/index.tsx +3 -0
- package/src/components/MainWrapper/index.tsx +1 -0
- package/src/components/SearchTagsBar/index.tsx +43 -0
- package/src/components/SearchTagsBar/style.tsx +30 -0
- package/src/components/TableFilters/CategoryFilter/index.tsx +17 -10
- package/src/components/TableFilters/CheckGroupFilter/index.tsx +12 -9
- package/src/components/TableFilters/DateFilter/index.tsx +3 -2
- package/src/components/TableFilters/LastAccessFilter/index.tsx +4 -4
- package/src/components/TableFilters/LiveFilter/index.tsx +26 -22
- package/src/components/TableFilters/NameFilter/index.tsx +4 -3
- package/src/components/TableFilters/PermissionsFilter/index.tsx +4 -3
- package/src/components/TableFilters/RoleFilter/index.tsx +17 -7
- package/src/components/TableFilters/SiteFilter/index.tsx +23 -8
- package/src/components/TableFilters/StateFilter/index.tsx +15 -6
- package/src/components/TableFilters/StatusFilter/index.tsx +3 -2
- package/src/components/TableFilters/TranslationsFilter/index.tsx +19 -11
- package/src/components/TableFilters/TypeFilter/index.tsx +9 -5
- package/src/components/TableFilters/UsersFilter/index.tsx +4 -3
- package/src/components/Tag/index.tsx +5 -4
- package/src/components/index.tsx +4 -0
- package/src/containers/Navigation/Menu/actions.tsx +1 -13
- package/src/containers/Navigation/Menu/constants.tsx +0 -1
- package/src/containers/Navigation/Menu/interfaces.tsx +1 -7
- package/src/containers/Navigation/Menu/reducer.tsx +0 -4
- package/src/containers/Sites/actions.tsx +2 -1
- package/src/containers/Sites/interfaces.tsx +2 -2
- package/src/containers/Sites/reducer.tsx +2 -2
- package/src/containers/StructuredData/actions.tsx +2 -1
- package/src/forms/editor.tsx +1 -1
- package/src/modules/Categories/CategoriesList/CategoryItem/style.tsx +2 -0
- package/src/modules/Content/BulkHeader/TableHeader/index.tsx +26 -14
- package/src/modules/Content/BulkHeader/index.tsx +3 -3
- package/src/modules/Content/PageItem/index.tsx +21 -23
- package/src/modules/Content/PageItem/style.tsx +2 -0
- package/src/modules/Content/hooks.tsx +23 -13
- package/src/modules/Content/index.tsx +44 -11
- package/src/modules/Content/style.tsx +19 -1
- package/src/modules/FileDrive/Breadcrumb/style.tsx +1 -1
- package/src/modules/FileDrive/FileDragAndDrop/index.tsx +7 -6
- package/src/modules/FileDrive/FileDragAndDrop/style.tsx +2 -0
- package/src/modules/FileDrive/FileFilters/SortBy/index.tsx +24 -8
- package/src/modules/FileDrive/FileFilters/Type/index.tsx +26 -22
- package/src/modules/FileDrive/hooks.tsx +28 -13
- package/src/modules/FileDrive/index.tsx +31 -18
- package/src/modules/FileDrive/style.tsx +20 -1
- package/src/modules/Navigation/Defaults/Item/style.tsx +2 -0
- package/src/modules/Navigation/Menus/List/Nav/index.tsx +10 -12
- package/src/modules/Navigation/Menus/List/Table/SidePanel/index.tsx +0 -2
- package/src/modules/Navigation/Menus/List/index.tsx +8 -5
- package/src/modules/Redirects/BulkHeader/TableHeader/index.tsx +4 -2
- package/src/modules/Redirects/BulkHeader/index.tsx +3 -2
- package/src/modules/Redirects/hooks.tsx +23 -15
- package/src/modules/Redirects/index.tsx +61 -44
- package/src/modules/Redirects/style.tsx +10 -0
- package/src/modules/Settings/Integrations/BulkHeader/TableHeader/index.tsx +7 -11
- package/src/modules/Settings/Integrations/BulkHeader/index.tsx +4 -8
- package/src/modules/Settings/Integrations/hooks.tsx +23 -19
- package/src/modules/Settings/Integrations/index.tsx +22 -26
- package/src/modules/Settings/Integrations/style.tsx +7 -0
- package/src/modules/Sites/SitesList/GridView/GridHeaderFilter/index.tsx +8 -7
- package/src/modules/Sites/SitesList/ListView/BulkHeader/TableHeader/index.tsx +10 -5
- package/src/modules/Sites/SitesList/ListView/BulkHeader/index.tsx +4 -3
- package/src/modules/Sites/SitesList/hooks.tsx +26 -20
- package/src/modules/Sites/SitesList/index.tsx +53 -22
- package/src/modules/Sites/SitesList/style.tsx +16 -0
- package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +3 -3
- package/src/modules/StructuredData/StructuredDataList/BulkHeader/index.tsx +3 -3
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +3 -3
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/style.tsx +2 -0
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/style.tsx +2 -0
- package/src/modules/StructuredData/StructuredDataList/hooks.tsx +25 -15
- package/src/modules/StructuredData/StructuredDataList/index.tsx +57 -14
- package/src/modules/StructuredData/StructuredDataList/style.tsx +10 -1
- package/src/modules/Users/Roles/BulkHeader/TableHeader/index.tsx +2 -2
- package/src/modules/Users/Roles/BulkHeader/index.tsx +2 -5
- package/src/modules/Users/Roles/hooks.tsx +24 -15
- package/src/modules/Users/Roles/index.tsx +7 -18
- package/src/modules/Users/UserList/BulkHeader/TableHeader/index.tsx +5 -18
- package/src/modules/Users/UserList/BulkHeader/index.tsx +15 -13
- package/src/modules/Users/UserList/hooks.tsx +27 -25
- package/src/modules/Users/UserList/index.tsx +69 -43
- package/src/modules/Users/UserList/style.tsx +10 -1
- package/src/types/index.tsx +19 -13
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import { CheckField,
|
|
3
|
+
import { CheckField, TableCounter, CheckGroupFilter, StateFilter } from "@ax/components";
|
|
4
|
+
import { IQueryValue } from "@ax/types";
|
|
5
|
+
|
|
4
6
|
import * as S from "./style";
|
|
5
7
|
|
|
6
8
|
const TableHeader = (props: IProps): JSX.Element => {
|
|
7
|
-
const { totalItems, selectAllItems, isScrolling, filterItems, filterValues
|
|
9
|
+
const { totalItems, selectAllItems, isScrolling, filterItems, filterValues } = props;
|
|
8
10
|
|
|
9
11
|
const filters = [
|
|
10
12
|
{
|
|
@@ -29,8 +31,6 @@ const TableHeader = (props: IProps): JSX.Element => {
|
|
|
29
31
|
},
|
|
30
32
|
];
|
|
31
33
|
|
|
32
|
-
const sortByName = (orderPointer: string, isAscendent: boolean) => sortItems("name", isAscendent);
|
|
33
|
-
|
|
34
34
|
return (
|
|
35
35
|
<S.TableHeader isScrolling={isScrolling}>
|
|
36
36
|
<S.CheckHeader>
|
|
@@ -44,9 +44,7 @@ const TableHeader = (props: IProps): JSX.Element => {
|
|
|
44
44
|
error={false}
|
|
45
45
|
/>
|
|
46
46
|
</S.CheckHeader>
|
|
47
|
-
<S.NameHeader>
|
|
48
|
-
Name
|
|
49
|
-
</S.NameHeader>
|
|
47
|
+
<S.NameHeader>Name</S.NameHeader>
|
|
50
48
|
<S.DescriptionHeader></S.DescriptionHeader>
|
|
51
49
|
<S.AppliedOnHeader>
|
|
52
50
|
<CheckGroupFilter
|
|
@@ -72,10 +70,8 @@ interface IProps {
|
|
|
72
70
|
totalItems: number;
|
|
73
71
|
isScrolling: boolean;
|
|
74
72
|
selectAllItems: () => void;
|
|
75
|
-
filterItems: (filterPointer: string, filtersSelected:
|
|
76
|
-
filterValues:
|
|
77
|
-
sortItems: (orderPointer: string, isAscending: boolean) => void;
|
|
78
|
-
sortedListStatus: { isAscending: boolean; sortedByTitle: boolean };
|
|
73
|
+
filterItems: (filterPointer: string, filtersSelected: IQueryValue[]) => void;
|
|
74
|
+
filterValues: Record<string, IQueryValue[]>;
|
|
79
75
|
}
|
|
80
76
|
|
|
81
77
|
export default TableHeader;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { BulkSelectionOptions } from "@ax/components";
|
|
3
|
+
import { IQueryValue } from "@ax/types";
|
|
4
|
+
|
|
3
5
|
import TableHeader from "./TableHeader";
|
|
4
6
|
|
|
5
7
|
const BulkHeader = (props: IProps): JSX.Element => {
|
|
@@ -12,8 +14,6 @@ const BulkHeader = (props: IProps): JSX.Element => {
|
|
|
12
14
|
isScrolling,
|
|
13
15
|
filterItems,
|
|
14
16
|
filterValues,
|
|
15
|
-
sortItems,
|
|
16
|
-
sortedListStatus,
|
|
17
17
|
bulkActions,
|
|
18
18
|
} = props;
|
|
19
19
|
|
|
@@ -31,8 +31,6 @@ const BulkHeader = (props: IProps): JSX.Element => {
|
|
|
31
31
|
isScrolling={isScrolling}
|
|
32
32
|
filterItems={filterItems}
|
|
33
33
|
filterValues={filterValues}
|
|
34
|
-
sortItems={sortItems}
|
|
35
|
-
sortedListStatus={sortedListStatus}
|
|
36
34
|
/>
|
|
37
35
|
);
|
|
38
36
|
};
|
|
@@ -44,10 +42,8 @@ interface IProps {
|
|
|
44
42
|
selectAllItems: () => void;
|
|
45
43
|
totalItems: number;
|
|
46
44
|
isScrolling: boolean;
|
|
47
|
-
filterItems: (filterPointer: string, filtersSelected:
|
|
48
|
-
filterValues:
|
|
49
|
-
sortItems: (orderPointer: string, isAscending: boolean) => void;
|
|
50
|
-
sortedListStatus: { isAscending: boolean; sortedByTitle: boolean };
|
|
45
|
+
filterItems: (filterPointer: string, filtersSelected: IQueryValue[]) => void;
|
|
46
|
+
filterValues: Record<string, IQueryValue[]>;
|
|
51
47
|
bulkActions: { icon: string; text: string; action: () => void }[];
|
|
52
48
|
}
|
|
53
49
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
|
+
import { IQueryValue } from "@ax/types";
|
|
2
3
|
|
|
3
4
|
const useSortedListStatus = () => {
|
|
4
5
|
const sortedInitialState: { isAscending: boolean; sortedByTitle: boolean } = {
|
|
@@ -15,56 +16,59 @@ const useSortedListStatus = () => {
|
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
const useFilterQuery = () => {
|
|
18
|
-
const initialQueryValues = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
filterState: "all",
|
|
19
|
+
const initialQueryValues: Record<string, IQueryValue[]> = {
|
|
20
|
+
filterApplication: [{ value: "all", label: "All" }],
|
|
21
|
+
filterState: [{ value: "all", label: "All" }],
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const [query, setQuery] = useState(initialQueryValues);
|
|
25
|
+
const [currentFilterQuery, setCurrentFilterQuery] = useState("");
|
|
25
26
|
|
|
26
|
-
const setFilterQuery = (filterValues:
|
|
27
|
-
const {
|
|
27
|
+
const setFilterQuery = (filterValues: Record<string, IQueryValue[]>) => {
|
|
28
|
+
const { filterApplication, filterState } = filterValues;
|
|
28
29
|
let filterQuery = "";
|
|
29
30
|
|
|
30
|
-
const currentQuery = (pointer: string, values:
|
|
31
|
-
|
|
31
|
+
const currentQuery = (pointer: string, values: IQueryValue[]): string => {
|
|
32
|
+
const stringValues = Array.isArray(values)
|
|
33
|
+
? values.map((value) => (value.value !== "all" ? value.value : "")).join(",")
|
|
34
|
+
: "";
|
|
35
|
+
|
|
36
|
+
return !stringValues.length ? filterQuery : filterQuery.concat(`&${pointer}=${stringValues}`);
|
|
32
37
|
};
|
|
33
38
|
|
|
34
|
-
const isNotInitialValue = (pointer: "
|
|
39
|
+
const isNotInitialValue = (pointer: "filterApplication" | "filterState") => {
|
|
35
40
|
return filterValues[pointer] && initialQueryValues[pointer] !== filterValues[pointer];
|
|
36
41
|
};
|
|
37
42
|
|
|
38
|
-
if (isNotInitialValue("order")) filterQuery = currentQuery("order", order);
|
|
39
43
|
if (isNotInitialValue("filterApplication")) filterQuery = currentQuery("filterApplication", filterApplication);
|
|
40
44
|
if (isNotInitialValue("filterState")) filterQuery = currentQuery("filterState", filterState);
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
setCurrentFilterQuery(filterQuery);
|
|
43
47
|
};
|
|
44
48
|
|
|
45
|
-
const setFiltersSelection = (pointer: string, filter:
|
|
46
|
-
const {
|
|
47
|
-
const orderMethod = isAscendent ? "asc" : "desc";
|
|
49
|
+
const setFiltersSelection = (pointer: string, filter: IQueryValue[]) => {
|
|
50
|
+
const { filterApplication, filterState } = query;
|
|
48
51
|
const filterValues = {
|
|
49
|
-
order: pointer === "order" ? `${filter}-${orderMethod}` : order,
|
|
50
52
|
filterApplication: pointer === "filterApplication" ? filter : filterApplication,
|
|
51
53
|
filterState: pointer === "filterState" ? filter : filterState,
|
|
52
54
|
};
|
|
53
55
|
|
|
54
56
|
setQuery(filterValues);
|
|
55
|
-
|
|
56
|
-
return filterValues;
|
|
57
|
+
setFilterQuery(filterValues);
|
|
57
58
|
};
|
|
58
59
|
|
|
59
|
-
const resetFilterQuery = () =>
|
|
60
|
+
const resetFilterQuery = () => {
|
|
61
|
+
setQuery(initialQueryValues);
|
|
62
|
+
setCurrentFilterQuery("");
|
|
63
|
+
}
|
|
60
64
|
|
|
61
65
|
const isFiltered = Object.keys(query).some((key: any) => query[key as never] !== initialQueryValues[key as never]);
|
|
62
66
|
|
|
63
67
|
return {
|
|
64
68
|
setFiltersSelection,
|
|
65
|
-
setFilterQuery,
|
|
66
69
|
resetFilterQuery,
|
|
67
70
|
filterValues: query,
|
|
71
|
+
filterQuery: currentFilterQuery,
|
|
68
72
|
isFiltered,
|
|
69
73
|
};
|
|
70
74
|
};
|
|
@@ -2,16 +2,15 @@ import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
|
2
2
|
import { connect } from "react-redux";
|
|
3
3
|
import { DragDropContext, Droppable, Draggable, DropResult } from "react-beautiful-dnd";
|
|
4
4
|
|
|
5
|
-
import { IEmptyStateProps, IIntegration, IRootState } from "@ax/types";
|
|
6
|
-
import { MainWrapper, ErrorToast, TableList, EmptyState, Toast } from "@ax/components";
|
|
5
|
+
import { IEmptyStateProps, IIntegration, IQueryValue, IRootState } from "@ax/types";
|
|
6
|
+
import { MainWrapper, ErrorToast, TableList, EmptyState, Toast, FilterTagsBar } from "@ax/components";
|
|
7
7
|
import { integrationsActions } from "@ax/containers/Integrations";
|
|
8
8
|
import { appActions } from "@ax/containers/App";
|
|
9
9
|
import { useBulkSelection, useEmptyState, useModal, usePermission, useToast } from "@ax/hooks";
|
|
10
10
|
|
|
11
11
|
import BulkHeader from "./BulkHeader";
|
|
12
12
|
import IntegrationItem from "./IntegrationItem";
|
|
13
|
-
import { useFilterQuery
|
|
14
|
-
import { getSortedListStatus } from "./utils";
|
|
13
|
+
import { useFilterQuery } from "./hooks";
|
|
15
14
|
import { DeactivateModal, DeleteModal } from "./atoms";
|
|
16
15
|
|
|
17
16
|
import * as S from "./style";
|
|
@@ -37,9 +36,7 @@ const Integrations = (props: IIntegrationsProps): JSX.Element => {
|
|
|
37
36
|
|
|
38
37
|
const [isScrolling, setIsScrolling] = useState(false);
|
|
39
38
|
const tableRef = useRef<HTMLDivElement>(null);
|
|
40
|
-
const
|
|
41
|
-
const { setFiltersSelection, setFilterQuery, filterValues, isFiltered } = useFilterQuery();
|
|
42
|
-
const { sortedListStatus, setSortedListStatus } = useSortedListStatus();
|
|
39
|
+
const { setFiltersSelection, resetFilterQuery, filterValues, filterQuery, isFiltered } = useFilterQuery();
|
|
43
40
|
const { isOpen: isOpenDelete, toggleModal: toggleModalDelete } = useModal();
|
|
44
41
|
const { isOpen: isOpenDeactivate, toggleModal: toggleModalDeactivate } = useModal();
|
|
45
42
|
const {
|
|
@@ -73,11 +70,11 @@ const Integrations = (props: IIntegrationsProps): JSX.Element => {
|
|
|
73
70
|
const getParams = useCallback(() => {
|
|
74
71
|
const params = {
|
|
75
72
|
pagination: false,
|
|
76
|
-
filter:
|
|
73
|
+
filter: filterQuery,
|
|
77
74
|
};
|
|
78
75
|
|
|
79
76
|
return params;
|
|
80
|
-
}, [
|
|
77
|
+
}, [filterQuery]);
|
|
81
78
|
|
|
82
79
|
useEffect(() => {
|
|
83
80
|
const params = getParams();
|
|
@@ -88,7 +85,7 @@ const Integrations = (props: IIntegrationsProps): JSX.Element => {
|
|
|
88
85
|
resetIntegrations();
|
|
89
86
|
};
|
|
90
87
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
-
}, [currentSite,
|
|
88
|
+
}, [currentSite, filterQuery]);
|
|
92
89
|
|
|
93
90
|
const {
|
|
94
91
|
resetBulkSelection,
|
|
@@ -126,20 +123,8 @@ const Integrations = (props: IIntegrationsProps): JSX.Element => {
|
|
|
126
123
|
|
|
127
124
|
const handleSelectAll = () => selectAllItems();
|
|
128
125
|
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
setSortedListStatus(sortedState);
|
|
132
|
-
|
|
133
|
-
const filtersSelection = setFiltersSelection("order", orderPointer, isAscending);
|
|
134
|
-
const filterQuery = setFilterQuery(filtersSelection);
|
|
135
|
-
setCurrentFilterQuery(filterQuery);
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const filterItems = async (filterPointer: string, filtersSelected: string) => {
|
|
139
|
-
const filtersSelection = setFiltersSelection(filterPointer, filtersSelected);
|
|
140
|
-
const filterQuery = setFilterQuery(filtersSelection);
|
|
141
|
-
setCurrentFilterQuery(filterQuery);
|
|
142
|
-
};
|
|
126
|
+
const filterItems = async (filterPointer: string, filtersSelected: IQueryValue[]) =>
|
|
127
|
+
setFiltersSelection(filterPointer, filtersSelected);
|
|
143
128
|
|
|
144
129
|
const bulkActions: { icon: string; text: string; action: () => void | Promise<void> }[] =
|
|
145
130
|
isAllowedToDeleteIntegrations
|
|
@@ -170,8 +155,6 @@ const Integrations = (props: IIntegrationsProps): JSX.Element => {
|
|
|
170
155
|
isScrolling={isScrolling}
|
|
171
156
|
filterItems={filterItems}
|
|
172
157
|
filterValues={filterValues}
|
|
173
|
-
sortItems={sortItems}
|
|
174
|
-
sortedListStatus={sortedListStatus}
|
|
175
158
|
bulkActions={bulkActions}
|
|
176
159
|
/>
|
|
177
160
|
);
|
|
@@ -253,6 +236,11 @@ const Integrations = (props: IIntegrationsProps): JSX.Element => {
|
|
|
253
236
|
});
|
|
254
237
|
});
|
|
255
238
|
|
|
239
|
+
const filterLabels: Record<string, string> = {
|
|
240
|
+
filterApplication: "Applied on",
|
|
241
|
+
filterState: "State",
|
|
242
|
+
};
|
|
243
|
+
|
|
256
244
|
return (
|
|
257
245
|
<MainWrapper backLink={false} title="Add-ons" rightButton={rightButtonProps}>
|
|
258
246
|
<S.Wrapper data-testid="integrations-main-wrapper">
|
|
@@ -264,6 +252,14 @@ const Integrations = (props: IIntegrationsProps): JSX.Element => {
|
|
|
264
252
|
</S.TitleWrapper>
|
|
265
253
|
<S.TableWrapper>
|
|
266
254
|
<TableList tableHeader={TableHeader} onScroll={onScroll} hasFixedHeader={true} tableRef={tableRef}>
|
|
255
|
+
<S.SearchTags>
|
|
256
|
+
<FilterTagsBar
|
|
257
|
+
filters={filterValues}
|
|
258
|
+
setFilters={setFiltersSelection}
|
|
259
|
+
resetFilters={resetFilterQuery}
|
|
260
|
+
labels={filterLabels}
|
|
261
|
+
/>
|
|
262
|
+
</S.SearchTags>
|
|
267
263
|
{isEmpty ? (
|
|
268
264
|
<S.EmptyWrapper>
|
|
269
265
|
<EmptyState {...emptyStateProps} />
|
|
@@ -54,6 +54,12 @@ const OrderNote = styled.div`
|
|
|
54
54
|
margin-bottom: ${(p) => p.theme.spacing.xs};
|
|
55
55
|
`;
|
|
56
56
|
|
|
57
|
+
const SearchTags = styled.div`
|
|
58
|
+
& > div:nth-child(1) {
|
|
59
|
+
margin-bottom: ${(p) => p.theme.spacing.xs};
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
|
|
57
63
|
export {
|
|
58
64
|
Wrapper,
|
|
59
65
|
ContentWrapper,
|
|
@@ -64,4 +70,5 @@ export {
|
|
|
64
70
|
EmptyWrapper,
|
|
65
71
|
ModalContent,
|
|
66
72
|
OrderNote,
|
|
73
|
+
SearchTags,
|
|
67
74
|
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
3
|
import { Icon, FloatingMenu, ListTitle, ListItem } from "@ax/components";
|
|
4
|
+
import { IQueryValue } from "@ax/types";
|
|
4
5
|
|
|
5
6
|
import * as S from "./style";
|
|
6
7
|
|
|
7
8
|
const GridHeaderFilter = ({ sortItems, sortedState }: IGridHeaderFilterProps): JSX.Element => {
|
|
8
9
|
const { isAscending, sortedByTitle, sortedByLastAccess, sortedByDateCreated } = sortedState;
|
|
9
10
|
|
|
10
|
-
const sortAscendingName = () => sortItems("name", true);
|
|
11
|
-
const sortDescendingName = () => sortItems("name", false);
|
|
12
|
-
const sortAscendingLastAccess = () => sortItems("lastAccess", true);
|
|
13
|
-
const sortDescendingLastAccess = () => sortItems("lastAccess", false);
|
|
14
|
-
const sortAscendingDateCreated = () => sortItems("dateCreated", true);
|
|
15
|
-
const sortDescendingDateCreated = () => sortItems("dateCreated", false);
|
|
11
|
+
const sortAscendingName = () => sortItems([{ value: "name", label: "name" }], true);
|
|
12
|
+
const sortDescendingName = () => sortItems([{ value: "name", label: "name" }], false);
|
|
13
|
+
const sortAscendingLastAccess = () => sortItems([{ value: "lastAccess", label: "lastAccess" }], true);
|
|
14
|
+
const sortDescendingLastAccess = () => sortItems([{ value: "lastAccess", label: "lastAccess" }], false);
|
|
15
|
+
const sortAscendingDateCreated = () => sortItems([{ value: "dateCreated", label: "dateCreated" }], true);
|
|
16
|
+
const sortDescendingDateCreated = () => sortItems([{ value: "dateCreated", label: "dateCreated" }], false);
|
|
16
17
|
|
|
17
18
|
const SortedStateArrow = () =>
|
|
18
19
|
isAscending ? <Icon name="FullArrowUp" size="16" /> : <Icon name="FullArrowDown" size="16" />;
|
|
@@ -66,7 +67,7 @@ const GridHeaderFilter = ({ sortItems, sortedState }: IGridHeaderFilterProps): J
|
|
|
66
67
|
|
|
67
68
|
export interface IGridHeaderFilterProps {
|
|
68
69
|
sortedState: any;
|
|
69
|
-
sortItems(orderPointer:
|
|
70
|
+
sortItems(orderPointer: IQueryValue[], isAscending: boolean): any;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
export default GridHeaderFilter;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
3
|
import { CheckField, TableCounter, LastAccessFilter, NameFilter, LiveFilter } from "@ax/components";
|
|
4
|
+
import { IQueryValue } from "@ax/types";
|
|
4
5
|
|
|
5
6
|
import * as S from "./style";
|
|
6
7
|
|
|
@@ -16,12 +17,16 @@ const TableHeader = (props: IProps): JSX.Element => {
|
|
|
16
17
|
filterValues,
|
|
17
18
|
} = props;
|
|
18
19
|
|
|
19
|
-
const liveStatusValue:
|
|
20
|
+
const liveStatusValue: Record<string, string> = {
|
|
20
21
|
all: "all",
|
|
21
22
|
online: "active",
|
|
22
23
|
offline: "offline",
|
|
23
24
|
};
|
|
24
25
|
|
|
26
|
+
const liveFilterValue = filterValues.liveStatus.length
|
|
27
|
+
? [{ value: liveStatusValue[filterValues.liveStatus[0].value], label: filterValues.liveStatus[0].label }]
|
|
28
|
+
: [];
|
|
29
|
+
|
|
25
30
|
return (
|
|
26
31
|
<S.TableHeader isScrolling={isScrolling} data-testid="sites-table-header">
|
|
27
32
|
<S.CheckHeader>
|
|
@@ -40,7 +45,7 @@ const TableHeader = (props: IProps): JSX.Element => {
|
|
|
40
45
|
</S.NameWrapper>
|
|
41
46
|
<S.DomainHeader>Domain</S.DomainHeader>
|
|
42
47
|
<S.LiveHeader>
|
|
43
|
-
<LiveFilter filterItems={filterItems} value={
|
|
48
|
+
<LiveFilter filterItems={filterItems} value={liveFilterValue} hasBasicStatus={true} />
|
|
44
49
|
</S.LiveHeader>
|
|
45
50
|
<S.LastAccessCell>
|
|
46
51
|
<LastAccessFilter sortItems={sortItems} sortedState={sortedListStatus} />
|
|
@@ -55,10 +60,10 @@ interface IProps {
|
|
|
55
60
|
totalItems: number;
|
|
56
61
|
selectAllItems: () => void;
|
|
57
62
|
checkState: Record<string, boolean>;
|
|
58
|
-
sortItems: (orderPointer:
|
|
59
|
-
filterItems: (filterPointer: string, filtersSelected:
|
|
63
|
+
sortItems: (orderPointer: IQueryValue[], isAscending: boolean) => void;
|
|
64
|
+
filterItems: (filterPointer: string, filtersSelected: IQueryValue[]) => void;
|
|
60
65
|
sortedListStatus: { isAscending: boolean; sortedByDate: boolean; sortedByTitle: boolean; sortedByURL: boolean };
|
|
61
|
-
filterValues:
|
|
66
|
+
filterValues: Record<string, IQueryValue[]>;
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
export default TableHeader;
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
|
|
3
3
|
import { BulkSelectionOptions } from "@ax/components";
|
|
4
4
|
import { usePermission } from "@ax/hooks";
|
|
5
|
+
import { IQueryValue } from "@ax/types";
|
|
5
6
|
|
|
6
7
|
import TableHeader from "./TableHeader";
|
|
7
8
|
|
|
@@ -75,10 +76,10 @@ export interface IBulkHeaderProps {
|
|
|
75
76
|
selectItems: () => void;
|
|
76
77
|
selectAllItems: () => void;
|
|
77
78
|
totalItems: number;
|
|
78
|
-
sortItems: (orderPointer:
|
|
79
|
-
filterItems: (filterPointer: string, filtersSelected:
|
|
79
|
+
sortItems: (orderPointer: IQueryValue[], isAscending: any) => void;
|
|
80
|
+
filterItems: (filterPointer: string, filtersSelected: IQueryValue[]) => void;
|
|
80
81
|
sortedListStatus: any;
|
|
81
|
-
filterValues:
|
|
82
|
+
filterValues: Record<string, IQueryValue[]>;
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
export default BulkHeader;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { ISitesQueryValues } from "@ax/types";
|
|
2
|
+
import { IQueryValue, ISitesQueryValues } from "@ax/types";
|
|
3
3
|
|
|
4
4
|
const useSortedListStatus = () => {
|
|
5
5
|
const sortedInitialState: {
|
|
@@ -22,20 +22,21 @@ const useSortedListStatus = () => {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const useFilterQuery = (defaultValues?: { order:
|
|
26
|
-
const initialQueryValues = {
|
|
27
|
-
order:
|
|
28
|
-
liveStatus:
|
|
25
|
+
const useFilterQuery = (defaultValues?: { order: IQueryValue[]; liveStatus: IQueryValue[] }): ISitesFilterQuery => {
|
|
26
|
+
const initialQueryValues: Record<string, IQueryValue[]> = {
|
|
27
|
+
order: [{ value: "lastAccess-desc", label: "lastAccess-desc"}],
|
|
28
|
+
liveStatus: [{ value: "all", label: "All"}],
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
const [query, setQuery] = useState(initialQueryValues);
|
|
31
|
+
const [query, setQuery] = useState(defaultValues || initialQueryValues);
|
|
32
|
+
const [currentFilterQuery, setCurrentFilterQuery] = useState("");
|
|
32
33
|
|
|
33
34
|
const setFilterQuery = (filterValues: ISitesQueryValues) => {
|
|
34
35
|
const { order, liveStatus } = filterValues;
|
|
35
36
|
|
|
36
37
|
let filterQuery = "";
|
|
37
|
-
const currentQuery = (pointer: string, values:
|
|
38
|
-
return `&${pointer}=${values}
|
|
38
|
+
const currentQuery = (pointer: string, values: IQueryValue[]) => {
|
|
39
|
+
return values.length && values[0].value !== "all" ? `&${pointer}=${values[0].value}` : "";
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
const isNotInitialValue = (pointer: keyof ISitesQueryValues) => {
|
|
@@ -52,34 +53,39 @@ const useFilterQuery = (defaultValues?: { order: string; liveStatus: string }):
|
|
|
52
53
|
filterQuery = `${filterQuery}${query}`;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
|
|
56
|
+
setCurrentFilterQuery(filterQuery);
|
|
56
57
|
};
|
|
57
58
|
|
|
58
|
-
const setFiltersSelection = (pointer: string, filter:
|
|
59
|
+
const setFiltersSelection = (pointer: string, filter: IQueryValue[], isAscendent?: boolean) => {
|
|
59
60
|
const { order, liveStatus } = query;
|
|
60
|
-
const
|
|
61
|
+
const orderMethod = isAscendent ? "asc" : "desc";
|
|
62
|
+
const liveStatusValue: Record<string, string> = {
|
|
61
63
|
all: "all",
|
|
62
64
|
active: "online",
|
|
63
65
|
offline: "offline",
|
|
64
66
|
};
|
|
65
67
|
|
|
68
|
+
const liveValue = filter.length > 0 ? [{value: liveStatusValue[filter[0].value], label: filter[0].label}] : []
|
|
69
|
+
|
|
66
70
|
const filterValues = {
|
|
67
|
-
order: pointer === "order" ? `${filter}-${orderMethod}
|
|
68
|
-
liveStatus: pointer === "liveStatus" ?
|
|
71
|
+
order: pointer === "order" ? [{ value: `${filter[0].value}-${orderMethod}`, label: filter[0].label }] : order,
|
|
72
|
+
liveStatus: pointer === "liveStatus" ? liveValue : liveStatus,
|
|
69
73
|
};
|
|
70
74
|
|
|
71
75
|
setQuery(filterValues);
|
|
72
|
-
|
|
73
|
-
return filterValues;
|
|
76
|
+
setFilterQuery(filterValues);
|
|
74
77
|
};
|
|
75
78
|
|
|
76
|
-
const resetFilterQuery = () =>
|
|
79
|
+
const resetFilterQuery = () => {
|
|
80
|
+
setQuery(initialQueryValues);
|
|
81
|
+
setCurrentFilterQuery("");
|
|
82
|
+
}
|
|
77
83
|
|
|
78
84
|
return {
|
|
79
85
|
setFiltersSelection,
|
|
80
|
-
setFilterQuery,
|
|
81
86
|
resetFilterQuery,
|
|
82
87
|
filterValues: query,
|
|
88
|
+
filterQuery: currentFilterQuery,
|
|
83
89
|
};
|
|
84
90
|
};
|
|
85
91
|
|
|
@@ -92,10 +98,10 @@ const useIsMount = () => {
|
|
|
92
98
|
};
|
|
93
99
|
|
|
94
100
|
interface ISitesFilterQuery {
|
|
95
|
-
setFiltersSelection(pointer: string, filter:
|
|
96
|
-
setFilterQuery(filterValues: ISitesQueryValues): string;
|
|
101
|
+
setFiltersSelection(pointer: string, filter: IQueryValue[], isAscendent?: boolean): void;
|
|
97
102
|
resetFilterQuery(): void;
|
|
98
|
-
filterValues:
|
|
103
|
+
filterValues: Record<string, IQueryValue[]>;
|
|
104
|
+
filterQuery: string;
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
export { useSortedListStatus, useFilterQuery, useIsMount };
|
|
@@ -3,10 +3,21 @@ import { connect } from "react-redux";
|
|
|
3
3
|
|
|
4
4
|
import { appActions } from "@ax/containers/App";
|
|
5
5
|
import { sitesActions } from "@ax/containers/Sites";
|
|
6
|
-
import { ICheck, IGetSitesParams, IRootState, ISettingsForm, ISite, ISiteListConfig } from "@ax/types";
|
|
6
|
+
import { ICheck, IGetSitesParams, IQueryValue, IRootState, ISettingsForm, ISite, ISiteListConfig } from "@ax/types";
|
|
7
7
|
import { IError } from "@ax/containers/App/reducer";
|
|
8
8
|
import { useBulkSelection, useModal, usePermission } from "@ax/hooks";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
MainWrapper,
|
|
11
|
+
Modal,
|
|
12
|
+
ErrorToast,
|
|
13
|
+
Icon,
|
|
14
|
+
IconAction,
|
|
15
|
+
TableList,
|
|
16
|
+
EmptyState,
|
|
17
|
+
Pagination,
|
|
18
|
+
SearchTagsBar,
|
|
19
|
+
FilterTagsBar,
|
|
20
|
+
} from "@ax/components";
|
|
10
21
|
|
|
11
22
|
import { useFilterQuery, useSortedListStatus, useIsMount } from "./hooks";
|
|
12
23
|
import { filterByStatus, getSortedListStatus } from "./utils";
|
|
@@ -59,8 +70,7 @@ const SitesList = (props: ISitesListProps): JSX.Element => {
|
|
|
59
70
|
currentConfig.displayRecentSites
|
|
60
71
|
);
|
|
61
72
|
const [displayMode, setDisplayMode] = useState<string | "list" | "grid">(currentConfig.mode);
|
|
62
|
-
const [searchQuery, setSearchQuery] = useState<string
|
|
63
|
-
const [currentFilterQuery, setCurrentFilterQuery] = useState(currentConfig.filter);
|
|
73
|
+
const [searchQuery, setSearchQuery] = useState<string>("");
|
|
64
74
|
const tableRef = useRef<HTMLDivElement>(null);
|
|
65
75
|
const errorRef = useRef<HTMLDivElement>(null);
|
|
66
76
|
|
|
@@ -84,20 +94,22 @@ const SitesList = (props: ISitesListProps): JSX.Element => {
|
|
|
84
94
|
: undefined;
|
|
85
95
|
|
|
86
96
|
const { setSortedListStatus } = useSortedListStatus();
|
|
87
|
-
const { setFiltersSelection,
|
|
97
|
+
const { setFiltersSelection, resetFilterQuery, filterValues, filterQuery } = useFilterQuery(
|
|
98
|
+
currentConfig.filterValues
|
|
99
|
+
);
|
|
88
100
|
|
|
89
101
|
const getParams = useCallback((): IGetSitesParams => {
|
|
90
|
-
const query = searchQuery ? `&query=${searchQuery}` : "";
|
|
102
|
+
const query = searchQuery.length ? `&query=${searchQuery}` : "";
|
|
91
103
|
return {
|
|
92
104
|
pagination: true,
|
|
93
105
|
language: undefined,
|
|
94
106
|
recentSitesNumber: 7,
|
|
95
107
|
page,
|
|
96
108
|
itemsPerPage,
|
|
97
|
-
filterQuery:
|
|
109
|
+
filterQuery: filterQuery,
|
|
98
110
|
searchQuery: query,
|
|
99
111
|
};
|
|
100
|
-
}, [
|
|
112
|
+
}, [filterQuery, searchQuery, page]);
|
|
101
113
|
|
|
102
114
|
useEffect(() => {
|
|
103
115
|
if (token) {
|
|
@@ -162,27 +174,22 @@ const SitesList = (props: ISitesListProps): JSX.Element => {
|
|
|
162
174
|
setDisplayMode(mode);
|
|
163
175
|
};
|
|
164
176
|
|
|
165
|
-
const sortItems = (orderPointer:
|
|
177
|
+
const sortItems = (orderPointer: IQueryValue[], isAscending: boolean) => {
|
|
166
178
|
setPage(firstPage);
|
|
167
|
-
const
|
|
168
|
-
const sortedState = getSortedListStatus(
|
|
179
|
+
const orderString = orderPointer[0].value.toString();
|
|
180
|
+
const sortedState = getSortedListStatus(orderString, isAscending);
|
|
169
181
|
setSortedListStatus(sortedState);
|
|
170
|
-
const pointer =
|
|
171
|
-
|
|
172
|
-
const filterQuery = setFilterQuery(filtersSelection);
|
|
182
|
+
const pointer = orderString === "title" ? [{ value: "name", label: "value" }] : orderPointer;
|
|
183
|
+
setFiltersSelection("order", pointer, isAscending);
|
|
173
184
|
const updatedConfig = { ...currentConfig, filter: filterQuery, sortedListStatus: sortedState };
|
|
174
185
|
setListConfig(updatedConfig);
|
|
175
|
-
setCurrentFilterQuery(filterQuery);
|
|
176
186
|
};
|
|
177
187
|
|
|
178
|
-
const filterItems = async (filterPointer: string, filtersSelected:
|
|
188
|
+
const filterItems = async (filterPointer: string, filtersSelected: IQueryValue[]) => {
|
|
179
189
|
setPage(firstPage);
|
|
180
|
-
|
|
181
|
-
const filterQuery = setFilterQuery(filtersSelection);
|
|
190
|
+
setFiltersSelection(filterPointer, filtersSelected);
|
|
182
191
|
const updatedConfig = { ...currentConfig, filter: filterQuery };
|
|
183
192
|
setListConfig(updatedConfig);
|
|
184
|
-
|
|
185
|
-
setCurrentFilterQuery(filterQuery);
|
|
186
193
|
};
|
|
187
194
|
|
|
188
195
|
const RecentSitesHeader = () => (
|
|
@@ -313,6 +320,9 @@ const SitesList = (props: ISitesListProps): JSX.Element => {
|
|
|
313
320
|
const showPagination = totalItems > itemsPerPage;
|
|
314
321
|
return (
|
|
315
322
|
<>
|
|
323
|
+
<S.SearchTagsGrid>
|
|
324
|
+
<SearchTagsBar query={searchQuery} setQuery={setSearchQuery} />
|
|
325
|
+
</S.SearchTagsGrid>
|
|
316
326
|
<S.GridList data-testid="sites-grid-list" isEmpty={sites.length === 0} fullWidth={sites.length >= 5}>
|
|
317
327
|
{mappedSites}
|
|
318
328
|
</S.GridList>
|
|
@@ -325,9 +335,24 @@ const SitesList = (props: ISitesListProps): JSX.Element => {
|
|
|
325
335
|
);
|
|
326
336
|
};
|
|
327
337
|
|
|
338
|
+
const filterLabels = {
|
|
339
|
+
liveStatus: "Live",
|
|
340
|
+
};
|
|
341
|
+
|
|
328
342
|
const ListTable = () => (
|
|
329
343
|
<TableList tableHeader={Header} pagination={pagination} hasFixedHeader={true} tableRef={tableRef}>
|
|
330
|
-
|
|
344
|
+
<>
|
|
345
|
+
<S.SearchTags>
|
|
346
|
+
<SearchTagsBar query={searchQuery} setQuery={setSearchQuery} />
|
|
347
|
+
<FilterTagsBar
|
|
348
|
+
filters={filterValues}
|
|
349
|
+
setFilters={setFiltersSelection}
|
|
350
|
+
resetFilters={resetFilterQuery}
|
|
351
|
+
labels={filterLabels}
|
|
352
|
+
/>
|
|
353
|
+
</S.SearchTags>
|
|
354
|
+
{mappedSites}
|
|
355
|
+
</>
|
|
331
356
|
</TableList>
|
|
332
357
|
);
|
|
333
358
|
|
|
@@ -340,7 +365,13 @@ const SitesList = (props: ISitesListProps): JSX.Element => {
|
|
|
340
365
|
const handleAnimationEnd = () => setHasAnimation(false);
|
|
341
366
|
|
|
342
367
|
return (
|
|
343
|
-
<MainWrapper
|
|
368
|
+
<MainWrapper
|
|
369
|
+
title="Sites"
|
|
370
|
+
rightButton={rightButtonProps}
|
|
371
|
+
searchAction={setSearchQuery}
|
|
372
|
+
hasAnimation={hasAnimation}
|
|
373
|
+
searchValue={searchQuery}
|
|
374
|
+
>
|
|
344
375
|
<ErrorToast ref={errorRef} />
|
|
345
376
|
<S.SitesListWrapper className={hasAnimation ? "animate" : ""}>
|
|
346
377
|
{recentSites?.length > 0 ? <RecentSitesList /> : null}
|