Skip to content
Snippets Groups Projects
Commit b6dfa759 authored by Tamlyn Rhodes's avatar Tamlyn Rhodes
Browse files

Update fragment actions for top level fragment API

Allow passing a falsy value as the collection and construct the appropriate URL
parent 9debb4e5
No related branches found
No related tags found
No related merge requests found
......@@ -2,19 +2,10 @@ import * as api from '../helpers/api'
import * as T from './types'
export const fragmentUrl = (collection, fragment) => {
let url = `/collections/${collection.id}/fragments`
if (fragment.id) url += `/${fragment.id}`
return url
}
export const collectionUrl = (collection, suffix) => {
let url = '/collections'
if (collection) url += `/${collection.id}`
if (suffix) url += `/${suffix}`
let url = ''
if (collection) url += `/collections/${collection.id}`
url += '/fragments'
if (fragment && fragment.id) url += `/${fragment.id}`
return url
}
......@@ -46,7 +37,7 @@ export function getFragments(collection, options) {
return dispatch => {
dispatch(getFragmentsRequest(collection))
let url = collectionUrl(collection, 'fragments')
let url = fragmentUrl(collection)
if (options && options.fields) {
url += '?fields=' + encodeURIComponent(options.fields.join(','))
......
......@@ -36,7 +36,8 @@ describe('fragments actions', () => {
})
describeAction('createFragment', {
firstarg: mockcol,
// no collection routes to top level fragment endpoint
firstarg: null,
secondarg: {
title: 'mock fragment',
type: 'some_fragment',
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment