Skip to content

Commit

Permalink
actions cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno12mota committed May 5, 2016
1 parent b64c1a6 commit 8ba501e
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 244 deletions.
33 changes: 15 additions & 18 deletions lib/shared/actions/draft.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import actionTypes from 'actions';
import request from 'helpers/request';
import {mutation} from 'relate-js';
import {fragmentToQL} from 'relax-fragments';

export function saveDraft () {
return (dispatch, getState) => {
Expand Down Expand Up @@ -36,21 +33,21 @@ export function saveDraft () {
};
}

export function dropDraft (fragments, id) {
return (dispatch) => (
request({
dispatch,
type: actionTypes.dropDraft,
query: `
mutation dropDraft ($id: String!) {
dropDraft (id: $id) {
${fragmentToQL(fragments.draft)}
}
export function dropDraft (id) {
return mutation({
fragments: {
dropDraft: {
_id: 1
}
},
variables: {
dropDraft: {
id: {
type: 'ID!',
value: id
}
`,
variables: {
id
}
})
);
},
type: 'REMOVE'
});
}
14 changes: 0 additions & 14 deletions lib/shared/actions/elements.js

This file was deleted.

21 changes: 0 additions & 21 deletions lib/shared/actions/graphql.js

This file was deleted.

38 changes: 5 additions & 33 deletions lib/shared/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
export default {
// Session
authenticate: 'AUTHENTICATE',
// Admin menu
openAdminMenu: 'OPEN_ADMIN_MENU',
closeAdminMenu: 'CLOSE_ADMIN_MENU',
// Colors
updateColor: 'UPDATE_COLOR',
addColor: 'ADD_COLOR',
removeColor: 'REMOVE_COLOR',
// Display
changeDisplay: 'CHANGE_DISPLAY',
// DND
startDragging: 'START_DRAGGING',
onDroppable: 'ON_DROPPABLE',
outDroppable: 'OUT_DROPPABLE',
stopDragging: 'STOP_DRAGGING',
// Fonts
changeFontsPreviewText: 'CHANGE_FONTS_PREVIEW_TEXT',
changeFontsPreviewLayout: 'CHANGE_FONTS_PREVIEW_LAYOUT',
Expand All @@ -25,14 +24,9 @@ export default {
uploadingMedia: 'UPLOADING_MEDIA',
mediaUploadSuccess: 'UPLOAD_MEDIA_SUCCESS',
mediaUploadError: 'UPLOAD_MEDIA_ERROR',
addMedia: 'ADD_MEDIA',
removeMedia: 'REMOVE_MEDIA',
removeMediaItem: 'REMOVE_MEDIA_ITEM',
// Menu
addMenu: 'ADD_MENU',
addMenuItem: 'ADD_MENU_ITEM',
moveMenuItem: 'MOVE_MENU_ITEM',
removeMenu: 'REMOVE_MENU',
// Page
getPage: 'GET_PAGE',
updatePage: 'UPDATE_PAGE',
Expand All @@ -42,9 +36,6 @@ export default {
validatePageSlug: 'VALIDATE_PAGE_SLUG',
restorePage: 'RESTORE_PAGE',
savePageFromDraft: 'SAVE_PAGE_FROM_DRAFT',
// Pages
removePage: 'REMOVE_PAGE',
duplicatePage: 'DUPLICATE_PAGE',
// Schema
changeSchemaType: 'CHANGE_SCHEMA_TYPE',
changeSchemaTitle: 'CHANGE_SCHEMA_TITLE',
Expand Down Expand Up @@ -73,14 +64,6 @@ export default {
// Settings
changeSettingValue: 'CHANGE_SETTING_VALUE',
saveSettings: 'SAVE_SETTINGS',
// Users
removeUser: 'REMOVE_USER',
addUser: 'ADD_USER',
// DND
startDragging: 'START_DRAGGING',
onDroppable: 'ON_DROPPABLE',
outDroppable: 'OUT_DROPPABLE',
stopDragging: 'STOP_DRAGGING',
// Page builder
pbToggleEditing: 'PB_TOGGLE_EDITING',
pbSetMenuOpened: 'PB_SET_MENU_OPENED',
Expand All @@ -102,18 +85,7 @@ export default {
pbCloseLinkDataMode: 'PB_CLOSE_LINK_DATA_MODE',
pbLinkFormDataMode: 'PB_LINK_FORM_DATA_MODE',
pbCloseLinkFormDataMode: 'PB_CLOSE_LINK_FORM_DATA_MODE',
// Symbols
makeElementSymbol: 'MAKE_ELEMENT_SYMBOL',
getSymbol: 'GET_SYMBOL',
// Elements
getElementData: 'GET_ELEMENT_DATA',
// Revisions
getRevisions: 'GET_REVISIONS',
// Draft
saveDraft: 'SAVE_DRAFT',
dropDraft: 'DROP_DRAFT',
// Tabs
removeTab: 'REMOVE_TAB',
// styles
saveStyle: 'SAVE_STYLE',
updateStyle: 'UPDATE_STYLE',
Expand Down
64 changes: 0 additions & 64 deletions lib/shared/actions/media.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import actionTypes from 'actions';
import request from 'helpers/request';
import {mutation} from 'relate-js';
import {fragmentToQL} from 'relax-fragments';

export function changeMediaDisplay (display) {
return {
Expand All @@ -10,68 +8,6 @@ export function changeMediaDisplay (display) {
};
}

export function getMediaItem (fragments, id) {
return (dispatch) => (
request({
dispatch,
type: actionTypes.getMediaItem,
query: `
query mediaItem ($id: ID!) {
mediaItem (id: $id) {
${fragmentToQL(fragments.media)}
}
}
`,
variables: {
id
}
})
);
}

export function uploadMedia (fragments, file) {
const data = {
file
};

return (dispatch) => (
request({
dispatch,
type: actionTypes.addMedia,
query: `
mutation addMedia ($data: MediaInput!) {
addMedia (data: $data) {
${fragmentToQL(fragments.media)}
}
}
`,
files: [file],
variables: {
data
}
})
);
}

export function addingMedia (fileInfo) {
return {
type: actionTypes.addingMedia,
fileInfo
};
}

export function addMedia (fragments, file, fileInfo) {
return {
types: [
'ADD_MEDIA_START',
'ADD_MEDIA_SUCCESS',
'ADD_MEDIA_ERROR'
],
payload: [addingMedia.bind(null, fileInfo), uploadMedia.bind(null, fragments, file)],
sequence: true
};
}

const uploadsAtTime = 3;
let uploadsID = 0;
let uploadingNumber = 0;
Expand Down
23 changes: 0 additions & 23 deletions lib/shared/actions/revisions.js

This file was deleted.

26 changes: 0 additions & 26 deletions lib/shared/actions/session.js

This file was deleted.

22 changes: 0 additions & 22 deletions lib/shared/actions/symbols.js

This file was deleted.

6 changes: 1 addition & 5 deletions lib/shared/elements/dynamic-list/container.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import * as elementsActions from 'actions/elements';

import utils from 'helpers/utils';
import React, {PropTypes} from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {buildQueryAndVariables} from 'relax-fragments';

import settings from './settings';
Expand All @@ -16,8 +13,7 @@ import List from './list';
elements: state.elements,
linkingData: state.pageBuilder.linkingData,
linkingDataElementId: state.pageBuilder.linkingDataElementId
}),
(dispatch) => bindActionCreators(elementsActions, dispatch)
})
)
export default class DynamicListContainer extends Component {
static fragments = {
Expand Down
6 changes: 1 addition & 5 deletions lib/shared/elements/symbol/container.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import * as symbolsActions from 'actions/symbols';

import React, {PropTypes} from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';

import settings from './settings';
import Component from '../component';
Expand All @@ -11,8 +8,7 @@ import Element from '../element';
@connect(
(state) => ({
symbols: state.symbols
}),
(dispatch) => bindActionCreators(symbolsActions, dispatch)
})
)
export default class DynamicListContainer extends Component {
static fragments = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import Menu from './menu';
fragments: Menu.fragments,
variablesTypes: {
menu: {
_id: 'ID!'
id: 'ID!'
}
},
initialVariables: {
menu: {
_id: props.menuId
id: props.menuId
}
}
})
Expand All @@ -37,7 +37,7 @@ export default class MenuContainer extends Component {
if (this.props.menuId !== nextProps.menuId) {
this.props.relate.setVariables({
menu: {
_id: nextProps.menuId
id: nextProps.menuId
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import * as elementsActions from 'actions/elements';

import cloneDeep from 'lodash.clonedeep';
import forEach from 'lodash.foreach';
import staticProperties from 'helpers/schema-static-properties';
import Component from 'components/component';
import React, {PropTypes} from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {buildQueryAndVariables} from 'relax-fragments';

import Filters from './filters';
Expand All @@ -16,8 +13,7 @@ import Filters from './filters';
elements: state.elements,
selectedId: state.pageBuilder.selectedId,
selectedElement: state.pageBuilder.selectedElement
}),
(dispatch) => bindActionCreators(elementsActions, dispatch)
})
)
export default class FiltersContainer extends Component {
static fragments = Filters.fragments;
Expand Down
Loading

0 comments on commit 8ba501e

Please sign in to comment.