Skip to content

Commit

Permalink
Handle side effects when logged in user is added as a collaborator
Browse files Browse the repository at this point in the history
  • Loading branch information
pavish committed Oct 1, 2024
1 parent 4291b3b commit 98e48ea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions mathesar_ui/src/contexts/DatabaseSettingsRouteContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export class DatabaseSettingsRouteContext {
this.collaborators.updateResolvedValue((collaborators) =>
collaborators.with(newCollaborator.id, newCollaborator),
);
return newCollaborator;
}

async deleteCollaborator(collaborator: Collaborator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
export let configuredRolesMap: ImmutableMap<number, ConfiguredRole>;
export let usersMap: ImmutableMap<number, User>;
export let collaboratorsMap: ImmutableMap<number, Collaborator>;
export let onAdd: (collaborator: Collaborator) => void;
const userId = requiredField<number | undefined>(undefined);
const configuredRoleId = requiredField<number | undefined>(undefined);
Expand All @@ -41,7 +42,11 @@
async function addCollaborator() {
if ($userId && $configuredRoleId) {
await $routeContext.addCollaborator($userId, $configuredRoleId);
const collaborator = await $routeContext.addCollaborator(
$userId,
$configuredRoleId,
);
onAdd(collaborator);
controller.close();
toast.success($_('collaborator_added_successfully'));
form.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
usersMap={$users.resolvedValue}
configuredRolesMap={$configuredRoles.resolvedValue}
collaboratorsMap={$collaborators.resolvedValue}
onAdd={checkAndHandleSideEffects}
/>
{/if}

Expand Down

0 comments on commit 98e48ea

Please sign in to comment.