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
14123f51
Commit
14123f51
authored
Sep 28, 2021
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use GlAlert for integrations table errors
Changelog: fixed
parent
cbc1b00b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
18 deletions
+30
-18
app/assets/javascripts/integrations/overrides/components/integration_overrides.vue
...tegrations/overrides/components/integration_overrides.vue
+12
-7
spec/frontend/integrations/overrides/components/integration_overrides_spec.js
...ations/overrides/components/integration_overrides_spec.js
+18
-11
No files found.
app/assets/javascripts/integrations/overrides/components/integration_overrides.vue
View file @
14123f51
<
script
>
import
{
GlLink
,
GlLoadingIcon
,
GlPagination
,
GlTable
}
from
'
@gitlab/ui
'
;
import
{
GlLink
,
GlLoadingIcon
,
GlPagination
,
GlTable
,
GlAlert
}
from
'
@gitlab/ui
'
;
import
*
as
Sentry
from
'
@sentry/browser
'
;
import
{
DEFAULT_PER_PAGE
}
from
'
~/api
'
;
import
createFlash
from
'
~/flash
'
;
import
{
fetchOverrides
}
from
'
~/integrations/overrides/api
'
;
import
{
parseIntPagination
,
normalizeHeaders
}
from
'
~/lib/utils/common_utils
'
;
import
{
truncateNamespace
}
from
'
~/lib/utils/text_utility
'
;
...
...
@@ -16,6 +16,7 @@ export default {
GlLoadingIcon
,
GlPagination
,
GlTable
,
GlAlert
,
ProjectAvatar
,
},
props
:
{
...
...
@@ -36,6 +37,7 @@ export default {
overrides
:
[],
page
:
1
,
totalItems
:
0
,
errorMessage
:
null
,
};
},
computed
:
{
...
...
@@ -49,6 +51,7 @@ export default {
methods
:
{
loadOverrides
(
page
=
this
.
page
)
{
this
.
isLoading
=
true
;
this
.
errorMessage
=
null
;
fetchOverrides
(
this
.
overridesPath
,
{
page
,
...
...
@@ -61,11 +64,9 @@ export default {
this
.
overrides
=
data
;
})
.
catch
((
error
)
=>
{
createFlash
({
message
:
this
.
$options
.
i18n
.
defaultErrorMessage
,
error
,
captureError
:
true
,
});
this
.
errorMessage
=
this
.
$options
.
i18n
.
defaultErrorMessage
;
Sentry
.
captureException
(
error
);
})
.
finally
(()
=>
{
this
.
isLoading
=
false
;
...
...
@@ -85,7 +86,11 @@ export default {
<
template
>
<div>
<gl-alert
v-if=
"errorMessage"
variant=
"danger"
:dismissible=
"false"
>
{{
errorMessage
}}
</gl-alert>
<gl-table
v-else
:items=
"overrides"
:fields=
"$options.fields"
:busy=
"isLoading"
...
...
spec/frontend/integrations/overrides/components/integration_overrides_spec.js
View file @
14123f51
import
{
GlTable
,
GlLink
,
GlPagination
}
from
'
@gitlab/ui
'
;
import
{
GlTable
,
GlLink
,
GlPagination
,
GlAlert
}
from
'
@gitlab/ui
'
;
import
*
as
Sentry
from
'
@sentry/browser
'
;
import
{
shallowMount
,
mount
}
from
'
@vue/test-utils
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
DEFAULT_PER_PAGE
}
from
'
~/api
'
;
import
createFlash
from
'
~/flash
'
;
import
IntegrationOverrides
from
'
~/integrations/overrides/components/integration_overrides.vue
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
httpStatus
from
'
~/lib/utils/http_status
'
;
import
ProjectAvatar
from
'
~/vue_shared/components/project_avatar.vue
'
;
jest
.
mock
(
'
~/flash
'
);
const
mockOverrides
=
Array
(
DEFAULT_PER_PAGE
*
3
)
.
fill
(
1
)
.
map
((
_
,
index
)
=>
({
...
...
@@ -62,6 +60,7 @@ describe('IntegrationOverrides', () => {
text
:
link
.
text
(),
};
});
const
findAlert
=
()
=>
wrapper
.
findComponent
(
GlAlert
);
describe
(
'
while loading
'
,
()
=>
{
it
(
'
sets GlTable `busy` attribute to `true`
'
,
()
=>
{
...
...
@@ -104,18 +103,26 @@ describe('IntegrationOverrides', () => {
describe
(
'
when request fails
'
,
()
=>
{
beforeEach
(
async
()
=>
{
jest
.
spyOn
(
Sentry
,
'
captureException
'
);
mockAxios
.
onGet
(
defaultProps
.
overridesPath
).
reply
(
httpStatus
.
INTERNAL_SERVER_ERROR
);
createComponent
();
await
waitForPromises
();
});
it
(
'
calls createFlash
'
,
()
=>
{
expect
(
createFlash
).
toHaveBeenCalledTimes
(
1
);
expect
(
createFlash
).
toHaveBeenCalledWith
({
message
:
IntegrationOverrides
.
i18n
.
defaultErrorMessage
,
captureError
:
true
,
error
:
expect
.
any
(
Error
),
});
it
(
'
displays error alert
'
,
()
=>
{
const
alert
=
findAlert
();
expect
(
alert
.
exists
()).
toBe
(
true
);
expect
(
alert
.
text
()).
toBe
(
IntegrationOverrides
.
i18n
.
defaultErrorMessage
);
});
it
(
'
hides overrides table
'
,
()
=>
{
const
table
=
findGlTable
();
expect
(
table
.
exists
()).
toBe
(
false
);
});
it
(
'
captures exception in Sentry
'
,
()
=>
{
expect
(
Sentry
.
captureException
).
toHaveBeenCalledWith
(
expect
.
any
(
Error
));
});
});
...
...
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