Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tilfin committed Oct 15, 2023
1 parent 2a98572 commit d5583f6
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 838 deletions.
10 changes: 5 additions & 5 deletions src/js/lib/create_role_list_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ export function createRoleListItem(document, item, url, region, { hidesAccountId
const anchor = document.createElement('a');
anchor.href = "#";
anchor.title = item.role_name + '@' + item.aws_account_id;
anchor.dataset.profile = item.profile;
anchor.dataset.profile = item.name;
anchor.dataset.rolename = item.role_name;
anchor.dataset.account = item.aws_account_id;
anchor.dataset.color = item.color || 'aaaaaa';
anchor.dataset.redirecturi = createRedirectUri(url, region, item.region);
anchor.dataset.search = item.profile.toLowerCase() + ' ' + item.aws_account_id;
anchor.dataset.search = item.name.toLowerCase() + ' ' + item.aws_account_id;

anchor.appendChild(headSquare);
anchor.appendChild(document.createTextNode(item.profile));
anchor.appendChild(document.createTextNode(item.name));

if (hidesAccountId) {
anchor.dataset.displayname = createDisplayName(item.profile);
anchor.dataset.displayname = createDisplayName(item.name);
} else {
anchor.dataset.displayname = createDisplayName(item.profile, item.aws_account_id);
anchor.dataset.displayname = createDisplayName(item.name, item.aws_account_id);

const accountIdSpan = document.createElement('span');
accountIdSpan.className = 'suffixAccountId';
Expand Down
12 changes: 6 additions & 6 deletions src/js/lib/create_role_list_item.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('createRoleListItem', () => {
describe("profile has minimum properties", () => {
it('returns li element', () => {
const item = {
profile: 'profileA',
name: 'profileA',
aws_account_id: '222233334444',
role_name: 'roleA',
}
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('createRoleListItem', () => {
describe('profile has color', () => {
it('returns li element', () => {
const item = {
profile: 'profile-b',
name: 'profile-b',
aws_account_id: '000011115555',
role_name: 'role-b',
color: 'ffaa99',
Expand All @@ -82,7 +82,7 @@ describe('createRoleListItem', () => {
describe('profile has image', () => {
it('returns li element', () => {
const item = {
profile: 'prf',
name: 'prf',
aws_account_id: '333344441111',
role_name: 'img-role',
image: '"https://www.exapmle.com/icon.png"',
Expand All @@ -99,7 +99,7 @@ background-image: url(https://www.exapmle.com/icon.png);"> </span>prf<span class
describe('profile has color and image', () => {
it('returns li element', () => {
const item = {
profile: 'prf',
name: 'prf',
aws_account_id: '333344441111',
role_name: 'img-role',
color: 'ffaa22',
Expand All @@ -117,7 +117,7 @@ background-image: url(https://www.exapmle.com/icon.png);"> </span>prf<span class
describe('profile has region', () => {
it('returns li element', () => {
const item = {
profile: 'foo',
name: 'foo',
aws_account_id: '111122225555',
role_name: 'role-foo',
region: 'us-west-2',
Expand All @@ -133,7 +133,7 @@ background-image: url(https://www.exapmle.com/icon.png);"> </span>prf<span class
describe('hidesAccountId is true', () => {
it('returns li element', () => {
const item = {
profile: 'ProfileC',
name: 'ProfileC',
aws_account_id: '000011117777',
role_name: 'role-C',
}
Expand Down
9 changes: 6 additions & 3 deletions src/js/lib/profile_db.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ export async function writeProfileItemsToTable(items, replace = false) {
}

await dbManager.transaction('profiles', async dbTable => {
let i = 1;
for (const item of items) {
const num = `${i}`.padStart(6, '0')
const { profile, source_profile, single, ...props } = item;
const profilePath = (() => {
if (single) return `[SINGLE];${profile}`;
if (single) return `[SINGLE];${num}`;
if (source_profile) {
return `${source_profile};${profile}`;
return `${source_profile};${num}`;
} else {
return `[COMPLEX];${profile}`;
return `[COMPLEX];${num}`;
}
})();
const record = {
Expand All @@ -29,6 +31,7 @@ export async function writeProfileItemsToTable(items, replace = false) {
...props,
};
await dbTable.insert(record);
i++;
}
});

Expand Down
94 changes: 0 additions & 94 deletions src/js/lib/profile_set.js

This file was deleted.

Loading

0 comments on commit d5583f6

Please sign in to comment.