-
Notifications
You must be signed in to change notification settings - Fork 272
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
feat: Multi-tenancy / Add support for multiple tenants #561
Conversation
* Add multitenancy app with some basic model configuration * Add creation of signup tenant and add it in currentUser query schema. * Add tests * Add short documentation for multi tenancy manager * PR fixes & linter fix * Add migration * Documentation grammar
* feat: Add crud for Tenants & middleware for current tenant and user role * Add missing migration * Add documentation * Reformat docs * Add batch creation of tenants to tests * Change the omitting rule for test coverage * PR fixes * Slug generation refactor * Refactor tenant model tests
* Working invitation flow * Add migration * Fix existing tests * Add tests and connect existing invitations to newly created memberships * Add tenants queries with permission specific fields * Fix & add tests * Add invitation token & tests * Add some basic documentation * Handle invitation accepted at date * PR fixes
* Add first name, last name, email and avatar to TenantMembershipType * Add mutations for update/delete tenant membership. Introduce validation for having at least one owner in tenant, and block inviting to default type tenant
* Change subscribtion customer model to Tenant * Fix tests * Add billing model
* Fix enum type converter * Remove type for role field, make it default * Add migration * Fix migrations conflict
* Make tenant dependent example CRUD demo item model * Remove redundant function * Possibly fix test * Send notifictions about CRUD item changes to tenant owners
* feat: allow the user to change membership role * chore: update tenant membership graphql adjustments * chore: update unit tests * chore: membership entry test refactor * chore: MembershipEntry tests refactor * feat: add onCompleted handler * chore: add toast test * chore: refactor membership entry tests * feat: add fil message, update tests * chore: snapshot update
* Add notifications for created, accepted and declined invitation * Make tenantId required
* feat: multi tenancy subscription plan adjustments * chore: refactor tests * chore: Modify `webapp-finances` rendering utils to include tenant providers * chore: adjust routing, tests fixes * chore: fix type error --------- Co-authored-by: Michal Kleszcz <[email protected]>
Add TenantRoleAccess component, fix subscriptions routing, add Subscription tab to tenant settings page
* feat: add a danger zone into General Settings of the organization with removal mutation --------- Co-authored-by: Michal Kleszcz <[email protected]>
* Add delete tenant validation and subscription cancellation to mutation * Add test for tenant with free plan (nothing to cancel)
# Conflicts: # packages/webapp-libs/webapp-finances/src/utils/storybook.tsx # packages/webapp/package.json # pnpm-lock.yaml
Add multi tenancy notifications, Add reloadCommonQuery trigger to the notifications
Fix test coverage for webapp-tenants
Add additional info in the personal settings' members tab
# Conflicts: # pnpm-lock.yaml
# Conflicts: # packages/webapp-libs/webapp-core/package.json # pnpm-lock.yaml
@@ -8,7 +8,7 @@ | |||
"postinstall": "node packages/internal/cli/scripts/build.js" | |||
}, | |||
"devDependencies": { | |||
"@apollo/client": "^3.8.8", | |||
"@apollo/client": "^3.9.6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this update on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm... Interesting. I think it should go with the newer version
const { data, loading } = useQuery(editCrudDemoItemQuery, { variables: { id: id ?? '' } }); | ||
const { data, loading } = useQuery(editCrudDemoItemQuery, { | ||
variables: { id: id ?? '', tenantId: currentTenant?.id ?? '' }, | ||
skip: !currentTenant, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it should be skipped also when !id
|
||
const successDeleteMessage = intl.formatMessage({ | ||
id: 'Tenant form / DeleteTenant / Success message', | ||
defaultMessage: '🎉 Tenant deleted successfully!', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use Organization
here, same for failed
|
||
const successMessage = intl.formatMessage({ | ||
id: 'Tenant form / AddTenant / Success message', | ||
defaultMessage: '🎉 Tenant added successfully!', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Organization copy
|
||
const successMessage = intl.formatMessage({ | ||
id: 'Tenant form / UpdateTenant / Success message', | ||
defaultMessage: '🎉 Tenant updated successfully!', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking about it because it can be triggered inside of organization and personal account. Maybe we could notify without this tenant
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. The copy could be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking of leaving it as an Organization
, as there are a lot of copies inside of this settings suggesting its organization
.
@mkleszcz
const navigate = useNavigate(); | ||
const isPersonal = useCurrentTenant().data?.type === TenantType.PERSONAL; | ||
|
||
const handleLastInvitationClick = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a typo before. It should be handleNewTenantClick
BREAKING CHANGE: Important migration instructions Before running the multi-tenancy migrations on your existing codebase or database, it is crucial to follow these steps to avoid any issues: 1. Remove or comment `DJSTRIPE_SUBSCRIBER_MODEL` setting 2. Run the migrations 3. Revert the change: After the migrations have successfully completed, revert the change by uncommenting or re-adding the `DJSTRIPE_SUBSCRIBER_MODEL` setting.
Please check if the PR fulfills these requirements
What kind of change does this PR introduce?
Closes #382
Add multi tenancy feature to SB. Feature is described in issue #382
Does this PR introduce a breaking change?
Yes.