Skip to content

feat(frontend): add operator-contextual dropdowns for tenant selection #3289

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

Merged
merged 5 commits into from
Feb 19, 2025

Conversation

njlie
Copy link
Contributor

@njlie njlie commented Feb 11, 2025

Changes proposed in this pull request

  • Adds tenant dropdown menus if the user is an operator for the following frontend pages:
    • Asset creation
    • Wallet Address creation
    • Peer creation
    • These resources will be created with the selected tenant, or with the selected asset associated with a given tenant.
  • Does not display this option if the user is a tenant.

Context

Fixes #3273.

Checklist

  • Related issues linked using fixes #number
  • Tests added/updated
  • Make sure that all checks pass
  • Bruno collection updated (if necessary)
  • Documentation issue created with user-docs label (if necessary)
  • OpenAPI specs updated (if necessary)

@github-actions github-actions bot added type: tests Testing related pkg: backend Changes in the backend package. pkg: frontend Changes in the frontend package. type: source Changes business logic pkg: mock-ase pkg: mock-account-service-lib labels Feb 11, 2025
<Dropdown
options={tenants.map((tenant) => ({
label: tenant.node.id,
value: `${tenant.node.id} ${tenant.node.publicName ? `(${tenant.node.publicName})` : ''}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call.... came here to suggest using the name for the select after just seeing the id in the UI, but I understand the default operator just doesnt have one.

required
/>
{tenants ? (
<Select
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why chose Select here and in wallet address create, but Dropdown in asset create? Just wondering if we can standardize them or if they need to be different?

I see the asset defaults to the session tenant (ie the operator) and the others dont.

Comment on lines 143 to 148
export const createAsset = async (
request: Request,
args: CreateAssetInput,
tenantId?: string
) => {
const apolloClient = await getApolloClient(request, tenantId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something is missing here.

The tenantId is never passed in createAsset (just called once) nor getApolloClient (only passed in here but its undefined). And there is no tenantId on the CreateAssetInput. The backend mutation uses the header, so it's just always going to be the operator.

You can validate this by changing the defaultValue on the tenant dropdown to any bogus value and submitting and see that it works (should fail because its not a real tenant id).

I think the intention was probably to pass the tenantId in here and override the header but I think previously we agreed we didn't want to do that to ensure the header always identifies the requestor.

I think we can remove the header overriding, put the tenantId on the gql input, and use the ctx.forTenantId provided by the setForTenantIdGraphQLMutationMiddleware (looks like mutation context type for assets needs to be updated to ForTenantIdContext).

@njlie njlie requested a review from BlairCurrey February 13, 2025 19:54
@mkurapov mkurapov linked an issue Feb 17, 2025 that may be closed by this pull request
3 tasks
}
}
)
ctx.logger.info({ tenantId }, 'tenantId for create asset')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ctx.logger.info({ tenantId }, 'tenantId for create asset')

@@ -669,6 +671,7 @@ type Asset implements Model {
): FeesConnection
"The date and time when the asset was created."
createdAt: String!
tenantId: String
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tenantId: String
tenantId: ID!

@@ -0,0 +1,84 @@
import { gql } from '@apollo/client'
Copy link
Contributor

@mkurapov mkurapov Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you update 2893/multi-tenancy-v1 locally, you should see changes for this file from #3256

@njlie njlie force-pushed the nl/3273/admin-ui-tenant-selection branch from a3ba1dd to ff4054f Compare February 18, 2025 15:25
@njlie njlie requested a review from mkurapov February 18, 2025 19:00
@njlie njlie merged commit 9d32bb6 into 2893/multi-tenancy-v1 Feb 19, 2025
32 of 37 checks passed
@njlie njlie deleted the nl/3273/admin-ui-tenant-selection branch February 19, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: backend Changes in the backend package. pkg: frontend Changes in the frontend package. pkg: mock-account-service-lib pkg: mock-ase type: source Changes business logic type: tests Testing related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Multi-Tenant] Add tenant selection when creating resources in Admin UI
3 participants