Commit c8e704cb authored by Donald Cook's avatar Donald Cook Committed by Mayra Cabrera

Added description markdown field to iteration

parent 19240517
...@@ -7644,6 +7644,11 @@ type Iteration { ...@@ -7644,6 +7644,11 @@ type Iteration {
""" """
description: String description: String
"""
The GitLab Flavored Markdown rendering of `description`
"""
descriptionHtml: String
""" """
Timestamp of the iteration due date Timestamp of the iteration due date
""" """
......
...@@ -21042,6 +21042,20 @@ ...@@ -21042,6 +21042,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "descriptionHtml",
"description": "The GitLab Flavored Markdown rendering of `description`",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "dueDate", "name": "dueDate",
"description": "Timestamp of the iteration due date", "description": "Timestamp of the iteration due date",
...@@ -1152,6 +1152,7 @@ Represents an iteration object. ...@@ -1152,6 +1152,7 @@ Represents an iteration object.
| --- | ---- | ---------- | | --- | ---- | ---------- |
| `createdAt` | Time! | Timestamp of iteration creation | | `createdAt` | Time! | Timestamp of iteration creation |
| `description` | String | Description of the iteration | | `description` | String | Description of the iteration |
| `descriptionHtml` | String | The GitLab Flavored Markdown rendering of `description` |
| `dueDate` | Time | Timestamp of the iteration due date | | `dueDate` | Time | Timestamp of the iteration due date |
| `id` | ID! | ID of the iteration | | `id` | ID! | ID of the iteration |
| `iid` | ID! | Internal ID of the iteration | | `iid` | ID! | Internal ID of the iteration |
......
...@@ -69,6 +69,11 @@ export default { ...@@ -69,6 +69,11 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
previewMarkdownPath: {
type: String,
required: false,
default: '',
},
}, },
data() { data() {
return { return {
...@@ -126,6 +131,7 @@ export default { ...@@ -126,6 +131,7 @@ export default {
:group-path="fullPath" :group-path="fullPath"
:is-editing="true" :is-editing="true"
:iteration="iteration" :iteration="iteration"
:preview-markdown-path="previewMarkdownPath"
@updated="isEditing = false" @updated="isEditing = false"
@cancel="isEditing = false" @cancel="isEditing = false"
/> />
...@@ -157,7 +163,7 @@ export default { ...@@ -157,7 +163,7 @@ export default {
</gl-new-dropdown> </gl-new-dropdown>
</div> </div>
<h3 ref="title" class="page-title">{{ iteration.title }}</h3> <h3 ref="title" class="page-title">{{ iteration.title }}</h3>
<div ref="description" v-text="iteration.description"></div> <div ref="description" v-html="iteration.descriptionHtml"></div>
<iteration-report-summary :group-path="fullPath" :iteration-id="iteration.id" /> <iteration-report-summary :group-path="fullPath" :iteration-id="iteration.id" />
<iteration-report-tabs :group-path="fullPath" :iteration-id="iteration.id" /> <iteration-report-tabs :group-path="fullPath" :iteration-id="iteration.id" />
</template> </template>
......
...@@ -52,7 +52,7 @@ export function initIterationForm() { ...@@ -52,7 +52,7 @@ export function initIterationForm() {
export function initIterationReport() { export function initIterationReport() {
const el = document.querySelector('.js-iteration'); const el = document.querySelector('.js-iteration');
const { fullPath, iterationIid, editIterationPath } = el.dataset; const { fullPath, iterationIid, editIterationPath, previewMarkdownPath } = el.dataset;
const canEdit = parseBoolean(el.dataset.canEdit); const canEdit = parseBoolean(el.dataset.canEdit);
return new Vue({ return new Vue({
...@@ -65,6 +65,7 @@ export function initIterationReport() { ...@@ -65,6 +65,7 @@ export function initIterationReport() {
iterationIid, iterationIid,
canEdit, canEdit,
editIterationPath, editIterationPath,
previewMarkdownPath,
}, },
}); });
}, },
......
...@@ -7,6 +7,7 @@ query GroupIteration($groupPath: ID!, $iid: ID!) { ...@@ -7,6 +7,7 @@ query GroupIteration($groupPath: ID!, $iid: ID!) {
iid iid
id id
description description
descriptionHtml
webPath webPath
startDate startDate
dueDate dueDate
......
...@@ -20,6 +20,7 @@ module Types ...@@ -20,6 +20,7 @@ module Types
field :description, GraphQL::STRING_TYPE, null: true, field :description, GraphQL::STRING_TYPE, null: true,
description: 'Description of the iteration' description: 'Description of the iteration'
markdown_field :description_html, null: true
field :state, Types::IterationStateEnum, null: false, field :state, Types::IterationStateEnum, null: false,
description: 'State of the iteration' description: 'State of the iteration'
......
...@@ -59,7 +59,7 @@ describe('Iterations tabs', () => { ...@@ -59,7 +59,7 @@ describe('Iterations tabs', () => {
const iteration = { const iteration = {
title: 'June week 1', title: 'June week 1',
id: 'gid://gitlab/Iteration/2', id: 'gid://gitlab/Iteration/2',
description: 'The first week of June', descriptionHtml: 'The first week of June',
startDate: '2020-06-02', startDate: '2020-06-02',
dueDate: '2020-06-08', dueDate: '2020-06-08',
}; };
...@@ -89,24 +89,7 @@ describe('Iterations tabs', () => { ...@@ -89,24 +89,7 @@ describe('Iterations tabs', () => {
it('shows title and description', () => { it('shows title and description', () => {
expect(findTitle().text()).toContain(iteration.title); expect(findTitle().text()).toContain(iteration.title);
expect(findDescription().text()).toContain(iteration.description); expect(findDescription().text()).toContain(iteration.descriptionHtml);
});
it('escapes html in description', async () => {
wrapper.setData({
namespace: {
iteration: {
...iteration,
description: `<img src=x onerror=alert(document.domain)>`,
},
},
});
await wrapper.vm.$nextTick();
expect(findDescription().html()).toEqual(
'<div>&lt;img src=x onerror=alert(document.domain)&gt;</div>',
);
}); });
}); });
}); });
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