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
fb12120e
Commit
fb12120e
authored
May 06, 2020
by
Tristan Read
Committed by
Ash McKenzie
May 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alert Management detail page graphql initial setup
parent
3df9df27
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
154 additions
and
38 deletions
+154
-38
app/assets/javascripts/alert_management/components/alert_details.vue
...javascripts/alert_management/components/alert_details.vue
+48
-19
app/assets/javascripts/alert_management/details.js
app/assets/javascripts/alert_management/details.js
+18
-1
app/assets/javascripts/alert_management/graphql/queries/details.query.graphql
...ts/alert_management/graphql/queries/details.query.graphql
+17
-0
app/controllers/projects/alert_management_controller.rb
app/controllers/projects/alert_management_controller.rb
+1
-0
app/helpers/projects/alert_management_helper.rb
app/helpers/projects/alert_management_helper.rb
+7
-0
app/views/projects/alert_management/details.html.haml
app/views/projects/alert_management/details.html.haml
+1
-1
spec/controllers/projects/alert_management_controller_spec.rb
.../controllers/projects/alert_management_controller_spec.rb
+8
-0
spec/frontend/alert_management/components/alert_management_detail_spec.js
...ert_management/components/alert_management_detail_spec.js
+41
-15
spec/helpers/projects/alert_management_helper_spec.rb
spec/helpers/projects/alert_management_helper_spec.rb
+13
-2
No files found.
app/assets/javascripts/alert_management/components/alert_details.vue
View file @
fb12120e
<
script
>
<
script
>
import
{
GlNewDropdown
,
GlNewDropdownItem
,
GlTabs
,
GlTab
}
from
'
@gitlab/ui
'
;
import
{
GlNewDropdown
,
GlNewDropdownItem
,
GlTabs
,
GlTab
}
from
'
@gitlab/ui
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
}
from
'
~/locale
'
;
import
query
from
'
../graphql/queries/details.query.graphql
'
;
import
{
fetchPolicies
}
from
'
~/lib/graphql
'
;
export
default
{
export
default
{
statuses
:
{
statuses
:
{
...
@@ -18,11 +20,40 @@ export default {
...
@@ -18,11 +20,40 @@ export default {
GlTab
,
GlTab
,
GlTabs
,
GlTabs
,
},
},
props
:
{
alertId
:
{
type
:
String
,
required
:
true
,
},
projectPath
:
{
type
:
String
,
required
:
true
,
},
},
apollo
:
{
alert
:
{
fetchPolicy
:
fetchPolicies
.
CACHE_AND_NETWORK
,
query
,
variables
()
{
return
{
fullPath
:
this
.
projectPath
,
alertId
:
this
.
alertId
,
};
},
update
(
data
)
{
return
data
?.
project
?.
alertManagementAlerts
?.
nodes
?.[
0
]
??
null
;
},
},
},
data
()
{
return
{
alert
:
null
};
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
<div>
<div>
<div
class=
"d-flex justify-content-between border-bottom pb-2 pt-1"
>
<div
v-if=
"alert"
class=
"d-flex justify-content-between border-bottom pb-2 pt-1"
>
<div></div>
<gl-new-dropdown
class=
"align-self-center"
right
>
<gl-new-dropdown
class=
"align-self-center"
right
>
<gl-new-dropdown-item
<gl-new-dropdown-item
v-for=
"(label, field) in $options.statuses"
v-for=
"(label, field) in $options.statuses"
...
@@ -33,23 +64,21 @@ export default {
...
@@ -33,23 +64,21 @@ export default {
</gl-new-dropdown-item>
</gl-new-dropdown-item>
</gl-new-dropdown>
</gl-new-dropdown>
</div>
</div>
<div
class=
"d-flex"
>
<gl-tabs
v-if=
"alert"
data-testid=
"alertDetailsTabs"
>
<gl-tabs>
<gl-tab
data-testid=
"overviewTab"
:title=
"$options.i18n.overviewTitle"
>
<gl-tab
data-testid=
"overviewTab"
:title=
"$options.i18n.overviewTitle"
>
<ul
class=
"pl-3"
>
<ul
class=
"pl-3"
>
<li
data-testid=
"startTimeItem"
class=
"font-weight-bold mb-3 mt-2"
>
<li
data-testid=
"startTimeItem"
class=
"font-weight-bold mb-3 mt-2"
>
{{
s__
(
'
AlertManagement|Start time:
'
)
}}
{{
s__
(
'
AlertManagement|Start time:
'
)
}}
</li>
</li>
<li
class=
"font-weight-bold my-3"
>
<li
class=
"font-weight-bold my-3"
>
{{
s__
(
'
AlertManagement|End time:
'
)
}}
{{
s__
(
'
AlertManagement|End time:
'
)
}}
</li>
</li>
<li
class=
"font-weight-bold my-3"
>
<li
class=
"font-weight-bold my-3"
>
{{
s__
(
'
AlertManagement|Events:
'
)
}}
{{
s__
(
'
AlertManagement|Events:
'
)
}}
</li>
</li>
</ul>
</ul>
</gl-tab>
</gl-tab>
<gl-tab
data-testid=
"fullDetailsTab"
:title=
"$options.i18n.fullAlertDetailsTitle"
/>
<gl-tab
data-testid=
"fullDetailsTab"
:title=
"$options.i18n.fullAlertDetailsTitle"
/>
</gl-tabs>
</gl-tabs>
</div>
</div>
</div>
</
template
>
</
template
>
app/assets/javascripts/alert_management/details.js
View file @
fb12120e
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
createDefaultClient
from
'
~/lib/graphql
'
;
import
AlertDetails
from
'
./components/alert_details.vue
'
;
import
AlertDetails
from
'
./components/alert_details.vue
'
;
Vue
.
use
(
VueApollo
);
export
default
selector
=>
{
export
default
selector
=>
{
const
domEl
=
document
.
querySelector
(
selector
);
const
{
alertId
,
projectPath
}
=
domEl
.
dataset
;
const
apolloProvider
=
new
VueApollo
({
defaultClient
:
createDefaultClient
(),
});
// eslint-disable-next-line no-new
// eslint-disable-next-line no-new
new
Vue
({
new
Vue
({
el
:
selector
,
el
:
selector
,
apolloProvider
,
components
:
{
components
:
{
AlertDetails
,
AlertDetails
,
},
},
render
(
createElement
)
{
render
(
createElement
)
{
return
createElement
(
'
alert-details
'
,
{});
return
createElement
(
'
alert-details
'
,
{
props
:
{
alertId
,
projectPath
,
},
});
},
},
});
});
};
};
app/assets/javascripts/alert_management/graphql/queries/details.query.graphql
0 → 100644
View file @
fb12120e
query
alertDetails
(
$fullPath
:
ID
!,
$alertId
:
String
)
{
project
(
fullPath
:
$fullPath
)
{
alertManagementAlerts
(
iid
:
$alertId
)
{
nodes
{
iid
endedAt
eventCount
monitoringTool
service
severity
startedAt
status
title
}
}
}
}
app/controllers/projects/alert_management_controller.rb
View file @
fb12120e
...
@@ -7,6 +7,7 @@ class Projects::AlertManagementController < Projects::ApplicationController
...
@@ -7,6 +7,7 @@ class Projects::AlertManagementController < Projects::ApplicationController
end
end
def
details
def
details
@alert_id
=
params
[
:id
]
end
end
private
private
...
...
app/helpers/projects/alert_management_helper.rb
View file @
fb12120e
...
@@ -10,4 +10,11 @@ module Projects::AlertManagementHelper
...
@@ -10,4 +10,11 @@ module Projects::AlertManagementHelper
'alert-management-enabled'
=>
Feature
.
enabled?
(
:alert_management_minimal
,
project
).
to_s
'alert-management-enabled'
=>
Feature
.
enabled?
(
:alert_management_minimal
,
project
).
to_s
}
}
end
end
def
alert_management_detail_data
(
project_path
,
alert_id
)
{
'alert-id'
=>
alert_id
,
'project-path'
=>
project_path
}
end
end
end
app/views/projects/alert_management/details.html.haml
View file @
fb12120e
-
add_to_breadcrumbs
s_
(
'AlertManagement|Alerts'
),
project_alert_management_index_path
(
@project
)
-
add_to_breadcrumbs
s_
(
'AlertManagement|Alerts'
),
project_alert_management_index_path
(
@project
)
-
page_title
s_
(
'AlertManagement|Alert detail'
)
-
page_title
s_
(
'AlertManagement|Alert detail'
)
#js-alert_details
#js-alert_details
{
data:
alert_management_detail_data
(
@project
.
full_path
,
@alert_id
)
}
spec/controllers/projects/alert_management_controller_spec.rb
View file @
fb12120e
...
@@ -64,4 +64,12 @@ describe Projects::AlertManagementController do
...
@@ -64,4 +64,12 @@ describe Projects::AlertManagementController do
end
end
end
end
end
end
describe
'set_alert_id'
do
it
'sets alert id from the route'
do
get
:details
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
id
}
expect
(
assigns
(
:alert_id
)).
to
eq
(
id
.
to_s
)
end
end
end
end
spec/frontend/alert_management/components/alert_management_detail_spec.js
View file @
fb12120e
...
@@ -4,14 +4,18 @@ import AlertDetails from '~/alert_management/components/alert_details.vue';
...
@@ -4,14 +4,18 @@ import AlertDetails from '~/alert_management/components/alert_details.vue';
describe
(
'
AlertDetails
'
,
()
=>
{
describe
(
'
AlertDetails
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
function
mountComponent
()
{
function
mountComponent
(
alert
=
{})
{
wrapper
=
shallowMount
(
AlertDetails
);
wrapper
=
shallowMount
(
AlertDetails
,
{
propsData
:
{
alertId
:
'
alertId
'
,
projectPath
:
'
projectPath
'
,
},
data
()
{
return
{
alert
};
},
});
}
}
beforeEach
(()
=>
{
mountComponent
();
});
afterEach
(()
=>
{
afterEach
(()
=>
{
if
(
wrapper
)
{
if
(
wrapper
)
{
wrapper
.
destroy
();
wrapper
.
destroy
();
...
@@ -19,20 +23,42 @@ describe('AlertDetails', () => {
...
@@ -19,20 +23,42 @@ describe('AlertDetails', () => {
});
});
describe
(
'
Alert details
'
,
()
=>
{
describe
(
'
Alert details
'
,
()
=>
{
it
(
'
renders a tab with overview information
'
,
()
=>
{
describe
(
'
when alert is null
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="overviewTab"]
'
).
exists
()).
toBe
(
true
);
beforeEach
(()
=>
{
});
mountComponent
(
null
);
});
it
(
'
renders a tab with full alert information
'
,
()
=>
{
describe
(
'
when alert is null
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="fullDetailsTab"]
'
).
exists
()).
toBe
(
true
);
beforeEach
(()
=>
{
mountComponent
(
null
);
});
it
(
'
shows an empty state
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="alertDetailsTabs"]
'
).
exists
()).
toBe
(
false
);
});
});
});
});
it
(
'
renders alert details
'
,
()
=>
{
describe
(
'
when alert is present
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="startTimeItem"]
'
).
exists
()).
toBe
(
true
);
beforeEach
(()
=>
{
mountComponent
();
});
it
(
'
renders a tab with overview information
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="overviewTab"]
'
).
exists
()).
toBe
(
true
);
});
it
(
'
renders a tab with full alert information
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="fullDetailsTab"]
'
).
exists
()).
toBe
(
true
);
});
it
(
'
renders alert details
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="startTimeItem"]
'
).
exists
()).
toBe
(
true
);
});
});
});
it
(
'
renders a status dropdown
'
,
()
=>
{
it
(
'
renders a status dropdown
containing three items
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="statusDropdownItem"]
'
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
All
(
'
[data-testid="statusDropdownItem"]
'
).
length
).
toBe
(
3
);
});
});
});
});
});
});
spec/helpers/projects/alert_management_helper_spec.rb
View file @
fb12120e
...
@@ -7,11 +7,11 @@ describe Projects::AlertManagementHelper do
...
@@ -7,11 +7,11 @@ describe Projects::AlertManagementHelper do
let_it_be
(
:project
,
reload:
true
)
{
create
(
:project
)
}
let_it_be
(
:project
,
reload:
true
)
{
create
(
:project
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:project_path
)
{
project
.
full_path
}
describe
'#alert_management_data'
do
describe
'#alert_management_data'
do
let
(
:user_can_enable_alert_management
)
{
false
}
let
(
:user_can_enable_alert_management
)
{
false
}
let
(
:setting_path
)
{
project_settings_operations_path
(
project
)
}
let
(
:setting_path
)
{
project_settings_operations_path
(
project
)
}
let
(
:project_path
)
{
project
.
full_path
}
before
do
before
do
allow
(
helper
)
allow
(
helper
)
...
@@ -21,7 +21,7 @@ describe Projects::AlertManagementHelper do
...
@@ -21,7 +21,7 @@ describe Projects::AlertManagementHelper do
end
end
context
'without alert_managements_setting'
do
context
'without alert_managements_setting'
do
it
'returns
frontend
configuration'
do
it
'returns
index page
configuration'
do
expect
(
alert_management_data
(
current_user
,
project
)).
to
eq
(
expect
(
alert_management_data
(
current_user
,
project
)).
to
eq
(
'project-path'
=>
project_path
,
'project-path'
=>
project_path
,
'enable-alert-management-path'
=>
setting_path
,
'enable-alert-management-path'
=>
setting_path
,
...
@@ -32,4 +32,15 @@ describe Projects::AlertManagementHelper do
...
@@ -32,4 +32,15 @@ describe Projects::AlertManagementHelper do
end
end
end
end
end
end
describe
'#alert_management_detail_data'
do
let
(
:alert_id
)
{
1
}
it
'returns detail page configuration'
do
expect
(
alert_management_detail_data
(
project_path
,
alert_id
)).
to
eq
(
'alert-id'
=>
alert_id
,
'project-path'
=>
project_path
)
end
end
end
end
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