Skip to content

Commit

Permalink
Remove unnecessary action creator
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-collier committed Jul 23, 2019
1 parent 006f2f5 commit 39f0cbc
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 25 deletions.
4 changes: 1 addition & 3 deletions __tests__/components/editor/ResourceTemplate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ describe('<ResourceTemplate />', () => {
resourceLabel: 'BF2 Work',
}
const loadLanguages = jest.fn()
const clearResourceURIMessage = jest.fn()

const wrapper = shallow(<ResourceTemplate.WrappedComponent resourceTemplateId="resourceTemplate:bf2:Note"
resourceTemplate={resourceTemplate}
loadLanguages={loadLanguages}
retrieveResourceTemplate={jest.fn()}
clearResourceURIMessage={clearResourceURIMessage} />)
retrieveResourceTemplate={jest.fn()} />)
it('loads the languages', () => {
expect(loadLanguages).toHaveBeenCalled()
})
Expand Down
13 changes: 0 additions & 13 deletions src/actionCreators/messages.js

This file was deleted.

3 changes: 3 additions & 0 deletions src/actionCreators/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
assignBaseURL, updateStarted, updateFinished,
retrieveResourceStarted, setResource, updateProperty,
toggleCollapse, appendResource, clearResourceTemplates,
clearResourceURIMessage,
} from 'actions/index'
import { fetchResourceTemplate } from 'actionCreators/resourceTemplates'
import { updateRDFResource, loadRDFResource } from 'sinopiaServer'
Expand Down Expand Up @@ -47,12 +48,14 @@ export const newResource = resourceTemplateId => (dispatch) => {
const resource = {}
resource[resourceTemplateId] = {}
dispatch(clearResourceTemplates())
dispatch(clearResourceURIMessage())
dispatch(setResource(resource))
dispatch(stubResource(true))
}

// A thunk that stubs out an existing new resource
export const existingResource = (resource, uri) => (dispatch) => {
dispatch(clearResourceURIMessage())
dispatch(setResource(resource))
dispatch(assignBaseURL(uri))
dispatch(stubResource(false))
Expand Down
4 changes: 2 additions & 2 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export const showResourceURIMessage = resourceUri => ({
payload: resourceUri,
})

export const clearingResourceURIMessage = () => ({
type: 'CLEARING_RESOURCE_URI_MESSAGE',
export const clearResourceURIMessage = () => ({
type: 'CLEAR_RESOURCE_URI_MESSAGE',
})

export const updateStarted = () => ({
Expand Down
5 changes: 1 addition & 4 deletions src/components/editor/ResourceTemplate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { bindActionCreators } from 'redux'
import loadLanguages from 'actionCreators/languages'
import ResourceURIMessage from './ResourceURIMessage'
import _ from 'lodash'
import clearResourceURIMessage from 'actionCreators/messages'

/**
* This is the root component of the editor on the resource edit page
Expand All @@ -19,7 +18,6 @@ class ResourceTemplate extends Component {
componentDidMount() {
// We load the languages once here so that each literal doesn't try to hit the LOC endpoint
this.props.loadLanguages()
this.props.clearResourceURIMessage()
}

render() {
Expand Down Expand Up @@ -49,7 +47,6 @@ ResourceTemplate.propTypes = {
error: PropTypes.string,
newResource: PropTypes.func,
loadLanguages: PropTypes.func,
clearResourceURIMessage: PropTypes.func,
}

const mapStateToProps = (state) => {
Expand All @@ -63,6 +60,6 @@ const mapStateToProps = (state) => {
}
}

const mapDispatchToProps = dispatch => bindActionCreators({ loadLanguages, newResource, clearResourceURIMessage }, dispatch)
const mapDispatchToProps = dispatch => bindActionCreators({ loadLanguages, newResource }, dispatch)

export default connect(mapStateToProps, mapDispatchToProps)(ResourceTemplate)
4 changes: 2 additions & 2 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { combineReducers } from 'redux'
import authenticate from './authenticate'
import {
removeMyItem, setItemsOrSelections, setBaseURL, showResourceURIMessage, clearingResourceURIMessage,
removeMyItem, setItemsOrSelections, setBaseURL, showResourceURIMessage, clearResourceURIMessage,
setMyItemsLang, showGroupChooser, closeGroupChooser, showRdfPreview,
} from './inputs'
import {
Expand Down Expand Up @@ -111,7 +111,7 @@ const handlers = {
RETRIEVE_RESOURCE_TEMPLATE_STARTED: clearRetrieveError,
SET_BASE_URL: setBaseURL,
SHOW_RESOURCE_URI_MESSAGE: showResourceURIMessage,
CLEARING_RESOURCE_URI_MESSAGE: clearingResourceURIMessage,
CLEAR_RESOURCE_URI_MESSAGE: clearResourceURIMessage,
SHOW_SEARCH_RESULTS: showSearchResults,
SHOW_GROUP_CHOOSER: showGroupChooser,
CLOSE_GROUP_CHOOSER: closeGroupChooser,
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const showResourceURIMessage = (state, action) => {
* @param {Object} action the payload of the action is the URI returned from saving the resource
* @return {Object} the next redux state
*/
export const clearingResourceURIMessage = (state) => {
export const clearResourceURIMessage = (state) => {
const newState = { ...state }

newState.editor.resourceURIMessage.show = false
Expand Down

0 comments on commit 39f0cbc

Please sign in to comment.