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
744fb186
Commit
744fb186
authored
Jun 30, 2021
by
Tristan Read
Committed by
Olena Horal-Koretska
Jun 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert minutes to seconds for escalation policies
parent
4df1d532
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
58 additions
and
29 deletions
+58
-29
ee/app/assets/javascripts/escalation_policies/components/add_edit_escalation_policy_form.vue
...n_policies/components/add_edit_escalation_policy_form.vue
+2
-2
ee/app/assets/javascripts/escalation_policies/components/add_edit_escalation_policy_modal.vue
..._policies/components/add_edit_escalation_policy_modal.vue
+4
-4
ee/app/assets/javascripts/escalation_policies/components/escalation_policies_wrapper.vue
...ation_policies/components/escalation_policies_wrapper.vue
+2
-1
ee/app/assets/javascripts/escalation_policies/components/escalation_policy.vue
...ipts/escalation_policies/components/escalation_policy.vue
+3
-3
ee/app/assets/javascripts/escalation_policies/components/escalation_rule.vue
...cripts/escalation_policies/components/escalation_rule.vue
+5
-5
ee/app/assets/javascripts/escalation_policies/constants.js
ee/app/assets/javascripts/escalation_policies/constants.js
+1
-1
ee/app/assets/javascripts/escalation_policies/utils.js
ee/app/assets/javascripts/escalation_policies/utils.js
+26
-1
ee/spec/frontend/escalation_policies/__snapshots__/escalation_policy_spec.js.snap
...ion_policies/__snapshots__/escalation_policy_spec.js.snap
+2
-2
ee/spec/frontend/escalation_policies/add_edit_escalation_policy_form_spec.js
...calation_policies/add_edit_escalation_policy_form_spec.js
+1
-1
ee/spec/frontend/escalation_policies/add_edit_escalation_policy_modal_spec.js
...alation_policies/add_edit_escalation_policy_modal_spec.js
+5
-4
ee/spec/frontend/escalation_policies/escalation_policy_spec.js
...ec/frontend/escalation_policies/escalation_policy_spec.js
+2
-1
ee/spec/frontend/escalation_policies/escalation_policy_wrapper_spec.js
...end/escalation_policies/escalation_policy_wrapper_spec.js
+2
-1
ee/spec/frontend/escalation_policies/mocks/mockPolicies.json
ee/spec/frontend/escalation_policies/mocks/mockPolicies.json
+3
-3
No files found.
ee/app/assets/javascripts/escalation_policies/components/add_edit_escalation_policy_form.vue
View file @
744fb186
...
...
@@ -76,13 +76,13 @@ export default {
this
.
rules
=
this
.
form
.
rules
.
map
((
rule
)
=>
{
const
{
status
,
elapsedTime
Second
s
,
elapsedTime
Minute
s
,
oncallSchedule
:
{
iid
:
oncallScheduleIid
},
}
=
rule
;
return
{
status
,
elapsedTime
Second
s
,
elapsedTime
Minute
s
,
action
:
DEFAULT_ACTION
,
oncallScheduleIid
,
key
:
uniqueId
(),
...
...
ee/app/assets/javascripts/escalation_policies/components/add_edit_escalation_policy_modal.vue
View file @
744fb186
...
...
@@ -9,7 +9,7 @@ import {
import
createEscalationPolicyMutation
from
'
../graphql/mutations/create_escalation_policy.mutation.graphql
'
;
import
updateEscalationPolicyMutation
from
'
../graphql/mutations/update_escalation_policy.mutation.graphql
'
;
import
getEscalationPoliciesQuery
from
'
../graphql/queries/get_escalation_policies.query.graphql
'
;
import
{
isNameFieldValid
,
getRulesValidationState
}
from
'
../utils
'
;
import
{
isNameFieldValid
,
getRulesValidationState
,
serializeRule
}
from
'
../utils
'
;
import
AddEditEscalationPolicyForm
from
'
./add_edit_escalation_policy_form.vue
'
;
export
const
i18n
=
{
...
...
@@ -91,7 +91,7 @@ export default {
},
requestParams
()
{
const
id
=
this
.
isEditMode
?
{
id
:
this
.
escalationPolicy
.
id
}
:
{};
return
{
...
this
.
form
,
...
id
,
rules
:
this
.
getRules
(
this
.
form
.
rules
)
};
return
{
...
this
.
form
,
...
id
,
rules
:
this
.
getRules
(
this
.
form
.
rules
)
.
map
(
serializeRule
)
};
},
},
methods
:
{
...
...
@@ -186,9 +186,9 @@ export default {
},
getRules
(
rules
)
{
return
rules
.
map
(
({
status
,
elapsedTime
Second
s
,
oncallScheduleIid
,
oncallSchedule
:
{
iid
}
=
{}
})
=>
({
({
status
,
elapsedTime
Minute
s
,
oncallScheduleIid
,
oncallSchedule
:
{
iid
}
=
{}
})
=>
({
status
,
elapsedTime
Second
s
,
elapsedTime
Minute
s
,
oncallScheduleIid
:
oncallScheduleIid
||
iid
,
}),
);
...
...
ee/app/assets/javascripts/escalation_policies/components/escalation_policies_wrapper.vue
View file @
744fb186
...
...
@@ -4,6 +4,7 @@ import * as Sentry from '@sentry/browser';
import
{
s__
}
from
'
~/locale
'
;
import
{
addEscalationPolicyModalId
}
from
'
../constants
'
;
import
getEscalationPoliciesQuery
from
'
../graphql/queries/get_escalation_policies.query.graphql
'
;
import
{
parsePolicy
}
from
'
../utils
'
;
import
AddEscalationPolicyModal
from
'
./add_edit_escalation_policy_modal.vue
'
;
import
EscalationPolicy
from
'
./escalation_policy.vue
'
;
...
...
@@ -47,7 +48,7 @@ export default {
};
},
update
({
project
})
{
return
project
?.
incidentManagementEscalationPolicies
?.
nodes
??
[];
return
project
?.
incidentManagementEscalationPolicies
?.
nodes
.
map
(
parsePolicy
)
??
[];
},
error
(
error
)
{
Sentry
.
captureException
(
error
);
...
...
ee/app/assets/javascripts/escalation_policies/components/escalation_policy.vue
View file @
744fb186
...
...
@@ -29,9 +29,9 @@ export const i18n = {
minutes
:
s__
(
'
EscalationPolicies|mins
'
),
};
const
isRuleValid
=
({
status
,
elapsedTime
Second
s
,
oncallSchedule
:
{
name
}
})
=>
const
isRuleValid
=
({
status
,
elapsedTime
Minute
s
,
oncallSchedule
:
{
name
}
})
=>
Object
.
keys
(
ALERT_STATUSES
).
includes
(
status
)
&&
typeof
elapsedTime
Second
s
===
'
number
'
&&
typeof
elapsedTime
Minute
s
===
'
number
'
&&
typeof
name
===
'
string
'
;
export
default
{
...
...
@@ -145,7 +145,7 @@ export default {
</
template
>
<
template
#minutes
>
<span
class=
"gl-font-weight-bold"
>
{{
rule
.
elapsedTime
Second
s
}}
{{
$options
.
i18n
.
minutes
}}
{{
rule
.
elapsedTime
Minute
s
}}
{{
$options
.
i18n
.
minutes
}}
</span>
</
template
>
<
template
#then
>
...
...
ee/app/assets/javascripts/escalation_policies/components/escalation_rule.vue
View file @
744fb186
...
...
@@ -76,10 +76,10 @@ export default {
},
},
data
()
{
const
{
status
,
elapsedTime
Second
s
,
action
,
oncallScheduleIid
}
=
this
.
rule
;
const
{
status
,
elapsedTime
Minute
s
,
action
,
oncallScheduleIid
}
=
this
.
rule
;
return
{
status
,
elapsedTime
Second
s
,
elapsedTime
Minute
s
,
action
,
oncallScheduleIid
,
};
...
...
@@ -119,7 +119,7 @@ export default {
oncallScheduleIid
:
parseInt
(
this
.
oncallScheduleIid
,
10
),
action
:
this
.
action
,
status
:
this
.
status
,
elapsedTime
Seconds
:
parseInt
(
this
.
elapsedTimeSeconds
,
10
)
,
elapsedTime
Minutes
:
this
.
elapsedTimeMinutes
,
},
});
},
...
...
@@ -169,9 +169,9 @@ export default {
</
template
>
<
template
#minutes
>
<gl-form-input
v-model=
"elapsedTime
Second
s"
v-model=
"elapsedTime
Minute
s"
class=
"gl-mx-3 gl-inset-border-1-gray-200! gl-w-12"
type=
"number"
number
min=
"0"
@
input=
"emitUpdate"
/>
...
...
ee/app/assets/javascripts/escalation_policies/constants.js
View file @
744fb186
...
...
@@ -13,7 +13,7 @@ export const ACTIONS = {
export
const
DEFAULT_ESCALATION_RULE
=
{
status
:
'
ACKNOWLEDGED
'
,
elapsedTime
Second
s
:
0
,
elapsedTime
Minute
s
:
0
,
action
:
'
EMAIL_ONCALL_SCHEDULE_USER
'
,
oncallScheduleIid
:
null
,
};
...
...
ee/app/assets/javascripts/escalation_policies/utils.js
View file @
744fb186
...
...
@@ -17,8 +17,33 @@ export const isNameFieldValid = (name) => {
export
const
getRulesValidationState
=
(
rules
)
=>
{
return
rules
.
map
((
rule
)
=>
{
return
{
isTimeValid
:
parseInt
(
rule
.
elapsedTime
Second
s
,
10
)
>=
0
,
isTimeValid
:
parseInt
(
rule
.
elapsedTime
Minute
s
,
10
)
>=
0
,
isScheduleValid
:
Boolean
(
rule
.
oncallScheduleIid
),
};
});
};
/**
* Serializes a rule by converting elapsed minutes to seconds
* @param {Object} rule
*
* @returns {Object} rule
*/
export
const
serializeRule
=
({
elapsedTimeMinutes
,
...
ruleParams
})
=>
({
...
ruleParams
,
elapsedTimeSeconds
:
elapsedTimeMinutes
*
60
,
});
/**
* Parses a policy by converting elapsed seconds to minutes
* @param {Object} policy
*
* @returns {Object} policy
*/
export
const
parsePolicy
=
(
policy
)
=>
({
...
policy
,
rules
:
policy
.
rules
.
map
(({
elapsedTimeSeconds
,
...
ruleParams
})
=>
({
...
ruleParams
,
elapsedTimeMinutes
:
elapsedTimeSeconds
/
60
,
})),
});
ee/spec/frontend/escalation_policies/__snapshots__/escalation_policy_spec.js.snap
View file @
744fb186
...
...
@@ -38,7 +38,7 @@ exports[`EscalationPolicy renders policy with rules 1`] = `
class="gl-font-weight-bold"
>
1
0
mins
1 mins
</span>
...
...
@@ -81,7 +81,7 @@ exports[`EscalationPolicy renders policy with rules 1`] = `
class="gl-font-weight-bold"
>
2
0
mins
2 mins
</span>
...
...
ee/spec/frontend/escalation_policies/add_edit_escalation_policy_form_spec.js
View file @
744fb186
...
...
@@ -82,7 +82,7 @@ describe('AddEscalationPolicyForm', () => {
it
(
'
on rule update emitted should update rules array and emit updates up
'
,
()
=>
{
const
updatedRule
=
{
status
:
'
TRIGGERED
'
,
elapsedTime
Seconds
:
30
,
elapsedTime
Minutes
:
3
,
oncallScheduleIid
:
2
,
};
findRules
().
at
(
0
).
vm
.
$emit
(
'
update-escalation-rule
'
,
{
index
:
0
,
rule
:
updatedRule
});
...
...
ee/spec/frontend/escalation_policies/add_edit_escalation_policy_modal_spec.js
View file @
744fb186
...
...
@@ -23,7 +23,8 @@ describe('AddEditsEscalationPolicyModal', () => {
const
mockEscalationPolicy
=
cloneDeep
(
mockPolicies
[
0
]);
const
updatedName
=
'
Policy name
'
;
const
updatedDescription
=
'
Policy description
'
;
const
updatedRules
=
[{
status
:
'
RESOLVED
'
,
elapsedTimeSeconds
:
10
,
oncallScheduleIid
:
1
}];
const
updatedRules
=
[{
status
:
'
RESOLVED
'
,
elapsedTimeMinutes
:
1
,
oncallScheduleIid
:
1
}];
const
serializedRules
=
[{
status
:
'
RESOLVED
'
,
elapsedTimeSeconds
:
60
,
oncallScheduleIid
:
1
}];
const
createComponent
=
({
escalationPolicy
,
isEditMode
=
false
,
modalId
,
data
}
=
{})
=>
{
wrapper
=
shallowMount
(
AddEscalationPolicyModal
,
{
...
...
@@ -99,7 +100,7 @@ describe('AddEditsEscalationPolicyModal', () => {
projectPath
,
name
:
updatedName
,
description
:
updatedDescription
,
rules
:
updat
edRules
,
rules
:
serializ
edRules
,
},
},
update
:
expect
.
any
(
Function
),
...
...
@@ -168,7 +169,7 @@ describe('AddEditsEscalationPolicyModal', () => {
input
:
{
name
:
updatedName
,
description
:
updatedDescription
,
rules
:
updat
edRules
,
rules
:
serializ
edRules
,
id
:
mockEscalationPolicy
.
id
,
},
},
...
...
@@ -264,7 +265,7 @@ describe('AddEditsEscalationPolicyModal', () => {
});
form
.
vm
.
$emit
(
'
update-escalation-policy-form
'
,
{
field
:
'
rules
'
,
value
:
[{
status
:
'
RESOLVED
'
,
elapsedTime
Seconds
:
10
,
oncallScheduleIid
:
1
}],
value
:
[{
status
:
'
RESOLVED
'
,
elapsedTime
Minutes
:
1
,
oncallScheduleIid
:
1
}],
});
await
wrapper
.
vm
.
$nextTick
();
expect
(
findModal
().
props
(
'
actionPrimary
'
).
attributes
).
toContainEqual
({
disabled
:
false
});
...
...
ee/spec/frontend/escalation_policies/escalation_policy_spec.js
View file @
744fb186
...
...
@@ -9,11 +9,12 @@ import {
deleteEscalationPolicyModalId
,
editEscalationPolicyModalId
,
}
from
'
ee/escalation_policies/constants
'
;
import
{
parsePolicy
}
from
'
ee/escalation_policies/utils
'
;
import
mockPolicies
from
'
./mocks/mockPolicies.json
'
;
describe
(
'
EscalationPolicy
'
,
()
=>
{
let
wrapper
;
const
escalationPolicy
=
cloneDeep
(
mockPolicies
[
0
]
);
const
escalationPolicy
=
parsePolicy
(
cloneDeep
(
mockPolicies
[
0
])
);
const
createComponent
=
()
=>
{
wrapper
=
shallowMount
(
EscalationPolicy
,
{
...
...
ee/spec/frontend/escalation_policies/escalation_policy_wrapper_spec.js
View file @
744fb186
import
{
GlEmptyState
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
EscalationPoliciesWrapper
from
'
ee/escalation_policies/components/escalation_policies_wrapper.vue
'
;
import
EscalationPolicy
from
'
ee/escalation_policies/components/escalation_policy.vue
'
;
import
{
parsePolicy
}
from
'
ee/escalation_policies/utils
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
mockEscalationPolicies
from
'
./mocks/mockPolicies.json
'
;
...
...
@@ -55,7 +56,7 @@ describe('Escalation Policies Wrapper', () => {
beforeEach
(()
=>
{
mountComponent
({
loading
,
escalationPolicies
,
escalationPolicies
:
escalationPolicies
.
map
(
parsePolicy
)
,
});
});
...
...
ee/spec/frontend/escalation_policies/mocks/mockPolicies.json
View file @
744fb186
...
...
@@ -7,7 +7,7 @@
{
"id"
:
"gid://gitlab/IncidentManagement::EscalationRule/22"
,
"status"
:
"ACKNOWLEDGED"
,
"elapsedTimeSeconds"
:
1
0
,
"elapsedTimeSeconds"
:
6
0
,
"oncallSchedule"
:
{
"iid"
:
"3"
,
"name"
:
"Schedule to fill in"
...
...
@@ -16,7 +16,7 @@
{
"id"
:
"gid://gitlab/IncidentManagement::EscalationRule/23"
,
"status"
:
"RESOLVED"
,
"elapsedTimeSeconds"
:
20
,
"elapsedTimeSeconds"
:
1
20
,
"oncallSchedule"
:
{
"iid"
:
"4"
,
"name"
:
"Monitor schedule"
...
...
@@ -32,7 +32,7 @@
{
"id"
:
"gid://gitlab/IncidentManagement::EscalationRule/48"
,
"status"
:
"ACKNOWLEDGED"
,
"elapsedTimeSeconds"
:
3
0
,
"elapsedTimeSeconds"
:
18
0
,
"oncallSchedule"
:
{
"iid"
:
"3"
,
"name"
:
"Schedule to fill in"
...
...
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