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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
c8bf1bc0
Commit
c8bf1bc0
authored
Feb 13, 2020
by
Sean Nichols
Committed by
Paul Slaughter
Feb 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor WebIDE error message to use GlAlert
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/23300
parent
8b5f1fc2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
36 deletions
+43
-36
app/assets/javascripts/ide/components/error_message.vue
app/assets/javascripts/ide/components/error_message.vue
+21
-20
changelogs/unreleased/36854-webide-use-gl-alert.yml
changelogs/unreleased/36854-webide-use-gl-alert.yml
+5
-0
spec/frontend/ide/components/error_message_spec.js
spec/frontend/ide/components/error_message_spec.js
+15
-14
spec/javascripts/ide/components/ide_spec.js
spec/javascripts/ide/components/ide_spec.js
+2
-2
No files found.
app/assets/javascripts/ide/components/error_message.vue
View file @
c8bf1bc0
<
script
>
import
{
mapActions
}
from
'
vuex
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
Gl
Alert
,
Gl
LoadingIcon
}
from
'
@gitlab/ui
'
;
export
default
{
components
:
{
GlAlert
,
GlLoadingIcon
,
},
props
:
{
...
...
@@ -17,9 +18,14 @@ export default {
isLoading
:
false
,
};
},
computed
:
{
canDismiss
()
{
return
!
this
.
message
.
action
;
},
},
methods
:
{
...
mapActions
([
'
setErrorMessage
'
]),
click
Action
()
{
do
Action
()
{
if
(
this
.
isLoading
)
return
;
this
.
isLoading
=
true
;
...
...
@@ -33,28 +39,23 @@ export default {
this
.
isLoading
=
false
;
});
},
clickFlash
()
{
if
(
!
this
.
message
.
action
)
{
this
.
setErrorMessage
(
null
);
}
dismiss
()
{
this
.
setErrorMessage
(
null
);
},
},
};
</
script
>
<
template
>
<div
class=
"flash-container flash-container-page"
@
click=
"clickFlash"
>
<div
class=
"flash-alert"
data-qa-selector=
"flash_alert"
>
<span
v-html=
"message.text"
>
</span>
<button
v-if=
"message.action"
type=
"button"
class=
"flash-action text-white p-0 border-top-0 border-right-0 border-left-0 bg-transparent"
@
click.stop.prevent=
"clickAction"
>
{{
message
.
actionText
}}
<gl-loading-icon
v-show=
"isLoading"
inline
/>
</button>
</div>
</div>
<gl-alert
data-qa-selector=
"flash_alert"
variant=
"danger"
:dismissible=
"canDismiss"
:primary-button-text=
"message.actionText"
@
dismiss=
"dismiss"
@
primaryAction=
"doAction"
>
<span
v-html=
"message.text"
></span>
<gl-loading-icon
v-show=
"isLoading"
inline
class=
"vertical-align-middle ml-1"
/>
</gl-alert>
</
template
>
changelogs/unreleased/36854-webide-use-gl-alert.yml
0 → 100644
View file @
c8bf1bc0
---
title
:
Fix Web IDE alert message look and feel
merge_request
:
23300
author
:
Sean Nichols
type
:
fixed
spec/frontend/ide/components/error_message_spec.js
View file @
c8bf1bc0
import
{
shallowM
ount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
m
ount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
Vuex
from
'
vuex
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
ErrorMessage
from
'
~/ide/components/error_message.vue
'
;
...
...
@@ -15,7 +15,7 @@ describe('IDE error message component', () => {
actions
:
{
setErrorMessage
:
setErrorMessageMock
},
});
wrapper
=
shallowM
ount
(
ErrorMessage
,
{
wrapper
=
m
ount
(
ErrorMessage
,
{
propsData
:
{
message
:
{
text
:
'
some text
'
,
...
...
@@ -38,15 +38,18 @@ describe('IDE error message component', () => {
wrapper
=
null
;
});
const
findDismissButton
=
()
=>
wrapper
.
find
(
'
button[aria-label=Dismiss]
'
);
const
findActionButton
=
()
=>
wrapper
.
find
(
'
button.gl-alert-action
'
);
it
(
'
renders error message
'
,
()
=>
{
const
text
=
'
error message
'
;
createComponent
({
text
});
expect
(
wrapper
.
text
()).
toContain
(
text
);
});
it
(
'
clears error message on click
'
,
()
=>
{
it
(
'
clears error message on
dismiss
click
'
,
()
=>
{
createComponent
();
wrapper
.
trigger
(
'
click
'
);
findDismissButton
()
.
trigger
(
'
click
'
);
expect
(
setErrorMessageMock
).
toHaveBeenCalledWith
(
expect
.
any
(
Object
),
null
,
undefined
);
});
...
...
@@ -68,29 +71,27 @@ describe('IDE error message component', () => {
});
it
(
'
renders action button
'
,
()
=>
{
const
button
=
wrapper
.
find
(
'
button
'
);
const
button
=
findActionButton
(
);
expect
(
button
.
exists
()).
toBe
(
true
);
expect
(
button
.
text
()).
toContain
(
message
.
actionText
);
});
it
(
'
does not clear error message on click
'
,
()
=>
{
wrapper
.
trigger
(
'
click
'
);
expect
(
setErrorMessageMock
).
not
.
toHaveBeenCalled
();
it
(
'
does not show dismiss button
'
,
()
=>
{
expect
(
findDismissButton
().
exists
()).
toBe
(
false
);
});
it
(
'
dispatches action
'
,
()
=>
{
wrapper
.
find
(
'
button
'
).
trigger
(
'
click
'
);
findActionButton
(
).
trigger
(
'
click
'
);
expect
(
actionMock
).
toHaveBeenCalledWith
(
message
.
actionPayload
);
});
it
(
'
does not dispatch action when already loading
'
,
()
=>
{
wrapper
.
find
(
'
button
'
).
trigger
(
'
click
'
);
findActionButton
(
).
trigger
(
'
click
'
);
actionMock
.
mockReset
();
return
wrapper
.
vm
.
$nextTick
(()
=>
{
wrapper
.
find
(
'
button
'
).
trigger
(
'
click
'
);
findActionButton
(
).
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
expect
(
actionMock
).
not
.
toHaveBeenCalled
();
...
...
@@ -106,7 +107,7 @@ describe('IDE error message component', () => {
resolveAction
=
resolve
;
}),
);
wrapper
.
find
(
'
button
'
).
trigger
(
'
click
'
);
findActionButton
(
).
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
expect
(
wrapper
.
find
(
GlLoadingIcon
).
isVisible
()).
toBe
(
true
);
...
...
@@ -115,7 +116,7 @@ describe('IDE error message component', () => {
});
it
(
'
hides loading icon when operation finishes
'
,
()
=>
{
wrapper
.
find
(
'
button
'
).
trigger
(
'
click
'
);
findActionButton
(
).
trigger
(
'
click
'
);
return
actionMock
()
.
then
(()
=>
wrapper
.
vm
.
$nextTick
())
.
then
(()
=>
{
...
...
spec/javascripts/ide/components/ide_spec.js
View file @
c8bf1bc0
...
...
@@ -61,14 +61,14 @@ describe('ide component, non-empty repo', () => {
});
it
(
'
shows error message when set
'
,
done
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.
flash-container
'
)).
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.
gl-alert
'
)).
toBe
(
null
);
vm
.
$store
.
state
.
errorMessage
=
{
text
:
'
error
'
,
};
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.
flash-container
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.
gl-alert
'
)).
not
.
toBe
(
null
);
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