Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added deduplication and sorting for displayed accounts in the dropdown menu #1500

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading