11import * as ActionTypes from '../constants/actionTypes' ;
22import _ from 'underscore' ;
33import moment from 'moment' ;
4-
4+ import { validationError } from '../actions/utils' ;
5+ import { get , put , del } from '../utils/fetch' ;
6+ import { validator } from '../utils/validation' ;
7+ import { slugify } from '../utils/helpers' ;
58import {
69 getCollectionsUrl ,
710 getCollectionUrl ,
@@ -10,18 +13,16 @@ import {
1013 putCollectionDocumentUrl ,
1114 deleteCollectionDocumentUrl
1215} from '../constants/api' ;
13-
1416import {
1517 getCollections ,
1618 getCollection ,
1719 getCollectionDocuments
1820} from '../constants/api' ;
19-
20- import { validationError } from '../actions/utils' ;
21-
22- import { get , put , del } from '../utils/fetch' ;
23- import { validator } from '../utils/validation' ;
24- import { slugify } from '../utils/helpers' ;
21+ import {
22+ getTitleRequiredMessage ,
23+ getFilenameRequiredMessage ,
24+ getFilenameNotValidMessage
25+ } from '../constants/messages' ;
2526
2627export function fetchCollections ( ) {
2728 return dispatch => {
@@ -76,15 +77,15 @@ export function putDocument(id, collection) {
7677 'path' : 'required'
7778 } ;
7879 let messages = {
79- 'title.required' : 'The title is required.' ,
80- 'path.required' : 'The filename is required.'
80+ 'title.required' : getTitleRequiredMessage ( ) ,
81+ 'path.required' : getFilenameRequiredMessage ( )
8182 } ;
8283 if ( collection == 'posts' ) {
8384 validations [ 'path' ] = 'required|date' ;
84- messages [ 'path.date' ] = 'The filename is not valid.' ;
85+ messages [ 'path.date' ] = getFilenameNotValidMessage ( ) ;
8586 } else {
8687 validations [ 'path' ] = 'required|filename' ;
87- messages [ 'path.filename' ] = 'The filename is not valid.' ;
88+ messages [ 'path.filename' ] = getFilenameNotValidMessage ( ) ;
8889 }
8990 const errors = validator ( metadata , validations , messages ) ;
9091 if ( errors . length ) {
@@ -101,7 +102,6 @@ export function putDocument(id, collection) {
101102 } ) ,
102103 raw_content
103104 } ) ;
104- // TODO dispatch({type: ActionTypes.PUT_DOCUMENT_REQUEST, doc});
105105 return put (
106106 putCollectionDocumentUrl (
107107 collection , id || path . substring ( path . lastIndexOf ( '/' ) + 1 )
0 commit comments