@@ -266,10 +289,17 @@ function mapDispatchToProps(dispatch) {
);
}
-const withConnect = connect(mapStateToProps, mapDispatchToProps);
+const withConnect = connect(
+ mapStateToProps,
+ mapDispatchToProps,
+);
const withReducer = injectReducer({ key: 'homePage', reducer });
const withSaga = injectSaga({ key: 'homePage', saga });
// export default connect(mapDispatchToProps)(HomePage);
-export default compose(withReducer, withSaga, withConnect)(HomePage);
+export default compose(
+ withReducer,
+ withSaga,
+ withConnect,
+)(HomePage);
diff --git a/packages/strapi-admin/admin/src/containers/HomePage/saga.js b/packages/strapi-admin/admin/src/containers/HomePage/saga.js
index 881ecb72e3..90fd9ea455 100644
--- a/packages/strapi-admin/admin/src/containers/HomePage/saga.js
+++ b/packages/strapi-admin/admin/src/containers/HomePage/saga.js
@@ -1,14 +1,7 @@
import 'whatwg-fetch';
import { dropRight, take } from 'lodash';
import removeMd from 'remove-markdown';
-import {
- all,
- call,
- fork,
- put,
- select,
- takeLatest,
-} from 'redux-saga/effects';
+import { all, call, fork, put, select, takeLatest } from 'redux-saga/effects';
import request from 'utils/request';
import { getArticlesSucceeded, submitSucceeded } from './actions';
import { GET_ARTICLES, SUBMIT } from './constants';
@@ -19,7 +12,11 @@ function* getArticles() {
const articles = yield call(fetchArticles);
const posts = articles.posts.reduce((acc, curr) => {
// Limit to 200 characters and remove last word.
- const content = dropRight(take(removeMd(curr.markdown), 250).join('').split(' ')).join(' ');
+ const content = dropRight(
+ take(removeMd(curr.markdown), 250)
+ .join('')
+ .split(' '),
+ ).join(' ');
acc.push({
title: curr.title,
@@ -31,17 +28,19 @@ function* getArticles() {
}, []);
yield put(getArticlesSucceeded(posts));
- } catch(err) {
+ } catch (err) {
// Silent
}
}
-
function* submit() {
try {
const body = yield select(makeSelectBody());
- yield call(request, 'https://analytics.strapi.io/register', { method: 'POST', body });
- } catch(err) {
+ yield call(request, 'https://analytics.strapi.io/register', {
+ method: 'POST',
+ body,
+ });
+ } catch (err) {
// silent
} finally {
strapi.notification.success('HomePage.notification.newsLetter.success');
@@ -56,11 +55,12 @@ function* defaultSaga() {
]);
}
-
function fetchArticles() {
- return fetch('https://blog.strapi.io/ghost/api/v0.1/posts/?client_id=ghost-frontend&client_secret=1f260788b4ec&limit=2', {})
- .then(resp => {
- return resp.json ? resp.json() : resp;
- });
+ return fetch(
+ 'https://blog.strapi.io/ghost/api/v0.1/posts/?client_id=ghost-frontend&client_secret=1f260788b4ec&limit=2',
+ {},
+ ).then(resp => {
+ return resp.json ? resp.json() : resp;
+ });
}
export default defaultSaga;
diff --git a/packages/strapi-admin/admin/src/containers/Onboarding/actions.js b/packages/strapi-admin/admin/src/containers/Onboarding/actions.js
new file mode 100644
index 0000000000..5f78a9b7c3
--- /dev/null
+++ b/packages/strapi-admin/admin/src/containers/Onboarding/actions.js
@@ -0,0 +1,64 @@
+/*
+ *
+ * Onboarding actions
+ *
+ */
+
+import { GET_VIDEOS, GET_VIDEOS_SUCCEEDED, SHOULD_OPEN_MODAL, ON_CLICK, SET_VIDEOS_DURATION, UPDATE_VIDEO_START_TIME, SET_VIDEO_END, REMOVE_VIDEOS } from './constants';
+
+export function getVideos() {
+ return {
+ type: GET_VIDEOS,
+ };
+}
+
+export function getVideosSucceeded(videos) {
+ return {
+ type: GET_VIDEOS_SUCCEEDED,
+ videos,
+ };
+}
+
+export function shouldOpenModal(opened) {
+ return {
+ type: SHOULD_OPEN_MODAL,
+ opened,
+ };
+}
+
+export function onClick(e) {
+ return {
+ type: ON_CLICK,
+ index: parseInt(e.currentTarget.id, 10),
+ };
+}
+
+export function setVideoDuration(index, duration) {
+ return {
+ type: SET_VIDEOS_DURATION,
+ index: parseInt(index, 10),
+ duration: parseFloat(duration, 10),
+ };
+}
+
+export function updateVideoStartTime(index, startTime) {
+ return {
+ type: UPDATE_VIDEO_START_TIME,
+ index: parseInt(index, 10),
+ startTime: parseFloat(startTime, 10),
+ };
+}
+
+export function setVideoEnd(index, end) {
+ return {
+ type: SET_VIDEO_END,
+ index: parseInt(index, 10),
+ end,
+ };
+}
+
+export function removeVideos() {
+ return {
+ type: REMOVE_VIDEOS,
+ };
+}
diff --git a/packages/strapi-admin/admin/src/containers/Onboarding/constants.js b/packages/strapi-admin/admin/src/containers/Onboarding/constants.js
new file mode 100644
index 0000000000..23e9a7c753
--- /dev/null
+++ b/packages/strapi-admin/admin/src/containers/Onboarding/constants.js
@@ -0,0 +1,15 @@
+/*
+ *
+ * Onboarding constants
+ *
+ */
+
+export const GET_VIDEOS = 'StrapiAdmin/Onboarding/GET_VIDEOS';
+export const GET_VIDEOS_SUCCEEDED =
+ 'StrapiAdmin/Onboarding/GET_VIDEOS_SUCCEEDED';
+export const SHOULD_OPEN_MODAL = 'StrapiAdmin/Onboarding/SHOULD_OPEN_MODAL';
+export const ON_CLICK = 'StrapiAdmin/Onboarding/ON_CLICK';
+export const SET_VIDEOS_DURATION = 'StrapiAdmin/Onboarding/SET_VIDEOS_DURATION';
+export const UPDATE_VIDEO_START_TIME = 'StrapiAdmin/Onboarding/UPDATE_VIDEO_START_TIME';
+export const SET_VIDEO_END = 'StrapiAdmin/Onboarding/SET_VIDEO_END';
+export const REMOVE_VIDEOS = 'StrapiAdmin/Onboarding/REMOVE_VIDEOS';
diff --git a/packages/strapi-admin/admin/src/containers/Onboarding/index.js b/packages/strapi-admin/admin/src/containers/Onboarding/index.js
new file mode 100644
index 0000000000..c6978797cb
--- /dev/null
+++ b/packages/strapi-admin/admin/src/containers/Onboarding/index.js
@@ -0,0 +1,182 @@
+/**
+ *
+ * Onboarding
+ *
+ */
+
+import React from 'react';
+import PropTypes from 'prop-types';
+import cn from 'classnames';
+import { connect } from 'react-redux';
+import { bindActionCreators, compose } from 'redux';
+import { FormattedMessage } from 'react-intl';
+import injectSaga from 'utils/injectSaga';
+import injectReducer from 'utils/injectReducer';
+
+import OnboardingVideo from 'components/OnboardingVideo';
+
+import { getVideos, onClick, removeVideos, setVideoDuration, setVideoEnd, updateVideoStartTime } from './actions';
+import makeSelectOnboarding from './selectors';
+import reducer from './reducer';
+import saga from './saga';
+
+import styles from './styles.scss';
+
+export class Onboarding extends React.Component {
+ state = { showVideos: false };
+
+ componentDidMount() {
+ this.props.getVideos();
+ }
+
+ componentDidUpdate(prevProps) {
+ const { shouldOpenModal } = this.props;
+
+ if (shouldOpenModal !== prevProps.shouldOpenModal && shouldOpenModal) {
+ this.handleOpenModal();
+ }
+ }
+
+ componentWillUnmount() {
+ this.props.removeVideos();
+ }
+
+ setVideoEnd = () => {
+ this.setVideoEnd();
+ }
+
+ didPlayVideo = (index, currTime) => {
+ const eventName = `didPlay${index}GetStartedVideo`;
+ this.context.emitEvent(eventName, {timestamp: currTime});
+ }
+
+ didStopVideo = (index, currTime) => {
+ const eventName = `didStop${index}Video`;
+ this.context.emitEvent(eventName, {timestamp: currTime});
+ }
+
+ handleOpenModal = () => this.setState({ showVideos: true });
+
+ handleVideosToggle = () => {
+ this.setState(prevState => ({ showVideos: !prevState.showVideos }));
+
+ const { showVideos } = this.state;
+ const eventName = showVideos ? 'didOpenGetStartedVideoContainer' : 'didCloseGetStartedVideoContainer';
+
+ this.context.emitEvent(eventName);
+ };
+
+ updateCurrentTime = (index, current, duration) => {
+
+ this.props.updateVideoStartTime(index, current);
+
+ const percent = current * 100 / duration;
+ const video = this.props.videos[index];
+
+ if (percent >= 80) {
+ if (video.end === false) {
+ this.updateEnd(index);
+ }
+ }
+ };
+
+ updateEnd = (index) => {
+ this.props.setVideoEnd(index, true);
+ };
+
+ // eslint-disable-line jsx-handler-names
+ render() {
+ const { videos, onClick, setVideoDuration } = this.props;
+
+ return (
+
0 ? styles.visible : styles.hidden)}>
+
+
+
+ {videos.length && (
+
{Math.floor((videos.filter(v => v.end).length)*100/videos.length)}
+ )}
+
+
+ {videos.map((video, i) => {
+ return (
+
+ );
+ })}
+
+
+
+
+
+
+
+ );
+ }
+}
+Onboarding.contextTypes = {
+ emitEvent: PropTypes.func,
+};
+
+Onboarding.defaultProps = {
+ onClick: () => {},
+ removeVideos: () => {},
+ setVideoDuration: () => {},
+ setVideoEnd: () => {},
+ shouldOpenModal: false,
+ videos: [],
+ updateVideoStartTime: () => {},
+};
+
+Onboarding.propTypes = {
+ getVideos: PropTypes.func.isRequired,
+ onClick: PropTypes.func,
+ removeVideos: PropTypes.func,
+ setVideoDuration: PropTypes.func,
+ setVideoEnd: PropTypes.func,
+ shouldOpenModal: PropTypes.bool,
+ updateVideoStartTime: PropTypes.func,
+ videos: PropTypes.array,
+};
+
+const mapStateToProps = makeSelectOnboarding();
+
+function mapDispatchToProps(dispatch) {
+ return bindActionCreators({ getVideos, onClick, setVideoDuration, updateVideoStartTime, setVideoEnd, removeVideos }, dispatch);
+}
+
+const withConnect = connect(
+ mapStateToProps,
+ mapDispatchToProps,
+);
+
+/* Remove this line if the container doesn't have a route and
+ * check the documentation to see how to create the container's store
+ */
+const withReducer = injectReducer({ key: 'onboarding', reducer });
+
+/* Remove the line below the container doesn't have a route and
+ * check the documentation to see how to create the container's store
+ */
+const withSaga = injectSaga({ key: 'onboarding', saga });
+
+export default compose(
+ withReducer,
+ withSaga,
+ withConnect,
+)(Onboarding);
diff --git a/packages/strapi-admin/admin/src/containers/Onboarding/reducer.js b/packages/strapi-admin/admin/src/containers/Onboarding/reducer.js
new file mode 100644
index 0000000000..06e15ff8ec
--- /dev/null
+++ b/packages/strapi-admin/admin/src/containers/Onboarding/reducer.js
@@ -0,0 +1,69 @@
+/*
+ *
+ * Onboarding reducer
+ *
+ */
+
+import { fromJS } from 'immutable';
+import { GET_VIDEOS_SUCCEEDED, SHOULD_OPEN_MODAL, ON_CLICK, SET_VIDEOS_DURATION, UPDATE_VIDEO_START_TIME, SET_VIDEO_END, REMOVE_VIDEOS } from './constants';
+
+const initialState = fromJS({
+ videos: fromJS([]),
+});
+
+function onboardingReducer(state = initialState, action) {
+ switch (action.type) {
+ case GET_VIDEOS_SUCCEEDED:
+ return state.update('videos', () => fromJS(action.videos));
+ case SHOULD_OPEN_MODAL:
+ return state.update('shouldOpenModal', () => action.opened);
+ case ON_CLICK:
+ return state.updateIn(['videos'], list => {
+ return list.reduce((acc, current, index) => {
+
+ if (index === action.index) {
+ return acc.updateIn([index, 'isOpen'], v => !v);
+ }
+
+ return acc.updateIn([index, 'isOpen'], () => false);
+ }, list);
+ });
+ case SET_VIDEOS_DURATION:
+ return state.updateIn(['videos', action.index, 'duration'], () => action.duration);
+ case UPDATE_VIDEO_START_TIME: {
+
+ const storedVideos = JSON.parse(localStorage.getItem('videos'));
+ const videos = state.updateIn(['videos'], list => {
+ return list.reduce((acc, current, index) => {
+
+ if (index === action.index) {
+ storedVideos[index].startTime = action.startTime;
+ return acc.updateIn([index, 'startTime'], () => action.startTime);
+ }
+
+ storedVideos[index].startTime = 0;
+
+ return acc.updateIn([index, 'startTime'], () => 0);
+ }, list);
+ });
+
+ localStorage.setItem('videos', JSON.stringify(storedVideos));
+
+ return videos;
+ }
+ case SET_VIDEO_END: {
+
+ const storedVideos = JSON.parse(localStorage.getItem('videos'));
+ storedVideos[action.index].end = action.end;
+ localStorage.setItem('videos', JSON.stringify(storedVideos));
+
+ return state.updateIn(['videos', action.index, 'end'], () => action.end);
+ }
+ case REMOVE_VIDEOS:
+ return initialState;
+ default:
+ return state;
+ }
+}
+
+export default onboardingReducer;
diff --git a/packages/strapi-admin/admin/src/containers/Onboarding/saga.js b/packages/strapi-admin/admin/src/containers/Onboarding/saga.js
new file mode 100644
index 0000000000..541a9aed58
--- /dev/null
+++ b/packages/strapi-admin/admin/src/containers/Onboarding/saga.js
@@ -0,0 +1,66 @@
+import request from 'utils/request';
+import { all, call, fork, takeLatest, put } from 'redux-saga/effects';
+
+import { GET_VIDEOS } from './constants';
+import { getVideosSucceeded, shouldOpenModal } from './actions';
+
+function* getVideos() {
+ try {
+ const data = yield call(request, 'https://strapi.io/videos', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ },
+ false,
+ true,
+ { noAuth: true },
+ );
+
+ const storedVideo = JSON.parse(localStorage.getItem('videos')) || null;
+
+ const videos = data.map(video => {
+ const { end, startTime } = storedVideo ? storedVideo.find(v => v.order === video.order) : { end: false, startTime: 0};
+
+ return {
+ ...video,
+ duration: null,
+ end,
+ isOpen: false,
+ key: video.order,
+ startTime,
+ };
+ }).sort((a,b) => (a.order - b.order));
+
+ localStorage.setItem('videos', JSON.stringify(videos));
+
+ yield put(
+ getVideosSucceeded(videos),
+ );
+
+ const isFirstTime = JSON.parse(localStorage.getItem('onboarding')) || null;
+
+ if (isFirstTime === null) {
+ yield new Promise(resolve => {
+ setTimeout(() => {
+ resolve();
+ }, 500);
+ });
+
+ yield put(
+ shouldOpenModal(true),
+ );
+ localStorage.setItem('onboarding', true);
+ }
+
+ } catch (err) {
+ console.log(err); // eslint-disable-line no-console
+ }
+}
+
+
+function* defaultSaga() {
+ yield all([fork(takeLatest, GET_VIDEOS, getVideos)]);
+}
+
+export default defaultSaga;
diff --git a/packages/strapi-admin/admin/src/containers/Onboarding/selectors.js b/packages/strapi-admin/admin/src/containers/Onboarding/selectors.js
new file mode 100644
index 0000000000..2f5dd23c08
--- /dev/null
+++ b/packages/strapi-admin/admin/src/containers/Onboarding/selectors.js
@@ -0,0 +1,25 @@
+import { createSelector } from 'reselect';
+
+/**
+ * Direct selector to the onboarding state domain
+ */
+const selectOnboardingDomain = () => (state) => state.get('onboarding');
+
+/**
+ * Other specific selectors
+ */
+
+
+/**
+ * Default selector used by Onboarding
+ */
+
+const makeSelectOnboarding = () => createSelector(
+ selectOnboardingDomain(),
+ (substate) => substate.toJS()
+);
+
+export default makeSelectOnboarding;
+export {
+ selectOnboardingDomain,
+};
diff --git a/packages/strapi-admin/admin/src/containers/Onboarding/styles.scss b/packages/strapi-admin/admin/src/containers/Onboarding/styles.scss
new file mode 100644
index 0000000000..1d0af4dcd4
--- /dev/null
+++ b/packages/strapi-admin/admin/src/containers/Onboarding/styles.scss
@@ -0,0 +1,116 @@
+.videosWrapper {
+ position: fixed;
+ right: 15px;
+ bottom: 15px;
+ button,
+ button:focus,
+ a {
+ cursor: pointer;
+ outline: 0;
+ }
+ p {
+ margin-bottom: 0;
+ }
+ .videosHeader {
+ padding: 25px 15px 0 15px;
+ p {
+ display: inline-block;
+ vertical-align: top;
+ width: 50%;
+ font-family: Lato;
+ font-weight: bold;
+ font-size: 11px;
+ color: #5c5f66;
+ letter-spacing: 0.5px;
+ text-transform: uppercase;
+ &:last-of-type {
+ color: #5a9e06;
+ text-align: right;
+ }
+ }
+ }
+ &.visible {
+ opacity: 1;
+ }
+ &.hidden {
+ opacity: 0;
+ }
+ .videosContent {
+ min-width: 320px;
+ margin-bottom: 10px;
+ margin-right: 15px;
+ background-color: white;
+ box-shadow: 0 2px 4px 0 #e3e9f3;
+ border-radius: 3px;
+ overflow: hidden;
+ &.shown {
+ animation: fadeIn 0.5s forwards;
+ }
+ &.hide {
+ animation: fadeOut 0.5s forwards;
+ }
+
+ ul {
+ padding: 10px 0;
+ margin-bottom: 0;
+ list-style: none;
+ }
+ }
+ .openBtn {
+ float: right;
+ width: 38px;
+ height: 38px;
+ button {
+ width: 100%;
+ height: 100%;
+ border-radius: 50%;
+ color: white;
+ background: #0e7de7;
+ box-shadow: 0px 2px 4px 0px rgba(227, 233, 243, 1);
+ i:last-of-type {
+ display: none;
+ }
+ &.active {
+ i:first-of-type {
+ display: none;
+ }
+ i:last-of-type {
+ display: block;
+ }
+ }
+ }
+ }
+}
+
+
+@keyframes fadeIn {
+ 0% {
+ width: auto;
+ height: auto;
+ opacity: 0;
+ }
+
+ 5% {
+ opacity: 0;
+ }
+
+ 100% {
+ opacity: 1;
+ }
+}
+
+@keyframes fadeOut {
+ 0% {
+ opacity: 1;
+ }
+
+ 60% {
+ opacity: 0;
+ }
+
+ 100% {
+ opacity: 0;
+ width: 0;
+ height: 0;
+ }
+}
\ No newline at end of file
diff --git a/packages/strapi-admin/admin/src/containers/Onboarding/tests/actions.test.js b/packages/strapi-admin/admin/src/containers/Onboarding/tests/actions.test.js
new file mode 100644
index 0000000000..336c014b91
--- /dev/null
+++ b/packages/strapi-admin/admin/src/containers/Onboarding/tests/actions.test.js
@@ -0,0 +1,18 @@
+
+import {
+ defaultAction,
+} from '../actions';
+import {
+ DEFAULT_ACTION,
+} from '../constants';
+
+describe('Onboarding actions', () => {
+ describe('Default Action', () => {
+ it('has a type of DEFAULT_ACTION', () => {
+ const expected = {
+ type: DEFAULT_ACTION,
+ };
+ expect(defaultAction()).toEqual(expected);
+ });
+ });
+});
diff --git a/packages/strapi-admin/admin/src/containers/Onboarding/tests/index.test.js b/packages/strapi-admin/admin/src/containers/Onboarding/tests/index.test.js
new file mode 100644
index 0000000000..dec83b8b24
--- /dev/null
+++ b/packages/strapi-admin/admin/src/containers/Onboarding/tests/index.test.js
@@ -0,0 +1,10 @@
+// import React from 'react';
+// import { shallow } from 'enzyme';
+
+// import { Onboarding } from '../index';
+
+describe('
', () => {
+ it('Expect to have unit tests specified', () => {
+ expect(true).toEqual(true);
+ });
+});
diff --git a/packages/strapi-admin/admin/src/containers/Onboarding/tests/reducer.test.js b/packages/strapi-admin/admin/src/containers/Onboarding/tests/reducer.test.js
new file mode 100644
index 0000000000..dfe1223f3f
--- /dev/null
+++ b/packages/strapi-admin/admin/src/containers/Onboarding/tests/reducer.test.js
@@ -0,0 +1,9 @@
+
+import { fromJS } from 'immutable';
+import onboardingReducer from '../reducer';
+
+describe('onboardingReducer', () => {
+ it('returns the initial state', () => {
+ expect(onboardingReducer(undefined, [])).toEqual(fromJS([]));
+ });
+});
diff --git a/packages/strapi-admin/admin/src/containers/Onboarding/tests/saga.test.js b/packages/strapi-admin/admin/src/containers/Onboarding/tests/saga.test.js
new file mode 100644
index 0000000000..a5d8823023
--- /dev/null
+++ b/packages/strapi-admin/admin/src/containers/Onboarding/tests/saga.test.js
@@ -0,0 +1,15 @@
+/**
+ * Test sagas
+ */
+
+/* eslint-disable redux-saga/yield-effects */
+// import { take, call, put, select } from 'redux-saga/effects';
+// import { defaultSaga } from '../saga';
+
+// const generator = defaultSaga();
+
+describe('defaultSaga Saga', () => {
+ it('Expect to have unit tests specified', () => {
+ expect(true).toEqual(true);
+ });
+});
diff --git a/packages/strapi-admin/admin/src/containers/Onboarding/tests/selectors.test.js b/packages/strapi-admin/admin/src/containers/Onboarding/tests/selectors.test.js
new file mode 100644
index 0000000000..2c24a379eb
--- /dev/null
+++ b/packages/strapi-admin/admin/src/containers/Onboarding/tests/selectors.test.js
@@ -0,0 +1,10 @@
+// import { fromJS } from 'immutable';
+// import { makeSelectOnboardingDomain } from '../selectors';
+
+// const selector = makeSelectOnboardingDomain();
+
+describe('makeSelectOnboardingDomain', () => {
+ it('Expect to have unit tests specified', () => {
+ expect(true).toEqual(true);
+ });
+});
diff --git a/packages/strapi-admin/admin/src/translations/en.json b/packages/strapi-admin/admin/src/translations/en.json
index 67dacc1e6c..a8b948af6b 100644
--- a/packages/strapi-admin/admin/src/translations/en.json
+++ b/packages/strapi-admin/admin/src/translations/en.json
@@ -84,6 +84,8 @@
"app.components.NotFoundPage.back": "Back to homepage",
"app.components.NotFoundPage.description": "Not Found",
"app.components.Official": "Official",
+ "app.components.Onboarding.label.completed": "% completed",
+ "app.components.Onboarding.title": "Get Started Videos",
"app.components.PluginCard.Button.label.download": "Download",
"app.components.PluginCard.Button.label.install": "Already installed",
"app.components.PluginCard.Button.label.support": "Support us",
@@ -145,4 +147,4 @@
"notification.error.layout": "Couldn't retrieve the layout",
"request.error.model.unknown": "This model doesn't exist",
"app.utils.delete": "Delete"
-}
+}
\ No newline at end of file
diff --git a/packages/strapi-admin/admin/src/translations/fr.json b/packages/strapi-admin/admin/src/translations/fr.json
index ca05153c06..111f504adb 100644
--- a/packages/strapi-admin/admin/src/translations/fr.json
+++ b/packages/strapi-admin/admin/src/translations/fr.json
@@ -85,6 +85,8 @@
"app.components.NotFoundPage.back": "Retourner à la page d'accueil",
"app.components.NotFoundPage.description": "Page introuvable",
"app.components.Official": "Officiel",
+ "app.components.Onboarding.label.completed": "% complétées",
+ "app.components.Onboarding.title": "Démarrons ensemble",
"app.components.PluginCard.Button.label.download": "Télécharger",
"app.components.PluginCard.Button.label.install": "Déjà installé",
"app.components.PluginCard.Button.label.support": "Nous soutenir",
@@ -146,4 +148,4 @@
"notification.error.layout": "Impossible de récupérer le layout de l'admin",
"request.error.model.unknown": "Le model n'existe pas",
"app.utils.delete": "Supprimer"
-}
+}
\ No newline at end of file
diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json
index cf271d1c57..ff118fbbb2 100644
--- a/packages/strapi-admin/package.json
+++ b/packages/strapi-admin/package.json
@@ -27,8 +27,10 @@
"dependencies": {
"intl": "^1.2.5",
"react-ga": "^2.4.1",
+ "redux": "^4.0.1",
"remove-markdown": "^0.2.2",
- "shelljs": "^0.7.8"
+ "shelljs": "^0.7.8",
+ "video-react": "^0.13.2"
},
"devDependencies": {
"cross-env": "^5.0.5",
diff --git a/packages/strapi-helper-plugin/lib/internals/scripts/loadAdminConfigurations.js b/packages/strapi-helper-plugin/lib/internals/scripts/loadAdminConfigurations.js
index 1e5523f0d0..ed26d3c605 100644
--- a/packages/strapi-helper-plugin/lib/internals/scripts/loadAdminConfigurations.js
+++ b/packages/strapi-helper-plugin/lib/internals/scripts/loadAdminConfigurations.js
@@ -16,9 +16,13 @@ if (!isSetup) {
strapi.log.level = 'silent';
(async () => {
- await strapi.load({
- environment: process.env.NODE_ENV,
- });
+ try {
+ await strapi.load({
+ environment: process.env.NODE_ENV,
+ });
+ } catch (e) {
+ // console.log(e);
+ }
// Force exit process if an other process doen't exit during Strapi load.
process.exit();
diff --git a/packages/strapi-helper-plugin/lib/server/middlewares/frontendMiddleware.js b/packages/strapi-helper-plugin/lib/server/middlewares/frontendMiddleware.js
index 19b6228af6..3d9db23d93 100644
--- a/packages/strapi-helper-plugin/lib/server/middlewares/frontendMiddleware.js
+++ b/packages/strapi-helper-plugin/lib/server/middlewares/frontendMiddleware.js
@@ -47,7 +47,7 @@ const addDevMiddlewares = (app, webpackConfig) => {
/**
* Front-end middleware
*/
-module.exports = (app) => {
+module.exports = app => {
const webpackConfig = require('../../internals/webpack/webpack.dev.babel');
// const webpackConfig = require(path.resolve(process.cwd(), 'node_modules', 'strapi-helper-plugin', 'internals', 'webpack', 'webpack.dev.babel'));
diff --git a/packages/strapi-helper-plugin/lib/src/utils/auth.js b/packages/strapi-helper-plugin/lib/src/utils/auth.js
index e2316c2cb0..12afec93b5 100644
--- a/packages/strapi-helper-plugin/lib/src/utils/auth.js
+++ b/packages/strapi-helper-plugin/lib/src/utils/auth.js
@@ -21,7 +21,12 @@ const auth = {
clearAppStorage() {
if (localStorage) {
+ const videos = auth.get('videos');
+ const onboarding = auth.get('onboarding');
+
localStorage.clear();
+ localStorage.setItem('videos', JSON.stringify(videos));
+ localStorage.setItem('onboarding', onboarding);
}
if (sessionStorage) {
@@ -73,7 +78,6 @@ const auth = {
return null;
},
-
setToken(value = '', isLocalStorage = false, tokenKey = TOKEN_KEY) {
return auth.set(value, tokenKey, isLocalStorage);
},
diff --git a/packages/strapi-helper-plugin/lib/src/utils/request.js b/packages/strapi-helper-plugin/lib/src/utils/request.js
index 9a2f48182b..48bfa6233b 100644
--- a/packages/strapi-helper-plugin/lib/src/utils/request.js
+++ b/packages/strapi-helper-plugin/lib/src/utils/request.js
@@ -20,7 +20,7 @@ function parseJSON(response) {
* @return {object|undefined} Returns either the response, or throws an error
*/
function checkStatus(response, checkToken = true) {
- if (response.status >= 200 && response.status < 300) {
+ if ((response.status >= 200 && response.status < 300) || response.status === 0) {
return response;
}
@@ -41,21 +41,22 @@ function checkTokenValidity(response) {
method: 'GET',
headers: {
'Content-Type': 'application/json',
- 'Authorization': `Bearer ${auth.getToken()}`,
+ Authorization: `Bearer ${auth.getToken()}`,
},
};
if (auth.getToken()) {
- return fetch(`${strapi.backendURL}/user/me`, options)
- .then(() => {
- if (response.status === 401) {
- window.location = `${strapi.remoteURL}/plugins/users-permissions/auth/login`;
+ return fetch(`${strapi.backendURL}/user/me`, options).then(() => {
+ if (response.status === 401) {
+ window.location = `${
+ strapi.remoteURL
+ }/plugins/users-permissions/auth/login`;
- auth.clearAppStorage();
- }
+ auth.clearAppStorage();
+ }
- return checkStatus(response, false);
- });
+ return checkStatus(response, false);
+ });
}
}
@@ -72,12 +73,12 @@ function formatQueryParams(params) {
}
/**
-* Server restart watcher
-* @param response
-* @returns {object} the response data
-*/
+ * Server restart watcher
+ * @param response
+ * @returns {object} the response data
+ */
function serverRestartWatcher(response) {
- return new Promise((resolve) => {
+ return new Promise(resolve => {
fetch(`${strapi.backendURL}/_health`, {
method: 'HEAD',
mode: 'no-cors',
@@ -93,8 +94,7 @@ function serverRestartWatcher(response) {
})
.catch(() => {
setTimeout(() => {
- return serverRestartWatcher(response)
- .then(resolve);
+ return serverRestartWatcher(response).then(resolve);
}, 100);
});
});
@@ -108,22 +108,38 @@ function serverRestartWatcher(response) {
*
* @return {object} The response data
*/
-export default function request(url, options = {}, shouldWatchServerRestart = false, stringify = true ) {
+export default function request(...args) {
+ let [url, options = {}, shouldWatchServerRestart, stringify = true, ...rest] = args;
+ let noAuth;
+
+ try {
+ [{ noAuth }] = rest;
+ } catch(err) {
+ noAuth = false;
+ }
+
// Set headers
if (!options.headers) {
- options.headers = Object.assign({
- 'Content-Type': 'application/json',
- }, options.headers, {
- 'X-Forwarded-Host': 'strapi',
- });
+ options.headers = Object.assign(
+ {
+ 'Content-Type': 'application/json',
+ },
+ options.headers,
+ {
+ 'X-Forwarded-Host': 'strapi',
+ },
+ );
}
const token = auth.getToken();
- if (token) {
- options.headers = Object.assign({
- 'Authorization': `Bearer ${token}`,
- }, options.headers);
+ if (token && !noAuth) {
+ options.headers = Object.assign(
+ {
+ Authorization: `Bearer ${token}`,
+ },
+ options.headers,
+ );
}
// Add parameters to url
@@ -138,11 +154,11 @@ export default function request(url, options = {}, shouldWatchServerRestart = fa
if (options && options.body && stringify) {
options.body = JSON.stringify(options.body);
}
-
+
return fetch(url, options)
.then(checkStatus)
.then(parseJSON)
- .then((response) => {
+ .then(response => {
if (shouldWatchServerRestart) {
// Display the global OverlayBlocker
strapi.lockApp(shouldWatchServerRestart);
diff --git a/packages/strapi-hook-knex/lib/index.js b/packages/strapi-hook-knex/lib/index.js
index b71b7ecce6..3c1c05899f 100644
--- a/packages/strapi-hook-knex/lib/index.js
+++ b/packages/strapi-hook-knex/lib/index.js
@@ -155,6 +155,10 @@ module.exports = strapi => {
} catch (err) {
fs.mkdirSync(fileDirectory);
}
+
+ // Force base directory.
+ // Note: it removes the warning logs when starting the administration in development mode.
+ options.connection.filename = path.resolve(strapi.config.appPath, options.connection.filename);
// Disable warn log
// .returning() is not supported by sqlite3 and will not have any effect.
diff --git a/packages/strapi-provider-email-mailgun/lib/index.js b/packages/strapi-provider-email-mailgun/lib/index.js
index 51cce55d9b..c76dc64b96 100644
--- a/packages/strapi-provider-email-mailgun/lib/index.js
+++ b/packages/strapi-provider-email-mailgun/lib/index.js
@@ -55,7 +55,8 @@ module.exports = {
to: options.to,
subject: options.subject,
text: options.text,
- html: options.html
+ html: options.html,
+ ...(options.attachment && { attachment: options.attachment })
};
msg['h:Reply-To'] = options.replyTo;