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
0d858c23
Commit
0d858c23
authored
Jan 27, 2021
by
Tristan Read
Committed by
Olena Horal-Koretska
Jan 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consolidate incident SLA component
parent
09c2a929
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
42 deletions
+41
-42
app/assets/javascripts/incidents/components/incidents_list.vue
...ssets/javascripts/incidents/components/incidents_list.vue
+1
-1
ee/app/assets/javascripts/issue_show/components/incidents/incident_sla.vue
...ascripts/issue_show/components/incidents/incident_sla.vue
+14
-9
ee/app/assets/javascripts/vue_shared/components/incidents/service_level_agreement.vue
...e_shared/components/incidents/service_level_agreement.vue
+7
-7
ee/app/assets/javascripts/vue_shared/components/incidents/utils.js
...sets/javascripts/vue_shared/components/incidents/utils.js
+3
-0
ee/spec/frontend/issue_show/components/incidents/incident_sla_spec.js
...tend/issue_show/components/incidents/incident_sla_spec.js
+15
-24
ee/spec/frontend/vue_shared/components/incidents/service_level_agreement_spec.js
...ared/components/incidents/service_level_agreement_spec.js
+1
-1
No files found.
app/assets/javascripts/incidents/components/incidents_list.vue
View file @
0d858c23
...
...
@@ -102,7 +102,7 @@ export default {
GlIcon
,
PublishedCell
:
()
=>
import
(
'
ee_component/incidents/components/published_cell.vue
'
),
ServiceLevelAgreementCell
:
()
=>
import
(
'
ee_component/
incidents/components/service_level_agreement_cell
.vue
'
),
import
(
'
ee_component/
vue_shared/components/incidents/service_level_agreement
.vue
'
),
GlEmptyState
,
SeverityToken
,
PaginatedTableWithSearchAndTabs
,
...
...
ee/app/assets/javascripts/issue_show/components/incidents/incident_sla.vue
View file @
0d858c23
<
script
>
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
import
ServiceLevelAgreement
from
'
ee_component/vue_shared/components/incidents/service_level_agreement.vue
'
;
import
{
isValidSlaDueAt
}
from
'
ee/vue_shared/components/incidents/utils
'
;
import
createFlash
from
'
~/flash
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
formatTime
,
calculateRemainingMilliseconds
}
from
'
~/lib/utils/datetime_utility
'
;
import
TimeAgoTooltip
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
import
getSlaDueAt
from
'
./graphql/queries/get_sla_due_at.graphql
'
;
export
default
{
components
:
{
GlIcon
,
TimeAgoTooltip
},
components
:
{
GlIcon
,
ServiceLevelAgreement
},
inject
:
[
'
fullPath
'
,
'
iid
'
,
'
slaFeatureAvailable
'
],
apollo
:
{
slaDueAt
:
{
...
...
@@ -21,9 +22,14 @@ export default {
update
(
data
)
{
return
data
?.
project
?.
issue
?.
slaDueAt
;
},
result
({
data
}
=
{})
{
const
slaDueAt
=
data
?.
project
?.
issue
?.
slaDueAt
;
this
.
$emit
(
'
update
'
,
Boolean
(
slaDueAt
));
result
({
data
})
{
const
isValidSla
=
isValidSlaDueAt
(
data
?.
project
?.
issue
?.
slaDueAt
);
// Render component
this
.
hasData
=
isValidSla
;
// Render parent component
this
.
$emit
(
'
update
'
,
isValidSla
);
},
error
()
{
createFlash
({
...
...
@@ -35,6 +41,7 @@ export default {
data
()
{
return
{
slaDueAt
:
null
,
hasData
:
false
,
};
},
computed
:
{
...
...
@@ -49,13 +56,11 @@ export default {
</
script
>
<
template
>
<div
v-if=
"slaFeatureAvailable &&
slaDueAt
"
>
<div
v-if=
"slaFeatureAvailable &&
hasData
"
>
<span
class=
"gl-font-weight-bold"
>
{{
s__
(
'
HighlightBar|Time to SLA:
'
)
}}
</span>
<span
class=
"gl-white-space-nowrap"
>
<gl-icon
name=
"timer"
/>
<time-ago-tooltip
:time=
"slaDueAt"
>
{{
displayValue
}}
</time-ago-tooltip>
<service-level-agreement
:sla-due-at=
"slaDueAt"
/>
</span>
</div>
</
template
>
ee/app/assets/javascripts/
incidents/components/service_level_agreement_cell
.vue
→
ee/app/assets/javascripts/
vue_shared/components/incidents/service_level_agreement
.vue
View file @
0d858c23
...
...
@@ -2,26 +2,26 @@
import
{
GlTooltipDirective
}
from
'
@gitlab/ui
'
;
import
{
s__
,
sprintf
}
from
'
~/locale
'
;
import
{
formatTime
,
calculateRemainingMilliseconds
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
isValidSlaDueAt
}
from
'
./utils
'
;
export
default
{
i18n
:
{
longT
ext
:
s__
(
'
IncidentManagement|%{hours} hours, %{minutes} minutes remaining
'
),
shortT
ext
:
s__
(
'
IncidentManagement|%{minutes} minutes remaining
'
),
longT
itle
:
s__
(
'
IncidentManagement|%{hours} hours, %{minutes} minutes remaining
'
),
shortT
itle
:
s__
(
'
IncidentManagement|%{minutes} minutes remaining
'
),
},
directives
:
{
GlTooltip
:
GlTooltipDirective
,
},
props
:
{
slaDueAt
:
{
type
:
String
,
type
:
String
,
// ISODateString
required
:
false
,
default
:
null
,
},
},
computed
:
{
shouldShow
()
{
// Checks for a valid date string
return
this
.
slaDueAt
&&
!
Number
.
isNaN
(
Date
.
parse
(
this
.
slaDueAt
));
return
isValidSlaDueAt
(
this
.
slaDueAt
);
},
remainingTime
()
{
return
calculateRemainingMilliseconds
(
this
.
slaDueAt
);
...
...
@@ -37,9 +37,9 @@ export default {
const
hours
=
Math
.
floor
(
this
.
remainingTime
/
1000
/
60
/
60
);
if
(
hours
>
0
)
{
return
sprintf
(
this
.
$options
.
i18n
.
longT
ext
,
{
hours
,
minutes
});
return
sprintf
(
this
.
$options
.
i18n
.
longT
itle
,
{
hours
,
minutes
});
}
return
sprintf
(
this
.
$options
.
i18n
.
shortT
ext
,
{
hours
,
minutes
});
return
sprintf
(
this
.
$options
.
i18n
.
shortT
itle
,
{
minutes
});
},
},
};
...
...
ee/app/assets/javascripts/vue_shared/components/incidents/utils.js
0 → 100644
View file @
0d858c23
// Checks for a valid date string
export
const
isValidSlaDueAt
=
(
slaDueAt
)
=>
Boolean
(
slaDueAt
)
&&
!
Number
.
isNaN
(
Date
.
parse
(
slaDueAt
));
ee/spec/frontend/issue_show/components/incidents/incident_sla_spec.js
View file @
0d858c23
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
merge
}
from
'
lodash
'
;
import
IncidentSla
from
'
ee/issue_show/components/incidents/incident_sla.vue
'
;
import
{
formatTime
}
from
'
~/lib/utils/datetime_utility
'
;
import
TimeAgoTooltip
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
import
ServiceLevelAgreement
from
'
ee_component/vue_shared/components/incidents/service_level_agreement.vue
'
;
jest
.
mock
(
'
~/lib/utils/datetime_utility
'
);
const
defaultProvide
=
{
fullPath
:
'
test
'
,
iid
:
1
,
slaFeatureAvailable
:
true
};
const
mockSlaDueAt
=
'
2020-01-01T00:00:00.000Z
'
;
describe
(
'
Incident SLA
'
,
()
=>
{
let
wrapper
;
...
...
@@ -17,7 +17,7 @@ describe('Incident SLA', () => {
merge
(
{
data
()
{
return
{
slaDueAt
:
'
2020-01-01T00:00:00.000Z
'
};
return
{
slaDueAt
:
mockSlaDueAt
,
hasData
:
true
};
},
provide
:
{
...
defaultProvide
},
},
...
...
@@ -26,10 +26,6 @@ describe('Incident SLA', () => {
);
};
beforeEach
(()
=>
{
formatTime
.
mockImplementation
(()
=>
'
12:34:56
'
);
});
afterEach
(()
=>
{
if
(
wrapper
)
{
wrapper
.
destroy
();
...
...
@@ -37,28 +33,16 @@ describe('Incident SLA', () => {
}
});
const
find
Timer
=
()
=>
wrapper
.
find
(
TimeAgoTooltip
);
const
find
SLA
=
()
=>
wrapper
.
find
(
ServiceLevelAgreement
);
it
(
'
does not render an SLA when no sla is present
'
,
()
=>
{
it
(
'
renders a blank component when there is no data
'
,
()
=>
{
mountComponent
({
data
()
{
return
{
slaDueAt
:
null
};
return
{
hasData
:
false
};
},
});
expect
(
findTimer
().
exists
()).
toBe
(
false
);
});
it
(
'
renders an incident SLA when sla is present
'
,
()
=>
{
mountComponent
();
expect
(
findTimer
().
text
()).
toBe
(
'
12:34
'
);
});
it
(
'
renders a component when feature is available
'
,
()
=>
{
mountComponent
();
expect
(
wrapper
.
exists
()).
toBe
(
true
);
expect
(
wrapper
.
isVisible
()).
toBe
(
false
);
});
it
(
'
renders a blank component when feature is not available
'
,
()
=>
{
...
...
@@ -69,6 +53,13 @@ describe('Incident SLA', () => {
},
});
expect
(
wrapper
.
html
()).
toBe
(
''
);
expect
(
wrapper
.
isVisible
()).
toBe
(
false
);
});
it
(
'
renders an incident SLA when sla is present and feature is available
'
,
()
=>
{
mountComponent
();
expect
(
wrapper
.
isVisible
()).
toBe
(
true
);
expect
(
findSLA
().
attributes
(
'
sladueat
'
)).
toBe
(
mockSlaDueAt
);
});
});
ee/spec/frontend/
incidents/components/service_level_agreement_cell
_spec.js
→
ee/spec/frontend/
vue_shared/components/incidents/service_level_agreement
_spec.js
View file @
0d858c23
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
ServiceLevelAgreementCell
from
'
ee/
incidents/components/service_level_agreement_cell
.vue
'
;
import
ServiceLevelAgreementCell
from
'
ee/
vue_shared/components/incidents/service_level_agreement
.vue
'
;
import
{
calculateRemainingMilliseconds
,
formatTime
}
from
'
~/lib/utils/datetime_utility
'
;
jest
.
mock
(
'
~/lib/utils/datetime_utility
'
,
()
=>
({
...
...
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