mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-11-03 20:17:59 +00:00 
			
		
		
		
	* Update add-to-array and remove-from-array helpers * remove search-select-has-many, moved logic directly into mfa-login-enforcement-form (see #16470) * Replace add/remove object in MFA files - All MFA tests pass * Replace in PKI components (pki tests all passing) * Replace in core addon where applicable * glimmerize console service -- console tests pass * more replacements * update string-list, add comment to vertical-bar-chart * Refactor CSP Event service - only used one place (auth-form) so simplified that usage - glimmerize and refactor so that the tests work * small updates * more cleanup * Fix tests * Remove objectAt from console-helpers * Address PR comments * move commandIndex clearing back * Remove extra model set
		
			
				
	
	
		
			34 lines
		
	
	
		
			885 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			885 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/**
 | 
						|
 * Copyright (c) HashiCorp, Inc.
 | 
						|
 * SPDX-License-Identifier: BUSL-1.1
 | 
						|
 */
 | 
						|
 | 
						|
import { helper as buildHelper } from '@ember/component/helper';
 | 
						|
import { assert } from '@ember/debug';
 | 
						|
 | 
						|
function dedupe(items) {
 | 
						|
  return items.filter((v, i) => items.indexOf(v) === i);
 | 
						|
}
 | 
						|
 | 
						|
export function addManyToArray(array, otherArray) {
 | 
						|
  assert(`Both values must be an array`, Array.isArray(array) && Array.isArray(otherArray));
 | 
						|
  const newArray = [...array].concat(otherArray);
 | 
						|
  return dedupe(newArray);
 | 
						|
}
 | 
						|
 | 
						|
export function addToArray(array, string) {
 | 
						|
  if (!Array.isArray(array)) {
 | 
						|
    assert(`Value provided is not an array`, false);
 | 
						|
  }
 | 
						|
  const newArray = [...array];
 | 
						|
  newArray.push(string);
 | 
						|
  return dedupe(newArray);
 | 
						|
}
 | 
						|
 | 
						|
export default buildHelper(function ([array, string]) {
 | 
						|
  if (Array.isArray(string)) {
 | 
						|
    return addManyToArray(array, string);
 | 
						|
  }
 | 
						|
  return addToArray(array, string);
 | 
						|
});
 |