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
>
<
script
>
import
{
mapActions
}
from
'
vuex
'
;
import
{
mapActions
}
from
'
vuex
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
Gl
Alert
,
Gl
LoadingIcon
}
from
'
@gitlab/ui
'
;
export
default
{
export
default
{
components
:
{
components
:
{
GlAlert
,
GlLoadingIcon
,
GlLoadingIcon
,
},
},
props
:
{
props
:
{
...
@@ -17,9 +18,14 @@ export default {
...
@@ -17,9 +18,14 @@ export default {
isLoading
:
false
,
isLoading
:
false
,
};
};
},
},
computed
:
{
canDismiss
()
{
return
!
this
.
message
.
action
;
},
},
methods
:
{
methods
:
{
...
mapActions
([
'
setErrorMessage
'
]),
...
mapActions
([
'
setErrorMessage
'
]),
click
Action
()
{
do
Action
()
{
if
(
this
.
isLoading
)
return
;
if
(
this
.
isLoading
)
return
;
this
.
isLoading
=
true
;
this
.
isLoading
=
true
;
...
@@ -33,28 +39,23 @@ export default {
...
@@ -33,28 +39,23 @@ export default {
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
});
});
},
},
clickFlash
()
{
dismiss
()
{
if
(
!
this
.
message
.
action
)
{
this
.
setErrorMessage
(
null
);
this
.
setErrorMessage
(
null
);
}
},
},
},
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
<div
class=
"flash-container flash-container-page"
@
click=
"clickFlash"
>
<gl-alert
<div
class=
"flash-alert"
data-qa-selector=
"flash_alert"
>
data-qa-selector=
"flash_alert"
<span
v-html=
"message.text"
>
</span>
variant=
"danger"
<button
:dismissible=
"canDismiss"
v-if=
"message.action"
:primary-button-text=
"message.actionText"
type=
"button"
@
dismiss=
"dismiss"
class=
"flash-action text-white p-0 border-top-0 border-right-0 border-left-0 bg-transparent"
@
primaryAction=
"doAction"
@
click.stop.prevent=
"clickAction"
>
>
<span
v-html=
"message.text"
></span>
{{
message
.
actionText
}}
<gl-loading-icon
v-show=
"isLoading"
inline
class=
"vertical-align-middle ml-1"
/>
<gl-loading-icon
v-show=
"isLoading"
inline
/>
</gl-alert>
</button>
</div>
</div>
</
template
>
</
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
Vuex
from
'
vuex
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
ErrorMessage
from
'
~/ide/components/error_message.vue
'
;
import
ErrorMessage
from
'
~/ide/components/error_message.vue
'
;
...
@@ -15,7 +15,7 @@ describe('IDE error message component', () => {
...
@@ -15,7 +15,7 @@ describe('IDE error message component', () => {
actions
:
{
setErrorMessage
:
setErrorMessageMock
},
actions
:
{
setErrorMessage
:
setErrorMessageMock
},
});
});
wrapper
=
shallowM
ount
(
ErrorMessage
,
{
wrapper
=
m
ount
(
ErrorMessage
,
{
propsData
:
{
propsData
:
{
message
:
{
message
:
{
text
:
'
some text
'
,
text
:
'
some text
'
,
...
@@ -38,15 +38,18 @@ describe('IDE error message component', () => {
...
@@ -38,15 +38,18 @@ describe('IDE error message component', () => {
wrapper
=
null
;
wrapper
=
null
;
});
});
const
findDismissButton
=
()
=>
wrapper
.
find
(
'
button[aria-label=Dismiss]
'
);
const
findActionButton
=
()
=>
wrapper
.
find
(
'
button.gl-alert-action
'
);
it
(
'
renders error message
'
,
()
=>
{
it
(
'
renders error message
'
,
()
=>
{
const
text
=
'
error message
'
;
const
text
=
'
error message
'
;
createComponent
({
text
});
createComponent
({
text
});
expect
(
wrapper
.
text
()).
toContain
(
text
);
expect
(
wrapper
.
text
()).
toContain
(
text
);
});
});
it
(
'
clears error message on click
'
,
()
=>
{
it
(
'
clears error message on
dismiss
click
'
,
()
=>
{
createComponent
();
createComponent
();
wrapper
.
trigger
(
'
click
'
);
findDismissButton
()
.
trigger
(
'
click
'
);
expect
(
setErrorMessageMock
).
toHaveBeenCalledWith
(
expect
.
any
(
Object
),
null
,
undefined
);
expect
(
setErrorMessageMock
).
toHaveBeenCalledWith
(
expect
.
any
(
Object
),
null
,
undefined
);
});
});
...
@@ -68,29 +71,27 @@ describe('IDE error message component', () => {
...
@@ -68,29 +71,27 @@ describe('IDE error message component', () => {
});
});
it
(
'
renders action button
'
,
()
=>
{
it
(
'
renders action button
'
,
()
=>
{
const
button
=
wrapper
.
find
(
'
button
'
);
const
button
=
findActionButton
(
);
expect
(
button
.
exists
()).
toBe
(
true
);
expect
(
button
.
exists
()).
toBe
(
true
);
expect
(
button
.
text
()).
toContain
(
message
.
actionText
);
expect
(
button
.
text
()).
toContain
(
message
.
actionText
);
});
});
it
(
'
does not clear error message on click
'
,
()
=>
{
it
(
'
does not show dismiss button
'
,
()
=>
{
wrapper
.
trigger
(
'
click
'
);
expect
(
findDismissButton
().
exists
()).
toBe
(
false
);
expect
(
setErrorMessageMock
).
not
.
toHaveBeenCalled
();
});
});
it
(
'
dispatches action
'
,
()
=>
{
it
(
'
dispatches action
'
,
()
=>
{
wrapper
.
find
(
'
button
'
).
trigger
(
'
click
'
);
findActionButton
(
).
trigger
(
'
click
'
);
expect
(
actionMock
).
toHaveBeenCalledWith
(
message
.
actionPayload
);
expect
(
actionMock
).
toHaveBeenCalledWith
(
message
.
actionPayload
);
});
});
it
(
'
does not dispatch action when already loading
'
,
()
=>
{
it
(
'
does not dispatch action when already loading
'
,
()
=>
{
wrapper
.
find
(
'
button
'
).
trigger
(
'
click
'
);
findActionButton
(
).
trigger
(
'
click
'
);
actionMock
.
mockReset
();
actionMock
.
mockReset
();
return
wrapper
.
vm
.
$nextTick
(()
=>
{
return
wrapper
.
vm
.
$nextTick
(()
=>
{
wrapper
.
find
(
'
button
'
).
trigger
(
'
click
'
);
findActionButton
(
).
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
expect
(
actionMock
).
not
.
toHaveBeenCalled
();
expect
(
actionMock
).
not
.
toHaveBeenCalled
();
...
@@ -106,7 +107,7 @@ describe('IDE error message component', () => {
...
@@ -106,7 +107,7 @@ describe('IDE error message component', () => {
resolveAction
=
resolve
;
resolveAction
=
resolve
;
}),
}),
);
);
wrapper
.
find
(
'
button
'
).
trigger
(
'
click
'
);
findActionButton
(
).
trigger
(
'
click
'
);
return
wrapper
.
vm
.
$nextTick
(()
=>
{
return
wrapper
.
vm
.
$nextTick
(()
=>
{
expect
(
wrapper
.
find
(
GlLoadingIcon
).
isVisible
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
GlLoadingIcon
).
isVisible
()).
toBe
(
true
);
...
@@ -115,7 +116,7 @@ describe('IDE error message component', () => {
...
@@ -115,7 +116,7 @@ describe('IDE error message component', () => {
});
});
it
(
'
hides loading icon when operation finishes
'
,
()
=>
{
it
(
'
hides loading icon when operation finishes
'
,
()
=>
{
wrapper
.
find
(
'
button
'
).
trigger
(
'
click
'
);
findActionButton
(
).
trigger
(
'
click
'
);
return
actionMock
()
return
actionMock
()
.
then
(()
=>
wrapper
.
vm
.
$nextTick
())
.
then
(()
=>
wrapper
.
vm
.
$nextTick
())
.
then
(()
=>
{
.
then
(()
=>
{
...
...
spec/javascripts/ide/components/ide_spec.js
View file @
c8bf1bc0
...
@@ -61,14 +61,14 @@ describe('ide component, non-empty repo', () => {
...
@@ -61,14 +61,14 @@ describe('ide component, non-empty repo', () => {
});
});
it
(
'
shows error message when set
'
,
done
=>
{
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
=
{
vm
.
$store
.
state
.
errorMessage
=
{
text
:
'
error
'
,
text
:
'
error
'
,
};
};
vm
.
$nextTick
(()
=>
{
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.
flash-container
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.
gl-alert
'
)).
not
.
toBe
(
null
);
done
();
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