diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 81a301ac52..47723e14fb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,11 +21,11 @@ Every user can send a feature request using the [issues](https://github.com/stra ## Repository Organization We made the choice to use a monorepo design such as [React](https://github.com/facebook/react/tree/master/packages), [Babel](https://github.com/babel/babel/tree/master/packages), [Meteor](https://github.com/meteor/meteor/tree/devel/packages) or [Ember](https://github.com/emberjs/ember.js/tree/master/packages) do. It allows the community to easily maintain the whole ecosystem up-to-date and consistent. -The Babel team wrotes an excellent short post about [the pros and cons of the monorepo design](https://github.com/babel/babel/blob/master/doc/design/monorepo.md). +The Babel team wrote an excellent short post about [the pros and cons of the monorepo design](https://github.com/babel/babel/blob/master/doc/design/monorepo.md). -We will do our best to keep the master branch clean as possible, with tests passing all the times. However, it can happen that the master branch moves faster than the release cycle. To ensure to use the latest stable version, please refers to the [release on npm](https://www.npmjs.com/package/strapi). +We will do our best to keep the master branch as clean as possible, with tests passing all the times. However, it can happen that the master branch moves faster than the release cycle. To ensure you have the latest stable version, please refer to the [release on npm](https://www.npmjs.com/package/strapi). -If you send a pull request, please do it again the `master` branch. We are developing upcoming versions separately to ensure non-breaking changes from master to the latest stable major version. +If you send a pull request, please do it against the `master` branch. We are developing upcoming versions separately to ensure non-breaking changes from master to the latest stable major version. *** @@ -53,7 +53,7 @@ cd strapi **Two setup are available... with or without the front-end builds.** -Without the front-end builds, you won't be able to access to the administration panel via http://localhost:1337/admin, you'll have to run the administration separately and access it through http://localhost:4000/admin. +Without the front-end builds, you won't be able to access the administration panel via http://localhost:1337/admin. You'll have to run the administration separately and access it through http://localhost:4000/admin.
diff --git a/docs/3.x.x/en/README.md b/docs/3.x.x/en/README.md index eaac1d37a2..24bed369b4 100644 --- a/docs/3.x.x/en/README.md +++ b/docs/3.x.x/en/README.md @@ -15,10 +15,10 @@ The most advanced open-source Content Management Framework to build powerful API {% endcenter %} -## v3@alpha.13 is available! +## v3@alpha.14 is available! We've been working on a major update for Strapi during the past months, rewriting the core framework and the dashboard. -This documentation is only related to Strapi v3@alpha.13 ([v1 documentation is still available](http://strapi.io/documentation/1.x.x)). +This documentation is only related to Strapi v3@alpha.14 ([v1 documentation is still available](http://strapi.io/documentation/1.x.x)). **[Get Started](getting-started/installation.md)**
Learn how to install Strapi and start developing your API. diff --git a/docs/3.x.x/en/configurations/configurations.md b/docs/3.x.x/en/configurations/configurations.md index 56a2ba4d51..66e6ab89a5 100644 --- a/docs/3.x.x/en/configurations/configurations.md +++ b/docs/3.x.x/en/configurations/configurations.md @@ -335,7 +335,8 @@ Most of the application's configurations are defined by environment. It means th - `host` (string): Host name. Default value: `localhost`. - `port` (integer): Port on which the server should be running. Default value: `1337`. - - `autoReload` (boolean): Enable or disabled server reload on files update. Default value: depends on the environment. + - `autoReload` + - `enabled` (boolean): Enable or disabled server reload on files update. Default value: depends on the environment. - [`cron`](https://en.wikipedia.org/wiki/Cron) - `enabled` (boolean): Enable or disable CRON tasks to schedule jobs at specific dates. Default value: `false`. - `admin` diff --git a/docs/3.x.x/en/guides/authentication.md b/docs/3.x.x/en/guides/authentication.md index 7449c54e76..1e74f59b0f 100644 --- a/docs/3.x.x/en/guides/authentication.md +++ b/docs/3.x.x/en/guides/authentication.md @@ -190,6 +190,140 @@ The User object is available to successfully authenticated requests. ``` +## Add a new provider + +To add a new provider on strapi, you will need to perform changes onto the following files: + +``` +packages/strapi-plugin-users-permissions/services/Providers.js +packages/strapi-plugin-users-permissions/config/functions/bootstrap.js +packages/strapi-plugin-users-permissions/admin/src/components/PopUpForm/index.js +packages/strapi-plugin-users-permissions/admin/src/translations/en.json +``` + +We will go step by step. + +### Configure your Provider request +First, we need to configure our new provider onto `Provider.js` file. + +Jump onto the `getProfile` function, you will see the list of currently available providers in the form of a `switch...case`. + +As you can see, `getProfile` take three params: + +1. provider :: The name of the used provider as a string. +2. query :: The query is the result of the provider callback. +3. callback :: The callback function who will continue the internal strapi login logic. + +Let's take the `discord` one as an example since it's not the easier, it should cover most of the case you may encounter trying to implement your own provider. + +#### Configure your oauth generic information + +```js + case 'discord': { + const discord = new Purest({ + provider: 'discord', + config: { + 'discord': { + 'https://discordapp.com/api/': { + '__domain': { + 'auth': { + 'auth': {'bearer': '[0]'} + } + }, + '{endpoint}': { + '__path': { + 'alias': '__default' + } + } + } + } + } + }); +``` + +So here, you can see that we use a module called `Purest`. This module gives us with a generic way to interact with the REST API. + +To understand each value usage, and the templating syntax, I invite you to read the [Official Purest Documentation](https://github.com/simov/purest/tree/2.x) + +You may also want to take a look onto the numerous already made configurations [here](https://github.com/simov/purest-providers/blob/master/config/providers.json). + +#### Retrieve your user informations: +```js + discord.query().get('users/@me').auth(access_token).request((err, res, body) => { + if (err) { + callback(err); + } else { + // Combine username and discriminator because discord username is not unique + var username = `${body.username}#${body.discriminator}`; + callback(null, { + username: username, + email: body.email + }); + } + }); + break; + } +``` + +Here is the next part of our switch. Now that we have properly configured our provider, we want to use it to retrieve user information. + +Here you see the real power of `purest`, you can simply make a get request on the desired URL, using the `access_token` from the `query` parameter to authenticate. + +That way, you should be able to retrieve the user info you need. + +Now, you can simply call the `callback` function with the username and email of your user. That way, strapi will be able to retrieve your user from the database and log you in. + +#### Configure the new provider model onto database + +Now, we need to configure our 'model' for our new provider. That way, our settings can be stored in the database, and managed from the admin panel. + +Into: `packages/strapi-plugin-users-permissions/config/functions/bootstrap.js` + +Simply add the fields your provider need into the `grantConfig` object. +For our discord provider it will look like: + +```js + discord: { + enabled: false, // make this provider disabled by default + icon: 'comments', // The icon to use on the UI + key: '', // our provider app id (leave it blank, you will fill it with the content manager) + secret: '', // our provider secret key (leave it blank, you will fill it with the content manager) + callback: '/auth/discord/callback', // the callback endpoint of our provider + scope: [ // the scope that we need from our user to retrieve infos + 'identify', + 'email' + ] + }, +``` + + +You have already done the hard part, now, we simply need to make our new provider available from the front side of our application. So let's do it! + + + + + +### Configure frontend for your new provider + +First, let's edit: `packages/strapi-plugin-users-permissions/admin/src/components/PopUpForm/index.js` +As for backend, we have a `switch...case` where we need to put our new provider info. + +```js + case 'discord': + return `${strapi.backendURL}/connect/discord/callback`; +``` + +Add the corresponding translation into: `packages/strapi-plugin-users-permissions/admin/src/translations/en.json` + +```js + "PopUpForm.Providers.discord.providerConfig.redirectURL": "The redirect URL to add in your Discord application configurations", +```` + +These two change will set up the popup message who appear on the UI when we will configure our new provider. + +That's it, now you should be able to use your new provider. + + ## Email templates [See the documentation on GitHub](https://github.com/strapi/strapi/blob/master/packages/strapi-plugin-users-permissions/docs/email-templates.md) diff --git a/docs/3.x.x/en/guides/upload.md b/docs/3.x.x/en/guides/upload.md index 67a82b7054..96dfc72a64 100644 --- a/docs/3.x.x/en/guides/upload.md +++ b/docs/3.x.x/en/guides/upload.md @@ -13,6 +13,7 @@ The plugin exposes a single route `POST /upload` to upload one or multiple files **Parameters** - `files`: The file(s) to upload. The value(s) can be a Buffer or Stream. +- `path`: (optional): The folder where the file(s) will be uploaded to (only supported on strapi-upload-aws-s3 now). - `refId`: (optional): The ID of the entry which the file(s) will be linked to. - `ref`: (optional): The name of the model which the file(s) will be linked to (see more below). - `source`: (optional): The name of the plugin where the model is located. @@ -111,6 +112,7 @@ Let's say that you want to have a `User` model provided by the plugin `Users & P ```js { "files": "...", // Buffer or stream of file(s) + "path": "user/avatar", // Uploading folder of file(s). "refId": "5a993616b8e66660e8baf45c", // User's Id. "ref": "user", // Model name. "source": "users-permissions", // Plugin name. diff --git a/docs/3.x.x/en/plugin-development/frontend-use-cases.md b/docs/3.x.x/en/plugin-development/frontend-use-cases.md index 74d65ad409..2b6f4e723a 100644 --- a/docs/3.x.x/en/plugin-development/frontend-use-cases.md +++ b/docs/3.x.x/en/plugin-development/frontend-use-cases.md @@ -346,7 +346,7 @@ const send = require('koa-send'); module.exports = { autoReload: async ctx => { - ctx.send({ autoReload: _.get(strapi.config.environments, 'development.server.autoReload', false) }); + ctx.send({ autoReload: _.get(strapi.config.currentEnvironment, 'server.autoReload', { enabled: false }) }); } } ``` @@ -374,8 +374,8 @@ import request from 'utils/request'; const shouldRenderCompo = (plugin) => new Promise((resolve, request) => { request('/my-plugin/autoReload') .then(response => { - // If autoReload is enabled the response is `{ autoReload: true }` - plugin.preventComponentRendering = !response.autoReload; + // If autoReload is enabled the response is `{ autoReload: { enabled: true } }` + plugin.preventComponentRendering = !response.autoReload.enabled; // Set the BlockerComponent props plugin.blockerComponentProps = { blockerComponentTitle: 'my-plugin.blocker.title', @@ -407,8 +407,8 @@ import MyCustomBlockerComponent from 'components/MyCustomBlockerComponent'; const shouldRenderCompo = (plugin) => new Promise((resolve, request) => { request('/my-plugin/autoReload') .then(response => { - // If autoReload is enabled the response is `{ autoReload: true }` - plugin.preventComponentRendering = !response.autoReload; + // If autoReload is enabled the response is `{ autoReload: { enabled: true } }` + plugin.preventComponentRendering = !response.autoReload.enabled; // Tell which component to be rendered instead plugin.blockerComponent = MyCustomBlockerComponent; diff --git a/package.json b/package.json index e313d25372..fb77993c64 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "dependencies": {}, "devDependencies": { "assert": "~1.3.0", diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json index ac84a280e2..3e69ea16b9 100755 --- a/packages/strapi-admin/package.json +++ b/packages/strapi-admin/package.json @@ -1,6 +1,6 @@ { "name": "strapi-admin", - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "description": "Strapi Admin", "repository": { "type": "git", @@ -31,8 +31,8 @@ }, "devDependencies": { "sanitize.css": "^4.1.0", - "strapi-helper-plugin": "3.0.0-alpha.13.1", - "strapi-utils": "3.0.0-alpha.13.1" + "strapi-helper-plugin": "3.0.0-alpha.14", + "strapi-utils": "3.0.0-alpha.14" }, "author": { "name": "Strapi", diff --git a/packages/strapi-email-amazon-ses/package.json b/packages/strapi-email-amazon-ses/package.json index 47ece20ed4..0665aebc18 100644 --- a/packages/strapi-email-amazon-ses/package.json +++ b/packages/strapi-email-amazon-ses/package.json @@ -1,6 +1,6 @@ { "name": "strapi-email-amazon-ses", - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "description": "Amazon SES provider for strapi email", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-email-mailgun/package.json b/packages/strapi-email-mailgun/package.json index 5509d9eaeb..9df7eabd53 100644 --- a/packages/strapi-email-mailgun/package.json +++ b/packages/strapi-email-mailgun/package.json @@ -1,6 +1,6 @@ { "name": "strapi-email-mailgun", - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "description": "Mailgun provider for strapi email plugin", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-email-sendgrid/package.json b/packages/strapi-email-sendgrid/package.json index 317ae57c95..5303150007 100644 --- a/packages/strapi-email-sendgrid/package.json +++ b/packages/strapi-email-sendgrid/package.json @@ -1,6 +1,6 @@ { "name": "strapi-email-sendgrid", - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "description": "Sendgrid provider for strapi email", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-email-sendmail/package.json b/packages/strapi-email-sendmail/package.json index 2e5b075970..9e9edaff20 100644 --- a/packages/strapi-email-sendmail/package.json +++ b/packages/strapi-email-sendmail/package.json @@ -1,6 +1,6 @@ { "name": "strapi-email-sendmail", - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "description": "Sendmail provider for strapi email", "homepage": "http://strapi.io", "keywords": [ diff --git a/packages/strapi-generate-admin/package.json b/packages/strapi-generate-admin/package.json index 8be68236f4..252edc5b31 100755 --- a/packages/strapi-generate-admin/package.json +++ b/packages/strapi-generate-admin/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-admin", - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "description": "Generate the default admin panel for a Strapi application.", "homepage": "http://strapi.io", "keywords": [ @@ -15,8 +15,8 @@ "dependencies": { "fs-extra": "^4.0.1", "lodash": "^4.17.5", - "strapi-admin": "3.0.0-alpha.13.1", - "strapi-utils": "3.0.0-alpha.13.1" + "strapi-admin": "3.0.0-alpha.14", + "strapi-utils": "3.0.0-alpha.14" }, "author": { "email": "hi@strapi.io", diff --git a/packages/strapi-generate-api/package.json b/packages/strapi-generate-api/package.json index edd1955b79..c1969b5b95 100755 --- a/packages/strapi-generate-api/package.json +++ b/packages/strapi-generate-api/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-api", - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "description": "Generate an API for a Strapi application.", "homepage": "http://strapi.io", "keywords": [ @@ -43,4 +43,4 @@ "npm": ">= 5.3.0" }, "license": "MIT" -} \ No newline at end of file +} diff --git a/packages/strapi-generate-controller/package.json b/packages/strapi-generate-controller/package.json index 1c4c981e53..77b4835c81 100755 --- a/packages/strapi-generate-controller/package.json +++ b/packages/strapi-generate-controller/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-controller", - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "description": "Generate a controller for a Strapi API.", "homepage": "http://strapi.io", "keywords": [ @@ -43,4 +43,4 @@ "npm": ">= 5.3.0" }, "license": "MIT" -} \ No newline at end of file +} diff --git a/packages/strapi-generate-model/package.json b/packages/strapi-generate-model/package.json index afb74dee4f..06381732c0 100755 --- a/packages/strapi-generate-model/package.json +++ b/packages/strapi-generate-model/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-model", - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "description": "Generate a model for a Strapi API.", "homepage": "http://strapi.io", "keywords": [ @@ -43,4 +43,4 @@ "npm": ">= 5.3.0" }, "license": "MIT" -} \ No newline at end of file +} diff --git a/packages/strapi-generate-new/lib/before.js b/packages/strapi-generate-new/lib/before.js index d61c74c006..00be647da5 100755 --- a/packages/strapi-generate-new/lib/before.js +++ b/packages/strapi-generate-new/lib/before.js @@ -145,14 +145,14 @@ module.exports = (scope, cb) => { when: !hasDatabaseConfig && scope.client.database === 'mongo', type: 'boolean', name: 'srv', - message: '+srv connection::', + message: '+srv connection:', default: _.get(scope.database, 'srv', false) }, { when: !hasDatabaseConfig, type: 'input', name: 'port', - message: 'Port(It will be ignored if you enable +srv):', + message: 'Port (It will be ignored if you enable +srv):', default: (answers) => { // eslint-disable-line no-unused-vars if (_.get(scope.database, 'port')) { return scope.database.port; @@ -259,7 +259,7 @@ module.exports = (scope, cb) => { require(path.join(`${scope.tmpPath}`, '/node_modules/', `${scope.client.connector}/lib/utils/connectivity.js`))(scope, cb.success, connectionValidation); } catch(err) { shell.rm('-r', scope.tmpPath); - console.log(err) + console.log(err); cb.success(); } }); diff --git a/packages/strapi-generate-new/package.json b/packages/strapi-generate-new/package.json index adba7007e8..dddbb92822 100755 --- a/packages/strapi-generate-new/package.json +++ b/packages/strapi-generate-new/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-new", - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "description": "Generate a new Strapi application.", "homepage": "http://strapi.io", "keywords": [ @@ -19,7 +19,7 @@ "listr": "^0.14.1", "lodash": "^4.17.5", "ora": "^2.1.0", - "strapi-utils": "3.0.0-alpha.13.1", + "strapi-utils": "3.0.0-alpha.14", "uuid": "^3.1.0" }, "scripts": { @@ -49,4 +49,4 @@ "npm": ">= 5.3.0" }, "license": "MIT" -} \ No newline at end of file +} diff --git a/packages/strapi-generate-plugin/files/admin/src/translations/ar.json b/packages/strapi-generate-plugin/files/admin/src/translations/ar.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-generate-plugin/files/admin/src/translations/ar.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-generate-plugin/files/admin/src/translations/it.json b/packages/strapi-generate-plugin/files/admin/src/translations/it.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-generate-plugin/files/admin/src/translations/it.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-generate-plugin/files/admin/src/translations/ko.json b/packages/strapi-generate-plugin/files/admin/src/translations/ko.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-generate-plugin/files/admin/src/translations/ko.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-generate-plugin/files/admin/src/translations/nl.json b/packages/strapi-generate-plugin/files/admin/src/translations/nl.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-generate-plugin/files/admin/src/translations/nl.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-generate-plugin/files/admin/src/translations/pt-BR.json b/packages/strapi-generate-plugin/files/admin/src/translations/pt-BR.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-generate-plugin/files/admin/src/translations/pt-BR.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-generate-plugin/files/admin/src/translations/pt.json b/packages/strapi-generate-plugin/files/admin/src/translations/pt.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-generate-plugin/files/admin/src/translations/pt.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-generate-plugin/package.json b/packages/strapi-generate-plugin/package.json index d0141326c5..ffaca5fa38 100755 --- a/packages/strapi-generate-plugin/package.json +++ b/packages/strapi-generate-plugin/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-plugin", - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "description": "Generate an plugin for a Strapi application.", "homepage": "http://strapi.io", "keywords": [ @@ -44,4 +44,4 @@ "npm": ">= 5.3.0" }, "license": "MIT" -} \ No newline at end of file +} diff --git a/packages/strapi-generate-policy/package.json b/packages/strapi-generate-policy/package.json index 95020ab91a..d428912cc6 100755 --- a/packages/strapi-generate-policy/package.json +++ b/packages/strapi-generate-policy/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-policy", - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "description": "Generate a policy for a Strapi API.", "homepage": "http://strapi.io", "keywords": [ @@ -43,4 +43,4 @@ "npm": ">= 5.3.0" }, "license": "MIT" -} \ No newline at end of file +} diff --git a/packages/strapi-generate-service/package.json b/packages/strapi-generate-service/package.json index 52e765a4ed..34174d4357 100755 --- a/packages/strapi-generate-service/package.json +++ b/packages/strapi-generate-service/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate-service", - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "description": "Generate a service for a Strapi API.", "homepage": "http://strapi.io", "keywords": [ @@ -43,4 +43,4 @@ "npm": ">= 5.3.0" }, "license": "MIT" -} \ No newline at end of file +} diff --git a/packages/strapi-generate/package.json b/packages/strapi-generate/package.json index 32279fc009..d6c97ec741 100755 --- a/packages/strapi-generate/package.json +++ b/packages/strapi-generate/package.json @@ -1,6 +1,6 @@ { "name": "strapi-generate", - "version": "3.0.0-alpha.13.1", + "version": "3.0.0-alpha.14", "description": "Master of ceremonies for the Strapi generators.", "homepage": "http://strapi.io", "keywords": [ @@ -17,7 +17,7 @@ "fs-extra": "^4.0.0", "lodash": "^4.17.5", "reportback": "^2.0.1", - "strapi-utils": "3.0.0-alpha.13.1" + "strapi-utils": "3.0.0-alpha.14" }, "author": { "name": "Strapi team", diff --git a/packages/strapi-helper-plugin/lib/src/components/BlockerComponent/index.js b/packages/strapi-helper-plugin/lib/src/components/BlockerComponent/index.js index e0e450d54a..1826abc4c5 100644 --- a/packages/strapi-helper-plugin/lib/src/components/BlockerComponent/index.js +++ b/packages/strapi-helper-plugin/lib/src/components/BlockerComponent/index.js @@ -59,7 +59,7 @@ const renderIde = () => (  "port": 1337,
-  "autoReload": true, +  "autoReload": { enabled: true }
 "proxi": { diff --git a/packages/strapi-helper-plugin/lib/src/components/InputFile/index.js b/packages/strapi-helper-plugin/lib/src/components/InputFile/index.js index a65ba6f048..8763ba4ae6 100644 --- a/packages/strapi-helper-plugin/lib/src/components/InputFile/index.js +++ b/packages/strapi-helper-plugin/lib/src/components/InputFile/index.js @@ -38,6 +38,10 @@ class InputFile extends React.Component { handleChange = ({ target }) => this.addFilesToProps(target.files); addFilesToProps = (files) => { + if (files.length === 0) { + return; + } + const initAcc = this.props.multiple ? cloneDeep(this.props.value) : {}; const value = Object.keys(files).reduce((acc, current) => { diff --git a/packages/strapi-helper-plugin/lib/src/components/InputToggle/index.js b/packages/strapi-helper-plugin/lib/src/components/InputToggle/index.js index 4ad458b516..a435c08280 100644 --- a/packages/strapi-helper-plugin/lib/src/components/InputToggle/index.js +++ b/packages/strapi-helper-plugin/lib/src/components/InputToggle/index.js @@ -15,7 +15,7 @@ class InputToggle extends React.Component { const target = { name: this.props.name, type: 'toggle', - value: e.target.id.includes('on'), + value: e.target.id.includes('__ON__'), }; this.props.onChange({ target }); @@ -48,7 +48,7 @@ class InputToggle extends React.Component { autoFocus={autoFocus} disabled={disabled} className={cn('btn', !value && styles.gradientOff)} - id={`off_${name}`} + id={`__OFF__${name}`} onClick={this.handleClick} tabIndex={tabIndex} type="button" @@ -58,7 +58,7 @@ class InputToggle extends React.Component {