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 {
errorMsg
:
s__
(
'
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}
'
),
reportedAtWithTool
:
s__
(
'
AlertManagement|Reported %{when} by %{tool}
'
),
},
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
:
{
GlBadge
,
GlAlert
,
...
...
@@ -119,6 +130,18 @@ export default {
showErrorMsg
()
{
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
()
{
this
.
trackPageViews
();
...
...
@@ -257,8 +280,8 @@ export default {
>
<h2
data-testid=
"title"
>
{{ alert.title }}
</h2>
</div>
<gl-tabs
v-if=
"alert"
data-testid=
"alertDetailsTabs"
>
<gl-tab
data-testid=
"overviewTab"
:title=
"$options.i18n.overviewT
itle"
>
<gl-tabs
v-if=
"alert"
v-model=
"currentTabIndex"
data-testid=
"alertDetailsTabs"
>
<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
class=
"gl-font-weight-bold gl-w-13 gl-text-right gl-pr-3"
>
{{ s__('AlertManagement|Severity') }}:
...
...
@@ -309,7 +332,7 @@ export default {
</div>
</
template
>
</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
class=
"alert-management-details-table"
:items=
"[{ key: 'Value', ...alert }]"
...
...
@@ -325,7 +348,7 @@ export default {
</
template
>
</gl-table>
</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"
/>
</gl-tab>
</gl-tabs>
...
...
app/assets/javascripts/alert_management/details.js
View file @
346f8bfc
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
createDefaultClient
from
'
~/lib/graphql
'
;
import
createRouter
from
'
./router
'
;
import
{
defaultDataIdFromObject
}
from
'
apollo-cache-inmemory
'
;
import
AlertDetails
from
'
./components/alert_details.vue
'
;
import
sidebarStatusQuery
from
'
./graphql/queries/sidebar_status.query.graphql
'
;
...
...
@@ -10,6 +11,7 @@ Vue.use(VueApollo);
export
default
selector
=>
{
const
domEl
=
document
.
querySelector
(
selector
);
const
{
alertId
,
projectPath
,
projectIssuesPath
,
projectId
}
=
domEl
.
dataset
;
const
router
=
createRouter
();
const
resolvers
=
{
Mutation
:
{
...
...
@@ -54,6 +56,7 @@ export default selector => {
components
:
{
AlertDetails
,
},
router
,
render
(
createElement
)
{
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', () => {
const
projectPath
=
'
root/alerts
'
;
const
projectIssuesPath
=
'
root/alerts/-/issues
'
;
const
projectId
=
'
1
'
;
const
$router
=
{
replace
:
jest
.
fn
()
};
const
findDetailsTable
=
()
=>
wrapper
.
find
(
GlTable
);
...
...
@@ -44,6 +45,8 @@ describe('AlertDetails', () => {
sidebarStatus
:
{},
},
},
$router
,
$route
:
{
params
:
{}
},
},
stubs
,
});
...
...
@@ -81,11 +84,11 @@ describe('AlertDetails', () => {
});
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
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="fullDetails
Tab
"]
'
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
'
[data-testid="fullDetails"]
'
).
exists
()).
toBe
(
true
);
});
it
(
'
renders severity
'
,
()
=>
{
...
...
@@ -191,7 +194,7 @@ describe('AlertDetails', () => {
mountComponent
({
data
:
{
alert
:
mockAlert
}
});
});
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
);
});
});
...
...
@@ -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
'
,
()
=>
{
...
...
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