Commit 2e21443b authored by Phil Hughes's avatar Phil Hughes

Fixed design detail pages not opening

parent 5c0b1f18
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
<template> <template>
<router-link <router-link
:to="{ name: 'design', params: { id } }" :to="{ name: 'design', params: { id: name } }"
class="card cursor-pointer text-plain js-design-list-item" class="card cursor-pointer text-plain js-design-list-item"
> >
<div class="card-body p-0"> <div class="card-body p-0">
......
...@@ -14,7 +14,7 @@ export default { ...@@ -14,7 +14,7 @@ export default {
mixins: [timeagoMixin], mixins: [timeagoMixin],
props: { props: {
id: { id: {
type: Number, type: String,
required: true, required: true,
}, },
isLoading: { isLoading: {
......
...@@ -12,7 +12,7 @@ export default { ...@@ -12,7 +12,7 @@ export default {
mixins: [allDesignsMixin], mixins: [allDesignsMixin],
props: { props: {
id: { id: {
type: Number, type: String,
required: true, required: true,
}, },
}, },
...@@ -21,7 +21,7 @@ export default { ...@@ -21,7 +21,7 @@ export default {
return this.designs.length; return this.designs.length;
}, },
currentIndex() { currentIndex() {
return this.designs.findIndex(design => parseInt(design.id, 10) === this.id); return this.designs.findIndex(design => design.filename === this.id);
}, },
paginationText() { paginationText() {
return sprintf(s__('DesignManagement|%{current_design} of %{designs_count}'), { return sprintf(s__('DesignManagement|%{current_design} of %{designs_count}'), {
......
...@@ -24,7 +24,7 @@ export default { ...@@ -24,7 +24,7 @@ export default {
designLink() { designLink() {
if (!this.design) return {}; if (!this.design) return {};
return { name: 'design', params: { id: this.design.id } }; return { name: 'design', params: { id: this.design.filename } };
}, },
}, },
}; };
......
...@@ -15,9 +15,8 @@ const defaultClient = createDefaultClient({ ...@@ -15,9 +15,8 @@ const defaultClient = createDefaultClient({
variables: { fullPath: projectPath, iid: issueIid }, variables: { fullPath: projectPath, iid: issueIid },
}); });
return result.project.issue.designs.designs.edges.find( return result.project.issue.designs.designs.edges.find(({ node }) => node.filename === id)
({ node }) => parseInt(node.id, 10) === id, .node;
).node;
}, },
}, },
}); });
......
...@@ -12,7 +12,7 @@ export default { ...@@ -12,7 +12,7 @@ export default {
}, },
props: { props: {
id: { id: {
type: Number, type: String,
required: true, required: true,
}, },
}, },
......
query getDesign($id: ID!) { query getDesign($id: String!) {
design(id: $id) @client { design(id: $id) @client {
image image
filename filename
......
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore';
import Vue from 'vue'; import Vue from 'vue';
import VueRouter from 'vue-router'; import VueRouter from 'vue-router';
import Home from './pages/index.vue'; import Home from './pages/index.vue';
...@@ -39,9 +40,9 @@ const router = new VueRouter({ ...@@ -39,9 +40,9 @@ const router = new VueRouter({
from, from,
next, next,
) { ) {
if (id > 0) next(); if (_.isString(id)) next();
}, },
props: ({ params: { id } }) => ({ id: parseInt(id, 10) }), props: ({ params: { id } }) => ({ id }),
}, },
], ],
}, },
......
...@@ -7,20 +7,20 @@ exports[`Design management pagination component renders pagination buttons 1`] = ...@@ -7,20 +7,20 @@ exports[`Design management pagination component renders pagination buttons 1`] =
class="d-flex align-items-center" class="d-flex align-items-center"
> >
2 of 2 0 of 2
<div <div
class="btn-group ml-3" class="btn-group ml-3"
> >
<paginationbutton-stub <paginationbutton-stub
class="js-previous-design" class="js-previous-design"
design="[object Object]"
iconname="angle-left" iconname="angle-left"
title="Go to previous design" title="Go to previous design"
/> />
<paginationbutton-stub <paginationbutton-stub
class="js-next-design" class="js-next-design"
design="[object Object]"
iconname="angle-right" iconname="angle-right"
title="Go to next design" title="Go to next design"
/> />
......
...@@ -21,7 +21,7 @@ describe('Design management toolbar component', () => { ...@@ -21,7 +21,7 @@ describe('Design management toolbar component', () => {
vm = shallowMount(Toolbar, { vm = shallowMount(Toolbar, {
propsData: { propsData: {
id: 1, id: '1',
isLoading, isLoading,
name: 'test.jpg', name: 'test.jpg',
updatedAt: updatedAt.toString(), updatedAt: updatedAt.toString(),
......
...@@ -26,7 +26,7 @@ describe('Design management pagination button component', () => { ...@@ -26,7 +26,7 @@ describe('Design management pagination button component', () => {
}); });
it('renders router-link', () => { it('renders router-link', () => {
createComponent({ id: 2 }); createComponent({ id: '2' });
expect(vm.element).toMatchSnapshot(); expect(vm.element).toMatchSnapshot();
}); });
...@@ -39,11 +39,11 @@ describe('Design management pagination button component', () => { ...@@ -39,11 +39,11 @@ describe('Design management pagination button component', () => {
}); });
it('returns design link', () => { it('returns design link', () => {
createComponent({ id: 2 }); createComponent({ id: '2', filename: 'test' });
expect(vm.vm.designLink).toEqual({ expect(vm.vm.designLink).toEqual({
name: 'design', name: 'design',
params: { id: 2 }, params: { id: 'test' },
}); });
}); });
}); });
......
...@@ -7,7 +7,7 @@ describe('Design management pagination component', () => { ...@@ -7,7 +7,7 @@ describe('Design management pagination component', () => {
function createComponent() { function createComponent() {
vm = shallowMount(Pagination, { vm = shallowMount(Pagination, {
propsData: { propsData: {
id: 2, id: '2',
}, },
}); });
} }
...@@ -26,7 +26,7 @@ describe('Design management pagination component', () => { ...@@ -26,7 +26,7 @@ describe('Design management pagination component', () => {
it('renders pagination buttons', () => { it('renders pagination buttons', () => {
vm.setData({ vm.setData({
designs: [{ id: 1 }, { id: 2 }], designs: [{ id: '1' }, { id: '2' }],
}); });
expect(vm.element).toMatchSnapshot(); expect(vm.element).toMatchSnapshot();
......
...@@ -14,7 +14,7 @@ describe('Design management design index page', () => { ...@@ -14,7 +14,7 @@ describe('Design management design index page', () => {
}; };
vm = shallowMount(DesignIndex, { vm = shallowMount(DesignIndex, {
propsData: { id: 1 }, propsData: { id: '1' },
mocks: { $apollo }, mocks: { $apollo },
}); });
} }
......
...@@ -65,7 +65,7 @@ describe('Design management router', () => { ...@@ -65,7 +65,7 @@ describe('Design management router', () => {
const detail = vm.find(DesignDetail); const detail = vm.find(DesignDetail);
expect(detail.exists()).toBe(true); expect(detail.exists()).toBe(true);
expect(detail.props('id')).toEqual(1); expect(detail.props('id')).toEqual('1');
}); });
}); });
}); });
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