@localazy/strapi-plugin 1.0.8 → 1.0.10

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 (34) hide show
  1. package/dist/_chunks/{set-BRyy4Ra6.mjs → FetchIdentity-B9hYlR1E.mjs} +97 -7
  2. package/dist/_chunks/{set-CmcBsVOP.js → FetchIdentity-W-xq7F8q.js} +141 -51
  3. package/dist/_chunks/{LanguagesSelector-Bfrsr3-P.js → LanguagesSelector-Cq9JuASq.js} +10 -10
  4. package/dist/_chunks/{LanguagesSelector-u9iDsQqB.mjs → LanguagesSelector-zGN0icsS.mjs} +3 -3
  5. package/dist/_chunks/{App-Dl58PZKy.js → LocalazyApp-CTMwUa44.js} +60 -37
  6. package/dist/_chunks/{App-C0ogWaOz.mjs → LocalazyApp-CxQTCwbi.mjs} +40 -17
  7. package/dist/_chunks/{ContentTransferSetup-ClR8Nwv2.mjs → LocalazyContentTransferSetup-DOHIserI.mjs} +12 -8
  8. package/dist/_chunks/{ContentTransferSetup-DWQg9zDj.js → LocalazyContentTransferSetup-DhSv2HJo.js} +26 -22
  9. package/dist/_chunks/{GlobalSettings-BpY7BoXu.js → LocalazyGlobalSettings-D7fyS9ih.js} +58 -52
  10. package/dist/_chunks/{GlobalSettings-B_h5sPwa.mjs → LocalazyGlobalSettings-DCFs8AA1.mjs} +15 -9
  11. package/dist/_chunks/{LocalazyPanel-BedTxk3C.js → LocalazyPanel-CDgAmxqx.js} +1 -1
  12. package/dist/_chunks/{LocalazyPanel-CuvdSJYx.mjs → LocalazyPanel-N7__R7p9.mjs} +2 -2
  13. package/dist/_chunks/{LocalazyStatusColumn-Bf1ntoc7.js → LocalazyStatusColumn-CTjBaBqb.js} +1 -1
  14. package/dist/_chunks/{LocalazyStatusColumn-955GpXAv.mjs → LocalazyStatusColumn-CuGDwwZ8.mjs} +1 -1
  15. package/dist/_chunks/{isEqual-CrlZhAtq.js → RequireLocalazyAuth-BDtwyPLH.js} +50 -29
  16. package/dist/_chunks/{isEqual-BazjlHGf.mjs → RequireLocalazyAuth-BmimcHYI.mjs} +22 -1
  17. package/dist/_chunks/{entry-exclusion-service-bm-lp4za.js → entry-exclusion-service-BZkbrd3B.js} +2 -2
  18. package/dist/_chunks/{entry-exclusion-service-BlyFqyBY.mjs → entry-exclusion-service-COp5ZXUY.mjs} +1 -1
  19. package/dist/_chunks/{has-model-changed-B5SSh8XW.js → has-model-changed-BXqyvCRA.js} +31 -31
  20. package/dist/_chunks/{has-model-changed-DIHY9LBA.mjs → has-model-changed-K3Z8BNhV.mjs} +2 -2
  21. package/dist/_chunks/index-B_KJR1Xk.mjs +231 -0
  22. package/dist/_chunks/index-BtofOkFA.js +254 -0
  23. package/dist/_chunks/{index-DOCSzcPH.mjs → index-CgI_aKe_.mjs} +6 -6
  24. package/dist/_chunks/{index-Q3-srfXc.js → strapi-api-base-BfIxEUh2.mjs} +15 -380
  25. package/dist/_chunks/{index-C15Goe6p.mjs → strapi-api-base-S2_cFlNu.js} +7 -350
  26. package/dist/admin/index.js +1 -1
  27. package/dist/admin/index.mjs +1 -1
  28. package/dist/admin/src/components/RequireLocalazyAuth.d.ts +6 -0
  29. package/dist/admin/src/pages/LocalazyApp.d.ts +2 -0
  30. package/dist/admin/src/pages/LocalazyContentTransferSetup.d.ts +2 -0
  31. package/dist/admin/src/pages/LocalazyGlobalSettings.d.ts +2 -0
  32. package/dist/server/index.js +1 -1
  33. package/dist/server/index.mjs +1 -1
  34. package/package.json +1 -1
@@ -4,14 +4,15 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const reactRouterDom = require("react-router-dom");
5
5
  const index$1 = require("./index-CaY3BYnQ.js");
6
6
  const React = require("react");
7
- const index = require("./index-Q3-srfXc.js");
8
- const set = require("./set-CmcBsVOP.js");
7
+ const FetchIdentity = require("./FetchIdentity-W-xq7F8q.js");
8
+ const index = require("./index-BtofOkFA.js");
9
9
  const useTranslation = require("./useTranslation-BdIl-aLe.js");
10
10
  const _commonjsHelpers = require("./_commonjsHelpers-Bc2YnDe1.js");
11
- const LanguagesSelector = require("./LanguagesSelector-Bfrsr3-P.js");
11
+ const strapiApiBase = require("./strapi-api-base-S2_cFlNu.js");
12
+ const LanguagesSelector = require("./LanguagesSelector-Cq9JuASq.js");
12
13
  const admin = require("@strapi/strapi/admin");
13
14
  require("./i18n-0dV2P-Hm.js");
14
- const hasModelChanged = require("./has-model-changed-B5SSh8XW.js");
15
+ const hasModelChanged = require("./has-model-changed-BXqyvCRA.js");
15
16
  var PLUGIN_ROUTES = /* @__PURE__ */ ((PLUGIN_ROUTES2) => {
16
17
  PLUGIN_ROUTES2["ROOT"] = "";
17
18
  PLUGIN_ROUTES2["LOGIN"] = "login";
@@ -1117,7 +1118,7 @@ function l(t2, e2) {
1117
1118
  return "/" !== new URL(n2).pathname ? `${n2}?${a2.toString()}` : `${n2}/oauth/authorize?${a2.toString()}`;
1118
1119
  }
1119
1120
  const BASE_PATH$2 = "/auth";
1120
- const axiosInstance = index.createStrapiApiAxiosInstance();
1121
+ const axiosInstance = strapiApiBase.createStrapiApiAxiosInstance();
1121
1122
  class LocalazyLoginService {
1122
1123
  static async generateKeys() {
1123
1124
  try {
@@ -1136,7 +1137,7 @@ class LocalazyLoginService {
1136
1137
  }
1137
1138
  }
1138
1139
  }
1139
- const strapiApiInstance$1 = index.createStrapiApiAxiosInstance("/i18n");
1140
+ const strapiApiInstance$1 = strapiApiBase.createStrapiApiAxiosInstance("/i18n");
1140
1141
  class I18nService {
1141
1142
  static async getLocales() {
1142
1143
  try {
@@ -1278,7 +1279,7 @@ const client = new o({
1278
1279
  pluginId: c.STRAPI,
1279
1280
  genericConnectorUrl: config.LOCALAZY_PLUGIN_CONNECTOR_API_URL
1280
1281
  });
1281
- const strapiApiInstance = index.createStrapiApiAxiosInstance();
1282
+ const strapiApiInstance = strapiApiBase.createStrapiApiAxiosInstance();
1282
1283
  class PluginService {
1283
1284
  static async getPluginVersion() {
1284
1285
  try {
@@ -1370,9 +1371,9 @@ class ProductAnalyticsService {
1370
1371
  const Login = ({ title, subtitle, isLoading = false }) => {
1371
1372
  const { t: t2 } = useTranslation.useTranslation();
1372
1373
  const localazyStrapiDocsLink = "https://localazy.com/docs/strapi";
1373
- const { setIdentity, identity, isLoggedIn } = index.useLocalazyIdentity();
1374
+ const { setIdentity, identity, isLoggedIn } = FetchIdentity.useLocalazyIdentity();
1374
1375
  const onLoginResultFetched = async (result) => {
1375
- await index.LocalazyUserService.updateIdentity(result);
1376
+ await FetchIdentity.LocalazyUserService.updateIdentity(result);
1376
1377
  setIdentity(result);
1377
1378
  };
1378
1379
  React.useEffect(() => {
@@ -1425,11 +1426,11 @@ const SideNav = () => {
1425
1426
  const LogoutButton = (props) => {
1426
1427
  const { t: t2 } = useTranslation.useTranslation();
1427
1428
  const [isLoading, setIsLoading] = React.useState(false);
1428
- const { setIdentity } = index.useLocalazyIdentity();
1429
+ const { setIdentity } = FetchIdentity.useLocalazyIdentity();
1429
1430
  const logout = async () => {
1430
1431
  setIsLoading(true);
1431
- index.LocalazyUserService.deleteIdentity();
1432
- setIdentity(index.emptyIdentity);
1432
+ FetchIdentity.LocalazyUserService.deleteIdentity();
1433
+ setIdentity(FetchIdentity.emptyIdentity);
1433
1434
  setIsLoading(false);
1434
1435
  props.onResultFetched();
1435
1436
  };
@@ -1456,7 +1457,7 @@ const Overview = ({ title, subtitle, isLoadingProp = false }) => {
1456
1457
  const { t: t2 } = useTranslation.useTranslation();
1457
1458
  const { navigateToPluginRoute } = useRedirectToPluginRoute();
1458
1459
  const [isLoading, setIsLoading] = React.useState(true);
1459
- const { identity } = index.useLocalazyIdentity();
1460
+ const { identity } = FetchIdentity.useLocalazyIdentity();
1460
1461
  const projectUrl = identity.project.url;
1461
1462
  const [connectedProject, setConnectedProject] = React.useState(null);
1462
1463
  React.useEffect(() => {
@@ -1464,7 +1465,7 @@ const Overview = ({ title, subtitle, isLoadingProp = false }) => {
1464
1465
  setIsLoading(true);
1465
1466
  const project = await LanguagesSelector.ProjectService.getConnectedProject();
1466
1467
  setConnectedProject(project);
1467
- set.PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.OVERVIEW });
1468
+ FetchIdentity.PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.OVERVIEW });
1468
1469
  setIsLoading(false);
1469
1470
  }
1470
1471
  initComponent();
@@ -1539,7 +1540,7 @@ const BASE_PATH$1 = "/transfer";
1539
1540
  class LocalazyUploadService {
1540
1541
  static async upload(data = {}) {
1541
1542
  try {
1542
- const strapiApiInstance2 = index.createStrapiApiAxiosInstance();
1543
+ const strapiApiInstance2 = strapiApiBase.createStrapiApiAxiosInstance();
1543
1544
  const result = await strapiApiInstance2.post(`${BASE_PATH$1}/upload`, data);
1544
1545
  return result.data;
1545
1546
  } catch (e2) {
@@ -4933,7 +4934,7 @@ class UploadAlertsService extends AlertsService {
4933
4934
  const uploadAlertsService = new UploadAlertsService();
4934
4935
  const Upload = (props) => {
4935
4936
  const { t: t2 } = useTranslation.useTranslation();
4936
- const { identity } = index.useLocalazyIdentity();
4937
+ const { identity } = FetchIdentity.useLocalazyIdentity();
4937
4938
  const { navigateToPluginRoute } = useRedirectToPluginRoute();
4938
4939
  const [isLoading, setIsLoading] = React.useState(true);
4939
4940
  const [modelChanged, setModelChanged] = React.useState(false);
@@ -4984,11 +4985,17 @@ const Upload = (props) => {
4984
4985
  React.useEffect(() => {
4985
4986
  async function initComponent() {
4986
4987
  setIsLoading(true);
4987
- setStrapiDefaultLocale(await getStrapiDefaultLocale());
4988
- setLocalazySourceLanguage(await getLocalazySourceLanguage());
4989
- setModelChanged(await hasModelChanged.hasModelChanged());
4990
- setLocalesIncompatible(!await areLocalesCompatible(strapiDefaultLocale, localazySourceLanguage));
4991
- set.PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.UPLOAD });
4988
+ const [defaultLocale, sourceLanguage, modelChangedResult, localesCompatibleResult] = await Promise.all([
4989
+ getStrapiDefaultLocale(),
4990
+ getLocalazySourceLanguage(),
4991
+ hasModelChanged.hasModelChanged(),
4992
+ areLocalesCompatible(strapiDefaultLocale, localazySourceLanguage)
4993
+ ]);
4994
+ setStrapiDefaultLocale(defaultLocale);
4995
+ setLocalazySourceLanguage(sourceLanguage);
4996
+ setModelChanged(modelChangedResult);
4997
+ setLocalesIncompatible(!localesCompatibleResult);
4998
+ FetchIdentity.PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.UPLOAD });
4992
4999
  setIsLoading(false);
4993
5000
  }
4994
5001
  initComponent();
@@ -5087,7 +5094,7 @@ const BASE_PATH = "/transfer";
5087
5094
  class LocalazyDownloadService {
5088
5095
  static async download(data = {}) {
5089
5096
  try {
5090
- const strapiApiInstance2 = index.createStrapiApiAxiosInstance();
5097
+ const strapiApiInstance2 = strapiApiBase.createStrapiApiAxiosInstance();
5091
5098
  const result = await strapiApiInstance2.post(`${BASE_PATH}/download`, data);
5092
5099
  return result.data;
5093
5100
  } catch (e2) {
@@ -5106,7 +5113,7 @@ class DownloadAlertsService extends AlertsService {
5106
5113
  const downloadAlertsService = new DownloadAlertsService();
5107
5114
  const Download = (props) => {
5108
5115
  const { t: t2 } = useTranslation.useTranslation();
5109
- const { identity } = index.useLocalazyIdentity();
5116
+ const { identity } = FetchIdentity.useLocalazyIdentity();
5110
5117
  const [isLoading, setIsLoading] = React.useState(true);
5111
5118
  const [modelChanged, setModelChanged] = React.useState(false);
5112
5119
  const [localesIncompatible, setLocalesIncompatible] = React.useState(false);
@@ -5122,11 +5129,11 @@ const Download = (props) => {
5122
5129
  const [projectLanguages, setProjectLanguages] = React.useState([]);
5123
5130
  const [formModel, setFormModel] = React.useState({});
5124
5131
  const onDownloadLanguagesChange = (languages) => {
5125
- const newFormModel = set.cloneDeep(formModel);
5126
- set.set(newFormModel, "download.uiLanguages", languages);
5132
+ const newFormModel = FetchIdentity.cloneDeep(formModel);
5133
+ FetchIdentity.set(newFormModel, "download.uiLanguages", languages);
5127
5134
  setFormModel(newFormModel);
5128
5135
  try {
5129
- set.PluginSettingsService.updatePluginSettings(newFormModel);
5136
+ FetchIdentity.PluginSettingsService.updatePluginSettings(newFormModel);
5130
5137
  } catch (e2) {
5131
5138
  console.error(e2.message);
5132
5139
  }
@@ -5162,14 +5169,18 @@ const Download = (props) => {
5162
5169
  React.useEffect(() => {
5163
5170
  async function initComponent() {
5164
5171
  setIsLoading(true);
5165
- setModelChanged(await hasModelChanged.hasModelChanged());
5166
- setLocalesIncompatible(!await areLocalesCompatible());
5167
- const project = await LanguagesSelector.ProjectService.getConnectedProject();
5172
+ const [modelChangedResult, localesCompatibleResult, project, globalSettings] = await Promise.all([
5173
+ hasModelChanged.hasModelChanged(),
5174
+ areLocalesCompatible(),
5175
+ LanguagesSelector.ProjectService.getConnectedProject(),
5176
+ FetchIdentity.PluginSettingsService.getPluginSettings()
5177
+ ]);
5178
+ setModelChanged(modelChangedResult);
5179
+ setLocalesIncompatible(!localesCompatibleResult);
5168
5180
  const projectLanguagesWithoutDefaultLanguage = project?.languages?.filter((language) => language.id !== project.sourceLanguage) || [];
5169
5181
  setProjectLanguages(projectLanguagesWithoutDefaultLanguage);
5170
- const globalSettings = await set.PluginSettingsService.getPluginSettings();
5171
5182
  setFormModel(globalSettings);
5172
- set.PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.DOWNLOAD });
5183
+ FetchIdentity.PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.DOWNLOAD });
5173
5184
  setIsLoading(false);
5174
5185
  }
5175
5186
  initComponent();
@@ -5269,23 +5280,31 @@ const Download = (props) => {
5269
5280
  };
5270
5281
  const App = () => {
5271
5282
  const { navigateToPluginRoute } = useRedirectToPluginRoute();
5272
- const { isLoggedIn, isFetchingIdentity } = index.useLocalazyIdentity();
5283
+ const location2 = reactRouterDom.useLocation();
5284
+ const { isLoggedIn, isFetchingIdentity } = FetchIdentity.useLocalazyIdentity();
5273
5285
  const headerTitle = useHeaderTitle();
5274
5286
  const headerSubtitle = useHeaderSubtitle();
5287
+ const normalizedPath = location2.pathname.replace(/\/+$/, "");
5288
+ const pluginRoot = `/plugins/${index.PLUGIN_ID}`;
5289
+ const isAtPluginRoot = normalizedPath === pluginRoot;
5290
+ const isAtLoginRoute = normalizedPath === `${pluginRoot}/login`;
5291
+ const shouldRedirect = isAtPluginRoot || isAtLoginRoute;
5275
5292
  React.useEffect(() => {
5276
5293
  const fetchData = async () => {
5277
5294
  if (isFetchingIdentity) {
5278
5295
  return;
5279
5296
  }
5280
5297
  if (!isLoggedIn) {
5281
- navigateToPluginRoute(PLUGIN_ROUTES.LOGIN);
5282
- } else {
5283
- const lastRoute = (await set.PluginSettingsService.getPluginSettings()).defaultRoute || PLUGIN_ROUTES.UPLOAD;
5298
+ if (!isAtLoginRoute) {
5299
+ navigateToPluginRoute(PLUGIN_ROUTES.LOGIN);
5300
+ }
5301
+ } else if (shouldRedirect) {
5302
+ const lastRoute = (await FetchIdentity.PluginSettingsService.getPluginSettings()).defaultRoute || PLUGIN_ROUTES.UPLOAD;
5284
5303
  navigateToPluginRoute(lastRoute);
5285
5304
  }
5286
5305
  };
5287
5306
  fetchData();
5288
- }, [isLoggedIn, isFetchingIdentity]);
5307
+ }, [isLoggedIn, isFetchingIdentity, normalizedPath]);
5289
5308
  return /* @__PURE__ */ jsxRuntime.jsx(index$1.DesignSystemProvider, { theme: getDefaultTheme(), children: /* @__PURE__ */ jsxRuntime.jsx(index$1.Box, { background: "neutral100", children: /* @__PURE__ */ jsxRuntime.jsxs(admin.Layouts.Root, { sideNav: isLoggedIn && /* @__PURE__ */ jsxRuntime.jsx(SideNav, {}), children: [
5290
5309
  isFetchingIdentity && /* @__PURE__ */ jsxRuntime.jsx(PluginPageLoader, {}),
5291
5310
  /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
@@ -5303,4 +5322,8 @@ const App = () => {
5303
5322
  ] })
5304
5323
  ] }) }) });
5305
5324
  };
5306
- exports.App = App;
5325
+ const LocalazyApp = () => /* @__PURE__ */ jsxRuntime.jsxs(FetchIdentity.LocalazyIdentityProvider, { children: [
5326
+ /* @__PURE__ */ jsxRuntime.jsx(FetchIdentity.FetchIdentity, {}),
5327
+ /* @__PURE__ */ jsxRuntime.jsx(App, {})
5328
+ ] });
5329
+ exports.default = LocalazyApp;
@@ -1,15 +1,16 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { useNavigate, useLocation, NavLink, Routes, Route } from "react-router-dom";
3
- import { i as ForwardRef$2H, j as ForwardRef$d, k as ForwardRef$3P, F as Flex, L as Loader, B as Button, c as Box, T as Typography, l as Link, m as SubNav, n as SubNavHeader, o as SubNavSections, p as SubNavSection, q as SubNavLink, r as ForwardRef$L, G as Grid, D as Divider, s as darkTheme, t as lightTheme, A as Alert, u as DesignSystemProvider } from "./index-DOCSzcPH.mjs";
3
+ import { i as ForwardRef$2H, j as ForwardRef$d, k as ForwardRef$3P, c as Flex, L as Loader, B as Button, e as Box, T as Typography, l as Link, m as SubNav, n as SubNavHeader, o as SubNavSections, p as SubNavSection, q as SubNavLink, r as ForwardRef$L, G as Grid, D as Divider, s as darkTheme, t as lightTheme, A as Alert, u as DesignSystemProvider } from "./index-CgI_aKe_.mjs";
4
4
  import { useState, useEffect } from "react";
5
- import { P as PLUGIN_ID, c as createStrapiApiAxiosInstance, u as useLocalazyIdentity, L as LocalazyUserService, e as emptyIdentity } from "./index-C15Goe6p.mjs";
6
- import { P as PluginSettingsService, c as cloneDeep, s as set } from "./set-BRyy4Ra6.mjs";
5
+ import { u as useLocalazyIdentity, v as LocalazyUserService, w as emptyIdentity, P as PluginSettingsService, c as cloneDeep, s as set, L as LocalazyIdentityProvider, F as FetchIdentity } from "./FetchIdentity-B9hYlR1E.mjs";
6
+ import { P as PLUGIN_ID } from "./index-B_KJR1Xk.mjs";
7
7
  import { u as useTranslation } from "./useTranslation-CZQ4lU1m.mjs";
8
8
  import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-DWwsNxpa.mjs";
9
- import { P as ProjectService, L as LanguagesSelector } from "./LanguagesSelector-u9iDsQqB.mjs";
9
+ import { c as createStrapiApiAxiosInstance } from "./strapi-api-base-BfIxEUh2.mjs";
10
+ import { P as ProjectService, L as LanguagesSelector } from "./LanguagesSelector-zGN0icsS.mjs";
10
11
  import { Layouts, Page } from "@strapi/strapi/admin";
11
12
  import "./i18n-RoETLXdU.mjs";
12
- import { h as hasModelChanged } from "./has-model-changed-DIHY9LBA.mjs";
13
+ import { h as hasModelChanged } from "./has-model-changed-K3Z8BNhV.mjs";
13
14
  var PLUGIN_ROUTES = /* @__PURE__ */ ((PLUGIN_ROUTES2) => {
14
15
  PLUGIN_ROUTES2["ROOT"] = "";
15
16
  PLUGIN_ROUTES2["LOGIN"] = "login";
@@ -4982,10 +4983,16 @@ const Upload = (props) => {
4982
4983
  useEffect(() => {
4983
4984
  async function initComponent() {
4984
4985
  setIsLoading(true);
4985
- setStrapiDefaultLocale(await getStrapiDefaultLocale());
4986
- setLocalazySourceLanguage(await getLocalazySourceLanguage());
4987
- setModelChanged(await hasModelChanged());
4988
- setLocalesIncompatible(!await areLocalesCompatible(strapiDefaultLocale, localazySourceLanguage));
4986
+ const [defaultLocale, sourceLanguage, modelChangedResult, localesCompatibleResult] = await Promise.all([
4987
+ getStrapiDefaultLocale(),
4988
+ getLocalazySourceLanguage(),
4989
+ hasModelChanged(),
4990
+ areLocalesCompatible(strapiDefaultLocale, localazySourceLanguage)
4991
+ ]);
4992
+ setStrapiDefaultLocale(defaultLocale);
4993
+ setLocalazySourceLanguage(sourceLanguage);
4994
+ setModelChanged(modelChangedResult);
4995
+ setLocalesIncompatible(!localesCompatibleResult);
4989
4996
  PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.UPLOAD });
4990
4997
  setIsLoading(false);
4991
4998
  }
@@ -5160,12 +5167,16 @@ const Download = (props) => {
5160
5167
  useEffect(() => {
5161
5168
  async function initComponent() {
5162
5169
  setIsLoading(true);
5163
- setModelChanged(await hasModelChanged());
5164
- setLocalesIncompatible(!await areLocalesCompatible());
5165
- const project = await ProjectService.getConnectedProject();
5170
+ const [modelChangedResult, localesCompatibleResult, project, globalSettings] = await Promise.all([
5171
+ hasModelChanged(),
5172
+ areLocalesCompatible(),
5173
+ ProjectService.getConnectedProject(),
5174
+ PluginSettingsService.getPluginSettings()
5175
+ ]);
5176
+ setModelChanged(modelChangedResult);
5177
+ setLocalesIncompatible(!localesCompatibleResult);
5166
5178
  const projectLanguagesWithoutDefaultLanguage = project?.languages?.filter((language) => language.id !== project.sourceLanguage) || [];
5167
5179
  setProjectLanguages(projectLanguagesWithoutDefaultLanguage);
5168
- const globalSettings = await PluginSettingsService.getPluginSettings();
5169
5180
  setFormModel(globalSettings);
5170
5181
  PluginSettingsService.updatePluginSettings({ defaultRoute: PLUGIN_ROUTES.DOWNLOAD });
5171
5182
  setIsLoading(false);
@@ -5267,23 +5278,31 @@ const Download = (props) => {
5267
5278
  };
5268
5279
  const App = () => {
5269
5280
  const { navigateToPluginRoute } = useRedirectToPluginRoute();
5281
+ const location2 = useLocation();
5270
5282
  const { isLoggedIn, isFetchingIdentity } = useLocalazyIdentity();
5271
5283
  const headerTitle = useHeaderTitle();
5272
5284
  const headerSubtitle = useHeaderSubtitle();
5285
+ const normalizedPath = location2.pathname.replace(/\/+$/, "");
5286
+ const pluginRoot = `/plugins/${PLUGIN_ID}`;
5287
+ const isAtPluginRoot = normalizedPath === pluginRoot;
5288
+ const isAtLoginRoute = normalizedPath === `${pluginRoot}/login`;
5289
+ const shouldRedirect = isAtPluginRoot || isAtLoginRoute;
5273
5290
  useEffect(() => {
5274
5291
  const fetchData = async () => {
5275
5292
  if (isFetchingIdentity) {
5276
5293
  return;
5277
5294
  }
5278
5295
  if (!isLoggedIn) {
5279
- navigateToPluginRoute(PLUGIN_ROUTES.LOGIN);
5280
- } else {
5296
+ if (!isAtLoginRoute) {
5297
+ navigateToPluginRoute(PLUGIN_ROUTES.LOGIN);
5298
+ }
5299
+ } else if (shouldRedirect) {
5281
5300
  const lastRoute = (await PluginSettingsService.getPluginSettings()).defaultRoute || PLUGIN_ROUTES.UPLOAD;
5282
5301
  navigateToPluginRoute(lastRoute);
5283
5302
  }
5284
5303
  };
5285
5304
  fetchData();
5286
- }, [isLoggedIn, isFetchingIdentity]);
5305
+ }, [isLoggedIn, isFetchingIdentity, normalizedPath]);
5287
5306
  return /* @__PURE__ */ jsx(DesignSystemProvider, { theme: getDefaultTheme(), children: /* @__PURE__ */ jsx(Box, { background: "neutral100", children: /* @__PURE__ */ jsxs(Layouts.Root, { sideNav: isLoggedIn && /* @__PURE__ */ jsx(SideNav, {}), children: [
5288
5307
  isFetchingIdentity && /* @__PURE__ */ jsx(PluginPageLoader, {}),
5289
5308
  /* @__PURE__ */ jsxs(Routes, { children: [
@@ -5301,6 +5320,10 @@ const App = () => {
5301
5320
  ] })
5302
5321
  ] }) }) });
5303
5322
  };
5323
+ const LocalazyApp = () => /* @__PURE__ */ jsxs(LocalazyIdentityProvider, { children: [
5324
+ /* @__PURE__ */ jsx(FetchIdentity, {}),
5325
+ /* @__PURE__ */ jsx(App, {})
5326
+ ] });
5304
5327
  export {
5305
- App
5328
+ LocalazyApp as default
5306
5329
  };
@@ -1,10 +1,10 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import { forwardRef, useState, useEffect } from "react";
3
- import { i as isEqual } from "./isEqual-BazjlHGf.mjs";
4
- import { s as set, m as keys, n as isArrayLike, o as arrayEach, k as isArray, p as isObject, P as PluginSettingsService, c as cloneDeep } from "./set-BRyy4Ra6.mjs";
3
+ import { i as isEqual, R as RequireLocalazyAuth } from "./RequireLocalazyAuth-BmimcHYI.mjs";
4
+ import { s as set, m as keys, n as isArrayLike, o as arrayEach, k as isArray, p as isObject, P as PluginSettingsService, c as cloneDeep, L as LocalazyIdentityProvider, F as FetchIdentity } from "./FetchIdentity-B9hYlR1E.mjs";
5
5
  import { Layouts } from "@strapi/strapi/admin";
6
- import { C as CheckboxImpl, c as Box, g as Accordion, F as Flex, h as SwitchImpl, T as Typography, B as Button, b as ForwardRef$4z, A as Alert, D as Divider } from "./index-DOCSzcPH.mjs";
7
- import { S as SUPPORTED_CONTENT_TYPE_FIELDS, a as SUPPORTED_CUSTOM_FIELD_PLUGINS, g as getContentTransferSetupKeysSets, b as get, f as findModelValueByKey, c as StrapiModelService, d as getModelsTree, h as hasModelChanged } from "./has-model-changed-DIHY9LBA.mjs";
6
+ import { C as CheckboxImpl, e as Box, g as Accordion, c as Flex, h as SwitchImpl, T as Typography, B as Button, d as ForwardRef$4z, A as Alert, D as Divider } from "./index-CgI_aKe_.mjs";
7
+ import { S as SUPPORTED_CONTENT_TYPE_FIELDS, a as SUPPORTED_CUSTOM_FIELD_PLUGINS, g as getContentTransferSetupKeysSets, b as get, f as findModelValueByKey, c as StrapiModelService, d as getModelsTree, h as hasModelChanged } from "./has-model-changed-K3Z8BNhV.mjs";
8
8
  import { u as useTranslation } from "./useTranslation-CZQ4lU1m.mjs";
9
9
  import styled from "styled-components";
10
10
  import { Trans } from "./index-BIbKC7-V.mjs";
@@ -1056,11 +1056,11 @@ const ContentTransferSetup = () => {
1056
1056
  useEffect(() => {
1057
1057
  async function fetchData() {
1058
1058
  setIsLoading(true);
1059
- const [models, localizableModels] = await Promise.all([
1059
+ const [models, localizableModels, storedContentTransferSetup] = await Promise.all([
1060
1060
  StrapiModelService.getModels(),
1061
- StrapiModelService.getLocalizableModels()
1061
+ StrapiModelService.getLocalizableModels(),
1062
+ PluginSettingsService.getContentTransferSetup()
1062
1063
  ]);
1063
- const storedContentTransferSetup = await PluginSettingsService.getContentTransferSetup();
1064
1064
  const itemsExpandedModel = buildItemsExpandedModel(localizableModels);
1065
1065
  setItemsExpandedModel(itemsExpandedModel);
1066
1066
  const allModelsTree = getModelsTree(models, models);
@@ -1153,6 +1153,10 @@ const ContentTransferSetup = () => {
1153
1153
  ] })
1154
1154
  ] });
1155
1155
  };
1156
+ const LocalazyContentTransferSetup = () => /* @__PURE__ */ jsxs(LocalazyIdentityProvider, { children: [
1157
+ /* @__PURE__ */ jsx(FetchIdentity, {}),
1158
+ /* @__PURE__ */ jsx(RequireLocalazyAuth, { children: /* @__PURE__ */ jsx(ContentTransferSetup, {}) })
1159
+ ] });
1156
1160
  export {
1157
- ContentTransferSetup
1161
+ LocalazyContentTransferSetup as default
1158
1162
  };
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
- const isEqual = require("./isEqual-CrlZhAtq.js");
6
- const set = require("./set-CmcBsVOP.js");
5
+ const RequireLocalazyAuth = require("./RequireLocalazyAuth-BDtwyPLH.js");
6
+ const FetchIdentity = require("./FetchIdentity-W-xq7F8q.js");
7
7
  const admin = require("@strapi/strapi/admin");
8
8
  const index = require("./index-CaY3BYnQ.js");
9
- const hasModelChanged = require("./has-model-changed-B5SSh8XW.js");
9
+ const hasModelChanged = require("./has-model-changed-BXqyvCRA.js");
10
10
  const useTranslation = require("./useTranslation-BdIl-aLe.js");
11
11
  const styled = require("styled-components");
12
12
  const index$1 = require("./index-1he9s_bs.js");
@@ -42,16 +42,16 @@ const buildContentTransferSetupSchema = (localizableTree = [], storedSetupSchema
42
42
  const localizableTreeValueToSet = hasModelChanged.get(oStoredSetupSchema, key);
43
43
  const allModelsTreeValueToSet = hasModelChanged.findModelValueByKey(allModelsTree, key);
44
44
  if (allModelsTreeValueToSet === null) {
45
- set.set(destinationObject, key, null);
45
+ FetchIdentity.set(destinationObject, key, null);
46
46
  } else if (localizableTreeValueToSet !== null) {
47
- set.set(destinationObject, key, localizableTreeValueToSet);
47
+ FetchIdentity.set(destinationObject, key, localizableTreeValueToSet);
48
48
  } else {
49
49
  const newValueToSet = hasModelChanged.findModelValueByKey(allModelsTree, key);
50
- set.set(destinationObject, key, newValueToSet);
50
+ FetchIdentity.set(destinationObject, key, newValueToSet);
51
51
  }
52
52
  });
53
53
  newKeys.forEach((key) => {
54
- set.set(destinationObject, key, hasModelChanged.get(oLocalizableTree, key));
54
+ FetchIdentity.set(destinationObject, key, hasModelChanged.get(oLocalizableTree, key));
55
55
  });
56
56
  const destinationArray = [];
57
57
  const sortedDestinationObjectKeys = Object.keys(destinationObject).sort((a, b) => {
@@ -791,14 +791,14 @@ function createBaseFor(fromRight) {
791
791
  }
792
792
  var baseFor = createBaseFor();
793
793
  function baseForOwn(object, iteratee) {
794
- return object && baseFor(object, iteratee, set.keys);
794
+ return object && baseFor(object, iteratee, FetchIdentity.keys);
795
795
  }
796
796
  function createBaseEach(eachFunc, fromRight) {
797
797
  return function(collection, iteratee) {
798
798
  if (collection == null) {
799
799
  return collection;
800
800
  }
801
- if (!set.isArrayLike(collection)) {
801
+ if (!FetchIdentity.isArrayLike(collection)) {
802
802
  return eachFunc(collection, iteratee);
803
803
  }
804
804
  var length = collection.length, index2 = -1, iterable = Object(collection);
@@ -818,13 +818,13 @@ function castFunction(value) {
818
818
  return typeof value == "function" ? value : identity;
819
819
  }
820
820
  function forEach(collection, iteratee) {
821
- var func = set.isArray(collection) ? set.arrayEach : baseEach;
821
+ var func = FetchIdentity.isArray(collection) ? FetchIdentity.arrayEach : baseEach;
822
822
  return func(collection, castFunction(iteratee));
823
823
  }
824
824
  function flattenObject(obj, delimiter = ".") {
825
825
  const nobj = {};
826
826
  forEach(obj, (val, key) => {
827
- if (set.isObject(val) && !set.isArray(val)) {
827
+ if (FetchIdentity.isObject(val) && !FetchIdentity.isArray(val)) {
828
828
  const strip = flattenObject(val, delimiter);
829
829
  forEach(strip, (v, k) => {
830
830
  nobj[key + delimiter + k] = v;
@@ -1010,13 +1010,13 @@ const ContentTransferSetup = () => {
1010
1010
  const [formModel, setFormModel] = React.useState([]);
1011
1011
  const [hasUnsavedChanges, setHasUnsavedChanges] = React.useState(false);
1012
1012
  const onCancelClick = () => {
1013
- setFormModel(set.cloneDeep(originalFormModel));
1013
+ setFormModel(FetchIdentity.cloneDeep(originalFormModel));
1014
1014
  setHasUnsavedChanges(false);
1015
1015
  };
1016
1016
  const saveContentTransferSetup = async (data) => {
1017
1017
  try {
1018
- await set.PluginSettingsService.updateContentTransferSetup(data);
1019
- setOriginalFormModel(set.cloneDeep(data));
1018
+ await FetchIdentity.PluginSettingsService.updateContentTransferSetup(data);
1019
+ setOriginalFormModel(FetchIdentity.cloneDeep(data));
1020
1020
  setHasUnsavedChanges(false);
1021
1021
  setShowAlert(true);
1022
1022
  setShowModalChangedAlert(false);
@@ -1038,18 +1038,18 @@ const ContentTransferSetup = () => {
1038
1038
  if (model === void 0) {
1039
1039
  return prevState;
1040
1040
  }
1041
- const newState = set.cloneDeep(prevState);
1041
+ const newState = FetchIdentity.cloneDeep(prevState);
1042
1042
  keys.forEach((key) => {
1043
1043
  if (key.includes("__component__")) {
1044
1044
  return;
1045
1045
  }
1046
1046
  const isEditable = hasModelChanged.get(model, key) !== null;
1047
1047
  if (isEditable) {
1048
- set.set(model, key, !currentValue);
1048
+ FetchIdentity.set(model, key, !currentValue);
1049
1049
  }
1050
1050
  });
1051
1051
  newState.splice(arrayIndex, 1, model);
1052
- setHasUnsavedChanges(!isEqual.isEqual(originalFormModel, newState) || showModalChangedAlert);
1052
+ setHasUnsavedChanges(!RequireLocalazyAuth.isEqual(originalFormModel, newState) || showModalChangedAlert);
1053
1053
  return newState;
1054
1054
  });
1055
1055
  };
@@ -1060,11 +1060,11 @@ const ContentTransferSetup = () => {
1060
1060
  React.useEffect(() => {
1061
1061
  async function fetchData() {
1062
1062
  setIsLoading(true);
1063
- const [models, localizableModels] = await Promise.all([
1063
+ const [models, localizableModels, storedContentTransferSetup] = await Promise.all([
1064
1064
  hasModelChanged.StrapiModelService.getModels(),
1065
- hasModelChanged.StrapiModelService.getLocalizableModels()
1065
+ hasModelChanged.StrapiModelService.getLocalizableModels(),
1066
+ FetchIdentity.PluginSettingsService.getContentTransferSetup()
1066
1067
  ]);
1067
- const storedContentTransferSetup = await set.PluginSettingsService.getContentTransferSetup();
1068
1068
  const itemsExpandedModel = buildItemsExpandedModel(localizableModels);
1069
1069
  setItemsExpandedModel(itemsExpandedModel);
1070
1070
  const allModelsTree = hasModelChanged.getModelsTree(models, models);
@@ -1076,7 +1076,7 @@ const ContentTransferSetup = () => {
1076
1076
  allModelsTree
1077
1077
  );
1078
1078
  setFormModel(computedFormModel);
1079
- setOriginalFormModel(set.cloneDeep(computedFormModel));
1079
+ setOriginalFormModel(FetchIdentity.cloneDeep(computedFormModel));
1080
1080
  const localHasModelChanged = await hasModelChanged.hasModelChanged(localizableTree, storedContentTransferSetup.setup);
1081
1081
  setShowModalChangedAlert(localHasModelChanged);
1082
1082
  setHasUnsavedChanges(localHasModelChanged);
@@ -1157,4 +1157,8 @@ const ContentTransferSetup = () => {
1157
1157
  ] })
1158
1158
  ] });
1159
1159
  };
1160
- exports.ContentTransferSetup = ContentTransferSetup;
1160
+ const LocalazyContentTransferSetup = () => /* @__PURE__ */ jsxRuntime.jsxs(FetchIdentity.LocalazyIdentityProvider, { children: [
1161
+ /* @__PURE__ */ jsxRuntime.jsx(FetchIdentity.FetchIdentity, {}),
1162
+ /* @__PURE__ */ jsxRuntime.jsx(RequireLocalazyAuth.RequireLocalazyAuth, { children: /* @__PURE__ */ jsxRuntime.jsx(ContentTransferSetup, {}) })
1163
+ ] });
1164
+ exports.default = LocalazyContentTransferSetup;