mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 00:39:49 +00:00
Remove saga in admin
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
8b25ad614b
commit
ca93021bd0
@ -5,19 +5,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
EMIT_EVENT,
|
|
||||||
GET_PLUGINS_FROM_MARKETPLACE_SUCCEEDED,
|
GET_PLUGINS_FROM_MARKETPLACE_SUCCEEDED,
|
||||||
SET_APP_ERROR,
|
SET_APP_ERROR,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
|
|
||||||
export function emitEvent(event, properties) {
|
|
||||||
return {
|
|
||||||
type: EMIT_EVENT,
|
|
||||||
event,
|
|
||||||
properties,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getPluginsFromMarketPlaceSucceeded(plugins) {
|
export function getPluginsFromMarketPlaceSucceeded(plugins) {
|
||||||
return {
|
return {
|
||||||
type: GET_PLUGINS_FROM_MARKETPLACE_SUCCEEDED,
|
type: GET_PLUGINS_FROM_MARKETPLACE_SUCCEEDED,
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const EMIT_EVENT = 'app/Admin/EMIT_EVENT';
|
|
||||||
export const GET_PLUGINS_FROM_MARKETPLACE_SUCCEEDED =
|
export const GET_PLUGINS_FROM_MARKETPLACE_SUCCEEDED =
|
||||||
'StrapiAdmin/Admin/GET_PLUGINS_FROM_MARKETPLACE_SUCCEEDED';
|
'StrapiAdmin/Admin/GET_PLUGINS_FROM_MARKETPLACE_SUCCEEDED';
|
||||||
export const SET_APP_ERROR = 'StrapiAdmin/Admin/SET_APP_ERROR';
|
export const SET_APP_ERROR = 'StrapiAdmin/Admin/SET_APP_ERROR';
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import axios from 'axios';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createStructuredSelector } from 'reselect';
|
import { createStructuredSelector } from 'reselect';
|
||||||
import { bindActionCreators, compose } from 'redux';
|
import { bindActionCreators, compose } from 'redux';
|
||||||
@ -39,13 +40,10 @@ import {
|
|||||||
updatePlugin,
|
updatePlugin,
|
||||||
} from '../App/actions';
|
} from '../App/actions';
|
||||||
import makeSelecApp from '../App/selectors';
|
import makeSelecApp from '../App/selectors';
|
||||||
import injectSaga from '../../utils/injectSaga';
|
|
||||||
import injectReducer from '../../utils/injectReducer';
|
import injectReducer from '../../utils/injectReducer';
|
||||||
|
import { setAppError } from './actions';
|
||||||
import { emitEvent, setAppError } from './actions';
|
|
||||||
import makeSelectAdmin from './selectors';
|
import makeSelectAdmin from './selectors';
|
||||||
import reducer from './reducer';
|
import reducer from './reducer';
|
||||||
import saga from './saga';
|
|
||||||
import Wrapper from './Wrapper';
|
import Wrapper from './Wrapper';
|
||||||
import Content from './Content';
|
import Content from './Content';
|
||||||
|
|
||||||
@ -57,7 +55,7 @@ export class Admin extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.emitEvent('didAccessAuthenticatedAdministration');
|
this.emitEvent('didAccessAuthenticatedAdministration');
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(prevProps) {
|
shouldComponentUpdate(prevProps) {
|
||||||
@ -78,6 +76,20 @@ export class Admin extends React.Component {
|
|||||||
this.props.setAppError();
|
this.props.setAppError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emitEvent = async (event, properties) => {
|
||||||
|
const {
|
||||||
|
global: { uuid },
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
if (uuid) {
|
||||||
|
axios.post('https://analytics.strapi.io/track', {
|
||||||
|
event,
|
||||||
|
properties,
|
||||||
|
uuid,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
hasApluginNotReady = props => {
|
hasApluginNotReady = props => {
|
||||||
const {
|
const {
|
||||||
global: { plugins },
|
global: { plugins },
|
||||||
@ -133,7 +145,6 @@ export class Admin extends React.Component {
|
|||||||
strapiVersion,
|
strapiVersion,
|
||||||
},
|
},
|
||||||
disableGlobalOverlayBlocker,
|
disableGlobalOverlayBlocker,
|
||||||
emitEvent,
|
|
||||||
enableGlobalOverlayBlocker,
|
enableGlobalOverlayBlocker,
|
||||||
intl: { formatMessage, locale },
|
intl: { formatMessage, locale },
|
||||||
updatePlugin,
|
updatePlugin,
|
||||||
@ -152,7 +163,7 @@ export class Admin extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<GlobalContextProvider
|
<GlobalContextProvider
|
||||||
autoReload={autoReload}
|
autoReload={autoReload}
|
||||||
emitEvent={emitEvent}
|
emitEvent={this.emitEvent}
|
||||||
currentEnvironment={currentEnvironment}
|
currentEnvironment={currentEnvironment}
|
||||||
currentLocale={locale}
|
currentLocale={locale}
|
||||||
disableGlobalOverlayBlocker={disableGlobalOverlayBlocker}
|
disableGlobalOverlayBlocker={disableGlobalOverlayBlocker}
|
||||||
@ -230,7 +241,6 @@ Admin.propTypes = {
|
|||||||
appError: PropTypes.bool,
|
appError: PropTypes.bool,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
disableGlobalOverlayBlocker: PropTypes.func.isRequired,
|
disableGlobalOverlayBlocker: PropTypes.func.isRequired,
|
||||||
emitEvent: PropTypes.func.isRequired,
|
|
||||||
enableGlobalOverlayBlocker: PropTypes.func.isRequired,
|
enableGlobalOverlayBlocker: PropTypes.func.isRequired,
|
||||||
global: PropTypes.shape({
|
global: PropTypes.shape({
|
||||||
autoReload: PropTypes.bool,
|
autoReload: PropTypes.bool,
|
||||||
@ -240,6 +250,7 @@ Admin.propTypes = {
|
|||||||
plugins: PropTypes.object,
|
plugins: PropTypes.object,
|
||||||
showGlobalAppBlocker: PropTypes.bool,
|
showGlobalAppBlocker: PropTypes.bool,
|
||||||
strapiVersion: PropTypes.string,
|
strapiVersion: PropTypes.string,
|
||||||
|
uuid: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
intl: PropTypes.shape({
|
intl: PropTypes.shape({
|
||||||
formatMessage: PropTypes.func,
|
formatMessage: PropTypes.func,
|
||||||
@ -259,7 +270,6 @@ export function mapDispatchToProps(dispatch) {
|
|||||||
return bindActionCreators(
|
return bindActionCreators(
|
||||||
{
|
{
|
||||||
disableGlobalOverlayBlocker,
|
disableGlobalOverlayBlocker,
|
||||||
emitEvent,
|
|
||||||
enableGlobalOverlayBlocker,
|
enableGlobalOverlayBlocker,
|
||||||
setAppError,
|
setAppError,
|
||||||
updatePlugin,
|
updatePlugin,
|
||||||
@ -270,6 +280,5 @@ export function mapDispatchToProps(dispatch) {
|
|||||||
|
|
||||||
const withConnect = connect(mapStateToProps, mapDispatchToProps);
|
const withConnect = connect(mapStateToProps, mapDispatchToProps);
|
||||||
const withReducer = injectReducer({ key: 'admin', reducer });
|
const withReducer = injectReducer({ key: 'admin', reducer });
|
||||||
const withSaga = injectSaga({ key: 'admin', saga });
|
|
||||||
|
|
||||||
export default compose(injectIntl, withReducer, withSaga, withConnect)(Admin);
|
export default compose(injectIntl, withReducer, withConnect)(Admin);
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
import { all, fork, call, put, select, takeLatest } from 'redux-saga/effects';
|
|
||||||
import { EMIT_EVENT } from './constants';
|
|
||||||
import { makeSelectUuid } from '../App/selectors';
|
|
||||||
|
|
||||||
export function* emitter(action) {
|
|
||||||
try {
|
|
||||||
const requestURL = 'https://analytics.strapi.io/track';
|
|
||||||
const uuid = yield select(makeSelectUuid());
|
|
||||||
const { event, properties } = action;
|
|
||||||
|
|
||||||
if (uuid) {
|
|
||||||
yield call(
|
|
||||||
fetch, // eslint-disable-line no-undef
|
|
||||||
requestURL,
|
|
||||||
{
|
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify({ event, uuid, properties }),
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (err) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Individual exports for testing
|
|
||||||
export default function* defaultSaga() {
|
|
||||||
yield all([fork(takeLatest, EMIT_EVENT, emitter)]);
|
|
||||||
}
|
|
@ -1,19 +1,7 @@
|
|||||||
import { emitEvent, setAppError } from '../actions';
|
import { setAppError } from '../actions';
|
||||||
import { EMIT_EVENT, SET_APP_ERROR } from '../constants';
|
import { SET_APP_ERROR } from '../constants';
|
||||||
|
|
||||||
describe('<Admin /> actions', () => {
|
describe('<Admin /> actions', () => {
|
||||||
describe('EmitEvent', () => {
|
|
||||||
it('has a type EMIT_EVENT and returns the correct data', () => {
|
|
||||||
const expected = {
|
|
||||||
type: EMIT_EVENT,
|
|
||||||
event: 'test',
|
|
||||||
properties: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(emitEvent('test', {})).toEqual(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('SetAppError Action', () => {
|
describe('SetAppError Action', () => {
|
||||||
it('has a type of SET_APP_ERROR', () => {
|
it('has a type of SET_APP_ERROR', () => {
|
||||||
const expected = {
|
const expected = {
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
/**
|
|
||||||
* Test sagas
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* eslint-disable redux-saga/yield-effects */
|
|
||||||
/* eslint-disable redux-saga/no-unhandled-errors */
|
|
||||||
import { all, fork, takeLatest } from 'redux-saga/effects';
|
|
||||||
import defaultSaga, { emitter } from '../saga';
|
|
||||||
|
|
||||||
import { EMIT_EVENT } from '../constants';
|
|
||||||
|
|
||||||
describe('defaultSaga Saga', () => {
|
|
||||||
const defaultSagaSaga = defaultSaga();
|
|
||||||
|
|
||||||
it('should start task to watch for GET_INIT_DATA and GET_SECURED_DATA actions', () => {
|
|
||||||
const forkDescriptor = defaultSagaSaga.next().value;
|
|
||||||
|
|
||||||
expect(forkDescriptor).toEqual(
|
|
||||||
all([fork(takeLatest, EMIT_EVENT, emitter)])
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
x
Reference in New Issue
Block a user