BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
c33245e9
Unverified
Commit
c33245e9
authored
Feb 12, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reuse getter
Add loading button for better UX
parent
ab734240
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
21 deletions
+42
-21
comment_form.vue
app/assets/javascripts/notes/components/comment_form.vue
+31
-16
actions.js
app/assets/javascripts/notes/stores/actions.js
+2
-2
getters.js
app/assets/javascripts/notes/stores/getters.js
+1
-1
loading_button.vue
...sets/javascripts/vue_shared/components/loading_button.vue
+1
-1
actions_spec.js
spec/javascripts/notes/stores/actions_spec.js
+1
-1
getters_spec.js
spec/javascripts/notes/stores/getters_spec.js
+6
-0
No files found.
app/assets/javascripts/notes/components/comment_form.vue
View file @
c33245e9
...
...
@@ -9,10 +9,11 @@
import
*
as
constants
from
'../constants'
;
import
eventHub
from
'../event_hub'
;
import
issueWarning
from
'../../vue_shared/components/issue/issue_warning.vue'
;
import
noteSignedOutWidget
from
'./note_signed_out_widget.vue'
;
import
discussionLockedWidget
from
'./discussion_locked_widget.vue'
;
import
markdownField
from
'../../vue_shared/components/markdown/field.vue'
;
import
userAvatarLink
from
'../../vue_shared/components/user_avatar/user_avatar_link.vue'
;
import
loadingButton
from
'../../vue_shared/components/loading_button.vue'
;
import
noteSignedOutWidget
from
'./note_signed_out_widget.vue'
;
import
discussionLockedWidget
from
'./discussion_locked_widget.vue'
;
import
issuableStateMixin
from
'../mixins/issuable_state'
;
export
default
{
...
...
@@ -23,6 +24,7 @@
discussionLockedWidget
,
markdownField
,
userAvatarLink
,
loadingButton
,
},
mixins
:
[
issuableStateMixin
,
...
...
@@ -41,11 +43,8 @@
'getUserData'
,
'getNoteableData'
,
'getNotesData'
,
'
getI
ssueState'
,
'
i
ssueState'
,
]),
issueState
()
{
return
this
.
getIssueState
;
},
isLoggedIn
()
{
return
this
.
getUserData
.
id
;
},
...
...
@@ -131,6 +130,8 @@
}
},
handleSave
(
withIssueAction
)
{
this
.
isSubmitting
=
true
;
if
(
this
.
note
.
length
)
{
const
noteData
=
{
endpoint
:
this
.
endpoint
,
...
...
@@ -147,7 +148,6 @@
if
(
this
.
noteType
===
constants
.
DISCUSSION
)
{
noteData
.
data
.
note
.
type
=
constants
.
DISCUSSION_NOTE
;
}
this
.
isSubmitting
=
true
;
this
.
note
=
''
;
// Empty textarea while being requested. Repopulate in catch
this
.
resizeTextarea
();
this
.
stopPolling
();
...
...
@@ -189,13 +189,24 @@ Please check your network connection and try again.`;
this
.
toggleIssueState
();
}
},
enableButton
()
{
this
.
isSubmitting
=
false
;
},
toggleIssueState
()
{
if
(
this
.
isIssueOpen
)
{
this
.
closeIssue
()
.
catch
(()
=>
Flash
(
__
(
'Something went wrong while closing the issue. Please try again later'
)));
.
then
(()
=>
this
.
enableButton
())
.
catch
(()
=>
{
this
.
enableButton
();
Flash
(
__
(
'Something went wrong while closing the issue. Please try again later'
));
});
}
else
{
this
.
reopenIssue
()
.
catch
(()
=>
Flash
(
__
(
'Something went wrong while reopening the issue. Please try again later'
)));
.
then
(()
=>
this
.
enableButton
())
.
catch
(()
=>
{
this
.
enableButton
();
Flash
(
__
(
'Something went wrong while reopening the issue. Please try again later'
));
});
}
},
discard
(
shouldClear
=
true
)
{
...
...
@@ -373,15 +384,19 @@ append-right-10 comment-type-dropdown js-comment-type-dropdown droplab-dropdown"
</li>
</ul>
</div>
<button
type=
"button"
@
click=
"handleSave(true)"
<loading-button
v-if=
"canUpdateIssue"
:class=
"actionButtonClassNames"
:loading=
"isSubmitting"
@
click=
"handleSave(true)"
:container-class=
"[
actionButtonClassNames,
'btn btn-comment btn-comment-and-close js-action-button'
]"
:disabled=
"isSubmitting"
class=
"btn btn-comment btn-comment-and-close js-action-button"
>
{{
issueActionButtonTitle
}}
</button>
:label=
"issueActionButtonTitle"
/>
<button
type=
"button"
v-if=
"note.length"
...
...
app/assets/javascripts/notes/stores/actions.js
View file @
c33245e9
...
...
@@ -77,10 +77,10 @@ export const reopenIssue = ({ commit, dispatch, state }) => service
dispatch
(
'emitStateChangedEvent'
,
data
);
});
export
const
emitStateChangedEvent
=
({
commit
},
data
)
=>
{
export
const
emitStateChangedEvent
=
({
commit
,
getters
},
data
)
=>
{
const
event
=
new
CustomEvent
(
'issuable_vue_app:change'
,
{
detail
:
{
data
,
isClosed
:
data
.
s
tate
===
constants
.
CLOSED
,
isClosed
:
getters
.
issueS
tate
===
constants
.
CLOSED
,
}
});
document
.
dispatchEvent
(
event
);
...
...
app/assets/javascripts/notes/stores/getters.js
View file @
c33245e9
...
...
@@ -8,7 +8,7 @@ export const getNotesDataByProp = state => prop => state.notesData[prop];
export
const
getNoteableData
=
state
=>
state
.
noteableData
;
export
const
getNoteableDataByProp
=
state
=>
prop
=>
state
.
noteableData
[
prop
];
export
const
getI
ssueState
=
state
=>
state
.
noteableData
.
state
;
export
const
i
ssueState
=
state
=>
state
.
noteableData
.
state
;
export
const
getUserData
=
state
=>
state
.
userData
||
{};
export
const
getUserDataByProp
=
state
=>
prop
=>
state
.
userData
&&
state
.
userData
[
prop
];
...
...
app/assets/javascripts/vue_shared/components/loading_button.vue
View file @
c33245e9
...
...
@@ -40,7 +40,7 @@
required
:
false
,
},
containerClass
:
{
type
:
String
,
type
:
[
String
,
Array
,
Object
]
,
required
:
false
,
default
:
'btn btn-align-content'
,
},
...
...
spec/javascripts/notes/stores/actions_spec.js
View file @
c33245e9
...
...
@@ -109,7 +109,7 @@ describe('Actions Notes Store', () => {
it
(
'emits an event on the document'
,
()
=>
{
document
.
addEventListener
(
'issuable_vue_app:change'
,
(
event
)
=>
{
expect
(
event
.
detail
.
data
).
toEqual
({
id
:
'1'
,
state
:
'closed'
});
expect
(
event
.
detail
.
isClosed
).
toEqual
(
tru
e
);
expect
(
event
.
detail
.
isClosed
).
toEqual
(
fals
e
);
});
store
.
dispatch
(
'emitStateChangedEvent'
,
{
id
:
'1'
,
state
:
'closed'
});
...
...
spec/javascripts/notes/stores/getters_spec.js
View file @
c33245e9
...
...
@@ -55,4 +55,10 @@ describe('Getters Notes Store', () => {
expect
(
getters
.
getCurrentUserLastNote
(
state
)).
toEqual
(
individualNote
.
notes
[
0
]);
});
});
describe
(
'issueState'
,
()
=>
{
it
(
'should return the issue state'
,
()
=>
{
expect
(
getters
.
issueState
(
state
)).
toEqual
(
noteableDataMock
.
state
);
});
});
});
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