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
346f8bfc
Commit
346f8bfc
authored
Aug 13, 2020
by
Olena Horal-Koretska
Committed by
Kushal Pandya
Aug 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preserve active tab on page reload
parent
41cc47c4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
10 deletions
+73
-10
app/assets/javascripts/alert_management/components/alert_details.vue
...javascripts/alert_management/components/alert_details.vue
+30
-7
app/assets/javascripts/alert_management/details.js
app/assets/javascripts/alert_management/details.js
+3
-0
app/assets/javascripts/alert_management/router.js
app/assets/javascripts/alert_management/router.js
+13
-0
changelogs/unreleased/225661-preserve-active-tab-alerts-details.yml
.../unreleased/225661-preserve-active-tab-alerts-details.yml
+5
-0
spec/frontend/alert_management/components/alert_details_spec.js
...rontend/alert_management/components/alert_details_spec.js
+22
-3
No files found.
app/assets/javascripts/alert_management/components/alert_details.vue
View file @
346f8bfc
...
@@ -35,13 +35,24 @@ export default {
...
@@ -35,13 +35,24 @@ export default {
errorMsg
:
s__
(
errorMsg
:
s__
(
'
AlertManagement|There was an error displaying the alert. Please refresh the page to try again.
'
,
'
AlertManagement|There was an error displaying the alert. Please refresh the page to try again.
'
,
),
),
fullAlertDetailsTitle
:
s__
(
'
AlertManagement|Alert details
'
),
overviewTitle
:
s__
(
'
AlertManagement|Overview
'
),
metricsTitle
:
s__
(
'
AlertManagement|Metrics
'
),
reportedAt
:
s__
(
'
AlertManagement|Reported %{when}
'
),
reportedAt
:
s__
(
'
AlertManagement|Reported %{when}
'
),
reportedAtWithTool
:
s__
(
'
AlertManagement|Reported %{when} by %{tool}
'
),
reportedAtWithTool
:
s__
(
'
AlertManagement|Reported %{when} by %{tool}
'
),
},
},
severityLabels
:
ALERTS_SEVERITY_LABELS
,
severityLabels
:
ALERTS_SEVERITY_LABELS
,
tabsConfig
:
[
{
id
:
'
overview
'
,
title
:
s__
(
'
AlertManagement|Overview
'
),
},
{
id
:
'
fullDetails
'
,
title
:
s__
(
'
AlertManagement|Alert details
'
),
},
{
id
:
'
metrics
'
,
title
:
s__
(
'
AlertManagement|Metrics
'
),
},
],
components
:
{
components
:
{
GlBadge
,
GlBadge
,
GlAlert
,
GlAlert
,
...
@@ -119,6 +130,18 @@ export default {
...
@@ -119,6 +130,18 @@ export default {
showErrorMsg
()
{
showErrorMsg
()
{
return
this
.
errored
&&
!
this
.
isErrorDismissed
;
return
this
.
errored
&&
!
this
.
isErrorDismissed
;
},
},
activeTab
()
{
return
this
.
$route
.
params
.
tabId
||
this
.
$options
.
tabsConfig
[
0
].
id
;
},
currentTabIndex
:
{
get
()
{
return
this
.
$options
.
tabsConfig
.
findIndex
(
tab
=>
tab
.
id
===
this
.
activeTab
);
},
set
(
tabIdx
)
{
const
tabId
=
this
.
$options
.
tabsConfig
[
tabIdx
].
id
;
this
.
$router
.
replace
({
name
:
'
tab
'
,
params
:
{
tabId
}
});
},
},
},
},
mounted
()
{
mounted
()
{
this
.
trackPageViews
();
this
.
trackPageViews
();
...
@@ -257,8 +280,8 @@ export default {
...
@@ -257,8 +280,8 @@ export default {
>
>
<h2
data-testid=
"title"
>
{{ alert.title }}
</h2>
<h2
data-testid=
"title"
>
{{ alert.title }}
</h2>
</div>
</div>
<gl-tabs
v-if=
"alert"
data-testid=
"alertDetailsTabs"
>
<gl-tabs
v-if=
"alert"
v-model=
"currentTabIndex"
data-testid=
"alertDetailsTabs"
>
<gl-tab
data-testid=
"overviewTab"
:title=
"$options.i18n.overviewT
itle"
>
<gl-tab
:data-testid=
"$options.tabsConfig[0].id"
:title=
"$options.tabsConfig[0].t
itle"
>
<div
v-if=
"alert.severity"
class=
"gl-mt-3 gl-mb-5 gl-display-flex"
>
<div
v-if=
"alert.severity"
class=
"gl-mt-3 gl-mb-5 gl-display-flex"
>
<div
class=
"gl-font-weight-bold gl-w-13 gl-text-right gl-pr-3"
>
<div
class=
"gl-font-weight-bold gl-w-13 gl-text-right gl-pr-3"
>
{{ s__('AlertManagement|Severity') }}:
{{ s__('AlertManagement|Severity') }}:
...
@@ -309,7 +332,7 @@ export default {
...
@@ -309,7 +332,7 @@ export default {
</div>
</div>
</
template
>
</
template
>
</gl-tab>
</gl-tab>
<gl-tab
data-testid=
"fullDetailsTab"
:title=
"$options.i18n.fullAlertDetailsT
itle"
>
<gl-tab
:data-testid=
"$options.tabsConfig[1].id"
:title=
"$options.tabsConfig[1].t
itle"
>
<gl-table
<gl-table
class=
"alert-management-details-table"
class=
"alert-management-details-table"
:items=
"[{ key: 'Value', ...alert }]"
:items=
"[{ key: 'Value', ...alert }]"
...
@@ -325,7 +348,7 @@ export default {
...
@@ -325,7 +348,7 @@ export default {
</
template
>
</
template
>
</gl-table>
</gl-table>
</gl-tab>
</gl-tab>
<gl-tab
data-testId=
"metricsTab"
:title=
"$options.i18n.metricsT
itle"
>
<gl-tab
:data-testid=
"$options.tabsConfig[2].id"
:title=
"$options.tabsConfig[2].t
itle"
>
<alert-metrics
:dashboard-url=
"alert.metricsDashboardUrl"
/>
<alert-metrics
:dashboard-url=
"alert.metricsDashboardUrl"
/>
</gl-tab>
</gl-tab>
</gl-tabs>
</gl-tabs>
...
...
app/assets/javascripts/alert_management/details.js
View file @
346f8bfc
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
createDefaultClient
from
'
~/lib/graphql
'
;
import
createDefaultClient
from
'
~/lib/graphql
'
;
import
createRouter
from
'
./router
'
;
import
{
defaultDataIdFromObject
}
from
'
apollo-cache-inmemory
'
;
import
{
defaultDataIdFromObject
}
from
'
apollo-cache-inmemory
'
;
import
AlertDetails
from
'
./components/alert_details.vue
'
;
import
AlertDetails
from
'
./components/alert_details.vue
'
;
import
sidebarStatusQuery
from
'
./graphql/queries/sidebar_status.query.graphql
'
;
import
sidebarStatusQuery
from
'
./graphql/queries/sidebar_status.query.graphql
'
;
...
@@ -10,6 +11,7 @@ Vue.use(VueApollo);
...
@@ -10,6 +11,7 @@ Vue.use(VueApollo);
export
default
selector
=>
{
export
default
selector
=>
{
const
domEl
=
document
.
querySelector
(
selector
);
const
domEl
=
document
.
querySelector
(
selector
);
const
{
alertId
,
projectPath
,
projectIssuesPath
,
projectId
}
=
domEl
.
dataset
;
const
{
alertId
,
projectPath
,
projectIssuesPath
,
projectId
}
=
domEl
.
dataset
;
const
router
=
createRouter
();
const
resolvers
=
{
const
resolvers
=
{
Mutation
:
{
Mutation
:
{
...
@@ -54,6 +56,7 @@ export default selector => {
...
@@ -54,6 +56,7 @@ export default selector => {
components
:
{
components
:
{
AlertDetails
,
AlertDetails
,
},
},
router
,
render
(
createElement
)
{
render
(
createElement
)
{
return
createElement
(
'
alert-details
'
,
{});
return
createElement
(
'
alert-details
'
,
{});
},
},
...
...
app/assets/javascripts/alert_management/router.js
0 → 100644
View file @
346f8bfc
import
Vue
from
'
vue
'
;
import
VueRouter
from
'
vue-router
'
;
import
{
joinPaths
}
from
'
~/lib/utils/url_utility
'
;
Vue
.
use
(
VueRouter
);
export
default
function
createRouter
(
base
)
{
return
new
VueRouter
({
mode
:
'
hash
'
,
base
:
joinPaths
(
gon
.
relative_url_root
||
''
,
base
),
routes
:
[{
path
:
'
/:tabId
'
,
name
:
'
tab
'
}],
});
}
changelogs/unreleased/225661-preserve-active-tab-alerts-details.yml
0 → 100644
View file @
346f8bfc
---
title
:
Preserve active tab on alert details page reload
merge_request
:
39369
author
:
type
:
added
spec/frontend/alert_management/components/alert_
management_detail
_spec.js
→
spec/frontend/alert_management/components/alert_
details
_spec.js
View file @
346f8bfc
...
@@ -20,6 +20,7 @@ describe('AlertDetails', () => {
...
@@ -20,6 +20,7 @@ describe('AlertDetails', () => {
const
projectPath
=
'
root/alerts
'
;
const
projectPath
=
'
root/alerts
'
;
const
projectIssuesPath
=
'
root/alerts/-/issues
'
;
const
projectIssuesPath
=
'
root/alerts/-/issues
'
;
const
projectId
=
'
1
'
;
const
projectId
=
'
1
'
;
const
$router
=
{
replace
:
jest
.
fn
()
};
const
findDetailsTable
=
()
=>
wrapper
.
find
(
GlTable
);
const
findDetailsTable
=
()
=>
wrapper
.
find
(
GlTable
);
...
@@ -44,6 +45,8 @@ describe('AlertDetails', () => {
...
@@ -44,6 +45,8 @@ describe('AlertDetails', () => {
sidebarStatus
:
{},
sidebarStatus
:
{},
},
},
},
},
$router
,
$route
:
{
params
:
{}
},
},
},
stubs
,
stubs
,
});
});
...
@@ -81,11 +84,11 @@ describe('AlertDetails', () => {
...
@@ -81,11 +84,11 @@ describe('AlertDetails', () => {
});
});
it
(
'
renders a tab with overview information
'
,
()
=>
{
it
(
'
renders a tab with overview information
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="overview
Tab
"]
'
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
'
[data-testid="overview"]
'
).
exists
()).
toBe
(
true
);
});
});
it
(
'
renders a tab with full alert information
'
,
()
=>
{
it
(
'
renders a tab with full alert information
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="fullDetails
Tab
"]
'
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
'
[data-testid="fullDetails"]
'
).
exists
()).
toBe
(
true
);
});
});
it
(
'
renders severity
'
,
()
=>
{
it
(
'
renders severity
'
,
()
=>
{
...
@@ -191,7 +194,7 @@ describe('AlertDetails', () => {
...
@@ -191,7 +194,7 @@ describe('AlertDetails', () => {
mountComponent
({
data
:
{
alert
:
mockAlert
}
});
mountComponent
({
data
:
{
alert
:
mockAlert
}
});
});
});
it
(
'
should display a table of raw alert details data
'
,
()
=>
{
it
(
'
should display a table of raw alert details data
'
,
()
=>
{
wrapper
.
find
(
'
[data-testid="fullDetails
Tab
"]
'
).
trigger
(
'
click
'
);
wrapper
.
find
(
'
[data-testid="fullDetails"]
'
).
trigger
(
'
click
'
);
expect
(
findDetailsTable
().
exists
()).
toBe
(
true
);
expect
(
findDetailsTable
().
exists
()).
toBe
(
true
);
});
});
});
});
...
@@ -252,6 +255,22 @@ describe('AlertDetails', () => {
...
@@ -252,6 +255,22 @@ describe('AlertDetails', () => {
);
);
});
});
});
});
describe
(
'
tab navigation
'
,
()
=>
{
beforeEach
(()
=>
{
mountComponent
({
data
:
{
alert
:
mockAlert
}
});
});
it
.
each
`
index | tabId
${
0
}
|
${
'
overview
'
}
${
1
}
|
${
'
fullDetails
'
}
${
2
}
|
${
'
metrics
'
}
`
(
'
will navigate to the correct tab via $tabId
'
,
({
index
,
tabId
})
=>
{
wrapper
.
setData
({
currentTabIndex
:
index
});
expect
(
$router
.
replace
).
toHaveBeenCalledWith
({
name
:
'
tab
'
,
params
:
{
tabId
}
});
});
});
});
});
describe
(
'
Snowplow tracking
'
,
()
=>
{
describe
(
'
Snowplow tracking
'
,
()
=>
{
...
...
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