Commit c4c38f48 authored by pburdette's avatar pburdette

Make message dynamic

Make message dynamic based
on plan limit. Also put code
behind the feature flag.
parent 09e84bec
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
} from '@gitlab/ui'; } from '@gitlab/ui';
import { getWeekdayNames } from '~/lib/utils/datetime_utility'; import { getWeekdayNames } from '~/lib/utils/datetime_utility';
import { __, s__, sprintf } from '~/locale'; import { __, s__, sprintf } from '~/locale';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
const KEY_EVERY_DAY = 'everyDay'; const KEY_EVERY_DAY = 'everyDay';
const KEY_EVERY_WEEK = 'everyWeek'; const KEY_EVERY_WEEK = 'everyWeek';
...@@ -16,11 +17,6 @@ const KEY_EVERY_MONTH = 'everyMonth'; ...@@ -16,11 +17,6 @@ const KEY_EVERY_MONTH = 'everyMonth';
const KEY_CUSTOM = 'custom'; const KEY_CUSTOM = 'custom';
export default { export default {
i18n: {
cronInfo: __(
'Scheduled pipelines cannot run more frequently than once per hour. A pipeline configured to run more frequently only starts after one hour has elapsed since the last time it ran.',
),
},
components: { components: {
GlFormRadio, GlFormRadio,
GlFormRadioGroup, GlFormRadioGroup,
...@@ -31,12 +27,18 @@ export default { ...@@ -31,12 +27,18 @@ export default {
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
}, },
mixins: [glFeatureFlagMixin()],
props: { props: {
initialCronInterval: { initialCronInterval: {
type: String, type: String,
required: false, required: false,
default: '', default: '',
}, },
dailyLimit: {
type: String,
required: false,
default: '',
},
}, },
data() { data() {
return { return {
...@@ -90,13 +92,23 @@ export default { ...@@ -90,13 +92,23 @@ export default {
value: KEY_CUSTOM, value: KEY_CUSTOM,
text: s__('PipelineScheduleIntervalPattern|Custom (%{linkStart}Cron syntax%{linkEnd})'), text: s__('PipelineScheduleIntervalPattern|Custom (%{linkStart}Cron syntax%{linkEnd})'),
link: this.cronSyntaxUrl, link: this.cronSyntaxUrl,
helpText: this.$options.i18n.cronInfo,
}, },
]; ];
}, },
weekday() { weekday() {
return getWeekdayNames()[this.randomWeekDayIndex]; return getWeekdayNames()[this.randomWeekDayIndex];
}, },
parsedDailyLimit() {
return this.dailyLimit === '144' ? '5' : '60';
},
scheduleDailyLimitMsg() {
return sprintf(
__(
'Scheduled pipelines cannot run more frequently than once per %{limit} minutes. A pipeline configured to run more frequently only starts after %{limit} minutes have elapsed since the last time it ran.',
),
{ limit: this.parsedDailyLimit },
);
},
}, },
watch: { watch: {
cronInterval() { cronInterval() {
...@@ -128,6 +140,11 @@ export default { ...@@ -128,6 +140,11 @@ export default {
generateRandomDay() { generateRandomDay() {
return Math.floor(Math.random() * 28); return Math.floor(Math.random() * 28);
}, },
showDailyLimitMessage({ value }) {
return (
value === KEY_CUSTOM && this.glFeatures.ciDailyLimitForPipelineSchedules && this.dailyLimit
);
},
}, },
}; };
</script> </script>
...@@ -152,10 +169,10 @@ export default { ...@@ -152,10 +169,10 @@ export default {
<template v-else>{{ option.text }}</template> <template v-else>{{ option.text }}</template>
<gl-icon <gl-icon
v-if="option.helpText" v-if="showDailyLimitMessage(option)"
v-gl-tooltip.hover v-gl-tooltip.hover
name="question" name="question"
:title="option.helpText" :title="scheduleDailyLimitMsg"
/> />
</gl-form-radio> </gl-form-radio>
</gl-form-radio-group> </gl-form-radio-group>
......
...@@ -12,6 +12,7 @@ Vue.use(Translate); ...@@ -12,6 +12,7 @@ Vue.use(Translate);
function initIntervalPatternInput() { function initIntervalPatternInput() {
const intervalPatternMount = document.getElementById('interval-pattern-input'); const intervalPatternMount = document.getElementById('interval-pattern-input');
const initialCronInterval = intervalPatternMount?.dataset?.initialInterval; const initialCronInterval = intervalPatternMount?.dataset?.initialInterval;
const dailyLimit = intervalPatternMount.dataset?.dailyLimit;
return new Vue({ return new Vue({
el: intervalPatternMount, el: intervalPatternMount,
...@@ -22,6 +23,7 @@ function initIntervalPatternInput() { ...@@ -22,6 +23,7 @@ function initIntervalPatternInput() {
return createElement('interval-pattern-input', { return createElement('interval-pattern-input', {
props: { props: {
initialCronInterval, initialCronInterval,
dailyLimit,
}, },
}); });
}, },
......
...@@ -10,6 +10,10 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController ...@@ -10,6 +10,10 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
before_action :authorize_update_pipeline_schedule!, except: [:index, :new, :create, :play] before_action :authorize_update_pipeline_schedule!, except: [:index, :new, :create, :play]
before_action :authorize_admin_pipeline_schedule!, only: [:destroy] before_action :authorize_admin_pipeline_schedule!, only: [:destroy]
before_action do
push_frontend_feature_flag(:ci_daily_limit_for_pipeline_schedules, @project, default_enabled: :yaml)
end
feature_category :continuous_integration feature_category :continuous_integration
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
......
...@@ -43,6 +43,11 @@ describe('Interval Pattern Input Component', () => { ...@@ -43,6 +43,11 @@ describe('Interval Pattern Input Component', () => {
wrapper = mount(IntervalPatternInput, { wrapper = mount(IntervalPatternInput, {
propsData: { ...props }, propsData: { ...props },
provide: {
glFeatures: {
ciDailyLimitForPipelineSchedules: true,
},
},
data() { data() {
return { return {
randomHour: data?.hour || mockHour, randomHour: data?.hour || mockHour,
...@@ -208,7 +213,7 @@ describe('Interval Pattern Input Component', () => { ...@@ -208,7 +213,7 @@ describe('Interval Pattern Input Component', () => {
describe('Custom cron syntax quota info', () => { describe('Custom cron syntax quota info', () => {
it('the help text icon is only shown for the custom radio option', () => { it('the help text icon is only shown for the custom radio option', () => {
createWrapper(); createWrapper({ dailyLimit: '144' });
expect(findIcon().exists()).toBe(true); expect(findIcon().exists()).toBe(true);
expect(findAllIcons().length).toBe(1); expect(findAllIcons().length).toBe(1);
......
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