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
Jérome Perrin
gitlab-ce
Commits
203a94e3
Commit
203a94e3
authored
May 18, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-edit-inline' into issue-edit-inline-description-field-specs
[ci skip]
parents
6c34f5a2
f5675666
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
140 additions
and
11 deletions
+140
-11
app/assets/javascripts/issue_show/components/app.vue
app/assets/javascripts/issue_show/components/app.vue
+19
-6
app/assets/javascripts/issue_show/components/edit_actions.vue
...assets/javascripts/issue_show/components/edit_actions.vue
+11
-2
app/assets/javascripts/issue_show/components/fields/confidential_checkbox.vue
...ts/issue_show/components/fields/confidential_checkbox.vue
+23
-0
app/assets/javascripts/issue_show/components/fields/description.vue
.../javascripts/issue_show/components/fields/description.vue
+4
-1
app/assets/javascripts/issue_show/components/form.vue
app/assets/javascripts/issue_show/components/form.vue
+5
-0
app/assets/javascripts/issue_show/index.js
app/assets/javascripts/issue_show/index.js
+3
-0
app/assets/javascripts/issue_show/stores/index.js
app/assets/javascripts/issue_show/stores/index.js
+1
-0
app/views/projects/issues/show.html.haml
app/views/projects/issues/show.html.haml
+1
-0
spec/javascripts/issue_show/components/app_spec.js
spec/javascripts/issue_show/components/app_spec.js
+43
-2
spec/javascripts/issue_show/components/edit_actions_spec.js
spec/javascripts/issue_show/components/edit_actions_spec.js
+20
-0
spec/javascripts/issue_show/components/fields/description_spec.js
...ascripts/issue_show/components/fields/description_spec.js
+10
-0
No files found.
app/assets/javascripts/issue_show/components/app.vue
View file @
203a94e3
...
@@ -41,6 +41,10 @@ export default {
...
@@ -41,6 +41,10 @@ export default {
required
:
false
,
required
:
false
,
default
:
''
,
default
:
''
,
},
},
isConfidential
:
{
type
:
Boolean
,
required
:
true
,
},
markdownPreviewUrl
:
{
markdownPreviewUrl
:
{
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
...
@@ -75,18 +79,27 @@ export default {
...
@@ -75,18 +79,27 @@ export default {
},
},
methods
:
{
methods
:
{
openForm
()
{
openForm
()
{
if
(
!
this
.
showForm
)
{
this
.
showForm
=
true
;
this
.
showForm
=
true
;
this
.
store
.
formState
=
{
this
.
store
.
formState
=
{
title
:
this
.
state
.
titleText
,
title
:
this
.
state
.
titleText
,
confidential
:
this
.
isConfidential
,
description
:
this
.
state
.
descriptionText
,
description
:
this
.
state
.
descriptionText
,
};
};
}
},
},
closeForm
()
{
closeForm
()
{
this
.
showForm
=
false
;
this
.
showForm
=
false
;
},
},
updateIssuable
()
{
updateIssuable
()
{
this
.
service
.
updateIssuable
(
this
.
store
.
formState
)
this
.
service
.
updateIssuable
(
this
.
store
.
formState
)
.
then
(()
=>
{
.
then
((
res
)
=>
{
const
data
=
res
.
json
();
if
(
data
.
confidential
!==
this
.
isConfidential
)
{
location
.
reload
();
}
eventHub
.
$emit
(
'
close.form
'
);
eventHub
.
$emit
(
'
close.form
'
);
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
...
...
app/assets/javascripts/issue_show/components/edit_actions.vue
View file @
203a94e3
...
@@ -7,6 +7,10 @@
...
@@ -7,6 +7,10 @@
type
:
Boolean
,
type
:
Boolean
,
required
:
true
,
required
:
true
,
},
},
formState
:
{
type
:
Object
,
required
:
true
,
},
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -14,6 +18,11 @@
...
@@ -14,6 +18,11 @@
updateLoading
:
false
,
updateLoading
:
false
,
};
};
},
},
computed
:
{
isSubmitEnabled
()
{
return
this
.
formState
.
title
.
trim
()
!==
''
;
},
},
methods
:
{
methods
:
{
updateIssuable
()
{
updateIssuable
()
{
this
.
updateLoading
=
true
;
this
.
updateLoading
=
true
;
...
@@ -38,9 +47,9 @@
...
@@ -38,9 +47,9 @@
<div
class=
"prepend-top-default append-bottom-default clearfix"
>
<div
class=
"prepend-top-default append-bottom-default clearfix"
>
<button
<button
class=
"btn btn-save pull-left"
class=
"btn btn-save pull-left"
:class=
"
{ disabled: updateLoading }"
:class=
"
{ disabled: updateLoading
|| !isSubmitEnabled
}"
type="submit"
type="submit"
:disabled="updateLoading"
:disabled="updateLoading
|| !isSubmitEnabled
"
@click="updateIssuable">
@click="updateIssuable">
Save changes
Save changes
<i
<i
...
...
app/assets/javascripts/issue_show/components/fields/confidential_checkbox.vue
0 → 100644
View file @
203a94e3
<
script
>
export
default
{
props
:
{
formState
:
{
type
:
Object
,
required
:
true
,
},
},
};
</
script
>
<
template
>
<fieldset
class=
"checkbox"
>
<label
for=
"issue-confidential"
>
<input
type=
"checkbox"
value=
"1"
id=
"issue-confidential"
v-model=
"formState.confidential"
/>
This issue is confidential and should only be visible to team members with at least Reporter access.
</label>
</fieldset>
</
template
>
app/assets/javascripts/issue_show/components/fields/description.vue
View file @
203a94e3
...
@@ -20,6 +20,9 @@
...
@@ -20,6 +20,9 @@
components
:
{
components
:
{
markdownField
,
markdownField
,
},
},
mounted
()
{
this
.
$refs
.
textarea
.
focus
();
},
};
};
</
script
>
</
script
>
...
@@ -39,7 +42,7 @@
...
@@ -39,7 +42,7 @@
data-supports-slash-commands=
"false"
data-supports-slash-commands=
"false"
aria-label=
"Description"
aria-label=
"Description"
v-model=
"formState.description"
v-model=
"formState.description"
ref=
"texta
t
ea"
ref=
"texta
r
ea"
slot=
"textarea"
>
slot=
"textarea"
>
</textarea>
</textarea>
</markdown-field>
</markdown-field>
...
...
app/assets/javascripts/issue_show/components/form.vue
View file @
203a94e3
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
titleField
from
'
./fields/title.vue
'
;
import
titleField
from
'
./fields/title.vue
'
;
import
descriptionField
from
'
./fields/description.vue
'
;
import
descriptionField
from
'
./fields/description.vue
'
;
import
editActions
from
'
./edit_actions.vue
'
;
import
editActions
from
'
./edit_actions.vue
'
;
import
confidentialCheckbox
from
'
./fields/confidential_checkbox.vue
'
;
export
default
{
export
default
{
props
:
{
props
:
{
...
@@ -26,6 +27,7 @@
...
@@ -26,6 +27,7 @@
titleField
,
titleField
,
descriptionField
,
descriptionField
,
editActions
,
editActions
,
confidentialCheckbox
,
},
},
};
};
</
script
>
</
script
>
...
@@ -34,11 +36,14 @@
...
@@ -34,11 +36,14 @@
<form>
<form>
<title-field
<title-field
:form-state=
"formState"
/>
:form-state=
"formState"
/>
<confidential-checkbox
:form-state=
"formState"
/>
<description-field
<description-field
:form-state=
"formState"
:form-state=
"formState"
:markdown-preview-url=
"markdownPreviewUrl"
:markdown-preview-url=
"markdownPreviewUrl"
:markdown-docs=
"markdownDocs"
/>
:markdown-docs=
"markdownDocs"
/>
<edit-actions
<edit-actions
:form-state=
"formState"
:can-destroy=
"canDestroy"
/>
:can-destroy=
"canDestroy"
/>
</form>
</form>
</
template
>
</
template
>
app/assets/javascripts/issue_show/index.js
View file @
203a94e3
...
@@ -25,6 +25,7 @@ document.addEventListener('DOMContentLoaded', () => {
...
@@ -25,6 +25,7 @@ document.addEventListener('DOMContentLoaded', () => {
canDestroy
,
canDestroy
,
endpoint
,
endpoint
,
issuableRef
,
issuableRef
,
isConfidential
,
markdownPreviewUrl
,
markdownPreviewUrl
,
markdownDocs
,
markdownDocs
,
}
=
issuableElement
.
dataset
;
}
=
issuableElement
.
dataset
;
...
@@ -37,6 +38,7 @@ document.addEventListener('DOMContentLoaded', () => {
...
@@ -37,6 +38,7 @@ document.addEventListener('DOMContentLoaded', () => {
initialTitle
:
issuableTitleElement
.
innerHTML
,
initialTitle
:
issuableTitleElement
.
innerHTML
,
initialDescriptionHtml
:
issuableDescriptionElement
?
issuableDescriptionElement
.
innerHTML
:
''
,
initialDescriptionHtml
:
issuableDescriptionElement
?
issuableDescriptionElement
.
innerHTML
:
''
,
initialDescriptionText
:
issuableDescriptionTextarea
?
issuableDescriptionTextarea
.
textContent
:
''
,
initialDescriptionText
:
issuableDescriptionTextarea
?
issuableDescriptionTextarea
.
textContent
:
''
,
isConfidential
:
gl
.
utils
.
convertPermissionToBoolean
(
isConfidential
),
markdownPreviewUrl
,
markdownPreviewUrl
,
markdownDocs
,
markdownDocs
,
};
};
...
@@ -51,6 +53,7 @@ document.addEventListener('DOMContentLoaded', () => {
...
@@ -51,6 +53,7 @@ document.addEventListener('DOMContentLoaded', () => {
initialTitle
:
this
.
initialTitle
,
initialTitle
:
this
.
initialTitle
,
initialDescriptionHtml
:
this
.
initialDescriptionHtml
,
initialDescriptionHtml
:
this
.
initialDescriptionHtml
,
initialDescriptionText
:
this
.
initialDescriptionText
,
initialDescriptionText
:
this
.
initialDescriptionText
,
isConfidential
:
this
.
isConfidential
,
markdownPreviewUrl
:
this
.
markdownPreviewUrl
,
markdownPreviewUrl
:
this
.
markdownPreviewUrl
,
markdownDocs
:
this
.
markdownDocs
,
markdownDocs
:
this
.
markdownDocs
,
},
},
...
...
app/assets/javascripts/issue_show/stores/index.js
View file @
203a94e3
...
@@ -14,6 +14,7 @@ export default class Store {
...
@@ -14,6 +14,7 @@ export default class Store {
};
};
this
.
formState
=
{
this
.
formState
=
{
title
:
''
,
title
:
''
,
confidential
:
false
,
description
:
''
,
description
:
''
,
};
};
}
}
...
...
app/views/projects/issues/show.html.haml
View file @
203a94e3
...
@@ -55,6 +55,7 @@
...
@@ -55,6 +55,7 @@
"can-update"
=>
can?
(
current_user
,
:update_issue
,
@issue
).
to_s
,
"can-update"
=>
can?
(
current_user
,
:update_issue
,
@issue
).
to_s
,
"can-destroy"
=>
can?
(
current_user
,
:destroy_issue
,
@issue
).
to_s
,
"can-destroy"
=>
can?
(
current_user
,
:destroy_issue
,
@issue
).
to_s
,
"issuable-ref"
=>
@issue
.
to_reference
,
"issuable-ref"
=>
@issue
.
to_reference
,
"is-confidential"
=>
@issue
.
confidential
.
to_s
,
"markdown-preview-url"
=>
preview_markdown_path
(
@project
),
"markdown-preview-url"
=>
preview_markdown_path
(
@project
),
"markdown-docs"
=>
help_page_path
(
'user/markdown'
),
"markdown-docs"
=>
help_page_path
(
'user/markdown'
),
}
}
}
}
...
...
spec/javascripts/issue_show/components/app_spec.js
View file @
203a94e3
...
@@ -23,7 +23,7 @@ describe('Issuable output', () => {
...
@@ -23,7 +23,7 @@ describe('Issuable output', () => {
const
IssuableDescriptionComponent
=
Vue
.
extend
(
issuableApp
);
const
IssuableDescriptionComponent
=
Vue
.
extend
(
issuableApp
);
Vue
.
http
.
interceptors
.
push
(
issueShowInterceptor
(
issueShowData
.
initialRequest
));
Vue
.
http
.
interceptors
.
push
(
issueShowInterceptor
(
issueShowData
.
initialRequest
));
spyOn
(
eventHub
,
'
$emit
'
);
spyOn
(
eventHub
,
'
$emit
'
)
.
and
.
callThrough
()
;
vm
=
new
IssuableDescriptionComponent
({
vm
=
new
IssuableDescriptionComponent
({
propsData
:
{
propsData
:
{
...
@@ -34,7 +34,9 @@ describe('Issuable output', () => {
...
@@ -34,7 +34,9 @@ describe('Issuable output', () => {
initialTitle
:
''
,
initialTitle
:
''
,
initialDescriptionHtml
:
''
,
initialDescriptionHtml
:
''
,
initialDescriptionText
:
''
,
initialDescriptionText
:
''
,
showForm
:
false
,
isConfidential
:
false
,
markdownPreviewUrl
:
'
/
'
,
markdownDocs
:
'
/
'
,
},
},
}).
$mount
();
}).
$mount
();
});
});
...
@@ -88,6 +90,22 @@ describe('Issuable output', () => {
...
@@ -88,6 +90,22 @@ describe('Issuable output', () => {
});
});
});
});
it
(
'
does not update formState if form is already open
'
,
(
done
)
=>
{
vm
.
openForm
();
vm
.
state
.
titleText
=
'
testing 123
'
;
vm
.
openForm
();
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
store
.
formState
.
title
,
).
not
.
toBe
(
'
testing 123
'
);
done
();
});
});
describe
(
'
updateIssuable
'
,
()
=>
{
describe
(
'
updateIssuable
'
,
()
=>
{
it
(
'
correctly updates issuable data
'
,
(
done
)
=>
{
it
(
'
correctly updates issuable data
'
,
(
done
)
=>
{
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
)
=>
{
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
)
=>
{
...
@@ -108,6 +126,29 @@ describe('Issuable output', () => {
...
@@ -108,6 +126,29 @@ describe('Issuable output', () => {
});
});
});
});
it
(
'
reloads the page if the confidential status has changed
'
,
(
done
)
=>
{
spyOn
(
window
.
location
,
'
reload
'
);
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
)
=>
{
resolve
({
json
()
{
return
{
confidential
:
true
,
};
},
});
}));
vm
.
updateIssuable
();
setTimeout
(()
=>
{
expect
(
window
.
location
.
reload
,
).
toHaveBeenCalled
();
done
();
});
});
it
(
'
closes form on error
'
,
(
done
)
=>
{
it
(
'
closes form on error
'
,
(
done
)
=>
{
spyOn
(
window
,
'
Flash
'
).
and
.
callThrough
();
spyOn
(
window
,
'
Flash
'
).
and
.
callThrough
();
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
,
reject
)
=>
{
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(()
=>
new
Promise
((
resolve
,
reject
)
=>
{
...
...
spec/javascripts/issue_show/components/edit_actions_spec.js
View file @
203a94e3
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
editActions
from
'
~/issue_show/components/edit_actions.vue
'
;
import
editActions
from
'
~/issue_show/components/edit_actions.vue
'
;
import
eventHub
from
'
~/issue_show/event_hub
'
;
import
eventHub
from
'
~/issue_show/event_hub
'
;
import
Store
from
'
~/issue_show/stores
'
;
describe
(
'
Edit Actions components
'
,
()
=>
{
describe
(
'
Edit Actions components
'
,
()
=>
{
let
vm
;
let
vm
;
beforeEach
((
done
)
=>
{
beforeEach
((
done
)
=>
{
const
Component
=
Vue
.
extend
(
editActions
);
const
Component
=
Vue
.
extend
(
editActions
);
const
store
=
new
Store
({
titleHtml
:
''
,
descriptionHtml
:
''
,
issuableRef
:
''
,
});
store
.
formState
.
title
=
'
test
'
;
spyOn
(
eventHub
,
'
$emit
'
);
spyOn
(
eventHub
,
'
$emit
'
);
vm
=
new
Component
({
vm
=
new
Component
({
propsData
:
{
propsData
:
{
canDestroy
:
true
,
canDestroy
:
true
,
formState
:
store
.
formState
,
},
},
}).
$mount
();
}).
$mount
();
...
@@ -41,6 +49,18 @@ describe('Edit Actions components', () => {
...
@@ -41,6 +49,18 @@ describe('Edit Actions components', () => {
});
});
});
});
it
(
'
disables submit button when title is blank
'
,
(
done
)
=>
{
vm
.
formState
.
title
=
''
;
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.btn-save
'
).
getAttribute
(
'
disabled
'
),
).
toBe
(
'
disabled
'
);
done
();
});
});
describe
(
'
updateIssuable
'
,
()
=>
{
describe
(
'
updateIssuable
'
,
()
=>
{
it
(
'
sends update.issauble event when clicking save button
'
,
()
=>
{
it
(
'
sends update.issauble event when clicking save button
'
,
()
=>
{
vm
.
$el
.
querySelector
(
'
.btn-save
'
).
click
();
vm
.
$el
.
querySelector
(
'
.btn-save
'
).
click
();
...
...
spec/javascripts/issue_show/components/fields/description_spec.js
View file @
203a94e3
...
@@ -8,6 +8,7 @@ describe('Description field component', () => {
...
@@ -8,6 +8,7 @@ describe('Description field component', () => {
beforeEach
((
done
)
=>
{
beforeEach
((
done
)
=>
{
const
Component
=
Vue
.
extend
(
descriptionField
);
const
Component
=
Vue
.
extend
(
descriptionField
);
const
el
=
document
.
createElement
(
'
div
'
);
store
=
new
Store
({
store
=
new
Store
({
titleHtml
:
''
,
titleHtml
:
''
,
descriptionHtml
:
''
,
descriptionHtml
:
''
,
...
@@ -15,7 +16,10 @@ describe('Description field component', () => {
...
@@ -15,7 +16,10 @@ describe('Description field component', () => {
});
});
store
.
formState
.
description
=
'
test
'
;
store
.
formState
.
description
=
'
test
'
;
document
.
body
.
appendChild
(
el
);
vm
=
new
Component
({
vm
=
new
Component
({
el
,
propsData
:
{
propsData
:
{
markdownPreviewUrl
:
'
/
'
,
markdownPreviewUrl
:
'
/
'
,
markdownDocs
:
'
/
'
,
markdownDocs
:
'
/
'
,
...
@@ -43,4 +47,10 @@ describe('Description field component', () => {
...
@@ -43,4 +47,10 @@ describe('Description field component', () => {
done
();
done
();
});
});
});
});
it
(
'
focuses field when mounted
'
,
()
=>
{
expect
(
document
.
activeElement
,
).
toBe
(
vm
.
$refs
.
textarea
);
});
});
});
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