Commit a33757c3 authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch '332347-cleanup-policies-ui-do-not-show-nil-values' into 'master'

Show empty option for keep_n and older_than in Cleanup Policies

See merge request gitlab-org/gitlab!65722
parents c1650a4f 6d6f0514
...@@ -88,8 +88,6 @@ export default { ...@@ -88,8 +88,6 @@ export default {
return { return {
...this.value, ...this.value,
cadence: this.findDefaultOption('cadence'), cadence: this.findDefaultOption('cadence'),
keepN: this.findDefaultOption('keepN'),
olderThan: this.findDefaultOption('olderThan'),
}; };
}, },
showLoadingIcon() { showLoadingIcon() {
......
...@@ -11,11 +11,14 @@ export const olderThanTranslationGenerator = (variable) => n__('%d day', '%d day ...@@ -11,11 +11,14 @@ export const olderThanTranslationGenerator = (variable) => n__('%d day', '%d day
export const keepNTranslationGenerator = (variable) => export const keepNTranslationGenerator = (variable) =>
n__('%d tag per image name', '%d tags per image name', variable); n__('%d tag per image name', '%d tags per image name', variable);
export const optionLabelGenerator = (collection, translationFn) => export const optionLabelGenerator = (collection, translationFn) => {
collection.map((option) => ({ const result = collection.map((option) => ({
...option, ...option,
label: translationFn(option.variable), label: translationFn(option.variable),
})); }));
result.unshift({ key: null, label: '' });
return result;
};
export const formOptionsGenerator = () => { export const formOptionsGenerator = () => {
return { return {
......
...@@ -32,6 +32,10 @@ Array [ ...@@ -32,6 +32,10 @@ Array [
exports[`Utils formOptionsGenerator returns an object containing keepN 1`] = ` exports[`Utils formOptionsGenerator returns an object containing keepN 1`] = `
Array [ Array [
Object {
"key": null,
"label": "",
},
Object { Object {
"default": false, "default": false,
"key": "ONE_TAG", "key": "ONE_TAG",
...@@ -73,6 +77,10 @@ Array [ ...@@ -73,6 +77,10 @@ Array [
exports[`Utils formOptionsGenerator returns an object containing olderThan 1`] = ` exports[`Utils formOptionsGenerator returns an object containing olderThan 1`] = `
Array [ Array [
Object {
"key": null,
"label": "",
},
Object { Object {
"default": false, "default": false,
"key": "SEVEN_DAYS", "key": "SEVEN_DAYS",
......
...@@ -22,7 +22,7 @@ exports[`Settings Form Enable matches snapshot 1`] = ` ...@@ -22,7 +22,7 @@ exports[`Settings Form Enable matches snapshot 1`] = `
exports[`Settings Form Keep N matches snapshot 1`] = ` exports[`Settings Form Keep N matches snapshot 1`] = `
<expiration-dropdown-stub <expiration-dropdown-stub
data-testid="keep-n-dropdown" data-testid="keep-n-dropdown"
formoptions="[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]" formoptions="[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]"
label="Keep the most recent:" label="Keep the most recent:"
name="keep-n" name="keep-n"
value="TEN_TAGS" value="TEN_TAGS"
...@@ -44,7 +44,7 @@ exports[`Settings Form Keep Regex matches snapshot 1`] = ` ...@@ -44,7 +44,7 @@ exports[`Settings Form Keep Regex matches snapshot 1`] = `
exports[`Settings Form OlderThan matches snapshot 1`] = ` exports[`Settings Form OlderThan matches snapshot 1`] = `
<expiration-dropdown-stub <expiration-dropdown-stub
data-testid="older-than-dropdown" data-testid="older-than-dropdown"
formoptions="[object Object],[object Object],[object Object],[object Object]" formoptions="[object Object],[object Object],[object Object],[object Object],[object Object]"
label="Remove tags older than:" label="Remove tags older than:"
name="older-than" name="older-than"
value="FOURTEEN_DAYS" value="FOURTEEN_DAYS"
......
...@@ -132,9 +132,9 @@ describe('Settings Form', () => { ...@@ -132,9 +132,9 @@ describe('Settings Form', () => {
model | finder | fieldName | type | defaultValue model | finder | fieldName | type | defaultValue
${'enabled'} | ${findEnableToggle} | ${'Enable'} | ${'toggle'} | ${false} ${'enabled'} | ${findEnableToggle} | ${'Enable'} | ${'toggle'} | ${false}
${'cadence'} | ${findCadenceDropdown} | ${'Cadence'} | ${'dropdown'} | ${'EVERY_DAY'} ${'cadence'} | ${findCadenceDropdown} | ${'Cadence'} | ${'dropdown'} | ${'EVERY_DAY'}
${'keepN'} | ${findKeepNDropdown} | ${'Keep N'} | ${'dropdown'} | ${'TEN_TAGS'} ${'keepN'} | ${findKeepNDropdown} | ${'Keep N'} | ${'dropdown'} | ${''}
${'nameRegexKeep'} | ${findKeepRegexInput} | ${'Keep Regex'} | ${'textarea'} | ${''} ${'nameRegexKeep'} | ${findKeepRegexInput} | ${'Keep Regex'} | ${'textarea'} | ${''}
${'olderThan'} | ${findOlderThanDropdown} | ${'OlderThan'} | ${'dropdown'} | ${'NINETY_DAYS'} ${'olderThan'} | ${findOlderThanDropdown} | ${'OlderThan'} | ${'dropdown'} | ${''}
${'nameRegex'} | ${findRemoveRegexInput} | ${'Remove regex'} | ${'textarea'} | ${''} ${'nameRegex'} | ${findRemoveRegexInput} | ${'Remove regex'} | ${'textarea'} | ${''}
`('$fieldName', ({ model, finder, type, defaultValue }) => { `('$fieldName', ({ model, finder, type, defaultValue }) => {
it('matches snapshot', () => { it('matches snapshot', () => {
...@@ -293,10 +293,10 @@ describe('Settings Form', () => { ...@@ -293,10 +293,10 @@ describe('Settings Form', () => {
input: { input: {
cadence: 'EVERY_DAY', cadence: 'EVERY_DAY',
enabled: true, enabled: true,
keepN: 'TEN_TAGS', keepN: null,
nameRegex: 'asdasdssssdfdf', nameRegex: 'asdasdssssdfdf',
nameRegexKeep: 'sss', nameRegexKeep: 'sss',
olderThan: 'NINETY_DAYS', olderThan: null,
projectPath: 'path', projectPath: 'path',
}, },
}); });
......
...@@ -12,6 +12,7 @@ describe('Utils', () => { ...@@ -12,6 +12,7 @@ describe('Utils', () => {
olderThanTranslationGenerator, olderThanTranslationGenerator,
); );
expect(result).toEqual([ expect(result).toEqual([
{ key: null, label: '' },
{ variable: 1, label: '1 day' }, { variable: 1, label: '1 day' },
{ variable: 2, label: '2 days' }, { variable: 2, label: '2 days' },
]); ]);
......
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