* refactor: 💡 add custom sort * test: 💍 fix tests * test: 💍 fix more tests * refactor: 💡 use reusable sort function for name * refactor: 💡 use sort util in all resources w/ optional name * Add missing copyright headers * test: 💍 fix broken tests & add tests for new util * refactor: 💡 add name custom sort to users * test: 💍 fix import in tests * refactor: 💡 add custom name sort to scopes * test: 💍 pr feedback on util test cases * refactor: 💡 move sort function into object (pr feedback)
13 lines
307 B
JavaScript
13 lines
307 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
export function sortNameWithIdFallback(recordA, recordB) {
|
|
let a = recordA.attributes.name;
|
|
let b = recordB.attributes.name;
|
|
a = a ? a : recordA.id;
|
|
b = b ? b : recordB.id;
|
|
return String(a).localeCompare(String(b));
|
|
}
|