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
Léo-Paul Géneau
gitlab-ce
Commits
c33245e9
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
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
21 deletions
+42
-21
app/assets/javascripts/notes/components/comment_form.vue
app/assets/javascripts/notes/components/comment_form.vue
+31
-16
app/assets/javascripts/notes/stores/actions.js
app/assets/javascripts/notes/stores/actions.js
+2
-2
app/assets/javascripts/notes/stores/getters.js
app/assets/javascripts/notes/stores/getters.js
+1
-1
app/assets/javascripts/vue_shared/components/loading_button.vue
...sets/javascripts/vue_shared/components/loading_button.vue
+1
-1
spec/javascripts/notes/stores/actions_spec.js
spec/javascripts/notes/stores/actions_spec.js
+1
-1
spec/javascripts/notes/stores/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 @@
...
@@ -9,10 +9,11 @@
import
*
as
constants
from
'
../constants
'
;
import
*
as
constants
from
'
../constants
'
;
import
eventHub
from
'
../event_hub
'
;
import
eventHub
from
'
../event_hub
'
;
import
issueWarning
from
'
../../vue_shared/components/issue/issue_warning.vue
'
;
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
markdownField
from
'
../../vue_shared/components/markdown/field.vue
'
;
import
userAvatarLink
from
'
../../vue_shared/components/user_avatar/user_avatar_link.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
'
;
import
issuableStateMixin
from
'
../mixins/issuable_state
'
;
export
default
{
export
default
{
...
@@ -23,6 +24,7 @@
...
@@ -23,6 +24,7 @@
discussionLockedWidget
,
discussionLockedWidget
,
markdownField
,
markdownField
,
userAvatarLink
,
userAvatarLink
,
loadingButton
,
},
},
mixins
:
[
mixins
:
[
issuableStateMixin
,
issuableStateMixin
,
...
@@ -41,11 +43,8 @@
...
@@ -41,11 +43,8 @@
'
getUserData
'
,
'
getUserData
'
,
'
getNoteableData
'
,
'
getNoteableData
'
,
'
getNotesData
'
,
'
getNotesData
'
,
'
getI
ssueState
'
,
'
i
ssueState
'
,
]),
]),
issueState
()
{
return
this
.
getIssueState
;
},
isLoggedIn
()
{
isLoggedIn
()
{
return
this
.
getUserData
.
id
;
return
this
.
getUserData
.
id
;
},
},
...
@@ -131,6 +130,8 @@
...
@@ -131,6 +130,8 @@
}
}
},
},
handleSave
(
withIssueAction
)
{
handleSave
(
withIssueAction
)
{
this
.
isSubmitting
=
true
;
if
(
this
.
note
.
length
)
{
if
(
this
.
note
.
length
)
{
const
noteData
=
{
const
noteData
=
{
endpoint
:
this
.
endpoint
,
endpoint
:
this
.
endpoint
,
...
@@ -147,7 +148,6 @@
...
@@ -147,7 +148,6 @@
if
(
this
.
noteType
===
constants
.
DISCUSSION
)
{
if
(
this
.
noteType
===
constants
.
DISCUSSION
)
{
noteData
.
data
.
note
.
type
=
constants
.
DISCUSSION_NOTE
;
noteData
.
data
.
note
.
type
=
constants
.
DISCUSSION_NOTE
;
}
}
this
.
isSubmitting
=
true
;
this
.
note
=
''
;
// Empty textarea while being requested. Repopulate in catch
this
.
note
=
''
;
// Empty textarea while being requested. Repopulate in catch
this
.
resizeTextarea
();
this
.
resizeTextarea
();
this
.
stopPolling
();
this
.
stopPolling
();
...
@@ -189,13 +189,24 @@ Please check your network connection and try again.`;
...
@@ -189,13 +189,24 @@ Please check your network connection and try again.`;
this
.
toggleIssueState
();
this
.
toggleIssueState
();
}
}
},
},
enableButton
()
{
this
.
isSubmitting
=
false
;
},
toggleIssueState
()
{
toggleIssueState
()
{
if
(
this
.
isIssueOpen
)
{
if
(
this
.
isIssueOpen
)
{
this
.
closeIssue
()
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
{
}
else
{
this
.
reopenIssue
()
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
)
{
discard
(
shouldClear
=
true
)
{
...
@@ -373,15 +384,19 @@ append-right-10 comment-type-dropdown js-comment-type-dropdown droplab-dropdown"
...
@@ -373,15 +384,19 @@ append-right-10 comment-type-dropdown js-comment-type-dropdown droplab-dropdown"
</li>
</li>
</ul>
</ul>
</div>
</div>
<button
type=
"button"
<loading-button
@
click=
"handleSave(true)"
v-if=
"canUpdateIssue"
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"
:disabled=
"isSubmitting"
class=
"btn btn-comment btn-comment-and-close js-action-button"
>
:label=
"issueActionButtonTitle"
{{
issueActionButtonTitle
}}
/>
</button>
<button
<button
type=
"button"
type=
"button"
v-if=
"note.length"
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
...
@@ -77,10 +77,10 @@ export const reopenIssue = ({ commit, dispatch, state }) => service
dispatch
(
'
emitStateChangedEvent
'
,
data
);
dispatch
(
'
emitStateChangedEvent
'
,
data
);
});
});
export
const
emitStateChangedEvent
=
({
commit
},
data
)
=>
{
export
const
emitStateChangedEvent
=
({
commit
,
getters
},
data
)
=>
{
const
event
=
new
CustomEvent
(
'
issuable_vue_app:change
'
,
{
detail
:
{
const
event
=
new
CustomEvent
(
'
issuable_vue_app:change
'
,
{
detail
:
{
data
,
data
,
isClosed
:
data
.
s
tate
===
constants
.
CLOSED
,
isClosed
:
getters
.
issueS
tate
===
constants
.
CLOSED
,
}
});
}
});
document
.
dispatchEvent
(
event
);
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];
...
@@ -8,7 +8,7 @@ export const getNotesDataByProp = state => prop => state.notesData[prop];
export
const
getNoteableData
=
state
=>
state
.
noteableData
;
export
const
getNoteableData
=
state
=>
state
.
noteableData
;
export
const
getNoteableDataByProp
=
state
=>
prop
=>
state
.
noteableData
[
prop
];
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
getUserData
=
state
=>
state
.
userData
||
{};
export
const
getUserDataByProp
=
state
=>
prop
=>
state
.
userData
&&
state
.
userData
[
prop
];
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 @@
...
@@ -40,7 +40,7 @@
required
:
false
,
required
:
false
,
},
},
containerClass
:
{
containerClass
:
{
type
:
String
,
type
:
[
String
,
Array
,
Object
]
,
required
:
false
,
required
:
false
,
default
:
'
btn btn-align-content
'
,
default
:
'
btn btn-align-content
'
,
},
},
...
...
spec/javascripts/notes/stores/actions_spec.js
View file @
c33245e9
...
@@ -109,7 +109,7 @@ describe('Actions Notes Store', () => {
...
@@ -109,7 +109,7 @@ describe('Actions Notes Store', () => {
it
(
'
emits an event on the document
'
,
()
=>
{
it
(
'
emits an event on the document
'
,
()
=>
{
document
.
addEventListener
(
'
issuable_vue_app:change
'
,
(
event
)
=>
{
document
.
addEventListener
(
'
issuable_vue_app:change
'
,
(
event
)
=>
{
expect
(
event
.
detail
.
data
).
toEqual
({
id
:
'
1
'
,
state
:
'
closed
'
});
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
'
});
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', () => {
...
@@ -55,4 +55,10 @@ describe('Getters Notes Store', () => {
expect
(
getters
.
getCurrentUserLastNote
(
state
)).
toEqual
(
individualNote
.
notes
[
0
]);
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