@dexteel/mesf-core 7.10.1 → 7.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.
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "7.10.1"
2
+ ".": "7.11.0"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [7.11.0](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v7.10.1...@dexteel/mesf-core-v7.11.0) (2026-01-13)
4
+
5
+
6
+ ### Features
7
+
8
+ * **auth:** Enhance login flow with error handling and redirect support ([3015688](https://github.com/dexteel/mesf-core-frontend/commit/301568807376ed71de3198fb34c3702058617c2d))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **button-with-loading:** Difference isLoading and disabled. ([62642aa](https://github.com/dexteel/mesf-core-frontend/commit/62642aa289676460011ff895f1fbd8a222440254))
14
+
3
15
  ## [7.10.1](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v7.10.0...@dexteel/mesf-core-v7.10.1) (2025-12-30)
4
16
 
5
17
 
@@ -1,3 +1,3 @@
1
1
  import React from "react";
2
2
  import { LoginParams } from "./models/login.models";
3
- export declare function Login({ authConfig }: LoginParams): React.JSX.Element;
3
+ export declare function Login({ authConfig, initialError }: LoginParams): React.JSX.Element;
@@ -2,6 +2,7 @@ import { AuthConfig } from "../AuthProvider";
2
2
  export type LoginParams = {
3
3
  setToken?: Function;
4
4
  authConfig: AuthConfig;
5
+ initialError?: string;
5
6
  };
6
7
  type Permission = string;
7
8
  export type UserMESData = {
package/dist/index.esm.js CHANGED
@@ -7271,26 +7271,44 @@ var LoginWithAzureAD = function (_a) {
7271
7271
  };
7272
7272
 
7273
7273
  function Login(_a) {
7274
- var authConfig = _a.authConfig;
7274
+ var authConfig = _a.authConfig, initialError = _a.initialError;
7275
7275
  var params = useRef(new URL(document.location).searchParams);
7276
7276
  var _b = useState(false), open = _b[0], setOpen = _b[1];
7277
7277
  var _c = useState(""), message = _c[0], setMessage = _c[1];
7278
+ var _d = useState("info"), severity = _d[0], setSeverity = _d[1];
7278
7279
  var useEmailAndPassword = get(authConfig, "useEmailAndPassword", true);
7279
7280
  var useAzureAD = get(authConfig, "useAzureAD", false);
7280
7281
  var useWindowsAuth = get(authConfig, "useWindowsAuth", false);
7281
7282
  var guestIsEnabled = get(authConfig, "guestIsEnabled", false);
7283
+ var getBase = function () { var _a; return ((_a = document.getElementsByTagName("base")[0]) === null || _a === void 0 ? void 0 : _a.getAttribute("href")) || "/"; };
7282
7284
  var handleClose = function () {
7283
7285
  setOpen(false);
7284
- params.current.delete("message");
7285
- var newUrl = window.location.origin + "?" + params.current.toString();
7286
+ // Read current URL params (not the ref) to preserve redirectTo
7287
+ var currentParams = new URL(document.location).searchParams;
7288
+ currentParams.delete("message");
7289
+ currentParams.delete("error");
7290
+ var base = getBase();
7291
+ var queryString = currentParams.toString();
7292
+ var newUrl = "".concat(window.location.origin).concat(base).concat(queryString ? "?".concat(queryString) : "");
7286
7293
  window.history.replaceState({ path: newUrl }, "", newUrl);
7287
7294
  };
7288
7295
  useEffect(function () {
7289
- if (params.current.has("message")) {
7296
+ if (initialError) {
7297
+ setMessage(initialError);
7298
+ setSeverity("error");
7299
+ setOpen(true);
7300
+ }
7301
+ else if (params.current.has("error")) {
7302
+ setMessage(params.current.get("error"));
7303
+ setSeverity("error");
7304
+ setOpen(true);
7305
+ }
7306
+ else if (params.current.has("message")) {
7290
7307
  setMessage(params.current.get("message"));
7308
+ setSeverity("info");
7291
7309
  setOpen(true);
7292
7310
  }
7293
- }, [params.toString()]);
7311
+ }, [initialError]);
7294
7312
  return (React__default.createElement(Box, { sx: {
7295
7313
  minHeight: "100vh",
7296
7314
  backgroundImage: "linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%)",
@@ -7384,9 +7402,10 @@ function Login(_a) {
7384
7402
  useAzureAD && (React__default.createElement(LoginWithAzureAD, { config: authConfig.AzureConfig })),
7385
7403
  guestIsEnabled && React__default.createElement(LoginAsGuest, null))))))))),
7386
7404
  React__default.createElement(Snackbar, { open: open, autoHideDuration: 6000, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
7387
- React__default.createElement(Alert$4, { onClose: handleClose, severity: "info", variant: "filled" }, message))));
7405
+ React__default.createElement(Alert$4, { onClose: handleClose, severity: severity, variant: "filled" }, message))));
7388
7406
  }
7389
7407
 
7408
+ var getBase = function () { var _a; return ((_a = document.getElementsByTagName("base")[0]) === null || _a === void 0 ? void 0 : _a.getAttribute("href")) || "/"; };
7390
7409
  var AuthProvider = function (_a) {
7391
7410
  var children = _a.children, authConfig = _a.authConfig;
7392
7411
  var useTokenHook = useToken();
@@ -7397,18 +7416,42 @@ var AuthProvider = function (_a) {
7397
7416
  };
7398
7417
  var Authenticated = function (_a) {
7399
7418
  var children = _a.children;
7419
+ var redirectTo = new URL(document.location).searchParams.get("redirectTo");
7420
+ useEffect(function () {
7421
+ if (redirectTo) {
7422
+ window.location.href = decodeURIComponent(redirectTo);
7423
+ }
7424
+ }, []);
7425
+ if (redirectTo) {
7426
+ return null;
7427
+ }
7400
7428
  return React__default.createElement(React__default.Fragment, null, children);
7401
7429
  };
7402
7430
  var Unauthenticated = function (_a) {
7403
7431
  var authConfig = _a.authConfig;
7404
7432
  var clearUserData = useContext(AuthContext).clearUserData;
7405
- var params = useRef(new URL(document.location).searchParams);
7433
+ var currentUrl = new URL(document.location);
7434
+ var base = getBase();
7435
+ var basePath = base.endsWith("/") ? base.slice(0, -1) : base;
7436
+ var isRootPath = currentUrl.pathname === "/" ||
7437
+ currentUrl.pathname === base ||
7438
+ currentUrl.pathname === basePath;
7439
+ var hasRedirectTo = currentUrl.searchParams.has("redirectTo");
7440
+ var shouldShowError = !isRootPath && !hasRedirectTo;
7406
7441
  useEffect(function () {
7407
7442
  clearUserData();
7408
- var newUrl = window.location.origin + "?" + params.current.toString();
7409
- window.history.replaceState({ path: newUrl }, "", newUrl);
7443
+ if (shouldShowError) {
7444
+ var fullPath = currentUrl.pathname + currentUrl.search;
7445
+ var newParams = new URLSearchParams();
7446
+ newParams.set("redirectTo", fullPath);
7447
+ newParams.set("error", "Session expired. Please log in to continue");
7448
+ var newUrl = "".concat(window.location.origin).concat(base, "?").concat(newParams.toString());
7449
+ window.history.replaceState({ path: newUrl }, "", newUrl);
7450
+ }
7410
7451
  }, []);
7411
- return React__default.createElement(Login, { authConfig: authConfig });
7452
+ return (React__default.createElement(Login, { authConfig: authConfig, initialError: shouldShowError
7453
+ ? "Session expired. Please log in to continue"
7454
+ : undefined }));
7412
7455
  };
7413
7456
 
7414
7457
  function Logout() {
@@ -7506,7 +7549,7 @@ var TimeAndUserMenu = function () {
7506
7549
 
7507
7550
  var ButtonWithLoading = function (_a) {
7508
7551
  var children = _a.children, isLoading = _a.isLoading, props = __rest(_a, ["children", "isLoading"]);
7509
- return (React__default.createElement(Button, __assign({}, props, { disabled: isLoading }),
7552
+ return (React__default.createElement(Button, __assign({}, props, { disabled: isLoading || props.disabled }),
7510
7553
  isLoading && React__default.createElement(CircularProgress, { size: "1rem" }),
7511
7554
  children));
7512
7555
  };