mirror of https://github.com/rancher/dashboard.git
warn for deletion of any scan profile
This commit is contained in:
parent
26b3928b6d
commit
b3f449c2de
|
|
@ -327,7 +327,14 @@ chartHeading:
|
|||
|
||||
cis:
|
||||
addTest: Add Test ID
|
||||
alertOnComplete: Alert on scan completion
|
||||
alertOnFailure: Alert on scan failure
|
||||
benchmarkVersion: Benchmark Version
|
||||
deleteProfileWarning: |-
|
||||
{count, plural,
|
||||
=1 { Any scheduled scans using this profile will no longer work. }
|
||||
other { Any scheduled scans using either of these profiles will no longer work. }
|
||||
}
|
||||
noProfiles: There are no valid ClusterScanProfiles for this cluster type to select.
|
||||
profile: Profile
|
||||
testID: Test ID
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ import { uniq } from '@/utils/array';
|
|||
export default {
|
||||
components: { Card, LinkDetail },
|
||||
data() {
|
||||
return { confirmName: '', error: '' };
|
||||
return {
|
||||
confirmName: '', error: '', warning: '', preventDelete: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
names() {
|
||||
|
|
@ -54,20 +56,6 @@ export default {
|
|||
return (type === NAMESPACE || type === RIO.STACK) && this.toRemove.length === 1;
|
||||
},
|
||||
|
||||
preventDeletionMessage() {
|
||||
const toRemoveWithWarning = this.toRemove.filter(tr => tr?.preventDeletionMessage);
|
||||
|
||||
if (toRemoveWithWarning.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return toRemoveWithWarning[0].preventDeletionMessage;
|
||||
},
|
||||
|
||||
isDeleteDisabled() {
|
||||
return !!this.preventDeletionMessage;
|
||||
},
|
||||
|
||||
plusMore() {
|
||||
const remaining = this.toRemove.length - this.names.length;
|
||||
|
||||
|
|
@ -126,6 +114,31 @@ export default {
|
|||
} else {
|
||||
this.$modal.hide('promptRemove');
|
||||
}
|
||||
},
|
||||
|
||||
// check for any resources with a deletion prevention message,
|
||||
// if none found (delete is allowed), then check for any resources with a warning message
|
||||
toRemove(neu) {
|
||||
let message;
|
||||
const preventDeletionMessages = neu.filter(item => item.preventDeletionMessage);
|
||||
|
||||
if (!!preventDeletionMessages.length) {
|
||||
this.preventDelete = true;
|
||||
message = preventDeletionMessages[0].preventDeletionMessage;
|
||||
} else {
|
||||
const warnDeletionMessages = neu.filter(item => item.warnDeletionMessage);
|
||||
|
||||
if (!!warnDeletionMessages.length) {
|
||||
message = warnDeletionMessages[0].warnDeletionMessage;
|
||||
}
|
||||
}
|
||||
if (typeof message === 'function' ) {
|
||||
this.warning = message(this.toRemove);
|
||||
} else if (!!message) {
|
||||
this.warning = message;
|
||||
} else {
|
||||
this.warning = '';
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -231,10 +244,13 @@ export default {
|
|||
<span v-if="i===names.length-1" :key="resource+2">{{ plusMore }}</span><span v-else :key="resource+1">{{ i === toRemove.length-2 ? ', and ' : ', ' }}</span>
|
||||
</template>
|
||||
</template>
|
||||
<span class="text-warning">
|
||||
{{ warning }}
|
||||
</span>
|
||||
<span v-if="needsConfirm" :key="resource">Re-enter its name below to confirm:</span>
|
||||
</div>
|
||||
<input v-if="needsConfirm" id="confirm" v-model="confirmName" type="text" />
|
||||
<span class="text-warning">{{ preventDeletionMessage }}</span>
|
||||
|
||||
<span class="text-error">{{ error }}</span>
|
||||
<span v-if="!needsConfirm" class="text-info mt-20">{{ protip }}</span>
|
||||
</div>
|
||||
|
|
@ -242,7 +258,7 @@ export default {
|
|||
<button class="btn role-secondary" @click="close">
|
||||
Cancel
|
||||
</button>
|
||||
<button class="btn bg-error" :disabled="isDeleteDisabled" @click="remove">
|
||||
<button class="btn bg-error" :disabled="preventDelete" @click="remove">
|
||||
Delete
|
||||
</button>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -566,7 +566,7 @@ export default {
|
|||
-ms-word-break: break-all;
|
||||
word-break: break-word;
|
||||
display:flex;
|
||||
align-items:start;
|
||||
align-items:flex-start;
|
||||
}
|
||||
|
||||
&.extra-column {
|
||||
|
|
@ -581,7 +581,7 @@ export default {
|
|||
width: 100%;
|
||||
margin: 10px 0px 10px 0px;
|
||||
&.key {
|
||||
align-self: start;
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.text-monospace:not(.conceal) {
|
||||
|
|
|
|||
|
|
@ -7,11 +7,12 @@ import { CIS, CONFIG_MAP } from '@/config/types';
|
|||
import { mapGetters } from 'vuex';
|
||||
import createEditView from '@/mixins/create-edit-view';
|
||||
import { allHash } from '@/utils/promise';
|
||||
import Checkbox from '@/components/form/Checkbox';
|
||||
const semver = require('semver');
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CruResource, LabeledSelect, Banner, Loading
|
||||
CruResource, LabeledSelect, Banner, Loading, Checkbox
|
||||
},
|
||||
|
||||
mixins: [createEditView],
|
||||
|
|
@ -44,12 +45,9 @@ export default {
|
|||
if (!this.value.metadata.name) {
|
||||
this.value.metadata.generateName = 'scan-';
|
||||
}
|
||||
if (!this.value.spec) {
|
||||
this.value.spec = { scanProfileName: null };
|
||||
}
|
||||
|
||||
return {
|
||||
allProfiles: [], defaultConfigMap: null, scanProfileName: this.value.spec.scanProfileName
|
||||
allProfiles: [], defaultConfigMap: null, scanProfileName: this.value.spec.scanProfileName, scanAlertRule: this.value.spec.scanAlertRule
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -133,7 +131,7 @@ export default {
|
|||
<template>
|
||||
<Banner v-if="!validProfiles.length" color="warning" :label="t('cis.noProfiles')" />
|
||||
|
||||
<div v-else class="row">
|
||||
<div v-else class="row mb-20">
|
||||
<div class="col span-6">
|
||||
<LabeledSelect
|
||||
v-model="scanProfileName"
|
||||
|
|
@ -144,6 +142,13 @@ export default {
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col span-6">
|
||||
<Checkbox v-model="scanAlertRule.alertOnComplete" :label="t('cis.alertOnComplete')" />
|
||||
|
||||
<Checkbox v-model="scanAlertRule.alertOnFailure" :label="t('cis.alertOnFailure')" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</CruResource>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { CIS } from '@/config/types';
|
||||
import { downloadFile } from '@/utils/download';
|
||||
import { set } from '@/utils/object';
|
||||
|
||||
export default {
|
||||
_availableActions() {
|
||||
|
|
@ -28,6 +29,16 @@ export default {
|
|||
return out;
|
||||
},
|
||||
|
||||
applyDefaults() {
|
||||
return () => {
|
||||
const spec = this.spec || {};
|
||||
|
||||
spec.scanProfileName = null;
|
||||
spec.scanAlertRule = {};
|
||||
set(this, 'spec', spec);
|
||||
};
|
||||
},
|
||||
|
||||
hasReport: false,
|
||||
|
||||
getReport() {
|
||||
|
|
@ -56,4 +67,5 @@ export default {
|
|||
}
|
||||
};
|
||||
},
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
export default {
|
||||
warnDeletionMessage() {
|
||||
return (toRemove = []) => {
|
||||
return this.$rootGetters['i18n/t']('cis.deleteProfileWarning', { count: toRemove.length });
|
||||
};
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue