Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: initial v5 migration #126

Merged
merged 19 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { isEmpty } from 'lodash';
import { Button } from '@strapi/design-system';
import { Map } from 'immutable';
import { useNotification } from '@strapi/helper-plugin';
import { useNotification } from '@strapi/strapi/admin';

Check failure on line 7 in admin/src/components/ActionButtons/index.jsx

View workflow job for this annotation

GitHub Actions / lint (18)

Unable to resolve path to module '@strapi/strapi/admin'

Check failure on line 7 in admin/src/components/ActionButtons/index.jsx

View workflow job for this annotation

GitHub Actions / lint (20)

Unable to resolve path to module '@strapi/strapi/admin'
import { useIntl } from 'react-intl';

import ConfirmModal from '../ConfirmModal';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState } from 'react';
import { useIntl } from 'react-intl';
import { useDispatch } from 'react-redux';
import { NoContent, useNotification } from '@strapi/helper-plugin';
import { Button } from '@strapi/design-system';
import { useNotification } from '@strapi/strapi/admin';

Check failure on line 4 in admin/src/components/FirstExport/index.jsx

View workflow job for this annotation

GitHub Actions / lint (18)

Unable to resolve path to module '@strapi/strapi/admin'

Check failure on line 4 in admin/src/components/FirstExport/index.jsx

View workflow job for this annotation

GitHub Actions / lint (20)

Unable to resolve path to module '@strapi/strapi/admin'
import { Button, EmptyStateLayout } from '@strapi/design-system';

import { exportAllConfig } from '../../state/actions/Config';
import ConfirmModal from '../ConfirmModal';
Expand All @@ -21,7 +21,7 @@
type="export"
onSubmit={() => dispatch(exportAllConfig([], toggleNotification))}
/>
<NoContent
<EmptyStateLayout
content={{
id: 'emptyState',
defaultMessage:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { NoContent } from '@strapi/helper-plugin';
import { EmptyStateLayout } from '@strapi/design-system';
import { useIntl } from 'react-intl';

const NoChanges = () => {
const { formatMessage } = useIntl();
return (
<NoContent
<EmptyStateLayout
content={{
id: 'emptyState',
defaultMessage:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React from 'react';
import { Provider } from 'react-redux';
import { CheckPagePermissions } from '@strapi/helper-plugin';
import { Page } from '@strapi/strapi/admin';

Check failure on line 10 in admin/src/containers/App/index.jsx

View workflow job for this annotation

GitHub Actions / lint (18)

Unable to resolve path to module '@strapi/strapi/admin'

Check failure on line 10 in admin/src/containers/App/index.jsx

View workflow job for this annotation

GitHub Actions / lint (20)

Unable to resolve path to module '@strapi/strapi/admin'

import pluginPermissions from '../../permissions';
import Header from '../../components/Header';
Expand All @@ -16,12 +16,12 @@

const App = () => {
return (
<CheckPagePermissions permissions={pluginPermissions.settings}>
<Page.Protect permissions={pluginPermissions.settings}>
<Provider store={store}>
<Header />
<ConfigPage />
</Provider>
</CheckPagePermissions>
</Page.Protect>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Alert,
Typography,
} from '@strapi/design-system';
import { useNotification } from '@strapi/helper-plugin';
import { useNotification } from '@strapi/strapi/admin';

Check failure on line 10 in admin/src/containers/ConfigPage/index.jsx

View workflow job for this annotation

GitHub Actions / lint (18)

Unable to resolve path to module '@strapi/strapi/admin'

Check failure on line 10 in admin/src/containers/ConfigPage/index.jsx

View workflow job for this annotation

GitHub Actions / lint (20)

Unable to resolve path to module '@strapi/strapi/admin'

import { getAllConfigDiff, getAppEnv } from '../../state/actions/Config';
import ConfigList from '../../components/ConfigList';
Expand Down
4 changes: 2 additions & 2 deletions admin/src/helpers/pluginId.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const pluginPkg = require('../../../package.json');
import pluginPkg from '../../../package.json';

const pluginId = pluginPkg.name.replace(
/^strapi-plugin-/i,
'',
);

module.exports = pluginId;
export default pluginId;
11 changes: 11 additions & 0 deletions admin/src/helpers/prefixPluginTranslations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const prefixPluginTranslations = (trad, pluginId) => {
if (!pluginId) {
throw new TypeError("pluginId can't be empty");
}
return Object.keys(trad).reduce((acc, current) => {
acc[`${pluginId}.${current}`] = trad[current];
return acc;
}, {});
};

export { prefixPluginTranslations };
2 changes: 1 addition & 1 deletion admin/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { prefixPluginTranslations } from '@strapi/helper-plugin';
import pluginPkg from '../../package.json';
import pluginId from './helpers/pluginId';
import { prefixPluginTranslations } from './helpers/prefixPluginTranslations';
import pluginPermissions from './permissions';
// import pluginIcon from './components/PluginIcon';
// import getTrad from './helpers/getTrad';
Expand Down
30 changes: 13 additions & 17 deletions admin/src/state/actions/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
*
*/

import { request } from '@strapi/helper-plugin';
import { useFetchClient } from '@strapi/admin/strapi-admin';

Check failure on line 7 in admin/src/state/actions/Config.js

View workflow job for this annotation

GitHub Actions / lint (18)

Unable to resolve path to module '@strapi/admin/strapi-admin'

Check failure on line 7 in admin/src/state/actions/Config.js

View workflow job for this annotation

GitHub Actions / lint (20)

Unable to resolve path to module '@strapi/admin/strapi-admin'

export function getAllConfigDiff(toggleNotification) {
return async function(dispatch) {
const { get } = useFetchClient();
dispatch(setLoadingState(true));
try {
const configDiff = await request('/config-sync/diff', { method: 'GET' });
const configDiff = await get('/config-sync/diff');
dispatch(setConfigPartialDiffInState([]));
dispatch(setConfigDiffInState(configDiff));
dispatch(setLoadingState(false));
Expand Down Expand Up @@ -39,13 +40,11 @@

export function exportAllConfig(partialDiff, toggleNotification) {
return async function(dispatch) {
const { post } = useFetchClient();
dispatch(setLoadingState(true));
try {
const { message } = await request('/config-sync/export', {
method: 'POST',
body: partialDiff,
});
toggleNotification({ type: 'success', message });
const response = await post('/config-sync/export', partialDiff);
toggleNotification({ type: 'success', response });
dispatch(getAllConfigDiff(toggleNotification));
dispatch(setLoadingState(false));
} catch (err) {
Expand All @@ -57,16 +56,14 @@

export function importAllConfig(partialDiff, force, toggleNotification) {
return async function(dispatch) {
const { post } = useFetchClient();
dispatch(setLoadingState(true));
try {
const { message } = await request('/config-sync/import', {
method: 'POST',
body: {
force,
config: partialDiff,
},
const response = await post('/config-sync/import', {
force,
config: partialDiff,
});
toggleNotification({ type: 'success', message });
toggleNotification({ type: 'success', response });
dispatch(getAllConfigDiff(toggleNotification));
dispatch(setLoadingState(false));
} catch (err) {
Expand All @@ -86,10 +83,9 @@

export function getAppEnv(toggleNotification) {
return async function(dispatch) {
const { get } = useFetchClient();
try {
const envVars = await request('/config-sync/app-env', {
method: 'GET',
});
const envVars = await get('/config-sync/app-env');
dispatch(setAppEnvInState(envVars));
} catch (err) {
toggleNotification({ type: 'warning', message: { id: 'notification.error' } });
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"inquirer": "^8.2.0",
"react-diff-viewer-continued": "3.2.6",
"redux-immutable": "^4.0.0",
"react-intl": "6.6.2",
"redux-thunk": "^2.3.0"
},
"author": {
Expand All @@ -57,10 +58,9 @@
"@strapi/strapi": "^4.0.0"
boazpoolman marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"@strapi/design-system": "^1.14.1",
"@strapi/helper-plugin": "^4.19.0",
"@strapi/icons": "^1.14.1",
"@strapi/utils": "^4.19.0",
"@strapi/design-system": "^1.16.0",
"@strapi/icons": "^1.16.0",
"@strapi/utils": "5.0.0-beta.0",
"babel-eslint": "9.0.0",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
Expand All @@ -78,7 +78,6 @@
"jest-styled-components": "^7.0.2",
"lodash": "^4.17.11",
"react": "^17.0.2",
"react-intl": "^5.20.12",
"react-redux": "^7.2.2",
"redux": "^4.0.5",
"styled-components": "^5.2.3"
Expand Down
4 changes: 2 additions & 2 deletions strapi-admin.js
boazpoolman marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict';
import admin from './admin/src';

module.exports = require('./admin/src').default;
export default admin;
Loading
Loading