mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 18:48:08 +00:00 
			
		
		
		
	 56a10bb10f
			
		
	
	56a10bb10f
	
	
	
		
			
			* refactor ss+modal to accept multiple models * create policy form * cleanup and fix test * add tabs to policy modal form * add search select with modal to entity form * update group form; * allow modal to fit-content * add changelog * add check for policy create ability * add id so tests pass * filter out root option * fix test * add cleanup method * add ACL policy link * cleanup from comments * refactor sending action to parent * refactor, data down actions up! * cleanup comments * form field refactor * add ternary to options * update tests * Remodel component structure for clearer logic Includes fixing the wizard * address comments * cleanup args * refactor inline oidc assignment form * add line break * cleanup comments * fix tests * add policy template to ss+modal test * cleanup =true from test * final cleanup!!!!!! * actual final cleanup * fix typo, please be done Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com>
		
			
				
	
	
		
			72 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			72 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import Component from '@glimmer/component';
 | |
| import { action } from '@ember/object';
 | |
| import { inject as service } from '@ember/service';
 | |
| import { task } from 'ember-concurrency';
 | |
| import { tracked } from '@glimmer/tracking';
 | |
| 
 | |
| /**
 | |
|  * @module Oidc::AssignmentForm
 | |
|  * Oidc::AssignmentForm components are used to display the create view for OIDC providers assignments.
 | |
|  *
 | |
|  * @example
 | |
|  * ```js
 | |
|  * <Oidc::AssignmentForm @model={this.model}
 | |
|  * @onCancel={transition-to "vault.cluster.access.oidc.assignment"} @param1={{param1}}
 | |
|  * @onSave={transition-to "vault.cluster.access.oidc.assignments.assignment.details" this.model.name}
 | |
|  * />
 | |
|  * ```
 | |
| 
 | |
|  * @param {object} model - The parent's model
 | |
|  * @callback onCancel - callback triggered when cancel button is clicked
 | |
|  * @callback onSave - callback triggered when save button is clicked*
 | |
|  */
 | |
| 
 | |
| export default class OidcAssignmentFormComponent extends Component {
 | |
|   @service store;
 | |
|   @service flashMessages;
 | |
|   @tracked modelValidations;
 | |
|   @tracked errorBanner;
 | |
| 
 | |
|   @task
 | |
|   *save(event) {
 | |
|     event.preventDefault();
 | |
|     try {
 | |
|       const { isValid, state } = this.args.model.validate();
 | |
|       this.modelValidations = isValid ? null : state;
 | |
|       if (isValid) {
 | |
|         const { isNew, name } = this.args.model;
 | |
|         yield this.args.model.save();
 | |
|         this.flashMessages.success(`Successfully ${isNew ? 'created' : 'updated'} the assignment ${name}.`);
 | |
|         // this form is sometimes used in modal, passing the model notifies
 | |
|         // the parent if the save was successful
 | |
|         this.args.onSave(this.args.model);
 | |
|       }
 | |
|     } catch (error) {
 | |
|       const message = error.errors ? error.errors.join('. ') : error.message;
 | |
|       this.errorBanner = message;
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   @action
 | |
|   cancel() {
 | |
|     const method = this.args.model.isNew ? 'unloadRecord' : 'rollbackAttributes';
 | |
|     this.args.model[method]();
 | |
|     this.args.onCancel();
 | |
|   }
 | |
| 
 | |
|   @action
 | |
|   handleOperation({ target }) {
 | |
|     this.args.model.name = target.value;
 | |
|   }
 | |
| 
 | |
|   @action
 | |
|   onEntitiesSelect(selectedIds) {
 | |
|     this.args.model.entityIds = selectedIds;
 | |
|   }
 | |
| 
 | |
|   @action
 | |
|   onGroupsSelect(selectedIds) {
 | |
|     this.args.model.groupIds = selectedIds;
 | |
|   }
 | |
| }
 |