mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 18:48:08 +00:00 
			
		
		
		
	 c265f5a132
			
		
	
	c265f5a132
	
	
	
		
			
			* move list to component * use helper instead * add changelog * clarify changelog copy * delete components now that helper is in use * move helper to util, remove template helper invokation * add optional sorting to lazyPaginatedQuery based on sortBy query attribute * Add serialization to entity-alias and entity so that they can be sorted by name on list view * Same logic as base normalizeItems for extractLazyPaginatedData so that metadata shows on list * Add headers --------- Co-authored-by: Chelsea Shaw <cshaw@hashicorp.com> Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com>
		
			
				
	
	
		
			20 lines
		
	
	
		
			540 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			540 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /**
 | |
|  * Copyright (c) HashiCorp, Inc.
 | |
|  * SPDX-License-Identifier: BUSL-1.1
 | |
|  */
 | |
| 
 | |
| export default function sortObjects(array, key) {
 | |
|   if (Array.isArray(array) && array?.every((e) => e[key] && typeof e[key] === 'string')) {
 | |
|     return array.sort((a, b) => {
 | |
|       // ignore upper vs lowercase
 | |
|       const valueA = a[key].toUpperCase();
 | |
|       const valueB = b[key].toUpperCase();
 | |
|       if (valueA < valueB) return -1;
 | |
|       if (valueA > valueB) return 1;
 | |
|       return 0;
 | |
|     });
 | |
|   }
 | |
|   // if not sortable, return original array
 | |
|   return array;
 | |
| }
 |