From c5337034cfc44e148faf3c498fbf5451b6081e7b Mon Sep 17 00:00:00 2001 From: Miranda Fluharty Date: Fri, 18 Jul 2025 21:39:22 -0600 Subject: [PATCH] Try out manual save --- .../security_attributes/attribute_drawer.vue | 8 +- .../security_attributes/category_form.vue | 80 +++++++++++++++---- .../security_attributes/category_list.vue | 4 +- .../configure_attributes.vue | 59 +++++++++++++- locale/gitlab.pot | 25 ++++-- 5 files changed, 146 insertions(+), 30 deletions(-) diff --git a/ee/app/assets/javascripts/security_configuration/components/security_attributes/attribute_drawer.vue b/ee/app/assets/javascripts/security_configuration/components/security_attributes/attribute_drawer.vue index c6925d30a87c9e..b1776ec98fe382 100644 --- a/ee/app/assets/javascripts/security_configuration/components/security_attributes/attribute_drawer.vue +++ b/ee/app/assets/javascripts/security_configuration/components/security_attributes/attribute_drawer.vue @@ -18,8 +18,8 @@ export default { i18n: { addAttributeTitle: s__('SecurityAttributes|Add security attribute'), editAttributeTitle: s__('SecurityAttributes|Edit security attribute'), - updateAttributeButton: s__('SecurityAttributes|Update attribute'), - createAttributeButton: s__('SecurityAttributes|Add attribute'), + updateAttributeButton: s__('SecurityAttributes|Apply changes'), + createAttributeButton: s__('SecurityAttributes|Apply changes'), cancelButton: s__('SecurityAttributes|Cancel'), deleteButton: s__('SecurityAttributes|Delete'), }, @@ -111,7 +111,7 @@ export default {
defaultCategory, }, }, + data() { + return { + formErrors: { + name: null, + multipleSelection: null, + attributes: null, + }, + hasUnsavedChanges: false, + }; + }, computed: { isNew() { return !this.category?.id; @@ -68,14 +78,30 @@ export default { areAttributesEditable() { return this.category?.canEditAttributes || this.isNew; }, - categoryName() { - return this.category?.name; + attributes() { + return this.securityAttributes.filter( + (attribute) => attribute.categoryId === this.category.id, + ); }, - categoryDescription() { - return this.category?.description; + }, + methods: { + isFormValid() { + this.formErrors.name = this.category.name.trim() === '' ? __('Name is required') : null; + this.formErrors.multipleSelection = + this.category.multipleSelection === null ? __('Selection type is required') : null; + this.formErrors.attributes = + this.attributes.length === 0 ? __('At least one attribute is required') : null; + return ( + !this.formErrors.name && !this.formErrors.multipleSelection && !this.formErrors.attributes + ); }, - attributes() { - return this.category?.id ? this.securityAttributes : []; + handleSave() { + if (!this.isFormValid()) return; + this.$emit('updateCategory', this.category); + this.hasUnsavedChanges = false; + }, + handleUnsavedChange() { + this.hasUnsavedChanges = true; }, }, attributesTableFields: [ @@ -141,15 +167,32 @@ export default {

{{ s__('SecurityAttributes|Category details') }}

{{ s__('SecurityAttributes|View category settings and associated attributes.') }}

- - - {{ categoryName }} + + + {{ category.name }} - - {{ categoryDescription }} + + {{ category.description }} - + - + {{ s__('SecurityAttributes|Single selection') }} @@ -186,6 +229,8 @@ export default {
diff --git a/ee/app/assets/javascripts/security_configuration/components/security_attributes/category_list.vue b/ee/app/assets/javascripts/security_configuration/components/security_attributes/category_list.vue index d4fe985cf9b230..473ba39a037563 100644 --- a/ee/app/assets/javascripts/security_configuration/components/security_attributes/category_list.vue +++ b/ee/app/assets/javascripts/security_configuration/components/security_attributes/category_list.vue @@ -27,7 +27,7 @@ export default { category="primary" variant="confirm" size="small" - @click="$emit('selectCategory', {})" + @click="$emit('createCategory')" >{{ s__('SecurityAttributes|Create category') }}
@@ -47,7 +47,7 @@ export default { {{ category.description }}
- {{ category.attributeCount }} + {{ category.attributeCount }} diff --git a/ee/app/assets/javascripts/security_configuration/components/security_attributes/configure_attributes.vue b/ee/app/assets/javascripts/security_configuration/components/security_attributes/configure_attributes.vue index 787c842068c9b7..4e6c2fc252bb53 100644 --- a/ee/app/assets/javascripts/security_configuration/components/security_attributes/configure_attributes.vue +++ b/ee/app/assets/javascripts/security_configuration/components/security_attributes/configure_attributes.vue @@ -1,4 +1,6 @@