@griddo/ax 12.16.0 → 12.17.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/README.md +1 -0
- package/config/griddo-config/index.js +3 -2
- package/package.json +7 -4
- package/public/img/logos/logoGriddoDxp.svg +22 -0
- package/public/img/logos/logoGriddoG.svg +10 -0
- package/src/GlobalStore.tsx +32 -25
- package/src/__tests__/GlobalStore.session.test.tsx +98 -0
- package/src/__tests__/api/global.test.ts +64 -0
- package/src/__tests__/api/session.test.ts +311 -0
- package/src/__tests__/api/sessionRenewal.test.ts +705 -0
- package/src/__tests__/api/utils.test.ts +373 -0
- package/src/__tests__/components/Fields/FileField/FileField.test.tsx +33 -6
- package/src/__tests__/components/FieldsBehavior/FieldsBehavior.test.tsx +5 -3
- package/src/__tests__/components/Login/BrandPalette.test.tsx +145 -0
- package/src/__tests__/components/Login/Login.test.tsx +2 -33
- package/src/__tests__/components/Login/LoginCollapsible.test.tsx +271 -0
- package/src/__tests__/components/Login/LoginDropdownCard.test.tsx +311 -0
- package/src/__tests__/components/Login/LoginFooter.test.tsx +128 -0
- package/src/__tests__/components/Login/LoginGriddoId.test.tsx +213 -0
- package/src/__tests__/components/Login/LoginInlineError.test.tsx +116 -0
- package/src/__tests__/components/Login/RecoveryModal/RecoveryModal.test.tsx +3 -4
- package/src/__tests__/components/SsoDenied/SsoDenied.test.tsx +86 -0
- package/src/__tests__/config/webpackAliases.test.ts +18 -0
- package/src/__tests__/containers/App/reducer.griddoId.test.ts +18 -0
- package/src/__tests__/containers/App/session.test.ts +397 -0
- package/src/__tests__/containers/App/signInOut.test.ts +159 -0
- package/src/__tests__/helpers/griddoId.test.ts +56 -0
- package/src/__tests__/hooks/useShouldBeSaved.test.tsx +78 -0
- package/src/__tests__/locales/loginLocale.test.ts +37 -0
- package/src/__tests__/modules/App/Routing/NavMenu.test.tsx +54 -0
- package/src/__tests__/modules/App/Routing/PrivateRoute.test.tsx +64 -0
- package/src/__tests__/modules/App/Routing/Routing.startup.test.tsx +79 -0
- package/src/__tests__/modules/Login/Login.test.tsx +169 -0
- package/src/__tests__/modules/Login/loginError.uc.test.tsx +294 -0
- package/src/__tests__/modules/Login/signInOut.test.tsx +125 -0
- package/src/__tests__/modules/Redirects/RedirectPanel/RedirectPanel.test.tsx +9 -0
- package/src/__tests__/modules/Redirects/Redirects/Redirects.create.test.tsx +19 -0
- package/src/__tests__/modules/Redirects/Redirects/Redirects.edit.test.tsx +19 -0
- package/src/__tests__/modules/Redirects/Redirects/Redirects.filter.test.tsx +19 -0
- package/src/__tests__/modules/SsoDenied/SsoDenied.test.tsx +30 -0
- package/src/__tests__/routes/publicRoutes.test.ts +36 -0
- package/src/api/global.tsx +24 -1
- package/src/api/session.tsx +197 -0
- package/src/api/sessionRenewal.tsx +114 -0
- package/src/api/utils.tsx +22 -12
- package/src/{helpers/categoryColumns.tsx → components/CategoryCell/buildCategoryColumns.tsx} +3 -2
- package/src/components/Circle/index.tsx +1 -1
- package/src/components/Circle/style.tsx +4 -2
- package/src/components/ErrorPage/index.tsx +1 -1
- package/src/components/ErrorPage/style.tsx +11 -9
- package/src/components/ErrorToast/index.tsx +2 -0
- package/src/{helpers/fields.tsx → components/FieldsBehavior/getFieldByPath.tsx} +1 -1
- package/src/components/FieldsBehavior/index.tsx +3 -1
- package/src/components/Login/LoginFooter/index.tsx +16 -0
- package/src/components/Login/LoginFooter/style.tsx +17 -0
- package/src/components/Login/LoginForm/index.tsx +147 -79
- package/src/components/Login/LoginForm/style.tsx +147 -24
- package/src/components/Login/LoginGriddoId/index.tsx +56 -0
- package/src/components/Login/LoginGriddoId/style.tsx +35 -0
- package/src/components/Login/LoginSSO/index.tsx +4 -7
- package/src/components/Login/LoginSSO/style.tsx +10 -26
- package/src/components/Login/LoginSlider/style.tsx +5 -5
- package/src/components/Login/index.tsx +35 -6
- package/src/components/Login/style.tsx +40 -24
- package/src/components/Notification/index.tsx +3 -1
- package/src/components/SsoDenied/index.tsx +46 -0
- package/src/components/SsoDenied/style.tsx +37 -0
- package/src/components/index.tsx +11 -7
- package/src/containers/App/actions.tsx +114 -6
- package/src/containers/App/interfaces.tsx +2 -2
- package/src/containers/App/reducer.tsx +9 -0
- package/src/containers/Users/actions.tsx +28 -24
- package/src/helpers/griddoId.ts +28 -0
- package/src/helpers/index.tsx +4 -5
- package/src/hooks/forms.tsx +8 -5
- package/src/locales/en-US.ts +13 -0
- package/src/locales/es-ES.ts +13 -0
- package/src/locales/index.ts +9 -1
- package/src/modules/App/Routing/NavMenu/index.tsx +4 -4
- package/src/modules/Content/PageItem/index.tsx +6 -8
- package/src/modules/Login/index.tsx +33 -14
- package/src/modules/SsoDenied/index.tsx +9 -0
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +6 -8
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +9 -11
- package/src/modules/Users/UserEdit/index.tsx +9 -2
- package/src/routes/publicRoutes.tsx +3 -0
- package/src/themes/brandPalette.ts +16 -0
- package/public/img/logos/logoSQY.svg +0 -3
|
@@ -1,25 +1,26 @@
|
|
|
1
|
+
import { global, roles, users } from "@ax/api";
|
|
2
|
+
import { appActions } from "@ax/containers/App";
|
|
3
|
+
import { handleRequest } from "@ax/helpers";
|
|
4
|
+
import type { IActivateRole, ICreatePasswordParams, IGetRoles, IRole, IRootState, IUser } from "@ax/types";
|
|
5
|
+
|
|
1
6
|
import type { Dispatch } from "redux";
|
|
7
|
+
|
|
2
8
|
import {
|
|
3
|
-
SET_USERS,
|
|
4
|
-
SET_USER_FORM,
|
|
5
|
-
SET_CURRENT_USER,
|
|
6
|
-
SET_ROLES,
|
|
7
9
|
SET_CURRENT_PERMISSIONS,
|
|
10
|
+
SET_CURRENT_USER,
|
|
8
11
|
SET_GLOBAL_PERMISSIONS,
|
|
12
|
+
SET_ROLES,
|
|
13
|
+
SET_USER_FORM,
|
|
14
|
+
SET_USERS,
|
|
9
15
|
} from "./constants";
|
|
10
|
-
|
|
11
16
|
import type {
|
|
12
|
-
ISetUsers,
|
|
13
|
-
ISetCurrentUser,
|
|
14
|
-
ISetUserForm,
|
|
15
|
-
ISetRoles,
|
|
16
17
|
ISetCurrentPermissions,
|
|
18
|
+
ISetCurrentUser,
|
|
17
19
|
ISetGlobalPermissions,
|
|
20
|
+
ISetRoles,
|
|
21
|
+
ISetUserForm,
|
|
22
|
+
ISetUsers,
|
|
18
23
|
} from "./interfaces";
|
|
19
|
-
import type { ICreatePasswordParams, IActivateRole, IGetRoles, IRole, IUser, IRootState } from "@ax/types";
|
|
20
|
-
import { global, users, roles } from "@ax/api";
|
|
21
|
-
import { appActions } from "@ax/containers/App";
|
|
22
|
-
import { handleRequest, isReqOk } from "@ax/helpers";
|
|
23
24
|
|
|
24
25
|
function setUsers(users: IUser[]): ISetUsers {
|
|
25
26
|
return { type: SET_USERS, payload: { users } };
|
|
@@ -138,7 +139,10 @@ function updatePassword(id: number | null, data: any): (dispatch: Dispatch) => P
|
|
|
138
139
|
const callback = async () => users.updatePassword(id, data);
|
|
139
140
|
|
|
140
141
|
const responseActions = {
|
|
141
|
-
handleSuccess: (response: any) =>
|
|
142
|
+
handleSuccess: (response: any) => {
|
|
143
|
+
// Cambiar la propia contraseña revoca todas las sesiones: la API devuelve el par nuevo.
|
|
144
|
+
if (response?.token) appActions.applySession(response.token, response.refreshToken)(dispatch);
|
|
145
|
+
},
|
|
142
146
|
handleError: (response: any) => appActions.handleError(response)(dispatch),
|
|
143
147
|
};
|
|
144
148
|
|
|
@@ -178,7 +182,7 @@ function createPassword(
|
|
|
178
182
|
|
|
179
183
|
const responseActions = {
|
|
180
184
|
handleSuccess: async (response: any) => {
|
|
181
|
-
|
|
185
|
+
appActions.applySession(response.token, response.refreshToken)(dispatch);
|
|
182
186
|
await getRoles({ siteId: "global" }, response.token, false)(dispatch);
|
|
183
187
|
await getUser(id, response.token, false)(dispatch, getState);
|
|
184
188
|
},
|
|
@@ -357,18 +361,18 @@ function getUserCurrentPermissions(
|
|
|
357
361
|
}
|
|
358
362
|
|
|
359
363
|
export {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
updatePassword,
|
|
363
|
-
getUser,
|
|
364
|
-
setUserForm,
|
|
364
|
+
activateRoles,
|
|
365
|
+
createPassword,
|
|
365
366
|
createUser,
|
|
366
|
-
setCurrentUser,
|
|
367
367
|
deleteUser,
|
|
368
|
-
resendInvitation,
|
|
369
368
|
getRoles,
|
|
370
|
-
|
|
371
|
-
createPassword,
|
|
369
|
+
getUser,
|
|
372
370
|
getUserCurrentPermissions,
|
|
371
|
+
getUsers,
|
|
373
372
|
removeUserFromSite,
|
|
373
|
+
resendInvitation,
|
|
374
|
+
setCurrentUser,
|
|
375
|
+
setUserForm,
|
|
376
|
+
updatePassword,
|
|
377
|
+
updateUser,
|
|
374
378
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Tope del email que viaja como `login_hint`, en caracteres. Es de forma, como el de la API (254 bytes). */
|
|
2
|
+
export const MAX_LOGIN_HINT_LENGTH = 254;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* URL de arranque del login con `auth.griddo.io` (`GET /sso/start` de la API). Si el email escrito en el formulario,
|
|
6
|
+
* recortado, contiene `@` y mide como máximo {@link MAX_LOGIN_HINT_LENGTH} caracteres, lo añade como `login_hint`
|
|
7
|
+
* codificado para que la app de login lo prerrellene; en otro caso devuelve la URL sin query, como siempre.
|
|
8
|
+
*
|
|
9
|
+
* No valida la gramática del email (esa regla es de la app de login) ni cambia mayúsculas o espacios interiores. El
|
|
10
|
+
* tope evita que un pegado enorme produzca una URL que el servidor rechace (414/431) y deje sin SSO a la persona.
|
|
11
|
+
*
|
|
12
|
+
* @param apiUrl - URL base de la API (sin barra final).
|
|
13
|
+
* @param email - Texto del campo de email, tal cual lo escribió la persona.
|
|
14
|
+
* @returns `${apiUrl}/sso/start`, con `?login_hint=…` si el email es aceptable.
|
|
15
|
+
*/
|
|
16
|
+
export const buildGriddoIdStartUrl = (apiUrl: string, email: string): string => {
|
|
17
|
+
const startUrl = `${apiUrl}/sso/start`;
|
|
18
|
+
const hint = email.trim();
|
|
19
|
+
|
|
20
|
+
if (!hint.includes("@") || hint.length > MAX_LOGIN_HINT_LENGTH) return startUrl;
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
return `${startUrl}?login_hint=${encodeURIComponent(hint)}`;
|
|
24
|
+
} catch {
|
|
25
|
+
// Un sustituto suelto hace lanzar `URIError`: sin hint, pero el clic nunca se rompe.
|
|
26
|
+
return startUrl;
|
|
27
|
+
}
|
|
28
|
+
};
|
package/src/helpers/index.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { arrayInsert, isEmptyArray, moveArrayElement } from "./arrays";
|
|
2
|
-
import { buildCategoryColumns } from "./categoryColumns";
|
|
3
2
|
import {
|
|
4
3
|
areAllComponentsEmpty,
|
|
5
4
|
areEqual,
|
|
@@ -25,9 +24,9 @@ import {
|
|
|
25
24
|
stringToDate,
|
|
26
25
|
} from "./dates";
|
|
27
26
|
import { isDevelopment } from "./environment";
|
|
28
|
-
import { getFieldByPath } from "./fields";
|
|
29
27
|
import { getFileIcon, getNewBreadcrumb, updatePropertyById } from "./files";
|
|
30
28
|
import { protectFormKeys } from "./forms";
|
|
29
|
+
import { buildGriddoIdStartUrl, MAX_LOGIN_HINT_LENGTH } from "./griddoId";
|
|
31
30
|
import { compressImage, imageResizeCropAndCompress } from "./imageResize";
|
|
32
31
|
import { formatBytes, getCroppedImg, getImageFromHtml, getImageFromIFrame, imageToBase64 } from "./images";
|
|
33
32
|
import {
|
|
@@ -118,11 +117,12 @@ export {
|
|
|
118
117
|
areEqualDates,
|
|
119
118
|
areEquals,
|
|
120
119
|
arrayInsert,
|
|
121
|
-
|
|
120
|
+
buildGriddoIdStartUrl,
|
|
122
121
|
camelize,
|
|
123
122
|
capitalize,
|
|
124
123
|
compressImage,
|
|
125
124
|
copyTextToClipboard,
|
|
125
|
+
DEV_NOW,
|
|
126
126
|
dateToString,
|
|
127
127
|
decodeEntities,
|
|
128
128
|
deepClone,
|
|
@@ -150,7 +150,6 @@ export {
|
|
|
150
150
|
getDefaultTemplate,
|
|
151
151
|
getDefaultTheme,
|
|
152
152
|
getDisplayName,
|
|
153
|
-
getFieldByPath,
|
|
154
153
|
getFileExtension,
|
|
155
154
|
getFileIcon,
|
|
156
155
|
getFormattedDateWithTimezone,
|
|
@@ -177,7 +176,6 @@ export {
|
|
|
177
176
|
getSchemaFormCategories,
|
|
178
177
|
getSchemaThumbnails,
|
|
179
178
|
getSchemaType,
|
|
180
|
-
DEV_NOW,
|
|
181
179
|
getShareTokenInfo,
|
|
182
180
|
getSlugFromUrl,
|
|
183
181
|
getStringifyDateRange,
|
|
@@ -208,6 +206,7 @@ export {
|
|
|
208
206
|
isTemplateExcludedFromTheme,
|
|
209
207
|
isValidDate,
|
|
210
208
|
isValidDateRange,
|
|
209
|
+
MAX_LOGIN_HINT_LENGTH,
|
|
211
210
|
moveArrayElement,
|
|
212
211
|
parseTheme,
|
|
213
212
|
protectFormKeys,
|
package/src/hooks/forms.tsx
CHANGED
|
@@ -200,12 +200,15 @@ const useShouldBeSaved = (form: Record<string, any> | null | undefined, debug =
|
|
|
200
200
|
const [isDirty, setIsDirtyState] = useState(false);
|
|
201
201
|
const originalRef = useRef<Record<string, any>>();
|
|
202
202
|
|
|
203
|
-
// Intercept setIsDirty to update baseline when saved
|
|
203
|
+
// Intercept setIsDirty to update baseline when saved. `baseline` fija la referencia explícita (p. ej. el
|
|
204
|
+
// formulario ya sincronizado con la respuesta del servidor); sin ella se usa el `form` del render que creó este
|
|
205
|
+
// callback, que tras un guardado asíncrono puede estar desfasado (de ahí un «Update User» que no se apaga).
|
|
204
206
|
const setIsDirty = useCallback(
|
|
205
|
-
(value: boolean) => {
|
|
207
|
+
(value: boolean, baseline?: Record<string, any>) => {
|
|
206
208
|
setIsDirtyState(value);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
+
const base = baseline ?? form;
|
|
210
|
+
if (value === false && base) {
|
|
211
|
+
originalRef.current = deepClone(base);
|
|
209
212
|
}
|
|
210
213
|
},
|
|
211
214
|
[form],
|
|
@@ -252,4 +255,4 @@ const useShouldBeSaved = (form: Record<string, any> | null | undefined, debug =
|
|
|
252
255
|
return { isDirty, setIsDirty };
|
|
253
256
|
};
|
|
254
257
|
|
|
255
|
-
export { useDebounce, useDebouncedCallback, useEqualStructured,
|
|
258
|
+
export { useDebounce, useDebouncedCallback, useEqualStructured, useIsDirty, usePrevious, useShouldBeSaved };
|
package/src/locales/en-US.ts
CHANGED
|
@@ -28,6 +28,19 @@ export const enUS = {
|
|
|
28
28
|
activating: "activating",
|
|
29
29
|
typeSomething: "Type something",
|
|
30
30
|
},
|
|
31
|
+
login: {
|
|
32
|
+
griddoIdButton: "Sign in with Griddo",
|
|
33
|
+
griddoIdText: "To start using Griddo, sign in with your Griddo account.",
|
|
34
|
+
welcome: "Welcome",
|
|
35
|
+
startPublishing: "Login to start publishing",
|
|
36
|
+
slogan: "Edit. See. Publish",
|
|
37
|
+
emailPasswordText: "Login with email and password",
|
|
38
|
+
submit: "Login",
|
|
39
|
+
submitting: "Sending",
|
|
40
|
+
emailPasswordToggle: "Login with email and password",
|
|
41
|
+
deniedTitle: "You don't have access to this instance",
|
|
42
|
+
switchAccount: "Sign in with another account",
|
|
43
|
+
},
|
|
31
44
|
fields: {
|
|
32
45
|
tags: {
|
|
33
46
|
helptext: "Type a tag and press enter to create it",
|
package/src/locales/es-ES.ts
CHANGED
|
@@ -28,6 +28,19 @@ export const esES = {
|
|
|
28
28
|
activating: "activando",
|
|
29
29
|
typeSomething: "Escribe algo",
|
|
30
30
|
},
|
|
31
|
+
login: {
|
|
32
|
+
griddoIdButton: "Sign in with Griddo",
|
|
33
|
+
griddoIdText: "Para empezar a usar Griddo, entra con tu cuenta de Griddo.",
|
|
34
|
+
welcome: "Welcome",
|
|
35
|
+
startPublishing: "Login to start publishing",
|
|
36
|
+
slogan: "Edit. See. Publish",
|
|
37
|
+
emailPasswordText: "Login with email and password",
|
|
38
|
+
submit: "Iniciar sesión",
|
|
39
|
+
submitting: "Enviando",
|
|
40
|
+
emailPasswordToggle: "Iniciar sesión con email y contraseña",
|
|
41
|
+
deniedTitle: "No tienes acceso a esta instancia",
|
|
42
|
+
switchAccount: "Entrar con otra cuenta",
|
|
43
|
+
},
|
|
31
44
|
fields: {
|
|
32
45
|
tags: {
|
|
33
46
|
helptext: "Escribe una etiqueta y pulsa enter para crearla",
|
package/src/locales/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ItemLabel } from "@ax/constants";
|
|
|
3
3
|
import { enUS } from "./en-US";
|
|
4
4
|
import { esES } from "./es-ES";
|
|
5
5
|
|
|
6
|
-
const currentLocale = "en-US";
|
|
6
|
+
const currentLocale = "en-US" as const;
|
|
7
7
|
|
|
8
8
|
const allLocales = {
|
|
9
9
|
"en-US": enUS,
|
|
@@ -34,4 +34,12 @@ export function toTitleCase(text: string) {
|
|
|
34
34
|
.join(" ");
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Textos del login. Como el resto de AX, siempre en el idioma fijo `currentLocale` (inglés): no se detecta el idioma del
|
|
39
|
+
* navegador. El bloque `login` de `es-ES` queda sin uso.
|
|
40
|
+
*/
|
|
41
|
+
export function getLoginLocale() {
|
|
42
|
+
return allLocales[currentLocale].login;
|
|
43
|
+
}
|
|
44
|
+
|
|
37
45
|
export const LOCALE = allLocales[currentLocale as keyof typeof allLocales];
|
|
@@ -19,7 +19,7 @@ const NavMenu = (props: IProps) => {
|
|
|
19
19
|
const {
|
|
20
20
|
location,
|
|
21
21
|
setHistoryPush,
|
|
22
|
-
|
|
22
|
+
logoutAndEndCentralSession,
|
|
23
23
|
currentSiteInfo,
|
|
24
24
|
siteLanguages,
|
|
25
25
|
lang,
|
|
@@ -113,7 +113,7 @@ const NavMenu = (props: IProps) => {
|
|
|
113
113
|
name: "Logout",
|
|
114
114
|
icon: "Power",
|
|
115
115
|
path: "",
|
|
116
|
-
onClick:
|
|
116
|
+
onClick: logoutAndEndCentralSession,
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
const profileRoute = {
|
|
@@ -219,7 +219,7 @@ const NavMenu = (props: IProps) => {
|
|
|
219
219
|
};
|
|
220
220
|
|
|
221
221
|
interface IDispatchProps {
|
|
222
|
-
|
|
222
|
+
logoutAndEndCentralSession(): void;
|
|
223
223
|
setHistoryPush(path: string): void;
|
|
224
224
|
}
|
|
225
225
|
|
|
@@ -258,7 +258,7 @@ const mapStateToProps = (state: IRootState) => ({
|
|
|
258
258
|
type IProps = INavMenuProps & IDispatchProps & RouteComponentProps;
|
|
259
259
|
|
|
260
260
|
const mapDispatchToProps = {
|
|
261
|
-
|
|
261
|
+
logoutAndEndCentralSession: appActions.logoutAndEndCentralSession,
|
|
262
262
|
setHistoryPush: appActions.setHistoryPush,
|
|
263
263
|
};
|
|
264
264
|
|
|
@@ -2,6 +2,7 @@ import { type MouseEvent as ReactMouseEvent, useState } from "react";
|
|
|
2
2
|
import { connect } from "react-redux";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
buildCategoryColumns,
|
|
5
6
|
CheckField,
|
|
6
7
|
ContextMenu,
|
|
7
8
|
Flag,
|
|
@@ -15,13 +16,7 @@ import {
|
|
|
15
16
|
import { appActions } from "@ax/containers/App";
|
|
16
17
|
import { pageEditorActions } from "@ax/containers/PageEditor";
|
|
17
18
|
import { pageStatus } from "@ax/containers/PageEditor/interfaces";
|
|
18
|
-
import {
|
|
19
|
-
buildCategoryColumns,
|
|
20
|
-
getHumanLastModifiedDate,
|
|
21
|
-
getScheduleFormatDate,
|
|
22
|
-
getTemplateDisplayName,
|
|
23
|
-
slugify,
|
|
24
|
-
} from "@ax/helpers";
|
|
19
|
+
import { getHumanLastModifiedDate, getScheduleFormatDate, getTemplateDisplayName, slugify } from "@ax/helpers";
|
|
25
20
|
import { useContextMenu, useModals, usePermissionsForPage } from "@ax/hooks";
|
|
26
21
|
import type {
|
|
27
22
|
ICheck,
|
|
@@ -460,7 +455,10 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
|
|
|
460
455
|
|
|
461
456
|
menuOptions = page.haveDraftPage ? [...editOptions, ...menuOptions] : menuOptions;
|
|
462
457
|
|
|
463
|
-
menuOptions =
|
|
458
|
+
menuOptions =
|
|
459
|
+
page.liveStatus?.status === pageStatus.PUBLISHED
|
|
460
|
+
? [viewOption, newTabOption, ...menuOptions]
|
|
461
|
+
: [newTabOption, ...menuOptions];
|
|
464
462
|
|
|
465
463
|
const GlobalMark = () => (
|
|
466
464
|
<Tooltip content="Global Page">
|
|
@@ -2,28 +2,28 @@ import { useEffect, useState } from "react";
|
|
|
2
2
|
import { connect } from "react-redux";
|
|
3
3
|
import { useParams } from "react-router-dom";
|
|
4
4
|
|
|
5
|
-
import type { IRootState } from "@ax/types";
|
|
6
|
-
import { appActions } from "@ax/containers/App";
|
|
7
5
|
import { Login } from "@ax/components";
|
|
6
|
+
import type { ILoginSubmitContext } from "@ax/components/Login/LoginForm";
|
|
7
|
+
import { appActions } from "@ax/containers/App";
|
|
8
8
|
import type { IGlobalSettings } from "@ax/containers/App/reducer";
|
|
9
|
+
import { buildGriddoIdStartUrl } from "@ax/helpers";
|
|
10
|
+
import type { IRootState } from "@ax/types";
|
|
11
|
+
|
|
9
12
|
import { errorText } from "./constants";
|
|
10
13
|
|
|
11
14
|
const LoginModule = (props: IProps) => {
|
|
12
15
|
const { isLoggingIn, globalSettings, login, loginSSO, resetError, getGlobalSettings, setHistoryPush } = props;
|
|
13
16
|
|
|
14
17
|
const { petitionId } = useParams<{ petitionId?: string }>();
|
|
15
|
-
|
|
18
|
+
// `<código>` o `<código>+<email>`: el email puede llevar «+», así que solo se corta en el primero.
|
|
19
|
+
const [petitionCode, ...petitionEmail] = petitionId?.split("+") ?? [];
|
|
16
20
|
|
|
17
|
-
const getErrorMsg = (
|
|
18
|
-
if (petitionArray.length > 1) {
|
|
19
|
-
return errorText[petitionArray[0]].replace("{email}", petitionArray[1]);
|
|
20
|
-
} else {
|
|
21
|
-
return errorText[petitionArray[0]];
|
|
22
|
-
}
|
|
23
|
-
};
|
|
21
|
+
const getErrorMsg = (code: string, email: string) => errorText[code].replace("{email}", email);
|
|
24
22
|
|
|
25
23
|
const errorSSO =
|
|
26
|
-
|
|
24
|
+
petitionId && Object.keys(errorText).includes(petitionCode)
|
|
25
|
+
? getErrorMsg(petitionCode, petitionEmail.join("+"))
|
|
26
|
+
: null;
|
|
27
27
|
|
|
28
28
|
const initState = {
|
|
29
29
|
email: "",
|
|
@@ -57,9 +57,14 @@ const LoginModule = (props: IProps) => {
|
|
|
57
57
|
getGlobalSettings();
|
|
58
58
|
}, [getGlobalSettings]);
|
|
59
59
|
|
|
60
|
-
const handleSubmit = async (e: React.FormEvent<HTMLFormElement
|
|
60
|
+
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>, context?: ILoginSubmitContext) => {
|
|
61
61
|
e.preventDefault();
|
|
62
|
-
const isLogged = await login({
|
|
62
|
+
const isLogged = await login({
|
|
63
|
+
email: state.email,
|
|
64
|
+
password: state.password,
|
|
65
|
+
rememberMe: state.rememberMe,
|
|
66
|
+
onLostPassword: context?.onLostPassword,
|
|
67
|
+
});
|
|
63
68
|
if (isLogged) {
|
|
64
69
|
setIsSuccess(true);
|
|
65
70
|
}
|
|
@@ -72,6 +77,13 @@ const LoginModule = (props: IProps) => {
|
|
|
72
77
|
}
|
|
73
78
|
};
|
|
74
79
|
|
|
80
|
+
// Navegación completa a la API: arranca el flujo OIDC (state, nonce y PKCE los genera la API). Lleva el email
|
|
81
|
+
// escrito como `login_hint`; la contraseña nunca se lee.
|
|
82
|
+
const handleClickGriddoId = () =>
|
|
83
|
+
window.location.assign(
|
|
84
|
+
buildGriddoIdStartUrl(`${process.env.GRIDDO_API_URL || process.env.REACT_APP_API_ENDPOINT}`, state.email),
|
|
85
|
+
);
|
|
86
|
+
|
|
75
87
|
const _handleEmail = (email: string) => {
|
|
76
88
|
resetError();
|
|
77
89
|
setState((prev) => ({ ...prev, email }));
|
|
@@ -103,6 +115,7 @@ const LoginModule = (props: IProps) => {
|
|
|
103
115
|
isLoginSuccess={isSuccess}
|
|
104
116
|
handleLoginSuccess={handleLoginSuccess}
|
|
105
117
|
handleSSO={handleClickSSO}
|
|
118
|
+
handleGriddoId={handleClickGriddoId}
|
|
106
119
|
errorSSO={errorSSO}
|
|
107
120
|
/>
|
|
108
121
|
);
|
|
@@ -111,7 +124,13 @@ const LoginModule = (props: IProps) => {
|
|
|
111
124
|
interface IProps {
|
|
112
125
|
isLoggingIn: boolean;
|
|
113
126
|
globalSettings: IGlobalSettings;
|
|
114
|
-
login(loginData: {
|
|
127
|
+
login(loginData: {
|
|
128
|
+
email?: string;
|
|
129
|
+
password?: string;
|
|
130
|
+
rememberMe?: boolean;
|
|
131
|
+
petitionId?: string;
|
|
132
|
+
onLostPassword?: () => void;
|
|
133
|
+
}): Promise<boolean>;
|
|
115
134
|
loginSSO(): Promise<string | null>;
|
|
116
135
|
resetError(): void;
|
|
117
136
|
getGlobalSettings(): void;
|
|
@@ -2,6 +2,7 @@ import { type MouseEvent as ReactMouseEvent, useState } from "react";
|
|
|
2
2
|
import { connect } from "react-redux";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
buildCategoryColumns,
|
|
5
6
|
CheckField,
|
|
6
7
|
ContextMenu,
|
|
7
8
|
ElementsTooltip,
|
|
@@ -15,13 +16,7 @@ import {
|
|
|
15
16
|
import { appActions } from "@ax/containers/App";
|
|
16
17
|
import { pageEditorActions } from "@ax/containers/PageEditor";
|
|
17
18
|
import { type ISetCurrentPageIDAction, pageStatus } from "@ax/containers/PageEditor/interfaces";
|
|
18
|
-
import {
|
|
19
|
-
buildCategoryColumns,
|
|
20
|
-
getHumanLastModifiedDate,
|
|
21
|
-
getScheduleFormatDate,
|
|
22
|
-
getStructuredDataTitle,
|
|
23
|
-
trimText,
|
|
24
|
-
} from "@ax/helpers";
|
|
19
|
+
import { getHumanLastModifiedDate, getScheduleFormatDate, getStructuredDataTitle, trimText } from "@ax/helpers";
|
|
25
20
|
import { useContextMenu, useModals, usePermissionsForPage } from "@ax/hooks";
|
|
26
21
|
import type {
|
|
27
22
|
IAvailableSites,
|
|
@@ -320,7 +315,10 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
|
|
|
320
315
|
|
|
321
316
|
menuOptions = globalPage.haveDraftPage ? [...editOptions, ...menuOptions] : menuOptions;
|
|
322
317
|
|
|
323
|
-
menuOptions =
|
|
318
|
+
menuOptions =
|
|
319
|
+
globalPage.liveStatus?.status === pageStatus.PUBLISHED
|
|
320
|
+
? [viewOption, newTabOption, ...menuOptions]
|
|
321
|
+
: [newTabOption, ...menuOptions];
|
|
324
322
|
|
|
325
323
|
const isTranslated = globalPage.pageLanguages.length > 1;
|
|
326
324
|
|
|
@@ -2,6 +2,7 @@ import { type MouseEvent as ReactMouseEvent, useState } from "react";
|
|
|
2
2
|
import { connect } from "react-redux";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
buildCategoryColumns,
|
|
5
6
|
CheckField,
|
|
6
7
|
ContextMenu,
|
|
7
8
|
Flag,
|
|
@@ -13,12 +14,7 @@ import {
|
|
|
13
14
|
} from "@ax/components";
|
|
14
15
|
import { appActions } from "@ax/containers/App";
|
|
15
16
|
import { structuredDataActions } from "@ax/containers/StructuredData";
|
|
16
|
-
import {
|
|
17
|
-
buildCategoryColumns,
|
|
18
|
-
getActivatedDataPacksIds,
|
|
19
|
-
getHumanLastModifiedDate,
|
|
20
|
-
getScheduleFormatDate,
|
|
21
|
-
} from "@ax/helpers";
|
|
17
|
+
import { getActivatedDataPacksIds, getHumanLastModifiedDate, getScheduleFormatDate } from "@ax/helpers";
|
|
22
18
|
import { useContextMenu, useModal, usePermissionsForPage } from "@ax/hooks";
|
|
23
19
|
import type {
|
|
24
20
|
ICheck,
|
|
@@ -220,11 +216,13 @@ const StructuredDataItem = (props: IStructuredDataItemProps): JSX.Element => {
|
|
|
220
216
|
"Not translatable"
|
|
221
217
|
);
|
|
222
218
|
|
|
223
|
-
const menuOptions = [
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
219
|
+
const menuOptions = [
|
|
220
|
+
{
|
|
221
|
+
label: "Open in new tab",
|
|
222
|
+
icon: "openOutside",
|
|
223
|
+
action: handleOpenInNewTab,
|
|
224
|
+
},
|
|
225
|
+
];
|
|
228
226
|
|
|
229
227
|
if (!isDisabled && isEditable && isAllowedTo.duplicatePages) {
|
|
230
228
|
menuOptions.push({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
2
|
import { connect } from "react-redux";
|
|
3
3
|
|
|
4
4
|
import { Loading, MainWrapper, Modal, Toast } from "@ax/components";
|
|
@@ -27,11 +27,18 @@ const UserEdit = (props: IProps) => {
|
|
|
27
27
|
|
|
28
28
|
const { isDirty, setIsDirty } = useShouldBeSaved(form);
|
|
29
29
|
|
|
30
|
+
// Último form pintado: `handleSave` se queda con el del render del clic, y tras el `await` ya está desfasado.
|
|
31
|
+
const latestForm = useRef(form);
|
|
32
|
+
latestForm.current = form;
|
|
33
|
+
|
|
34
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: solo debe reaccionar al cambio de `user`
|
|
30
35
|
useEffect(() => {
|
|
31
36
|
const { timezone } = user;
|
|
32
37
|
const initForm = { ...user };
|
|
33
38
|
if (!timezone) initForm.timezone = "Europe/Madrid";
|
|
34
39
|
setForm(initForm);
|
|
40
|
+
// El form se sincroniza con el usuario del store (p. ej. la respuesta del guardado): esa es la nueva referencia.
|
|
41
|
+
setIsDirty(false, initForm);
|
|
35
42
|
}, [user]);
|
|
36
43
|
|
|
37
44
|
const handleSave = async () => {
|
|
@@ -40,7 +47,7 @@ const UserEdit = (props: IProps) => {
|
|
|
40
47
|
}
|
|
41
48
|
const updated = form.id ? await updateUser(form.id, form, false) : false;
|
|
42
49
|
if (updated) {
|
|
43
|
-
setIsDirty(false);
|
|
50
|
+
setIsDirty(false, latestForm.current);
|
|
44
51
|
toggleToast();
|
|
45
52
|
}
|
|
46
53
|
};
|
|
@@ -2,10 +2,13 @@ import CreatePass from "./../modules/CreatePass";
|
|
|
2
2
|
import Login from "./../modules/Login";
|
|
3
3
|
import PublicPreview from "./../modules/PublicPreview";
|
|
4
4
|
import ResetPass from "./../modules/ResetPass";
|
|
5
|
+
import SsoDenied from "./../modules/SsoDenied";
|
|
5
6
|
|
|
6
7
|
const publicRoutes = [
|
|
7
8
|
{ path: "/login/:petitionId", component: Login, name: "Login", hideNav: true },
|
|
8
9
|
{ path: "/login", component: Login, name: "Login", hideNav: true },
|
|
10
|
+
// Fuera de `/login/*`: `/login/:petitionId` capturaría el segmento como uuid y llamaría a `POST /login_check`.
|
|
11
|
+
{ path: "/sso-denied", component: SsoDenied, name: "SSO denied", hideNav: true },
|
|
9
12
|
{ path: "/new-password/:id/:token", component: ResetPass, name: "Reset Password", hideNav: true },
|
|
10
13
|
{ path: "/set-password/:id/:token", component: CreatePass, name: "Create Password", hideNav: true },
|
|
11
14
|
{ path: "/page-preview/:id/:entity/:token?", component: PublicPreview, name: "Preview", hideNav: true },
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paleta de marca de las pantallas de acceso (login, `SsoDenied`, `ErrorPage`), según el Figma «Login wow 2».
|
|
3
|
+
* Fuente única: `Login/style`, `Circle` y `ErrorPage` la importan en vez de repetir literales.
|
|
4
|
+
*/
|
|
5
|
+
export const BRAND_PALETTE = {
|
|
6
|
+
/** Fondo de la columna izquierda y de `ErrorPage`. */
|
|
7
|
+
navy: "#001B3C",
|
|
8
|
+
/** Fondo de los controles sobre el azul de marca (botón desplegable del login). */
|
|
9
|
+
navyControl: "#022958",
|
|
10
|
+
/** Blur/halo de marca (sustituye al amarillo `#FBE15C`). */
|
|
11
|
+
cyan: "#3CC3DD",
|
|
12
|
+
/** Halo de la columna izquierda (Figma `--turquoise`). */
|
|
13
|
+
turquoise: "#40E0D0",
|
|
14
|
+
/** Segundo blur de la columna derecha. */
|
|
15
|
+
purple: "#A950CF",
|
|
16
|
+
} as const;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path d="M20 9.99997C20 15.5228 15.5229 20 10 20C4.47712 20 0 15.5228 0 9.99997C0 4.4771 4.47712 0 10 0C15.5229 0 20 4.4771 20 9.99997ZM12.1697 15.1504C12.1548 15.299 12.244 15.3734 12.3926 15.3734H14.3096C14.4582 15.3734 14.5326 15.299 14.5326 15.1504V11.3907C14.5326 11.2421 14.4434 11.1679 14.3096 11.1679H12.0954C11.9616 11.1679 11.8724 11.2421 11.8724 11.3907V11.6434C11.8724 11.6434 11.5753 13.0254 9.86629 13.0254C9.22724 13.0254 8.79624 12.6835 8.79624 12.2378C8.79624 10.93 14.3245 11.4947 14.3245 7.86866C14.3245 5.9665 12.9424 4.61419 10.6984 4.61419C9.46504 4.61419 8.64769 4.98576 8.12758 5.50581L8.18701 4.92626C8.20185 4.77765 8.11267 4.70331 7.96405 4.70331H6.04704C5.89842 4.70331 5.82415 4.77765 5.82415 4.92626V8.68601C5.82415 8.83462 5.91327 8.90896 6.04704 8.90896H8.26128C8.39506 8.90896 8.48417 8.83462 8.48417 8.68601V8.44828C8.48417 7.85382 9.03404 7.12566 10.2972 7.12566C10.966 7.12566 11.3523 7.40798 11.3523 7.86866C11.3523 9.48851 5.46749 8.67117 5.46749 12.3269C5.46749 13.8872 6.52257 15.4773 9.12322 15.4773C11.0997 15.4773 12.1697 14.4223 12.1994 14.4223L12.1697 15.1504Z" fill="white"/>
|
|
3
|
-
</svg>
|