Commit 6482f315 authored by Jure's avatar Jure

Merge branch '54-fragment-actions' into 'master'

Update fragment actions for top level fragment API

Closes #54

See merge request !126
parents 31b0c39a b6dfa759
Pipeline #3023 passed with stage
in 1 minute and 58 seconds
......@@ -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',
......
Markdown is supported
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