Commit 5a75aa59 authored by Phil Hughes's avatar Phil Hughes

Merge branch '10095-job-getters' into 'master'

Moves shared quota getter into CE

Closes gitlab-ee#10094 and gitlab-ee#10095

See merge request gitlab-org/gitlab-ce!25733
parents ca402c1a be70cb79
...@@ -34,6 +34,7 @@ export default { ...@@ -34,6 +34,7 @@ export default {
StuckBlock, StuckBlock,
Sidebar, Sidebar,
GlLoadingIcon, GlLoadingIcon,
SharedRunner: () => import('ee_component/jobs/components/shared_runner_limit_block.vue'),
}, },
mixins: [delayedJobMixin], mixins: [delayedJobMixin],
props: { props: {
...@@ -84,6 +85,7 @@ export default { ...@@ -84,6 +85,7 @@ export default {
'shouldRenderCalloutMessage', 'shouldRenderCalloutMessage',
'shouldRenderTriggeredLabel', 'shouldRenderTriggeredLabel',
'hasEnvironment', 'hasEnvironment',
'shouldRenderSharedRunnerLimitWarning',
'hasTrace', 'hasTrace',
'emptyStateIllustration', 'emptyStateIllustration',
'isScrollingDown', 'isScrollingDown',
...@@ -221,6 +223,14 @@ export default { ...@@ -221,6 +223,14 @@ export default {
:runners-path="runnerSettingsUrl" :runners-path="runnerSettingsUrl"
/> />
<shared-runner
v-if="shouldRenderSharedRunnerLimitWarning"
class="js-shared-runner-limit"
:quota-used="job.runners.quota.used"
:quota-limit="job.runners.quota.limit"
:runners-path="runnerHelpUrl"
/>
<environments-block <environments-block
v-if="hasEnvironment" v-if="hasEnvironment"
class="js-job-environment" class="js-job-environment"
......
...@@ -28,6 +28,17 @@ export const emptyStateIllustration = state => ...@@ -28,6 +28,17 @@ export const emptyStateIllustration = state =>
export const emptyStateAction = state => export const emptyStateAction = state =>
(state.job && state.job.status && state.job.status.action) || null; (state.job && state.job.status && state.job.status.action) || null;
/**
* Shared runners limit is only rendered when
* used quota is bigger or equal than the limit
*
* @returns {Boolean}
*/
export const shouldRenderSharedRunnerLimitWarning = state =>
!_.isEmpty(state.job.runners) &&
!_.isEmpty(state.job.runners.quota) &&
state.job.runners.quota.used >= state.job.runners.quota.limit;
export const isScrollingDown = state => isScrolledToBottom() && !state.isTraceComplete; export const isScrollingDown = state => isScrolledToBottom() && !state.isTraceComplete;
export const hasRunnersForProject = state => export const hasRunnersForProject = state =>
......
---
title: Removes EE differences for jobs/getters.js
merge_request:
author:
type: other
...@@ -151,6 +151,61 @@ describe('Job Store Getters', () => { ...@@ -151,6 +151,61 @@ describe('Job Store Getters', () => {
}); });
}); });
describe('shouldRenderSharedRunnerLimitWarning', () => {
describe('without runners information', () => {
it('returns false', () => {
expect(getters.shouldRenderSharedRunnerLimitWarning(localState)).toEqual(false);
});
});
describe('with runners information', () => {
describe('when used quota is less than limit', () => {
it('returns false', () => {
localState.job.runners = {
quota: {
used: 33,
limit: 2000,
},
available: true,
online: true,
};
expect(getters.shouldRenderSharedRunnerLimitWarning(localState)).toEqual(false);
});
});
describe('when used quota is equal to limit', () => {
it('returns true', () => {
localState.job.runners = {
quota: {
used: 2000,
limit: 2000,
},
available: true,
online: true,
};
expect(getters.shouldRenderSharedRunnerLimitWarning(localState)).toEqual(true);
});
});
describe('when used quota is bigger than limit', () => {
it('returns true', () => {
localState.job.runners = {
quota: {
used: 2002,
limit: 2000,
},
available: true,
online: true,
};
expect(getters.shouldRenderSharedRunnerLimitWarning(localState)).toEqual(true);
});
});
});
});
describe('hasRunnersForProject', () => { describe('hasRunnersForProject', () => {
describe('with available and offline runners', () => { describe('with available and offline runners', () => {
it('returns true', () => { it('returns true', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment