From 25c8aa66de71198f69250175e94935118bc86305 Mon Sep 17 00:00:00 2001 From: cyril lopez Date: Thu, 11 Jan 2018 14:23:44 +0100 Subject: [PATCH 1/4] Add helpers in documentation --- docs/3.x.x/en/plugin-development/utils.md | 57 +++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/docs/3.x.x/en/plugin-development/utils.md b/docs/3.x.x/en/plugin-development/utils.md index ed2903421e..3d35014ec2 100644 --- a/docs/3.x.x/en/plugin-development/utils.md +++ b/docs/3.x.x/en/plugin-development/utils.md @@ -2,6 +2,63 @@ Strapi provides helpers so you don't have to develop again and again the same generic functions. +## Auth + +`auth.js` lets you get, set and delete data in either the browser's `localStorage` or `sessionStorage`. + +### Methods + +| Name | Description | +| ---- | ––––––––––– | +| clear(key) | Remove the data in either `localStorage` or `sessionStorage` | +| clearAppStorage() | Remove all data from both storage | +| clearToken() | Remove the user's `jwt Token` in the appropriate browser's storage | +| clearUserInfo() | Remove the user's info from storage | +| get(key) | Get the item in the browser's storage | +| getToken() | Get the user's `jwtToken` | +| getUserInfo() | Get the user's infos | +| set(value, key) | Set an item in the `sessionStorage`. If `true` is passed a 3rd parameter it sets the value in the `localStorage` | +| setToken(value) | Set the user's `jwtToken` in the `sessionStorage`. If `true` is passed a 3rd parameter it sets the value in the `localStorage` | +| setUserInfo(value) | Set the user's info in the `sessionStorage`. If `true` is passed a 3rd parameter it sets the value in the `localStorage` | + + +```js +import auth from 'utils/auth'; + +// ... +// +auth.setToken('12345', true); // This will set 1234 in the browser's localStorage associated with the key: jwtToken +``` + +## Colors + +This function allows to darken a color. + +### Usage + +```js +import { darken } from 'utils/colors'; + +const linkColor = darken('#f5f5f5', 1.5); // Will darken #F5F5F5 by 1.5% which gives #f2f2f2. +``` + +## Get URL Query Parameters + +The helpers allows to retrieve the query parameters in the URL + +### Example + +```js +import getQueryParameters from 'utils/getQueryParameters'; + +const URL = '/create?source=users-permissions'; +const source = getQueryParameters(URL, 'source'); + +console.log(source); // users-permissions + +``` + + ## Request helper A request helper is available to handle all requests inside a plugin. From 8222a30d98a30a218a0861ba12f0ff08a16621b9 Mon Sep 17 00:00:00 2001 From: cyril lopez Date: Wed, 17 Jan 2018 10:46:29 +0100 Subject: [PATCH 2/4] Fix doc typos --- docs/3.x.x/en/plugin-development/utils.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/3.x.x/en/plugin-development/utils.md b/docs/3.x.x/en/plugin-development/utils.md index 3d35014ec2..23bc3ab99c 100644 --- a/docs/3.x.x/en/plugin-development/utils.md +++ b/docs/3.x.x/en/plugin-development/utils.md @@ -9,7 +9,7 @@ Strapi provides helpers so you don't have to develop again and again the same ge ### Methods | Name | Description | -| ---- | ––––––––––– | +| ---- | ----------- | | clear(key) | Remove the data in either `localStorage` or `sessionStorage` | | clearAppStorage() | Remove all data from both storage | | clearToken() | Remove the user's `jwt Token` in the appropriate browser's storage | @@ -17,9 +17,9 @@ Strapi provides helpers so you don't have to develop again and again the same ge | get(key) | Get the item in the browser's storage | | getToken() | Get the user's `jwtToken` | | getUserInfo() | Get the user's infos | -| set(value, key) | Set an item in the `sessionStorage`. If `true` is passed a 3rd parameter it sets the value in the `localStorage` | -| setToken(value) | Set the user's `jwtToken` in the `sessionStorage`. If `true` is passed a 3rd parameter it sets the value in the `localStorage` | -| setUserInfo(value) | Set the user's info in the `sessionStorage`. If `true` is passed a 3rd parameter it sets the value in the `localStorage` | +| set(value, key, isLocalStorage) | Set an item in the `sessionStorage`. If `true` is passed as the 3rd parameter it sets the value in the `localStorage` | +| setToken(value, isLocalStorage) | Set the user's `jwtToken` in the `sessionStorage`. If `true` is passed as the 2nd parameter it sets the value in the `localStorage` | +| setUserInfo(value, isLocalStorage) | Set the user's info in the `sessionStorage`. If `true` is passed as the 2nd parameter it sets the value in the `localStorage` | ```js @@ -44,7 +44,7 @@ const linkColor = darken('#f5f5f5', 1.5); // Will darken #F5F5F5 by 1.5% which g ## Get URL Query Parameters -The helpers allows to retrieve the query parameters in the URL +The helpers allows to retrieve the query parameters in the URL. ### Example @@ -425,7 +425,6 @@ function* defaultSaga() { export default defaultSaga; ``` -*** *** ### Example with server autoReload watcher From 5adff6248194a8d52418869a72dd59346123db76 Mon Sep 17 00:00:00 2001 From: Jim Laurie Date: Thu, 18 Jan 2018 11:18:48 +0100 Subject: [PATCH 3/4] Update strapi version in documentation --- docs/3.x.x/en/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/3.x.x/en/README.md b/docs/3.x.x/en/README.md index 8b17e2ae75..47f4f89e13 100644 --- a/docs/3.x.x/en/README.md +++ b/docs/3.x.x/en/README.md @@ -12,10 +12,10 @@ The most advanced open-source Content Management Framework to build powerful API {% endcenter %} -## v3@alpha.7 is available! +## v3@alpha.8 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.7 ([v1 documentation is still available](http://strapi.io/documentation/1.x.x)). +This documentation is only related to Strapi v3@alpha.8 ([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. @@ -36,4 +36,4 @@ Understand how to develop your own plugin. Learn about Strapi's API, the `strapi` object that is available in your backend. **[Migration guide](migration/migration-guide.md)**
-Migrate from v1 to v3@alpha.7. +Migrate from v1 to v3@alpha.8. From f129a249206185f71fea9e0d3be39878baad581e Mon Sep 17 00:00:00 2001 From: Jim LAURIE Date: Thu, 18 Jan 2018 11:47:12 +0100 Subject: [PATCH 4/4] Delete text migration guide link --- docs/3.x.x/en/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/3.x.x/en/README.md b/docs/3.x.x/en/README.md index 47f4f89e13..dab7d7d2ed 100644 --- a/docs/3.x.x/en/README.md +++ b/docs/3.x.x/en/README.md @@ -36,4 +36,3 @@ Understand how to develop your own plugin. Learn about Strapi's API, the `strapi` object that is available in your backend. **[Migration guide](migration/migration-guide.md)**
-Migrate from v1 to v3@alpha.8.