Commit be70cb79 authored by Filipa Lacerda's avatar Filipa Lacerda Committed by Phil Hughes

Moves shared quota getter into CE

In jobs store, moves the check for
`shouldRenderSharedRunnerLimitWarning` to the CE
codebase.
parent ca402c1a
......@@ -34,6 +34,7 @@ export default {
StuckBlock,
Sidebar,
GlLoadingIcon,
SharedRunner: () => import('ee_component/jobs/components/shared_runner_limit_block.vue'),
},
mixins: [delayedJobMixin],
props: {
......@@ -84,6 +85,7 @@ export default {
'shouldRenderCalloutMessage',
'shouldRenderTriggeredLabel',
'hasEnvironment',
'shouldRenderSharedRunnerLimitWarning',
'hasTrace',
'emptyStateIllustration',
'isScrollingDown',
......@@ -221,6 +223,14 @@ export default {
: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
v-if="hasEnvironment"
class="js-job-environment"
......
......@@ -28,6 +28,17 @@ export const emptyStateIllustration = state =>
export const emptyStateAction = state =>
(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 hasRunnersForProject = state =>
......
---
title: Removes EE differences for jobs/getters.js
merge_request:
author:
type: other
......@@ -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('with available and offline runners', () => {
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