Skip to content

Feature/ab#34137 tenant creation updates - #2863

Draft
AndreGAot wants to merge 10 commits into
devfrom
feature/AB#34137-tenant-creation-updates
Draft

Feature/ab#34137 tenant creation updates#2863
AndreGAot wants to merge 10 commits into
devfrom
feature/AB#34137-tenant-creation-updates

Conversation

@AndreGAot

@AndreGAot AndreGAot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Reworks tenant creation to add onboarding field mapping, a Features/Metabase-aware New Tenant modal, and a
new automated Metabase registration step — plus a consolidation of the reporting-roles admin UI into Tenant
Management.

Tenant creation & onboarding

  • TenantCreateDto/TenantDto/OnboardingRequestDto gained Division and MetabaseUserEmails fields.
  • Onboarding field mapping now supports mapping Display Name and Division from a spreadsheet import, and
    OnboardingRequestAppService.CreateAsync forwards DisplayName/Division/MetabaseUserEmails through to
    tenant creation, applying any Metabase default-list deltas afterward.
  • The New Tenant modal gained Features and Metabase tabs, hidden client-side for non-IT-Admin/Ops users.

Metabase integration (new feature)

  • New generic post-tenant-creation pipeline (IPostTenantCreationStep / PostTenantCreationSequenceJob) — a
    self-re-enqueuing background job that runs registered steps in order, continuing or stopping per step
    based on ContinueOnError.
  • New MetabaseTenantRegistrationStep + IMetabaseApiClient/MetabaseApiClient, replacing a manual PowerShell
    runbook: registers the tenant's readonly database connection in Metabase, syncs/rescans it, creates a
    permissions group with the configured member emails, and grants database + collection access.
  • The step is idempotent by design — database/group/collection lookups are find-or-create by tenant name,
    and group membership is checked before posting — so re-running it after a partial failure never
    duplicates resources.
  • TenantCreatedEventHandler snapshots the resolved Metabase user-email list into a tenant-scoped setting at
    creation time (correctly distinguishing "no override provided" from "explicitly cleared"), so the async
    step reads a stable list even if the Global default changes before it runs.
  • TenantAppService.CreateAsync enforces IT Admin/Operations authorization before honoring
    FeatureKeys/MetabaseUserEmails, closing a path where a caller with only the plain Tenants.Create
    permission could otherwise grant arbitrary email addresses Metabase access to a tenant's database via
    direct API call.
  • Supporting config (MetabaseOptions, MetabaseSettings), a new dynamic-URL entry for the Metabase API base,
    and broad new test coverage across the client, the step, the job, and the event handler.

Reporting roles UI consolidation

  • Removed the standalone "Reporting Admin > Configuration" page, folding that functionality into Tenant
    Management's own configuration modal.
  • Reworked role lookup to prefer the auto-provisioned {LicencePlate}_readonly role over the legacy
    {tenantname}_readonly pattern, with live PostgreSQL role-existence checks so saving a role assignment
    fails fast instead of the background job silently no-op'ing against a nonexistent role.

AndreGAot and others added 2 commits August 20, 2026 14:15
… modal, Metabase post-creation step

Onboarding "Create Tenant" modal:
- Reorders field mapping so Name and the new Display Name field come first,
  then Ministry, Division, Branch, Program Area, Features, Program Managers.
- Adds Display Name and Division as mappable fields (stored on the tenant's
  ExtraProperties / passed through to TenantCreateDto).
- Fixes the Jaro-Winkler auto-detection matching a "ProgramManagerEmail"-style
  field to the Name canonical instead of a literal "Name" field, via an
  exact-match short-circuit before fuzzy scoring.

New Tenant modal (Tenants/CreateModal):
- Rebuilt to match the Edit Configuration modal's tabbed layout (Details,
  Program Managers, Features, Metabase) instead of a single flat form.
- Details tab now actually renders Division/Branch/Description/CAS Client
  Code (previously present on the model but never shown) plus Display Name.
- Program Managers search now uses the same field-selector UX as Edit.
- Features tab lets you pick features to enable at creation time, reusing
  the existing FeatureKeys -> TenantCreatedEventHandler mechanism.
- New Metabase tab manages the group's member emails, backed by ABP Settings
  (Global default list + per-tenant snapshot, with an "add for this tenant
  only" vs "save as default" option).

Tenants list: adds a Display Name column.

Post-tenant-creation pipeline (new):
- IPostTenantCreationStep (Unity.SharedKernel) - pluggable, ordered,
  per-step ContinueOnError.
- PostTenantCreationSequenceJob - a self-chaining ABP background job that
  runs steps in order, entirely via the job queue (durable/retryable per
  step), stopping on failure only where ContinueOnError is false.
- MetabaseTenantRegistrationStep - first step. Registers the new tenant
  with Metabase (database connection over its readonly Postgres role, a
  permissions group with its configured members, and a collection),
  automating what manual_deploy_new_metabase_tenant.ps1 used to do by hand.
  Resolves the Metabase endpoint via the existing DynamicUrls mechanism
  (new METABASE_API_BASE key) and the API key via new TenantCreation:
  Steps:Metabase:ApiKey config.
- IResilientHttpRequest gains an optional extraHeaders parameter (needed
  for Metabase's x-api-key auth), backward compatible with all existing
  call sites.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🧪 Unit Test Results (Parallel Execution)

Tests

📊 Summary

Result Count
✅ Passed 1029
❌ Failed 0
⚠️ Skipped 0

📄 HTML Reports

  • Merged Tests (HTML): Included in artifacts
    Generated automatically by CI.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates tenant provisioning with richer metadata, onboarding mappings, feature selection, and automated Metabase registration.

Changes:

  • Adds display name/division mapping and expanded tenant-creation interfaces.
  • Introduces queued post-creation steps and Metabase provisioning.
  • Adds configuration, localization, settings, and automated tests.

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 9 comments.

Show a summary per file

All paths are under applications/Unity.GrantManager/.

File Description
test/.../MetabaseTenantRegistrationStepTests.cs Tests Metabase registration behavior.
test/.../PostTenantCreationSequenceJobTests.cs Tests post-creation sequencing.
src/Unity.GrantManager.Web/appsettings.json Adds Metabase configuration.
src/Unity.GrantManager.Web/appsettings.Development.json Adds development Metabase settings.
src/Unity.GrantManager.Domain/Integrations/DynamicUrlDataSeeder.cs Seeds the Metabase endpoint.
src/Unity.GrantManager.Domain.Shared/Localization/GrantManager/en.json Adds tenant UI labels.
src/Unity.GrantManager.Domain.Shared/Integrations/DynamicUrlKeyNames.cs Defines the Metabase endpoint key.
src/Unity.GrantManager.Application/Tenants/PostCreation/Steps/MetabaseTenantRegistrationStep.cs Implements Metabase provisioning.
src/Unity.GrantManager.Application/Tenants/PostCreation/PostTenantCreationStepArgs.cs Defines sequence job arguments.
src/Unity.GrantManager.Application/Tenants/PostCreation/PostTenantCreationSequenceJob.cs Runs post-creation steps.
src/Unity.GrantManager.Application/Integrations/Metabase/MetabaseOptions.cs Defines Metabase options.
src/Unity.GrantManager.Application/Integrations/Metabase/MetabaseApiClient.cs Implements Metabase API calls.
src/Unity.GrantManager.Application/Integrations/Metabase/IMetabaseApiClient.cs Defines the Metabase client contract.
src/Unity.GrantManager.Application/Handlers/TenantCreatedEventHandler.cs Starts post-creation processing.
src/Unity.GrantManager.Application/GrantManagerApplicationModule.cs Registers Metabase services.
modules/Unity.TenantManagement/test/.../OnboardingRequestAppServiceTests.cs Tests Metabase onboarding inputs.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Web/UnityTenantManagementWebMapperlyProfile.cs Maps new creation fields.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Web/Pages/TenantManagement/Tenants/Index.js Adds display names and creation UI behavior.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Web/Pages/TenantManagement/Tenants/CreateModal.cshtml.cs Handles creation metadata and defaults.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Web/Pages/TenantManagement/Tenants/CreateModal.cshtml Redesigns the creation modal.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Web/Pages/TenantManagement/Onboarding/Index.js Adds mappings and Metabase controls.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Web/Pages/TenantManagement/Onboarding/CreateTenantModal.cshtml.cs Loads default Metabase users.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Web/Pages/TenantManagement/Onboarding/CreateTenantModal.cshtml Adds onboarding tabs and fields.
modules/Unity.TenantManagement/src/Unity.TenantManagement.HttpApi/OnboardingRequestController.cs Exposes new mapping parameters.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Application/UnityTenantManagementMapperlyProfile.cs Maps tenant display names.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Application/TenantAppService.cs Persists new tenant metadata.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Application/OnboardingRequestAppService.cs Processes mappings and Metabase defaults.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Application/Onboarding/OnboardingColumnConfigSettings.cs Adds mapping-setting keys.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Application/Onboarding/OnboardingColumnConfigSettingDefinitionProvider.cs Registers new mapping settings.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Application/Metabase/MetabaseSettingDefinitionProvider.cs Registers Metabase email settings.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Application.Contracts/TenantDto.cs Adds tenant display name.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Application.Contracts/TenantCreateOrUpdateDtoBase.cs Adds display name input.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Application.Contracts/TenantCreateDto.cs Adds Metabase email input.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Application.Contracts/OnboardingRequestDto.cs Adds display name and division.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Application.Contracts/OnboardingColumnConfigDto.cs Extends mapping and creation contracts.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Application.Contracts/Metabase/MetabaseSettings.cs Defines the email setting key.
modules/Unity.TenantManagement/src/Unity.TenantManagement.Application.Contracts/IOnboardingRequestAppService.cs Extends validation parameters.
modules/Unity.SharedKernel/PostTenantCreation/IPostTenantCreationStep.cs Defines extensible post-creation steps.
modules/Unity.SharedKernel/Http/ResilientHttpRequest.cs Supports additional HTTP headers.
modules/Unity.SharedKernel/Http/IResilientHttpRequest.cs Extends the HTTP abstraction.
Suppressed comments (1)

applications/Unity.GrantManager/src/Unity.GrantManager.Application/Integrations/Metabase/MetabaseApiClient.cs:92

  • The collection permissions graph has the same stale-revision race as the database graph: simultaneous tenant jobs can read one revision and then conflict or overwrite one another. Add a bounded retry that refetches the graph and reapplies this collection change after a revision conflict, or serialize these updates.
        await PutAsync("/api/collection/graph",
            new { groups, revision = graph.Value<int>("revision") }, cancellationToken);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread applications/Unity.GrantManager/src/Unity.GrantManager.Web/appsettings.json Outdated
@github-actions

Copy link
Copy Markdown

🧪 Unit Test Results (Parallel Execution)

Tests

📊 Summary

Result Count
✅ Passed 1029
❌ Failed 0
⚠️ Skipped 0

📄 HTML Reports

  • Merged Tests (HTML): Included in artifacts
    Generated automatically by CI.

@github-actions

Copy link
Copy Markdown

🧪 Unit Test Results (Parallel Execution)

Tests

📊 Summary

Result Count
✅ Passed 1034
❌ Failed 0
⚠️ Skipped 0

📄 HTML Reports

  • Merged Tests (HTML): Included in artifacts
    Generated automatically by CI.

@github-actions

Copy link
Copy Markdown

🧪 Unit Test Results (Parallel Execution)

Tests

📊 Summary

Result Count
✅ Passed 1036
❌ Failed 0
⚠️ Skipped 0

📄 HTML Reports

  • Merged Tests (HTML): Included in artifacts
    Generated automatically by CI.

@github-actions

Copy link
Copy Markdown

🧪 Unit Test Results (Parallel Execution)

Tests

📊 Summary

Result Count
✅ Passed 1047
❌ Failed 0
⚠️ Skipped 0

📄 HTML Reports

  • Merged Tests (HTML): Included in artifacts
    Generated automatically by CI.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 60 out of 60 changed files in this pull request and generated 4 comments.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

🧪 Unit Test Results (Parallel Execution)

Tests

📊 Summary

Result Count
✅ Passed 1047
❌ Failed 0
⚠️ Skipped 0

📄 HTML Reports

  • Merged Tests (HTML): Included in artifacts
    Generated automatically by CI.

@github-actions

Copy link
Copy Markdown

🧪 Unit Test Results (Parallel Execution)

Tests

📊 Summary

Result Count
✅ Passed 1059
❌ Failed 0
⚠️ Skipped 0

📄 HTML Reports

  • Merged Tests (HTML): Included in artifacts
    Generated automatically by CI.

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🧪 Unit Test Results (Parallel Execution)

Tests

📊 Summary

Result Count
✅ Passed 1068
❌ Failed 0
⚠️ Skipped 0

📄 HTML Reports

  • Merged Tests (HTML): Included in artifacts
    Generated automatically by CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants