Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
MonPote committed May 7, 2024
1 parent 3da606f commit 435d752
Show file tree
Hide file tree
Showing 3 changed files with 258 additions and 52 deletions.
5 changes: 5 additions & 0 deletions src/react/endpoint/EndpointList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
cloudServerDashboard,
} from './AdvancedMetricsButton';
import { DeleteEndpoint } from './DeleteEndpoint';
import { SelectAccountIAMRole } from '../ui-elements/SelectAccountIAMRole';
type CellProps = {
row: {
original: Endpoint;
Expand Down Expand Up @@ -139,6 +140,10 @@ function EndpointList({ endpoints, locations }: Props) {
dashboard={cloudServerDashboard}
/>
</div>
<div>
Demo
<SelectAccountIAMRole />

Check failure on line 145 in src/react/endpoint/EndpointList.tsx

View workflow job for this annotation

GitHub Actions / build

Property 'onChange' is missing in type '{}' but required in type 'SelectAccountIAMRoleProps'.

Check failure on line 145 in src/react/endpoint/EndpointList.tsx

View workflow job for this annotation

GitHub Actions / build-ui

Property 'onChange' is missing in type '{}' but required in type 'SelectAccountIAMRoleProps'.
</div>
</T.SearchContainer>

<Table.SingleSelectableContent
Expand Down
17 changes: 12 additions & 5 deletions src/react/ui-elements/SelectAccountIAMRole.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ const filterRoles = (
);
};

export const extractAccountIdFromARN = (arn: string) => {
return regexArn.exec(arn)?.groups?.['account_id'] ?? '';
};

/**
* DataServiceRoleProvider is using the path to figure out what is the current account.
* In order to reuse this logic, we need to have a router and set DataServiceRoleProvider under
Expand Down Expand Up @@ -169,10 +173,12 @@ const SelectAccountIAMRoleWithAccount = (
const rolesQuery = getListRolesQuery(accountName, IAMClient);
const queryClient = useQueryClient();

const assumedRoleAccountId = regexArn.exec(assumedRole?.AssumedRoleUser?.Arn)
?.groups?.['account_id'];
const selectedAccountId = regexArn.exec(account?.preferredAssumableRoleArn)
?.groups?.['account_id'];
const assumedRoleAccountId = extractAccountIdFromARN(
assumedRole?.AssumedRoleUser?.Arn,
);
const selectedAccountId = extractAccountIdFromARN(
account?.preferredAssumableRoleArn,
);

/**
* When we change account, it will take some time to assume the role for the new account.
Expand Down Expand Up @@ -263,7 +269,7 @@ export const _SelectAccountIAMRole = (props: SelectAccountIAMRoleProps) => {
} = props;

const accessibleAccountsAdapter = useAccessibleAccountsAdapter();
const metricsAdapter = new NoOppMetricsAdapter();
const metricsAdapter = new NoOpMetricsAdapter();
const accounts = useListAccounts({
accessibleAccountsAdapter,
metricsAdapter,
Expand All @@ -273,6 +279,7 @@ export const _SelectAccountIAMRole = (props: SelectAccountIAMRoleProps) => {
return (
<SelectAccountIAMRoleWithAccount
accounts={accounts.accounts.value}
// accounts={accounts.accounts.value.filter((_, idx) => idx < 5)}
defaultValue={defaultValue}
hideAccountRoles={hideAccountRoles}
onChange={onChange}
Expand Down
Loading

0 comments on commit 435d752

Please sign in to comment.