From 1d4a193f7eb0b0ac79aa3ae6e3cf36408ab39d54 Mon Sep 17 00:00:00 2001 From: Johann Pinson Date: Tue, 19 Jun 2018 11:13:32 +0200 Subject: [PATCH 1/8] feat(graphql): add DateTime support instead of String --- packages/strapi-plugin-graphql/package.json | 3 ++- packages/strapi-plugin-graphql/services/GraphQL.js | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/strapi-plugin-graphql/package.json b/packages/strapi-plugin-graphql/package.json index b048fa98e2..c8e35cade1 100644 --- a/packages/strapi-plugin-graphql/package.json +++ b/packages/strapi-plugin-graphql/package.json @@ -27,7 +27,8 @@ "graphql-depth-limit": "^1.1.0", "graphql-playground-middleware-koa": "^1.6.1", "graphql-tools": "^2.23.1", - "graphql-type-json": "^0.2.0", + "graphql-type-json": "^0.2.1", + "graphql-type-datetime": "^0.2.1", "pluralize": "^7.0.0", "strapi-utils": "3.0.0-alpha.12.4" }, diff --git a/packages/strapi-plugin-graphql/services/GraphQL.js b/packages/strapi-plugin-graphql/services/GraphQL.js index 0e43ea9674..c345637d1e 100644 --- a/packages/strapi-plugin-graphql/services/GraphQL.js +++ b/packages/strapi-plugin-graphql/services/GraphQL.js @@ -14,6 +14,7 @@ const pluralize = require('pluralize'); const graphql = require('graphql'); const { makeExecutableSchema } = require('graphql-tools'); const GraphQLJSON = require('graphql-type-json'); +const GraphQLDateTime = require('graphql-type-datetime'); const policyUtils = require('strapi-utils').policy; module.exports = { @@ -170,6 +171,9 @@ module.exports = { case 'float': type = 'Float'; break; + case 'date': + type = 'DateTime'; + break; case 'enumeration': type = this.convertEnumType(definition, modelName, attributeName); break; @@ -453,8 +457,8 @@ module.exports = { // Add timestamps attributes. if (_.get(model, 'options.timestamps') === true) { Object.assign(initialState, { - createdAt: 'String!', - updatedAt: 'String!' + createdAt: 'DateTime!', + updatedAt: 'DateTime!' }); Object.assign(acc.resolver[globalId], { @@ -777,10 +781,11 @@ module.exports = { addCustomScalar: (resolvers) => { Object.assign(resolvers, { - JSON: GraphQLJSON + JSON: GraphQLJSON, + DateTime: GraphQLDateTime, }); - return 'scalar JSON'; + return 'scalar JSON \n scalar DateTime'; }, /** From 34aef5bbc6e82c3a8251ebd47b3e4a9e0fa930a2 Mon Sep 17 00:00:00 2001 From: Johann Pinson Date: Wed, 20 Jun 2018 10:09:34 +0200 Subject: [PATCH 2/8] fix(datetime): update npm dependencies --- packages/strapi-plugin-graphql/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/strapi-plugin-graphql/package.json b/packages/strapi-plugin-graphql/package.json index c8e35cade1..91e065a726 100644 --- a/packages/strapi-plugin-graphql/package.json +++ b/packages/strapi-plugin-graphql/package.json @@ -28,7 +28,7 @@ "graphql-playground-middleware-koa": "^1.6.1", "graphql-tools": "^2.23.1", "graphql-type-json": "^0.2.1", - "graphql-type-datetime": "^0.2.1", + "graphql-type-datetime": "^0.2.2", "pluralize": "^7.0.0", "strapi-utils": "3.0.0-alpha.12.4" }, From 6bbc5c899333c8d16f7de3e1afbabbc9f840f31c Mon Sep 17 00:00:00 2001 From: Johann Pinson Date: Wed, 20 Jun 2018 19:08:58 +0200 Subject: [PATCH 3/8] fix(datetime): add `datetime` and `timestamp` detection --- packages/strapi-plugin-graphql/services/GraphQL.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/strapi-plugin-graphql/services/GraphQL.js b/packages/strapi-plugin-graphql/services/GraphQL.js index c345637d1e..e240236ec9 100644 --- a/packages/strapi-plugin-graphql/services/GraphQL.js +++ b/packages/strapi-plugin-graphql/services/GraphQL.js @@ -172,6 +172,8 @@ module.exports = { type = 'Float'; break; case 'date': + case 'datetime': + case 'timestamp': type = 'DateTime'; break; case 'enumeration': From ffaa3fb92aa4eaea2132b0ca2f0cda766c8e961e Mon Sep 17 00:00:00 2001 From: Johann Pinson Date: Tue, 3 Jul 2018 16:31:23 +0200 Subject: [PATCH 4/8] fix(graphql): add `time` attribute type to DateTime scalar --- packages/strapi-plugin-graphql/services/GraphQL.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/strapi-plugin-graphql/services/GraphQL.js b/packages/strapi-plugin-graphql/services/GraphQL.js index e240236ec9..2ad4ba572c 100644 --- a/packages/strapi-plugin-graphql/services/GraphQL.js +++ b/packages/strapi-plugin-graphql/services/GraphQL.js @@ -171,6 +171,7 @@ module.exports = { case 'float': type = 'Float'; break; + case 'time': case 'date': case 'datetime': case 'timestamp': From d3ef2f8e3cb11ac380494780bbe54e33c7dd8955 Mon Sep 17 00:00:00 2001 From: Kati Frantz Date: Tue, 3 Jul 2018 15:23:13 +0100 Subject: [PATCH 5/8] fetch current actions from database use results for comparing if new actions have been added to controllers --- .../services/UsersPermissions.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/strapi-plugin-users-permissions/services/UsersPermissions.js b/packages/strapi-plugin-users-permissions/services/UsersPermissions.js index 4e5fc46f2f..8064aa2aff 100644 --- a/packages/strapi-plugin-users-permissions/services/UsersPermissions.js +++ b/packages/strapi-plugin-users-permissions/services/UsersPermissions.js @@ -199,7 +199,11 @@ module.exports = { }, updatePermissions: async function (cb) { - const actions = strapi.plugins['users-permissions'].config.actions || []; + // fetch all the current permissions from the database, and format them into an array of actions. + const databasePermissions = await strapi.query('permission', 'users-permissions').find(); + const actions = databasePermissions + .map(permission => `${permission.type}.${permission.controller}.${permission.action}`); + // Aggregate first level actions. const appActions = Object.keys(strapi.api || {}).reduce((acc, api) => { @@ -232,7 +236,7 @@ module.exports = { // Merge array into one. const currentActions = appActions.concat(pluginsActions); // Count permissions available. - const permissions = await strapi.query('permission', 'users-permissions').count(); + const permissions = databasePermissions.length; // Compare to know if actions have been added or removed from controllers. if (!_.isEqual(actions, currentActions) || permissions < 1) { From f76e9baac90ca5391bdc0b9b881cbe8744d19344 Mon Sep 17 00:00:00 2001 From: Kamal Bennani Date: Mon, 16 Jul 2018 23:47:08 +0200 Subject: [PATCH 6/8] Take into account allowGa config prop --- .../strapi-admin/admin/src/containers/AdminPage/saga.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/strapi-admin/admin/src/containers/AdminPage/saga.js b/packages/strapi-admin/admin/src/containers/AdminPage/saga.js index 6f2437af0e..6bb488aeb9 100644 --- a/packages/strapi-admin/admin/src/containers/AdminPage/saga.js +++ b/packages/strapi-admin/admin/src/containers/AdminPage/saga.js @@ -11,15 +11,15 @@ import { GET_GA_STATUS, GET_LAYOUT } from './constants'; function* getGaStatus() { try { - const [allowGa, strapiVersion, currentEnvironment] = yield [ + const [{ allowGa }, { strapiVersion }, { currentEnvironment }] = yield [ call(request, '/admin/gaConfig', { method: 'GET' }), call(request, '/admin/strapiVersion', { method: 'GET' }), call(request, '/admin/currentEnvironment', { method: 'GET' }), ]; - yield put(getCurrEnvSucceeded(currentEnvironment.currentEnvironment)); + yield put(getCurrEnvSucceeded(currentEnvironment)); yield put(getGaStatusSucceeded(allowGa)); - yield put(getStrapiVersionSucceeded(strapiVersion.strapiVersion)); + yield put(getStrapiVersionSucceeded(strapiVersion)); } catch(err) { strapi.notification.error('notification.error'); } From a1330a5d811a4549dde4d62545065e3781b0c479 Mon Sep 17 00:00:00 2001 From: John Williamson Date: Tue, 17 Jul 2018 13:52:18 +1000 Subject: [PATCH 7/8] clarified path --- docs/3.x.x/en/guides/email.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/3.x.x/en/guides/email.md b/docs/3.x.x/en/guides/email.md index b9edddd7f8..f852e57929 100644 --- a/docs/3.x.x/en/guides/email.md +++ b/docs/3.x.x/en/guides/email.md @@ -27,8 +27,8 @@ To install a new provider run: $ npm install strapi-email-sendgrid@alpha --save ``` -We have two providers available `strapi-email-sendgrid` and `strapi-upload-mailgun`, use the alpha tag to install one of them. Then, visit `/admin/plugins/email/configurations/development` and configure the provider. +We have two providers available `strapi-email-sendgrid` and `strapi-upload-mailgun`, use the alpha tag to install one of them. Then, visit `/admin/plugins/email/configurations/development` on your web browser and configure the provider. If you want to create your own, make sure the name starts with `strapi-email-` (duplicating an existing one will be easier to create), modify the `auth` config object and customize the `send` functions. -Check all community providers available on npmjs.org - [Providers list](https://www.npmjs.com/search?q=strapi-email-) \ No newline at end of file +Check all community providers available on npmjs.org - [Providers list](https://www.npmjs.com/search?q=strapi-email-) From ea35200b8c05e049c6b6c8ae3eb38ad20ebf2026 Mon Sep 17 00:00:00 2001 From: John Williamson Date: Tue, 17 Jul 2018 14:06:12 +1000 Subject: [PATCH 8/8] Update upload.md --- docs/3.x.x/en/guides/upload.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/3.x.x/en/guides/upload.md b/docs/3.x.x/en/guides/upload.md index eae41c75f4..67a82b7054 100644 --- a/docs/3.x.x/en/guides/upload.md +++ b/docs/3.x.x/en/guides/upload.md @@ -133,7 +133,7 @@ To install a new provider run: $ npm install strapi-upload-aws-s3@alpha --save ``` -We have two providers available `strapi-upload-aws-s3` and `strapi-upload-cloudinary`, use the alpha tag to install one of them. Then, visit `/admin/plugins/upload/configurations/development` and configure the provider. +We have two providers available `strapi-upload-aws-s3` and `strapi-upload-cloudinary`, use the alpha tag to install one of them. Then, visit `/admin/plugins/upload/configurations/development` on your web browser and configure the provider. If you want to create your own, make sure the name starts with `strapi-upload-` (duplicating an existing one will be easier to create), modify the `auth` config object and customize the `upload` and `delete` functions.