Skip to content

Commit

Permalink
Added deduplication and sorting for displayed accounts in the dropdow…
Browse files Browse the repository at this point in the history
…n menu (#1500)
  • Loading branch information
vitalii-honchar authored Mar 8, 2024
1 parent 7fac02c commit 1bc7c23
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion deploy-board/deploy_board/webapp/cluster_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def get(self, request, name, stage):
'enable_ami_auto_update': ENABLE_AMI_AUTO_UPDATE,
'stateful_status': clusters_helper.StatefulStatuses.get_status(None),
'stateful_options': clusters_helper.StatefulStatuses.get_all_statuses(),
'accounts': list(map(create_ui_account, accounts)) if accounts is not None else None,
'accounts': create_ui_accounts(accounts),
'defaultAccountId': default_account['id'] if default_account is not None else None,
}
# cluster manager
Expand Down Expand Up @@ -589,6 +589,15 @@ def create_ui_account(account):
}


def create_ui_accounts(accounts):
if accounts is None:
return None

deduplicated_accounts = {account['id']: account for account in accounts}.values()
sorted_accounts = sorted(deduplicated_accounts, key=lambda account: account['name'])
return list(map(create_ui_account, sorted_accounts))


def get_default_account(accounts):
if accounts is None:
return None
Expand Down

0 comments on commit 1bc7c23

Please sign in to comment.