From 61797ee78116acf64b902c800b93268c2253e162 Mon Sep 17 00:00:00 2001 From: Sahiba Mittal Date: Wed, 1 Jun 2022 09:43:27 +0100 Subject: [PATCH] feature to limit tags to policy Signed-off-by: Sahiba Mittal --- src/i18n/locales/en.json | 3 + src/shared/api.json | 1 + src/views/policy/PolicyList.vue | 54 +++++++++++-- src/views/portfolio/tags/SelectTagModal.vue | 90 +++++++++++++++++++++ 4 files changed, 141 insertions(+), 7 deletions(-) create mode 100644 src/views/portfolio/tags/SelectTagModal.vue diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 8e7f410fa..7ca7cb78d 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -51,6 +51,7 @@ "occurred_on": "Occurred On", "risk_type": "Risk Type", "project_name": "Project Name", + "tag_name": "Tag Name", "version": "Version", "last_bom_import": "Last BOM Import", "bom_format": "BOM Format", @@ -228,6 +229,7 @@ "component_details": "Component Details", "snapshot_notification": "Snapshot Notification", "select_project": "Select Project", + "select_tag": "Select Tag", "select": "Select", "identity": "Identity", "extended": "Extended", @@ -471,6 +473,7 @@ "delete_alert": "Delete Alert", "limit_to": "Limit To", "limit_to_projects": "Limit to projects", + "limit_to_tags": "Limit to Tags", "alert_created": "Alert created", "alert_deleted": "Alert deleted", "change_password_next_login": "User must change password at next login", diff --git a/src/shared/api.json b/src/shared/api.json index 48b392659..b5edf577b 100644 --- a/src/shared/api.json +++ b/src/shared/api.json @@ -24,6 +24,7 @@ "URL_USER_SELF": "api/v1/user/self", "URL_PERMISSION": "api/v1/permission", "URL_PROJECT": "api/v1/project", + "URL_TAG": "api/v1/tag", "URL_FINDING": "api/v1/finding", "URL_LICENSE": "api/v1/license", "URL_LICENSE_CONCISE": "api/v1/license/concise", diff --git a/src/views/policy/PolicyList.vue b/src/views/policy/PolicyList.vue index 8274d7d2d..4ca00eb35 100644 --- a/src/views/policy/PolicyList.vue +++ b/src/views/policy/PolicyList.vue @@ -29,6 +29,7 @@ import PolicyCondition from "./PolicyCondition"; import BToggleableDisplayButton from "@/views/components/BToggleableDisplayButton"; import SelectProjectModal from "@/views/portfolio/projects/SelectProjectModal"; + import SelectTagModal from "@/views/portfolio/tags/SelectTagModal"; export default { mixins: [permissionsMixin, bootstrapTableMixin], @@ -128,11 +129,19 @@
- +
+ +
+ + + + +
+
@@ -141,6 +150,7 @@ +
`, mixins: [permissionsMixin], @@ -150,6 +160,7 @@ BInputGroupFormSelect, BToggleableDisplayButton, SelectProjectModal, + SelectTagModal, PolicyCondition }, data() { @@ -169,15 +180,16 @@ { value: 'FAIL', text: this.$t('violation.fail') } ], projects: row.projects, - limitToVisible: false + limitToVisible: false, + tags: row.tags } }, methods: { - formatProjectLabel: function(projectName, projectVersion) { - if (projectName && projectVersion) { - return projectName + " " + projectVersion; + formatLabel: function(labelName, labelProperty) { + if (labelName && labelProperty) { + return labelName + " " + labelProperty; } else { - return projectName; + return labelName; } }, addCondition: function() { @@ -229,7 +241,7 @@ this.violationState = policy.violationState; this.conditions = policy.policyConditions; }, - deleteLimiter: function(projectUuid) { + deleteProjectLimiter: function(projectUuid) { let url = `${this.$api.BASE_URL}/${this.$api.URL_POLICY}/${this.policy.uuid}/project/${projectUuid}`; this.axios.delete(url).then((response) => { let p = []; @@ -244,6 +256,21 @@ this.$toastr.w(this.$t('condition.unsuccessful_action')); }); }, + deleteTagLimiter: function(tagName) { + let url = `${this.$api.BASE_URL}/${this.$api.URL_POLICY}/${this.policy.uuid}/tag/${tagName}`; + this.axios.delete(url).then((response) => { + let p = []; + for (let i=0; i { + this.$toastr.w(this.$t('condition.unsuccessful_action')); + }); + }, updateProjectSelection: function(selections) { this.$root.$emit('bv::hide::modal', 'selectProjectModal'); for (let i=0; i { + this.tags.push(selection); + this.$toastr.s(this.$t('message.updated')); + }).catch((error) => { + this.$toastr.w(this.$t('condition.unsuccessful_action')); + }); + } } }, watch: { diff --git a/src/views/portfolio/tags/SelectTagModal.vue b/src/views/portfolio/tags/SelectTagModal.vue new file mode 100644 index 000000000..ee0b77540 --- /dev/null +++ b/src/views/portfolio/tags/SelectTagModal.vue @@ -0,0 +1,90 @@ + + +