@localazy/strapi-plugin 0.2.3 → 0.2.4

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 (28) hide show
  1. package/README.md +6 -0
  2. package/admin/src/config/development/index.js +14 -0
  3. package/admin/src/config/example/index.js +14 -0
  4. package/admin/src/config/index.js +21 -0
  5. package/admin/src/config/local/index.js +14 -0
  6. package/admin/src/config/production/index.js +15 -0
  7. package/admin/src/i18n.js +13 -9
  8. package/admin/src/index.js +8 -2
  9. package/admin/src/modules/@common/components/LanguagesSelector/index.js +0 -2
  10. package/admin/src/modules/@common/components/PluginPageLoader/index.js +0 -2
  11. package/admin/src/modules/@common/components/TransferReport/index.js +0 -1
  12. package/admin/src/modules/@common/utils/get-nav.js +1 -1
  13. package/admin/src/modules/@common/utils/redirect-to-plugin-route.js +2 -2
  14. package/admin/src/modules/localazy-upload/components/ReadDocsButton.js +0 -1
  15. package/admin/src/modules/login/components/LoginButton/index.js +3 -4
  16. package/admin/src/modules/login/components/LogoutButton/index.js +0 -1
  17. package/admin/src/modules/plugin-settings/components/ContentTransferSetup/index.js +1 -1
  18. package/admin/src/modules/plugin-settings/components/GlobalSettings/index.js +1 -1
  19. package/admin/src/modules/settings/components/PrerequisitiesInfo/index.js +0 -2
  20. package/admin/src/pages/App/index.js +4 -4
  21. package/admin/src/pages/Download/index.js +0 -1
  22. package/admin/src/pages/Login/index.js +0 -2
  23. package/admin/src/pages/PluginSettings/index.js +0 -2
  24. package/admin/src/pages/Settings/index.js +0 -2
  25. package/admin/src/pages/Upload/index.js +0 -2
  26. package/admin/src/utils/createPluginConnectorAxiosInstance.js +2 -2
  27. package/install/index.mjs +15 -2
  28. package/package.json +1 -1
package/README.md CHANGED
@@ -27,6 +27,12 @@ npm install @localazy/strapi-plugin@latest && npx @localazy/strapi-plugin
27
27
 
28
28
  Note: Localazy plugin requires an updated Webpack configuration of your Strapi project. Follow the instructions in the console output during the installation process. Steps are also available in the [Install plugin via NPM](https://localazy.com/docs/strapi/strapi-plugin-introduction-installation#install-plugin-via-npm) section of the Localazy Docs.
29
29
 
30
+ Due to the changes in Strapi core code it's also necessary to add an environment variable to your Strapi project. Add the following line to your `.env` file (value is empty):
31
+
32
+ ```
33
+ STRAPI_ADMIN_LOCALAZY_ENV=
34
+ ```
35
+
30
36
  ## Configuration
31
37
 
32
38
  Additional configuration object may be provided in the `plugins.js` file. The following options are available:
@@ -0,0 +1,14 @@
1
+ export default {
2
+ LOCALAZY_OAUTH_URL: "https://testing.localazy.com/oauth/authorize",
3
+ LOCALAZY_OAUTH_APP_CLIENT_ID: "18503917571895066466",
4
+ LOCALAZY_PLUGIN_CONNECTOR_API_URL: "https://testing.localazy.com/plugin-connector",
5
+ LOCALAZY_PUBLIC_API_URL: "https://testing.localazy.com/pubapi",
6
+ LOCALAZY_PLUGIN_ID: "1",
7
+ LOCALAZY_DEFAULT_FILE_NAME: "strapi.json",
8
+ LOCALAZY_DEFAULT_FILE_PATH: "",
9
+ LOCALAZY_DEFAULT_FILE_EXTENSION: "json",
10
+ LOCALAZY_DEFAULT_LOCALE: "en",
11
+ LOCALAZY_API_USER_JWT_COOKIE_NAME: "LOCALAZY-API-USER-JWT",
12
+ LOCALAZY_API_USER_COOKIE_EXPIRATION: 7,
13
+ LOCALAZY_PUBLIC_API_LIFTED_LIMITS: true,
14
+ };
@@ -0,0 +1,14 @@
1
+ export default {
2
+ LOCALAZY_OAUTH_URL: "",
3
+ LOCALAZY_OAUTH_APP_CLIENT_ID: "",
4
+ LOCALAZY_PLUGIN_CONNECTOR_API_URL: "",
5
+ LOCALAZY_PUBLIC_API_URL: "",
6
+ LOCALAZY_PLUGIN_ID: "",
7
+ LOCALAZY_DEFAULT_FILE_NAME: "",
8
+ LOCALAZY_DEFAULT_FILE_PATH: "",
9
+ LOCALAZY_DEFAULT_FILE_EXTENSION: "",
10
+ LOCALAZY_DEFAULT_LOCALE: "",
11
+ LOCALAZY_API_USER_JWT_COOKIE_NAME: "",
12
+ LOCALAZY_API_USER_COOKIE_EXPIRATION: -1,
13
+ LOCALAZY_PUBLIC_API_LIFTED_LIMITS: false,
14
+ };
@@ -0,0 +1,21 @@
1
+ import production from "./production/index";
2
+ import local from "./local/index";
3
+ import development from "./development/index";
4
+
5
+
6
+ // depending on the STRAPI_ADMIN_LOCALAZY_ENV, use the correct config
7
+ let config = production;
8
+
9
+ if (process.env.STRAPI_ADMIN_LOCALAZY_ENV === "local") {
10
+ config = local;
11
+ }
12
+
13
+ if (process.env.STRAPI_ADMIN_LOCALAZY_ENV === "development") {
14
+ config = development;
15
+ }
16
+
17
+ console.log(config);
18
+
19
+ export default {
20
+ ...config,
21
+ };
@@ -0,0 +1,14 @@
1
+ export default {
2
+ LOCALAZY_OAUTH_URL: "https://testing.localazy.com/oauth/authorize",
3
+ LOCALAZY_OAUTH_APP_CLIENT_ID: "18503917571895066465",
4
+ LOCALAZY_PLUGIN_CONNECTOR_API_URL: "http://localhost:3000",
5
+ LOCALAZY_PUBLIC_API_URL: "https://testing.localazy.com/pubapi",
6
+ LOCALAZY_PLUGIN_ID: "1",
7
+ LOCALAZY_DEFAULT_FILE_NAME: "strapi.json",
8
+ LOCALAZY_DEFAULT_FILE_PATH: "",
9
+ LOCALAZY_DEFAULT_FILE_EXTENSION: "json",
10
+ LOCALAZY_DEFAULT_LOCALE: "en",
11
+ LOCALAZY_API_USER_JWT_COOKIE_NAME: "LOCALAZY-API-USER-JWT",
12
+ LOCALAZY_API_USER_COOKIE_EXPIRATION: 7,
13
+ LOCALAZY_PUBLIC_API_LIFTED_LIMITS: false,
14
+ };
@@ -0,0 +1,15 @@
1
+ export default {
2
+ LOCALAZY_OAUTH_URL: "https://localazy.com/oauth/authorize",
3
+ LOCALAZY_OAUTH_APP_CLIENT_ID: "18395772851999073783",
4
+ LOCALAZY_PLUGIN_CONNECTOR_API_URL:
5
+ "https://plugins.localazy.com/generic-connector",
6
+ LOCALAZY_PUBLIC_API_URL: "https://api.localazy.com",
7
+ LOCALAZY_PLUGIN_ID: "1",
8
+ LOCALAZY_DEFAULT_FILE_NAME: "strapi.json",
9
+ LOCALAZY_DEFAULT_FILE_PATH: "",
10
+ LOCALAZY_DEFAULT_FILE_EXTENSION: "json",
11
+ LOCALAZY_DEFAULT_LOCALE: "en",
12
+ LOCALAZY_API_USER_JWT_COOKIE_NAME: "LOCALAZY-API-USER-JWT",
13
+ LOCALAZY_API_USER_COOKIE_EXPIRATION: 7,
14
+ LOCALAZY_PUBLIC_API_LIFTED_LIMITS: true,
15
+ };
package/admin/src/i18n.js CHANGED
@@ -8,14 +8,9 @@ import en_download from "./modules/localazy-download/locale/en";
8
8
  import en_upload from "./modules/localazy-upload/locale/en";
9
9
  import en_plugin_settings from "./modules/plugin-settings/locale/en";
10
10
 
11
- i18n
12
- // detect user language
13
- // pass the i18n instance to react-i18next.
14
- .use(initReactI18next)
15
- // init i18next
16
- // for all options read: https://www.i18next.com/overview/configuration-options
17
- .init({
18
- debug: process.env.STRAPI_ADMIN_LOCALAZY_ENV === "development",
11
+ const initI18nParams = () => {
12
+ return {
13
+ debug: false, // set `true` to see more logs
19
14
  fallbackLng: "en",
20
15
  interpolation: {
21
16
  escapeValue: false, // not needed for react as it escapes by default
@@ -32,6 +27,15 @@ i18n
32
27
  },
33
28
  },
34
29
  },
35
- });
30
+ };
31
+ }
32
+
33
+ i18n
34
+ // detect user language
35
+ // pass the i18n instance to react-i18next.
36
+ .use(initReactI18next)
37
+ // init i18next
38
+ // for all options read: https://www.i18next.com/overview/configuration-options
39
+ .init(initI18nParams());
36
40
 
37
41
  export default i18n;
@@ -54,9 +54,15 @@ export default {
54
54
  defaultMessage: upperCaseName,
55
55
  },
56
56
  Component: async () => {
57
- const component = await import("./pages/Index");
57
+ try {
58
+ const component = await import("./pages/Index");
58
59
 
59
- return component;
60
+ return component;
61
+ } catch (e) {
62
+ console.log(e);
63
+ }
64
+
65
+ return null;
60
66
  },
61
67
  permissions: [
62
68
  // Uncomment to set the permissions of the plugin here
@@ -5,8 +5,6 @@ import { useTranslation } from "react-i18next";
5
5
  import cloneDeep from "lodash-es/cloneDeep";
6
6
  import { Select, Option } from '@strapi/design-system/Select';
7
7
 
8
- import "../../../../i18n";
9
-
10
8
  function LanguagesSelector(props) {
11
9
  /**
12
10
  * Translation function
@@ -3,8 +3,6 @@ import { Flex } from '@strapi/design-system/Flex';
3
3
  import { Loader } from "@strapi/design-system/Loader";
4
4
  import { useTranslation } from "react-i18next";
5
5
 
6
- import "../../../../i18n";
7
-
8
6
  function PluginPageLoader() {
9
7
  const { t } = useTranslation();
10
8
 
@@ -3,7 +3,6 @@ import PropTypes from "prop-types";
3
3
  import { Alert } from "@strapi/design-system/Alert";
4
4
  import { useTranslation } from "react-i18next";
5
5
  import { Box } from "@strapi/design-system/Box";
6
- import "../../../../i18n";
7
6
 
8
7
  function TransferReport(props) {
9
8
  const { t } = useTranslation();
@@ -5,7 +5,7 @@ import Upload from "@strapi/icons/Upload";
5
5
  import pluginId from "../../../pluginId";
6
6
  import i18n from "../../../i18n";
7
7
 
8
- const BASE_PATH = `${process.env.ADMIN_PATH}plugins/${pluginId}`;
8
+ const BASE_PATH = `${process.env.ADMIN_PATH}/plugins/${pluginId}`;
9
9
  const t = i18n.t;
10
10
  const gevNav = () => {
11
11
  return [
@@ -13,10 +13,10 @@ export const PLUGIN_ROUTES = {
13
13
 
14
14
  export default (route) => {
15
15
  if (route === PLUGIN_ROUTES.CONTENT_TRANSFER_SETUP) {
16
- history.push(`${process.env.ADMIN_PATH}settings/${pluginId}/${route}`);
16
+ history.push(`${process.env.ADMIN_PATH}/settings/${pluginId}/${route}`);
17
17
 
18
18
  return;
19
19
  }
20
20
 
21
- history.push(`${process.env.ADMIN_PATH}plugins/${pluginId}/${route}`);
21
+ history.push(`${process.env.ADMIN_PATH}/plugins/${pluginId}/${route}`);
22
22
  };
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import { Button } from "@strapi/design-system/Button";
3
3
  import { useTranslation } from "react-i18next";
4
- import "../../../i18n";
5
4
 
6
5
  function ReadDocsButton() {
7
6
  const { t } = useTranslation();
@@ -11,8 +11,7 @@ import { useTranslation } from "react-i18next";
11
11
  import LocalazyLoginService from "../../services/localazy-login-service";
12
12
  import { getStrapiDefaultLocale } from "../../../@common/utils/get-default-locale";
13
13
  import { isoStrapiToLocalazy } from "../../../@common/utils/iso-locales-utils";
14
- import { config } from "../../../../../../server";
15
- import "../../../../i18n";
14
+ import config from "../../../../config";
16
15
 
17
16
  function LoginButton(props) {
18
17
  const { t } = useTranslation();
@@ -25,12 +24,12 @@ function LoginButton(props) {
25
24
  const localazyFormatLocaleCode = isoStrapiToLocalazy(strapiDefaultLocale.code);
26
25
  const keys = await LocalazyLoginService.generateKeys();
27
26
  const params = new URLSearchParams({
28
- client_id: config.default.LOCALAZY_OAUTH_APP_CLIENT_ID,
27
+ client_id: config.LOCALAZY_OAUTH_APP_CLIENT_ID,
29
28
  custom_id: keys.writeKey,
30
29
  allow_create: "true",
31
30
  create_locale: localazyFormatLocaleCode,
32
31
  });
33
- const url = `${config.default.LOCALAZY_OAUTH_URL}?${params.toString()}`;
32
+ const url = `${config.LOCALAZY_OAUTH_URL}?${params.toString()}`;
34
33
  window.open(url);
35
34
 
36
35
  const pollResult = await LocalazyLoginService.continuousPoll(keys.readKey);
@@ -11,7 +11,6 @@ import { useTranslation } from "react-i18next";
11
11
  import Exit from "@strapi/icons/Exit";
12
12
  import LocalazyUserService from "../../../user/services/localazy-user-service";
13
13
  import { setLocalazyIdentity } from "../../../../state/localazy-identity";
14
- import "../../../../i18n";
15
14
 
16
15
  function LogoutButton(props) {
17
16
  const { t } = useTranslation();
@@ -198,7 +198,7 @@ function ContentTransferSetup() {
198
198
 
199
199
  return (
200
200
  <>
201
- {!isLoading && !isLoggedIn && <Redirect to={`${process.env.ADMIN_PATH}plugins/${pluginId}/login`} />}
201
+ {!isLoading && !isLoggedIn && <Redirect to={`/plugins/${pluginId}/login`} />}
202
202
 
203
203
  <HeaderLayout
204
204
  title={t("plugin_settings.content_transfer_setup")}
@@ -120,7 +120,7 @@ function GlobalSettings() {
120
120
 
121
121
  return (
122
122
  <>
123
- {!isLoading && !isLoggedIn && <Redirect to={`${process.env.ADMIN_PATH}plugins/${pluginId}/login`} />}
123
+ {!isLoading && !isLoggedIn && <Redirect to={`/plugins/${pluginId}/login`} />}
124
124
 
125
125
  <HeaderLayout
126
126
  title={t("plugin_settings.global_settings")}
@@ -3,8 +3,6 @@ import { Box } from "@strapi/design-system/Box";
3
3
  import { useTranslation } from "react-i18next";
4
4
  import { Typography } from "@strapi/design-system/Typography";
5
5
 
6
- import "../../../../i18n";
7
-
8
6
  function PrerequisitiesInfo() {
9
7
  const { t } = useTranslation();
10
8
 
@@ -110,7 +110,7 @@ function App() {
110
110
  <>
111
111
  {!isLoggedIn && (
112
112
  <Switch>
113
- <Route path={`${process.env.ADMIN_PATH}plugins/${pluginId}/login`} exact>
113
+ <Route path={`${process.env.ADMIN_PATH}/plugins/${pluginId}/login`} exact>
114
114
  <Login
115
115
  title={headerTitle}
116
116
  subtitle={headerSubtitle}
@@ -121,19 +121,19 @@ function App() {
121
121
 
122
122
  {isLoggedIn && (
123
123
  <Switch>
124
- <Route path={`${process.env.ADMIN_PATH}plugins/${pluginId}/download`} exact>
124
+ <Route path={`${process.env.ADMIN_PATH}/plugins/${pluginId}/download`} exact>
125
125
  <Download
126
126
  title={headerTitle}
127
127
  subtitle={headerSubtitle}
128
128
  />
129
129
  </Route>
130
- <Route path={`${process.env.ADMIN_PATH}plugins/${pluginId}/upload`} exact>
130
+ <Route path={`${process.env.ADMIN_PATH}/plugins/${pluginId}/upload`} exact>
131
131
  <Upload
132
132
  title={headerTitle}
133
133
  subtitle={headerSubtitle}
134
134
  />
135
135
  </Route>
136
- <Route path={`${process.env.ADMIN_PATH}plugins/${pluginId}/settings`} exact>
136
+ <Route path={`${process.env.ADMIN_PATH}/plugins/${pluginId}/settings`} exact>
137
137
  <Settings
138
138
  title={headerTitle}
139
139
  subtitle={headerSubtitle}
@@ -17,7 +17,6 @@ import areLocalesCompatible from "../../modules/@common/utils/are-locales-compat
17
17
  import hasModelChanged from "../../modules/plugin-settings/functions/has-model-changed";
18
18
  import TransferReport from "../../modules/@common/components/TransferReport";
19
19
  import ReadDocsButton from "../../modules/localazy-upload/components/ReadDocsButton";
20
- import "../../i18n";
21
20
  import { getLocalazyIdentity } from "../../state/localazy-identity";
22
21
  import ProductAnalyticsService from "../../modules/@common/services/product-analytics-service";
23
22
  import PluginSettingsService from "../../modules/plugin-settings/services/plugin-settings-service";
@@ -21,8 +21,6 @@ import redirectToPluginRoute, {
21
21
  } from "../../modules/@common/utils/redirect-to-plugin-route";
22
22
  import ProductAnalyticsService from "../../modules/@common/services/product-analytics-service";
23
23
 
24
- import "../../i18n";
25
-
26
24
  function Login(props) {
27
25
  const history = useHistory();
28
26
  const { t } = useTranslation();
@@ -11,8 +11,6 @@ import LocalazyUserService from "../../modules/user/services/localazy-user-servi
11
11
  import { setLocalazyIdentity } from "../../state/localazy-identity";
12
12
  import Loader from "../../modules/@common/components/PluginPageLoader";
13
13
 
14
- import "../../i18n";
15
-
16
14
  function PluginSettings() {
17
15
  /**
18
16
  * Translation function
@@ -20,8 +20,6 @@ import ProductAnalyticsService from "../../modules/@common/services/product-anal
20
20
  import formatNumber from "../../modules/@common/utils/format-number";
21
21
  import PluginSettingsService from "../../modules/plugin-settings/services/plugin-settings-service";
22
22
 
23
- import "../../i18n";
24
-
25
23
  function Settings(props) {
26
24
  const history = useHistory();
27
25
  const { t } = useTranslation();
@@ -26,8 +26,6 @@ import ProductAnalyticsService from "../../modules/@common/services/product-anal
26
26
  import PluginSettingsService from "../../modules/plugin-settings/services/plugin-settings-service";
27
27
  import UploadAlertsService from "../../modules/localazy-upload/services/upload-alerts-service";
28
28
 
29
- import "../../i18n";
30
-
31
29
  const uploadAlertsService = new UploadAlertsService();
32
30
  uploadAlertsService.subscribe();
33
31
 
@@ -3,9 +3,9 @@
3
3
  */
4
4
 
5
5
  import axios from "axios";
6
- import { config } from "../../../server";
6
+ import config from "../config";
7
7
 
8
- const BASE_PLUGIN_PATH = config.default.LOCALAZY_PLUGIN_CONNECTOR_API_URL;
8
+ const BASE_PLUGIN_PATH = config.LOCALAZY_PLUGIN_CONNECTOR_API_URL;
9
9
 
10
10
  const createPluginConnectorAxiosInstance = (baseUrl = null) => {
11
11
  if (baseUrl === null) {
package/install/index.mjs CHANGED
@@ -39,7 +39,7 @@ const install = () => new Promise((resolve, reject) => {
39
39
  }
40
40
  });
41
41
 
42
- const updateConfig = () => new Promise((resolve, reject) => {
42
+ const createWebpackConfigSample = () => new Promise((resolve, reject) => {
43
43
  try {
44
44
  shell.exec(`echo "${template}" > src/admin/${exampleFileName}`, { silent: true }, () => {
45
45
  resolve();
@@ -49,6 +49,16 @@ const updateConfig = () => new Promise((resolve, reject) => {
49
49
  }
50
50
  });
51
51
 
52
+ const updateEnvConfig = () => new Promise((resolve, reject) => {
53
+ try {
54
+ shell.exec(`echo "STRAPI_ADMIN_LOCALAZY_ENV=" >> .env`, { silent: true }, () => {
55
+ resolve();
56
+ });
57
+ } catch (err) {
58
+ reject(err);
59
+ }
60
+ });
61
+
52
62
  console.log(banner);
53
63
 
54
64
  installSpinner.start(`Installing ${name}${version}`);
@@ -56,7 +66,10 @@ await install();
56
66
  installSpinner.succeed();
57
67
 
58
68
  installSpinner.start(`Creating example ${file} file in ${chalk.bold.green("src/admin")} folder`);
59
- await updateConfig();
69
+ await createWebpackConfigSample();
70
+ installSpinner.succeed();
71
+ installSpinner.start(`Updating ${chalk.bold.green(".env")} file with ${chalk.bold.green("STRAPI_ADMIN_LOCALAZY_ENV")} variable`);
72
+ await updateEnvConfig();
60
73
  installSpinner.succeed();
61
74
  installSpinner.succeed(`To run the plugin, you need to update your webpack config in ${chalk.bold.green("src/admin/webpack.config.js")} file`);
62
75
  installSpinner.succeed(`Don't forget to build the admin panel with ${chalk.bold.green("npm run build")} command`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localazy/strapi-plugin",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "The official Strapi Plugin by Localazy.",
5
5
  "strapi": {
6
6
  "name": "localazy",