Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
3301ca10
Commit
3301ca10
authored
May 16, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed up the template dropdown to correctly work
[ci skip]
parent
f1b0b4a4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
152 additions
and
31 deletions
+152
-31
app/assets/javascripts/issue_show/components/app.vue
app/assets/javascripts/issue_show/components/app.vue
+11
-1
app/assets/javascripts/issue_show/components/fields/description_template.vue
...pts/issue_show/components/fields/description_template.vue
+30
-8
app/assets/javascripts/issue_show/components/form.vue
app/assets/javascripts/issue_show/components/form.vue
+12
-1
app/assets/javascripts/issue_show/index.js
app/assets/javascripts/issue_show/index.js
+4
-0
app/helpers/issuables_helper.rb
app/helpers/issuables_helper.rb
+3
-1
spec/javascripts/issue_show/components/fields/description_template_spec.js
...issue_show/components/fields/description_template_spec.js
+47
-0
spec/javascripts/issue_show/components/fields/title_spec.js
spec/javascripts/issue_show/components/fields/title_spec.js
+0
-20
spec/javascripts/issue_show/components/form_spec.js
spec/javascripts/issue_show/components/form_spec.js
+45
-0
No files found.
app/assets/javascripts/issue_show/components/app.vue
View file @
3301ca10
...
@@ -54,6 +54,14 @@ export default {
...
@@ -54,6 +54,14 @@ export default {
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
projectPath
:
{
type
:
String
,
required
:
true
,
},
projectNamespace
:
{
type
:
String
,
required
:
true
,
},
},
},
data
()
{
data
()
{
const
store
=
new
Store
({
const
store
=
new
Store
({
...
@@ -161,7 +169,9 @@ export default {
...
@@ -161,7 +169,9 @@ export default {
:can-destroy=
"canDestroy"
:can-destroy=
"canDestroy"
:issuable-templates=
"issuableTemplates"
:issuable-templates=
"issuableTemplates"
:markdown-docs=
"markdownDocs"
:markdown-docs=
"markdownDocs"
:markdown-preview-url=
"markdownPreviewUrl"
/>
:markdown-preview-url=
"markdownPreviewUrl"
:project-path=
"projectPath"
:project-namespace=
"projectNamespace"
/>
<div
v-else
>
<div
v-else
>
<title-component
<title-component
:issuable-ref=
"issuableRef"
:issuable-ref=
"issuableRef"
...
...
app/assets/javascripts/issue_show/components/fields/description_template.vue
View file @
3301ca10
<
script
>
<
script
>
export
default
{
export
default
{
props
:
{
props
:
{
formState
:
{
type
:
Object
,
required
:
true
,
},
issuableTemplates
:
{
issuableTemplates
:
{
type
:
Array
,
type
:
Array
,
required
:
false
,
required
:
false
,
default
:
()
=>
[],
default
:
()
=>
[],
},
},
projectPath
:
{
type
:
String
,
required
:
true
,
},
projectNamespace
:
{
type
:
String
,
required
:
true
,
},
},
},
mounted
()
{
mounted
()
{
return
new
gl
.
IssuableTemplateSelectors
();
// Create the editor for the template
const
editor
=
$
(
'
.detail-page-description .note-textarea
'
);
editor
.
setValue
=
(
val
)
=>
{
this
.
formState
.
description
=
val
;
};
editor
.
getValue
=
()
=>
this
.
formState
.
description
;
this
.
issuableTemplate
=
new
gl
.
IssuableTemplateSelectors
({
$dropdowns
:
$
(
this
.
$refs
.
toggle
),
editor
,
});
},
},
};
};
</
script
>
</
script
>
...
@@ -20,13 +42,14 @@
...
@@ -20,13 +42,14 @@
<button
<button
class=
"dropdown-menu-toggle js-issuable-selector"
class=
"dropdown-menu-toggle js-issuable-selector"
type=
"button"
type=
"button"
:data-data=
"JSON.stringify(issuableTemplates)
"
ref=
"toggle
"
data-field-name=
"issuable_template"
data-field-name=
"issuable_template"
data-selected=
"null"
data-selected=
"null"
data-project-path=
"gitlab-ce"
data-toggle=
"dropdown"
data-namespace-path=
"gitlab-org"
:data-namespace-path=
"projectNamespace"
data-toggle=
"dropdown"
>
:data-project-path=
"projectPath"
<span
class=
"dropdown-toggle-text "
>
:data-data=
"JSON.stringify(issuableTemplates)"
>
<span
class=
"dropdown-toggle-text"
>
Choose a template
Choose a template
</span>
</span>
<i
<i
...
@@ -63,8 +86,7 @@
...
@@ -63,8 +86,7 @@
class=
"fa fa-times dropdown-input-clear js-dropdown-input-clear"
>
class=
"fa fa-times dropdown-input-clear js-dropdown-input-clear"
>
</i>
</i>
</div>
</div>
<div
class=
"dropdown-content "
>
<div
class=
"dropdown-content"
></div>
</div>
<div
class=
"dropdown-footer"
>
<div
class=
"dropdown-footer"
>
<ul
class=
"dropdown-footer-list"
>
<ul
class=
"dropdown-footer-list"
>
<li>
<li>
...
...
app/assets/javascripts/issue_show/components/form.vue
View file @
3301ca10
...
@@ -27,6 +27,14 @@
...
@@ -27,6 +27,14 @@
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
projectPath
:
{
type
:
String
,
required
:
true
,
},
projectNamespace
:
{
type
:
String
,
required
:
true
,
},
},
},
components
:
{
components
:
{
titleField
,
titleField
,
...
@@ -49,7 +57,10 @@
...
@@ -49,7 +57,10 @@
class=
"col-sm-4 col-lg-3"
class=
"col-sm-4 col-lg-3"
v-if=
"hasIssuableTemplates"
>
v-if=
"hasIssuableTemplates"
>
<description-template
<description-template
:issuable-templates=
"issuableTemplates"
/>
:form-state=
"formState"
:issuable-templates=
"issuableTemplates"
:project-path=
"projectPath"
:project-namespace=
"projectNamespace"
/>
</div>
</div>
<div
<div
:class=
"
{
:class=
"
{
...
...
app/assets/javascripts/issue_show/index.js
View file @
3301ca10
...
@@ -42,6 +42,8 @@ document.addEventListener('DOMContentLoaded', () => {
...
@@ -42,6 +42,8 @@ document.addEventListener('DOMContentLoaded', () => {
issuableTemplates
:
initialData
.
templates
,
issuableTemplates
:
initialData
.
templates
,
markdownPreviewUrl
,
markdownPreviewUrl
,
markdownDocs
,
markdownDocs
,
projectPath
:
initialData
.
project_path
,
projectNamespace
:
initialData
.
namespace_path
,
};
};
},
},
render
(
createElement
)
{
render
(
createElement
)
{
...
@@ -57,6 +59,8 @@ document.addEventListener('DOMContentLoaded', () => {
...
@@ -57,6 +59,8 @@ document.addEventListener('DOMContentLoaded', () => {
issuableTemplates
:
this
.
issuableTemplates
,
issuableTemplates
:
this
.
issuableTemplates
,
markdownPreviewUrl
:
this
.
markdownPreviewUrl
,
markdownPreviewUrl
:
this
.
markdownPreviewUrl
,
markdownDocs
:
this
.
markdownDocs
,
markdownDocs
:
this
.
markdownDocs
,
projectPath
:
this
.
projectPath
,
projectNamespace
:
this
.
projectNamespace
,
},
},
});
});
},
},
...
...
app/helpers/issuables_helper.rb
View file @
3301ca10
...
@@ -201,7 +201,9 @@ module IssuablesHelper
...
@@ -201,7 +201,9 @@ module IssuablesHelper
def
issuable_initial_data
(
issuable
)
def
issuable_initial_data
(
issuable
)
{
{
templates:
issuable_templates
(
issuable
)
templates:
issuable_templates
(
issuable
),
project_path:
ref_project
.
path
,
namespace_path:
ref_project
.
namespace
.
full_path
}.
to_json
}.
to_json
end
end
...
...
spec/javascripts/issue_show/components/fields/description_template_spec.js
0 → 100644
View file @
3301ca10
import
Vue
from
'
vue
'
;
import
descriptionTemplate
from
'
~/issue_show/components/fields/description_template.vue
'
;
import
'
~/templates/issuable_template_selector
'
;
import
'
~/templates/issuable_template_selectors
'
;
describe
(
'
Issue description template component
'
,
()
=>
{
let
vm
;
let
formState
;
beforeEach
((
done
)
=>
{
const
Component
=
Vue
.
extend
(
descriptionTemplate
);
formState
=
{
description
:
'
test
'
,
};
vm
=
new
Component
({
propsData
:
{
formState
,
issuableTemplates
:
[{
name
:
'
test
'
}],
},
}).
$mount
();
Vue
.
nextTick
(
done
);
});
it
(
'
renders templates as JSON array in data attribute
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-issuable-selector
'
).
getAttribute
(
'
data-data
'
),
).
toBe
(
'
[{"name":"test"}]
'
);
});
it
(
'
updates formState when changing template
'
,
()
=>
{
vm
.
issuableTemplate
.
editor
.
setValue
(
'
test new template
'
);
expect
(
formState
.
description
,
).
toBe
(
'
test new template
'
);
});
it
(
'
returns formState description with editor getValue
'
,
()
=>
{
formState
.
description
=
'
testing new template
'
;
expect
(
vm
.
issuableTemplate
.
editor
.
getValue
(),
).
toBe
(
'
testing new template
'
);
});
});
spec/javascripts/issue_show/components/fields/title_spec.js
View file @
3301ca10
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
Store
from
'
~/issue_show/stores
'
;
import
Store
from
'
~/issue_show/stores
'
;
import
titleField
from
'
~/issue_show/components/fields/title.vue
'
;
import
titleField
from
'
~/issue_show/components/fields/title.vue
'
;
import
'
~/templates/issuable_template_selectors
'
;
describe
(
'
Title field component
'
,
()
=>
{
describe
(
'
Title field component
'
,
()
=>
{
let
vm
;
let
vm
;
...
@@ -28,23 +27,4 @@ describe('Title field component', () => {
...
@@ -28,23 +27,4 @@ describe('Title field component', () => {
vm
.
$el
.
querySelector
(
'
.form-control
'
).
value
,
vm
.
$el
.
querySelector
(
'
.form-control
'
).
value
,
).
toBe
(
'
test
'
);
).
toBe
(
'
test
'
);
});
});
it
(
'
does not render template selector if no templates exist
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-issuable-selector-wrap
'
),
).
toBeNull
();
});
it
(
'
renders template selector when templates exists
'
,
(
done
)
=>
{
spyOn
(
gl
,
'
IssuableTemplateSelectors
'
);
vm
.
issuableTemplates
=
[
'
test
'
];
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-issuable-selector-wrap
'
),
).
not
.
toBeNull
();
done
();
});
});
});
});
spec/javascripts/issue_show/components/form_spec.js
0 → 100644
View file @
3301ca10
import
Vue
from
'
vue
'
;
import
formComponent
from
'
~/issue_show/components/form.vue
'
;
import
'
~/templates/issuable_template_selector
'
;
import
'
~/templates/issuable_template_selectors
'
;
describe
(
'
Inline edit form component
'
,
()
=>
{
let
vm
;
beforeEach
((
done
)
=>
{
const
Component
=
Vue
.
extend
(
formComponent
);
vm
=
new
Component
({
propsData
:
{
canDestroy
:
true
,
formState
:
{
title
:
'
b
'
,
description
:
'
a
'
,
},
markdownPreviewUrl
:
'
/
'
,
markdownDocs
:
'
/
'
,
},
}).
$mount
();
Vue
.
nextTick
(
done
);
});
it
(
'
does not render template selector if no templates exist
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-issuable-selector-wrap
'
),
).
toBeNull
();
});
it
(
'
renders template selector when templates exists
'
,
(
done
)
=>
{
spyOn
(
gl
,
'
IssuableTemplateSelectors
'
);
vm
.
issuableTemplates
=
[
'
test
'
];
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-issuable-selector-wrap
'
),
).
not
.
toBeNull
();
done
();
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment