@griddo/ax 1.55.14 → 1.56.2

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.
Files changed (33) hide show
  1. package/package.json +2 -2
  2. package/src/GlobalStore.tsx +3 -0
  3. package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/index.tsx +6 -0
  4. package/src/components/Fields/ArrayFieldGroup/ArrayFieldInline/index.tsx +16 -12
  5. package/src/components/Fields/ArrayFieldGroup/ArrayFieldItem/index.tsx +17 -15
  6. package/src/components/Fields/ConditionalField/index.tsx +1 -3
  7. package/src/components/Fields/FileField/index.tsx +1 -1
  8. package/src/components/Fields/Wysiwyg/config.tsx +0 -1
  9. package/src/components/Fields/Wysiwyg/index.tsx +16 -5
  10. package/src/components/Gallery/GalleryPanel/DetailPanel/index.tsx +110 -99
  11. package/src/components/Gallery/GalleryPanel/GalleryDragAndDrop/index.tsx +75 -55
  12. package/src/components/Gallery/GalleryPanel/index.tsx +14 -8
  13. package/src/components/Gallery/index.tsx +113 -151
  14. package/src/components/Gallery/style.tsx +40 -10
  15. package/src/components/MainWrapper/AppBar/index.tsx +1 -0
  16. package/src/components/Toast/index.tsx +15 -9
  17. package/src/components/Toast/style.tsx +2 -2
  18. package/src/containers/Gallery/actions.tsx +171 -0
  19. package/src/containers/Gallery/constants.tsx +18 -0
  20. package/src/containers/Gallery/index.tsx +7 -0
  21. package/src/containers/Gallery/interfaces.tsx +41 -0
  22. package/src/containers/Gallery/reducer.tsx +78 -0
  23. package/src/containers/PageEditor/actions.tsx +15 -5
  24. package/src/containers/StructuredData/actions.tsx +4 -21
  25. package/src/forms/fields.tsx +19 -6
  26. package/src/guards/error/index.tsx +3 -1
  27. package/src/modules/Content/HeaderMenus/Live/index.tsx +6 -5
  28. package/src/modules/Sites/SitesList/index.tsx +1 -1
  29. package/src/modules/StructuredData/Form/ConnectedField/index.tsx +2 -4
  30. package/src/modules/StructuredData/Form/index.tsx +10 -6
  31. package/src/modules/StructuredData/StructuredDataList/HeaderMenus/Live/index.tsx +1 -1
  32. package/src/types/index.tsx +20 -0
  33. package/src/components/Gallery/store.tsx +0 -186
@@ -45,7 +45,7 @@ const SitesList = (props: IProps): JSX.Element => {
45
45
 
46
46
  return (
47
47
  <MainWrapper title="Sites" rightButton={rightButtonProps}>
48
- {!isOpen && <ErrorToast />}
48
+ <ErrorToast />
49
49
  <S.Sites>
50
50
  {sites.map((site: ISite) => (
51
51
  <SiteItem key={site.id} site={site} />
@@ -13,9 +13,7 @@ const ConnectedField = (props: IProps) => {
13
13
 
14
14
  const value = form.content && form.content[fieldKey];
15
15
 
16
- const handleChange = (newValue: any) => {
17
- updateFormValue({ [fieldKey]: newValue });
18
- };
16
+ const handleChange = (newValue: any) => updateFormValue({ [fieldKey]: newValue });
19
17
 
20
18
  const isConditional = field.type === "ConditionalField";
21
19
  const isArrayGroup = field.type === "ArrayFieldGroup";
@@ -23,7 +21,7 @@ const ConnectedField = (props: IProps) => {
23
21
  let innerFields: JSX.Element[] = [];
24
22
 
25
23
  if (isConditional || isArrayGroup) {
26
- innerFields = getStructuredDataInnerFields(field.fields);
24
+ innerFields = getStructuredDataInnerFields(field.fields, form.content, updateFormValue);
27
25
  }
28
26
 
29
27
  const fieldProps = {
@@ -3,7 +3,7 @@ import { connect } from "react-redux";
3
3
 
4
4
  import { IDataPack, IRootState } from "@ax/types";
5
5
  import { structuredDataActions } from "@ax/containers/StructuredData";
6
- import { MainWrapper, ErrorToast, Notification } from "@ax/components";
6
+ import { MainWrapper, ErrorToast, Notification, Loading } from "@ax/components";
7
7
  import { getActivatedDataPacksIds } from "@ax/helpers";
8
8
  import { appActions } from "@ax/containers/App";
9
9
  import { RouteLeavingGuard } from "@ax/guards";
@@ -24,6 +24,7 @@ const Form = (props: IProps) => {
24
24
  createStructuredDataContent,
25
25
  updateStructuredDataContent,
26
26
  isSaving,
27
+ isLoading,
27
28
  siteLanguages,
28
29
  globalLangs,
29
30
  currentSite,
@@ -91,14 +92,12 @@ const Form = (props: IProps) => {
91
92
 
92
93
  const inversed = !currentSite;
93
94
 
94
- const setIsNewTranslation = (value: boolean) => {
95
- setisNewStructuredData(value);
96
- };
95
+ const createNewTranslation = (value: boolean) => setisNewStructuredData(value);
97
96
 
98
97
  const languageActions = {
99
98
  setLanguage,
100
99
  getDataContent,
101
- setIsNewTranslation,
100
+ createNewTranslation,
102
101
  };
103
102
 
104
103
  const languages = currentSite ? siteLanguages : globalLangs;
@@ -202,7 +201,9 @@ const Form = (props: IProps) => {
202
201
  languageActions: isDataTranslatable ? languageActions : null,
203
202
  };
204
203
 
205
- return (
204
+ return isLoading ? (
205
+ <Loading />
206
+ ) : (
206
207
  <>
207
208
  <RouteLeavingGuard when={isDirty} action={setRoute} text={modalText} />
208
209
  <MainWrapper
@@ -218,6 +219,7 @@ const Form = (props: IProps) => {
218
219
  pageStatus={status}
219
220
  downArrowMenu={downArrowMenu}
220
221
  isFromEditor={true}
222
+ currentPageID={form.id}
221
223
  >
222
224
  {isDisabled && (
223
225
  <S.NotificationWrapper>
@@ -242,6 +244,7 @@ interface IProps {
242
244
  site: any;
243
245
  currentStructuredData: any;
244
246
  isSaving: boolean;
247
+ isLoading: boolean;
245
248
  siteLanguages: any[];
246
249
  globalLangs: any[];
247
250
  currentSite: any;
@@ -263,6 +266,7 @@ const mapStateToProps = (state: IRootState) => ({
263
266
  site: state.sites.currentSiteInfo,
264
267
  currentStructuredData: state.structuredData.currentStructuredData,
265
268
  isSaving: state.app.isSaving,
269
+ isLoading: state.app.isLoading,
266
270
  lang: state.app.lang,
267
271
  siteLanguages: state.sites.currentSiteLanguages,
268
272
  globalLangs: state.app.globalLangs,
@@ -42,7 +42,7 @@ const Live = (props: ILiveProps): JSX.Element => {
42
42
  .then((items) => {
43
43
  items.forEach((item: IPageLiveStatus) => {
44
44
  const newFilter = {
45
- name: item.id,
45
+ name: item.status,
46
46
  value: item.status,
47
47
  title: item.title,
48
48
  icon: item.status,
@@ -7,6 +7,7 @@ import { IStructuredDataState } from "@ax/containers/StructuredData/reducer";
7
7
  import { ILanguageState } from "@ax/containers/Settings/Languages/reducer";
8
8
  import { IDataPacksState } from "@ax/containers/Settings/DataPacks/reducer";
9
9
  import { IUsersState } from "@ax/containers/Users/reducer";
10
+ import { IGalleryState } from "@ax/containers/Gallery/reducer";
10
11
 
11
12
  export interface IBreadcrumbItem {
12
13
  editorID: number;
@@ -147,6 +148,7 @@ export interface IImage {
147
148
  thumb: string;
148
149
  tags: string[];
149
150
  file: File;
151
+ orientation: string;
150
152
  }
151
153
 
152
154
  export interface IUrlField {
@@ -175,6 +177,7 @@ export interface IRootState {
175
177
  dataPacks: IDataPacksState;
176
178
  social: ISocialState;
177
179
  users: IUsersState;
180
+ gallery: IGalleryState;
178
181
  }
179
182
 
180
183
  export interface IStyledProps {
@@ -618,6 +621,23 @@ export interface IUserEditing {
618
621
  username: string;
619
622
  }
620
623
 
624
+ export interface IGetSiteImages {
625
+ site: number | string;
626
+ page?: number;
627
+ items: number;
628
+ query?: string;
629
+ search?: string;
630
+ more?: boolean;
631
+ }
632
+
633
+ export interface IImageForm {
634
+ id?: number;
635
+ alt: string;
636
+ title: string;
637
+ description: string;
638
+ tags: string[];
639
+ }
640
+
621
641
  export type Field =
622
642
  | "AsyncCheckGroup"
623
643
  | "AsyncSelect"
@@ -1,186 +0,0 @@
1
- import { isReqOk, compressImage } from "@ax/helpers";
2
- import { images, sites } from "@ax/api";
3
-
4
- const SET_DROP_DEPTH = "SET_DROP_DEPTH";
5
- const SET_IN_DROP_ZONE = "SET_IN_DROP_ZONE";
6
- const SET_IS_UPLOADING = "SET_IS_UPLOADING";
7
- const SET_UPLOAD_SUCCESS = "SET_UPLOAD_SUCCESS";
8
- const SET_UPLOAD_ERROR = "SET_UPLOAD_ERROR";
9
- const SET_INIT_FORM = "SET_INIT_FORM";
10
- const SET_FORM_FIELD = "SET_FORM_FIELD";
11
- const THUMB_WIDTH = 128;
12
- const THUMB_HEIGHT = 96;
13
- const MAX_SIZE = 10; // MB
14
-
15
- export const ITEMS_PER_PAGE = 50;
16
-
17
- export const reducer = (prevState: IGalleryStore, action: any): IGalleryStore => {
18
- switch (action.type) {
19
- case SET_DROP_DEPTH:
20
- return { ...prevState, dropDepth: action.payload.dropDepth };
21
- case SET_IN_DROP_ZONE:
22
- return {
23
- ...prevState,
24
- inDropZone: action.payload.inDropZone,
25
- isUploading: false,
26
- isError: false,
27
- isSuccess: false,
28
- errorMsg: "",
29
- };
30
- case SET_IS_UPLOADING:
31
- return { ...prevState, inDropZone: false, isUploading: true };
32
- case SET_UPLOAD_SUCCESS:
33
- return { ...prevState, isUploading: false, isSuccess: true };
34
- case SET_UPLOAD_ERROR:
35
- return { ...prevState, inDropZone: false, isUploading: false, isError: true, errorMsg: action.payload.msg };
36
- case SET_INIT_FORM:
37
- return {
38
- ...prevState,
39
- imageForm: {
40
- id: action.payload.id,
41
- alt: action.payload.alt,
42
- title: action.payload.title,
43
- description: action.payload.description,
44
- tags: action.payload.tags,
45
- },
46
- };
47
- case SET_FORM_FIELD:
48
- return { ...prevState, imageForm: { ...prevState.imageForm, [action.payload.field]: action.payload.value } };
49
- default:
50
- return prevState;
51
- }
52
- };
53
-
54
- export function setDropDepth(dropDepth: number) {
55
- return { type: SET_DROP_DEPTH, payload: { dropDepth } };
56
- }
57
-
58
- export function setInDropZone(inDropZone: boolean) {
59
- return { type: SET_IN_DROP_ZONE, payload: { inDropZone } };
60
- }
61
-
62
- export function setIsUploading() {
63
- return { type: SET_IS_UPLOADING };
64
- }
65
-
66
- export function setUploadSuccess() {
67
- return { type: SET_UPLOAD_SUCCESS };
68
- }
69
-
70
- export function setUploadError(errorMsg = "") {
71
- return { type: SET_UPLOAD_ERROR, payload: { errorMsg } };
72
- }
73
-
74
- export function setInitForm(imageData: IImageForm) {
75
- return {
76
- type: SET_INIT_FORM,
77
- payload: {
78
- id: imageData.id,
79
- title: imageData.title ? imageData.title : "",
80
- alt: imageData.alt ? imageData.alt : "",
81
- description: imageData.description ? imageData.description : "",
82
- tags: imageData.tags ? imageData.tags : [],
83
- },
84
- };
85
- }
86
-
87
- export function setFormField(field: string, value: string) {
88
- return { type: SET_FORM_FIELD, payload: { field, value } };
89
- }
90
-
91
- export const getSiteImages = async (props: IGetSiteImages): Promise<any> => {
92
- const { site, page = 1, items = null, query, search } = props
93
- try {
94
- const result = await sites.getSiteImages(site, page, items, THUMB_WIDTH, THUMB_HEIGHT, query, search);
95
- if (isReqOk(result.status)) {
96
- return result.data.items;
97
- }
98
- } catch (e) {
99
- console.log(e);
100
- }
101
- return false;
102
- };
103
-
104
- export const uploadImage = async (imageFile: File, site: number | string) => {
105
- try {
106
- const imageSize = imageFile.size / (1024 * 1024);
107
- const image = imageSize >= MAX_SIZE ? await compressImage(imageFile, 9999, 9999, MAX_SIZE, false) : imageFile;
108
-
109
- const form = new FormData();
110
- form.append("file", image);
111
- site && form.append("site", JSON.stringify(site));
112
- const result = await images.createImage(form);
113
- if (isReqOk(result.status)) {
114
- return result.data;
115
- }
116
- } catch (e) {
117
- console.log(e);
118
- }
119
- return false;
120
- };
121
-
122
- export const saveImageData = async (imageID: number, imageData: IImageForm) => {
123
- try {
124
- const result = await images.updateImage(imageID, imageData);
125
- if (isReqOk(result.status)) {
126
- return result.data;
127
- }
128
- } catch (e) {
129
- console.log(e);
130
- }
131
- return false;
132
- };
133
-
134
- export const deleteImageData = async (imageID: number) => {
135
- try {
136
- const result = await images.deleteImage(imageID);
137
- if (isReqOk(result.status)) {
138
- return true;
139
- }
140
- } catch (e) {
141
- console.log(e);
142
- }
143
- return false;
144
- };
145
-
146
- export const initialState: IGalleryStore = {
147
- dropDepth: 0,
148
- inDropZone: false,
149
- isUploading: false,
150
- isSuccess: false,
151
- isError: false,
152
- errorMsg: "",
153
- imageForm: {
154
- id: undefined,
155
- alt: "",
156
- title: "",
157
- description: "",
158
- tags: [],
159
- },
160
- };
161
-
162
- interface IImageForm {
163
- id?: number;
164
- alt: string;
165
- title: string;
166
- description: string;
167
- tags: string[];
168
- }
169
-
170
- interface IGalleryStore {
171
- dropDepth: number;
172
- inDropZone: boolean;
173
- isUploading: boolean;
174
- isSuccess: boolean;
175
- isError: boolean;
176
- errorMsg: string;
177
- imageForm: IImageForm;
178
- }
179
-
180
- interface IGetSiteImages {
181
- site: number | string;
182
- page?: number;
183
- items: number | null;
184
- query?: string;
185
- search?: string;
186
- }