Merge branch 'master' into fix/italic-style-is-ignored

This commit is contained in:
cyril lopez 2021-12-30 12:17:36 +01:00 committed by GitHub
commit 6d99de01a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 83 additions and 83 deletions

View File

@ -0,0 +1,6 @@
module.exports = ({ env }) => ({
// autoOpen: false,
auth: {
secret: env('ADMIN_JWT_SECRET', 'example-token'),
},
});

View File

@ -57,4 +57,5 @@ module.exports = {
}, },
transformIgnorePatterns: ['node_modules/(?!(react-dnd|dnd-core|react-dnd-html5-backend)/)'], transformIgnorePatterns: ['node_modules/(?!(react-dnd|dnd-core|react-dnd-html5-backend)/)'],
testMatch: ['/**/tests/**/?(*.)+(spec|test).[jt]s?(x)'], testMatch: ['/**/tests/**/?(*.)+(spec|test).[jt]s?(x)'],
testURL: 'http://localhost:1337/admin',
}; };

View File

@ -43,14 +43,20 @@ const App = () => {
); );
} }
// Array of models that are displayed in the content manager
const supportedModelsToDisplay = models.filter(({ isDisplayed }) => isDisplayed);
// Redirect the user to the 403 page // Redirect the user to the 403 page
// FIXME when changing the routing if (
if (authorisedModels.length === 0 && models.length > 0 && pathname !== '/content-manager/403') { authorisedModels.length === 0 &&
supportedModelsToDisplay.length > 0 &&
pathname !== '/content-manager/403'
) {
return <Redirect to="/content-manager/403" />; return <Redirect to="/content-manager/403" />;
} }
// Redirect the user to the create content type page // Redirect the user to the create content type page
if (models.length === 0 && pathname !== '/content-manager/no-content-types') { if (supportedModelsToDisplay.length === 0 && pathname !== '/content-manager/no-content-types') {
return <Redirect to="/content-manager/no-content-types" />; return <Redirect to="/content-manager/no-content-types" />;
} }

View File

@ -72,9 +72,15 @@ describe('Content manager | App | main', () => {
{ {
kind: 'collectionType', kind: 'collectionType',
uid: 'category', uid: 'category',
isDisplayed: true,
info: { label: 'Categories', name: 'category' }, info: { label: 'Categories', name: 'category' },
}, },
{ kind: 'singleType', uid: 'homepage', info: { label: 'Home page', name: 'homepage' } }, {
kind: 'singleType',
isDisplayed: true,
uid: 'homepage',
info: { label: 'Home page', name: 'homepage' },
},
], ],
components: [], components: [],
status: 'resolved', status: 'resolved',
@ -751,8 +757,14 @@ describe('Content manager | App | main', () => {
kind: 'collectionType', kind: 'collectionType',
uid: 'category', uid: 'category',
info: { label: 'Categories', name: 'category' }, info: { label: 'Categories', name: 'category' },
isDisplayed: true,
},
{
kind: 'singleType',
isDisplayed: true,
uid: 'homepage',
info: { label: 'Home page', name: 'homepage' },
}, },
{ kind: 'singleType', uid: 'homepage', info: { label: 'Home page', name: 'homepage' } },
], ],
components: [], components: [],
status: 'resolved', status: 'resolved',
@ -789,6 +801,7 @@ describe('Content manager | App | main', () => {
{ {
kind: 'collectionType', kind: 'collectionType',
uid: 'category', uid: 'category',
isDisplayed: true,
info: { label: 'Categories', name: 'category' }, info: { label: 'Categories', name: 'category' },
}, },
{ kind: 'singleType', uid: 'homepage', info: { label: 'Home page', name: 'homepage' } }, { kind: 'singleType', uid: 'homepage', info: { label: 'Home page', name: 'homepage' } },
@ -828,7 +841,14 @@ describe('Content manager | App | main', () => {
const contentManagerState = { const contentManagerState = {
collectionTypeLinks: [], collectionTypeLinks: [],
singleTypeLinks: [], singleTypeLinks: [],
models: [], models: [
{
kind: 'collectionType',
uid: 'category',
info: { label: 'Categories', name: 'category' },
isDisplayed: false,
},
],
components: [], components: [],
status: 'resolved', status: 'resolved',
}; };

View File

@ -133,7 +133,6 @@ program
program program
.command('build') .command('build')
.option('--clean', 'Remove the build and .cache folders', false)
.option('--no-optimization', 'Build the Administration without assets optimization') .option('--no-optimization', 'Build the Administration without assets optimization')
.description('Builds the strapi admin app') .description('Builds the strapi admin app')
.action(getLocalScript('build')); .action(getLocalScript('build'));

View File

@ -12,7 +12,7 @@ const getEnabledPlugins = require('../core/loaders/plugins/get-enabled-plugins')
/** /**
* `$ strapi build` * `$ strapi build`
*/ */
module.exports = async ({ clean, optimization, forceBuild = true }) => { module.exports = async ({ optimization, forceBuild = true }) => {
const dir = process.cwd(); const dir = process.cwd();
const strapiInstance = strapi({ const strapiInstance = strapi({
@ -28,9 +28,8 @@ module.exports = async ({ clean, optimization, forceBuild = true }) => {
console.log(`Building your admin UI with ${green(env)} configuration ...`); console.log(`Building your admin UI with ${green(env)} configuration ...`);
if (clean) { // Always remove the .cache and build folders
await strapiAdmin.clean({ dir }); await strapiAdmin.clean({ dir });
}
ee({ dir }); ee({ dir });

View File

@ -29,7 +29,7 @@ module.exports = async function({ build, watchAdmin, polling, browser }) {
// Don't run the build process if the admin is in watch mode // Don't run the build process if the admin is in watch mode
if (build && !watchAdmin && serveAdminPanel && !buildExists) { if (build && !watchAdmin && serveAdminPanel && !buildExists) {
try { try {
await buildAdmin({ clean: false, optimization: false, forceBuild: false }); await buildAdmin({ optimization: false, forceBuild: false });
} catch (err) { } catch (err) {
process.exit(1); process.exit(1);
} }

View File

@ -1,25 +0,0 @@
/**
*
* This component is the skeleton around the actual pages, and should only
* contain code that should be seen on all pages. (e.g. navigation bar)
*
*/
import React from 'react';
import { Switch, Route } from 'react-router-dom';
import { NotFound } from '@strapi/helper-plugin';
import pluginId from '../../pluginId';
import HomePage from '../HomePage';
const App = () => {
return (
<div>
<Switch>
<Route path={`/plugins/${pluginId}`} component={HomePage} exact />
<Route component={NotFound} />
</Switch>
</div>
);
};
export default App;

View File

@ -1,20 +0,0 @@
/*
*
* HomePage
*
*/
import React, { memo } from 'react';
// import PropTypes from 'prop-types';
import pluginId from '../../pluginId';
const HomePage = () => {
return (
<div>
<h1>{pluginId}&apos;s HomePage</h1>
<p>Happy coding</p>
</div>
);
};
export default memo(HomePage);

View File

@ -1,26 +0,0 @@
/**
*
* Initializer
*
*/
import { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import pluginId from '../../pluginId';
const Initializer = ({ setPlugin }) => {
const ref = useRef();
ref.current = setPlugin;
useEffect(() => {
ref.current(pluginId);
}, []);
return null;
};
Initializer.propTypes = {
setPlugin: PropTypes.func.isRequired,
};
export default Initializer;

View File

@ -0,0 +1,40 @@
/**
* axios with a custom config.
*/
import axios from 'axios';
import { auth } from '@strapi/helper-plugin';
const instance = axios.create({
baseURL: process.env.STRAPI_ADMIN_BACKEND_URL,
});
instance.interceptors.request.use(
async config => {
config.headers = {
Authorization: `Bearer ${auth.getToken()}`,
Accept: 'application/json',
'Content-Type': 'application/json',
};
return config;
},
error => {
Promise.reject(error);
}
);
instance.interceptors.response.use(
response => response,
error => {
// whatever you want to do with the error
if (error.response?.status === 401) {
auth.clearAppStorage();
window.location.reload();
}
throw error;
}
);
export default instance;