Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
23da1e27
Commit
23da1e27
authored
Mar 17, 2021
by
seotts
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Continued work
parent
cf71b776
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
9 deletions
+14
-9
src/views/preview/comment/compose-comment.jsx
src/views/preview/comment/compose-comment.jsx
+8
-6
test/unit/components/compose-comment.test.jsx
test/unit/components/compose-comment.test.jsx
+6
-3
No files found.
src/views/preview/comment/compose-comment.jsx
View file @
23da1e27
...
@@ -97,18 +97,20 @@ class ComposeComment extends React.Component {
...
@@ -97,18 +97,20 @@ class ComposeComment extends React.Component {
let
muteOpen
=
false
;
let
muteOpen
=
false
;
let
muteExpiresAtMs
=
0
;
let
muteExpiresAtMs
=
0
;
let
rejectedStatus
=
ComposeStatus
.
REJECTED
;
let
rejectedStatus
=
ComposeStatus
.
REJECTED
;
let
justMuted
=
true
;
let
showWarning
=
false
;
let
showWarning
=
false
;
let
muteType
=
null
;
let
muteType
=
null
;
if
(
body
.
status
&&
body
.
status
.
mute_status
)
{
if
(
body
.
status
&&
body
.
status
.
mute_status
)
{
muteExpiresAtMs
=
body
.
status
.
mute_status
.
muteExpiresAt
*
1000
;
// convert to ms
muteExpiresAtMs
=
body
.
status
.
mute_status
.
muteExpiresAt
*
1000
;
// convert to ms
if
(
body
.
rejected
===
'
isBad
'
)
{
if
(
body
.
rejected
===
JUST_MUTED_ERROR
)
{
rejectedStatus
=
ComposeStatus
.
REJECTED_MUTE
;
rejectedStatus
=
ComposeStatus
.
REJECTED_MUTE
;
}
else
{
}
else
{
rejectedStatus
=
ComposeStatus
.
COMPOSE_DISALLOWED
;
rejectedStatus
=
ComposeStatus
.
COMPOSE_DISALLOWED
;
justMuted
=
false
;
}
}
if
(
this
.
shouldShowMuteModal
(
body
.
status
.
mute_status
))
{
if
(
this
.
shouldShowMuteModal
(
body
.
status
.
mute_status
,
justMuted
))
{
muteOpen
=
true
;
muteOpen
=
true
;
}
}
...
@@ -170,7 +172,7 @@ class ComposeComment extends React.Component {
...
@@ -170,7 +172,7 @@ class ComposeComment extends React.Component {
muteOpen
:
true
muteOpen
:
true
});
});
}
}
shouldShowMuteModal
(
muteStatus
)
{
shouldShowMuteModal
(
muteStatus
,
justMuted
)
{
// We should show the mute modal if the user is in danger of being blocked or
// We should show the mute modal if the user is in danger of being blocked or
// when the user is newly muted or hasn't seen it for a while.
// when the user is newly muted or hasn't seen it for a while.
// We don't want to show it more than about once a week.
// We don't want to show it more than about once a week.
...
@@ -186,7 +188,7 @@ class ComposeComment extends React.Component {
...
@@ -186,7 +188,7 @@ class ComposeComment extends React.Component {
// If the user is already muted (for example, in a different tab),
// If the user is already muted (for example, in a different tab),
// do not show modal because it would be confusing
// do not show modal because it would be confusing
if
(
this
.
state
.
status
===
ComposeStatus
.
COMPOSE_DISALLOWED
)
{
if
(
!
justMuted
)
{
return
false
;
return
false
;
}
}
...
@@ -390,7 +392,7 @@ class ComposeComment extends React.Component {
...
@@ -390,7 +392,7 @@ class ComposeComment extends React.Component {
muteModalMessages=
{
this
.
getMuteMessageInfo
()
}
muteModalMessages=
{
this
.
getMuteMessageInfo
()
}
shouldCloseOnOverlayClick=
{
false
}
shouldCloseOnOverlayClick=
{
false
}
showFeedback=
{
showFeedback=
{
this
.
state
.
status
===
ComposeStatus
.
REJECTED_MUTE
&&
this
.
state
.
error
===
JUST_MUTED_ERROR
this
.
state
.
status
===
ComposeStatus
.
REJECTED_MUTE
}
}
showWarning=
{
this
.
state
.
showWarning
}
showWarning=
{
this
.
state
.
showWarning
}
startStep=
{
this
.
getMuteModalStartStep
()
}
startStep=
{
this
.
getMuteModalStartStep
()
}
...
...
test/unit/components/compose-comment.test.jsx
View file @
23da1e27
...
@@ -68,7 +68,10 @@ describe('Compose Comment test', () => {
...
@@ -68,7 +68,10 @@ describe('Compose Comment test', () => {
test
(
'
Error messages shows when comment rejected
'
,
()
=>
{
test
(
'
Error messages shows when comment rejected
'
,
()
=>
{
const
component
=
getComposeCommentWrapper
({});
const
component
=
getComposeCommentWrapper
({});
const
commentInstance
=
component
.
instance
();
const
commentInstance
=
component
.
instance
();
commentInstance
.
setState
({
error
:
'
isFlood
'
});
commentInstance
.
setState
({
error
:
'
isFlood
'
,
status
:
'
REJECTED
'
});
component
.
update
();
component
.
update
();
expect
(
component
.
find
(
'
FlexRow.compose-error-row
'
).
exists
()).
toEqual
(
true
);
expect
(
component
.
find
(
'
FlexRow.compose-error-row
'
).
exists
()).
toEqual
(
true
);
// Buttons stay enabled when comment rejected for non-mute reasons
// Buttons stay enabled when comment rejected for non-mute reasons
...
@@ -76,12 +79,12 @@ describe('Compose Comment test', () => {
...
@@ -76,12 +79,12 @@ describe('Compose Comment test', () => {
expect
(
component
.
find
(
'
Button.compose-cancel
'
).
props
().
disabled
).
toBe
(
false
);
expect
(
component
.
find
(
'
Button.compose-cancel
'
).
props
().
disabled
).
toBe
(
false
);
});
});
test
(
'
No error message shows when comment rejected because user muted
'
,
()
=>
{
test
(
'
No error message shows when comment rejected because user
is already
muted
'
,
()
=>
{
const
component
=
getComposeCommentWrapper
({});
const
component
=
getComposeCommentWrapper
({});
const
commentInstance
=
component
.
instance
();
const
commentInstance
=
component
.
instance
();
commentInstance
.
setState
({
commentInstance
.
setState
({
error
:
'
isMuted
'
,
error
:
'
isMuted
'
,
status
:
'
REJECTED_MUTE
'
status
:
'
COMPOSE_DISALLOWED
'
});
});
component
.
update
();
component
.
update
();
expect
(
component
.
find
(
'
FlexRow.compose-error-row
'
).
exists
()).
toEqual
(
false
);
expect
(
component
.
find
(
'
FlexRow.compose-error-row
'
).
exists
()).
toEqual
(
false
);
...
...
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