Skip to content

Commit

Permalink
Adjust some naming
Browse files Browse the repository at this point in the history
  • Loading branch information
seancolsen committed Sep 30, 2024
1 parent 2a2bb6e commit 2c39ff9
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 26 deletions.
2 changes: 1 addition & 1 deletion mathesar_ui/src/pages/database/DatabasePageWrapper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
const databaseRouteContext = DatabaseRouteContext.get();
$: ({ database, underlyingDatabase } = $databaseRouteContext);
$: void underlyingDatabase.runOptimally({ database_id: database.id });
$: void underlyingDatabase.runConservatively({ database_id: database.id });
const commonData = preloadCommonData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
const databaseRouteContext = DatabaseRouteContext.get();
$: ({ database, underlyingDatabase } = $databaseRouteContext);
$: void underlyingDatabase.runOptimally({ database_id: database.id });
$: void underlyingDatabase.runConservatively({ database_id: database.id });
$: schemasMap = $schemasStore.data;
$: schemasRequestStatus = $schemasStore.requestStatus;
$: isLoading =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import { Button, SpinnerButton } from '@mathesar-component-library';
export let collaborator: Collaborator;
export let editRoleForCollaborator: (collaborator: Collaborator) => void;
export let checkAndHandleSideEffects: (collaboror: Collaborator) => void;
export let onClickEditRole: (collaborator: Collaborator) => void;
export let onDelete: (collaborator: Collaborator) => void;
const routeContext = DatabaseSettingsRouteContext.get();
$: ({ configuredRoles, users } = $routeContext);
Expand All @@ -28,7 +28,7 @@
async function deleteCollaborator() {
await $routeContext.deleteCollaborator(collaborator);
checkAndHandleSideEffects(collaborator);
onDelete(collaborator);
toast.success($_('collaborator_removed_successfully'));
}
</script>
Expand All @@ -55,7 +55,7 @@
<div class="actions">
<Button
appearance="secondary"
on:click={() => editRoleForCollaborator(collaborator)}
on:click={() => onClickEditRole(collaborator)}
disabled={!isMathesarAdmin}
>
<Icon {...iconEdit} size="0.8em" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
collaborators.batchRunner({ database_id: database.id }),
configuredRoles.batchRunner({ server_id: database.server.id }),
]);
$: void users.runOptimally();
$: void users.runConservatively();
$: isLoading =
$collaborators.isLoading || $configuredRoles.isLoading || $users.isLoading;
$: isSuccess = $collaborators.isOk && $configuredRoles.isOk && $users.isOk;
Expand Down Expand Up @@ -105,8 +105,8 @@
{#each [...($collaborators.resolvedValue?.values() ?? [])] as collaborator (collaborator.id)}
<CollaboratorRow
{collaborator}
{editRoleForCollaborator}
{checkAndHandleSideEffects}
onClickEditRole={editRoleForCollaborator}
onDelete={checkAndHandleSideEffects}
/>
{/each}
</GridTable>
Expand All @@ -131,7 +131,7 @@
usersMap={$users.resolvedValue}
controller={editCollaboratorRoleModal}
configuredRolesMap={$configuredRoles.resolvedValue}
{checkAndHandleSideEffects}
onUpdateRole={checkAndHandleSideEffects}
/>
{/if}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
export let collaborator: Collaborator;
export let configuredRolesMap: ImmutableMap<number, ConfiguredRole>;
export let usersMap: ImmutableMap<number, User>;
export let checkAndHandleSideEffects: (collaboror: Collaborator) => void;
export let onUpdateRole: (collaborator: Collaborator) => void;
$: savedConfiguredRoleId = collaborator.configuredRoleId;
$: configuredRoleId = requiredField<number>($savedConfiguredRoleId);
Expand All @@ -34,7 +34,7 @@
async function updateRoleForCollaborator() {
await collaborator.setConfiguredRole($configuredRoleId);
checkAndHandleSideEffects(collaborator);
onUpdateRole(collaborator);
controller.close();
toast.success($_('collaborator_role_updated_successfully'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
export let controller: ModalController;
export let parentRole: Role;
export let rolesMap: ImmutableMap<number, Role>;
export let handleRoleChangeSideEffects: (role: Role) => void;
export let onSave: (props: { parentRole: Role }) => void;
$: savedMembers = parentRole.members;
$: savedMemberOids = new Set([...$savedMembers.keys()]);
Expand All @@ -52,7 +52,7 @@
async function saveMembers() {
await parentRole.setMembers(new Set($memberOids));
handleRoleChangeSideEffects(parentRole);
onSave({ parentRole });
controller.close();
toast.success($_('child_roles_saved_successfully'));
}
Expand Down
11 changes: 4 additions & 7 deletions mathesar_ui/src/pages/database/settings/roles/RoleRow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
export let role: Role;
export let rolesMap: ImmutableMap<number, Role>;
export let modifyMembersForRole: (role: Role) => void;
export let handleRoleChangeSideEffects: (role: Role) => void;
export let onClickEditMembers: (role: Role) => void;
export let onDrop: (role: Role) => void;
$: members = role.members;
async function dropRole() {
try {
await $routeContext.databaseRouteContext.deleteRole(role);
handleRoleChangeSideEffects(role);
onDrop(role);
toast.success($_('role_dropped_successfully'));
} catch (err) {
toast.error(getErrorMessage(err));
Expand All @@ -52,10 +52,7 @@
{/each}
</div>
<div class="actions">
<Button
appearance="secondary"
on:click={() => modifyMembersForRole(role)}
>
<Button appearance="secondary" on:click={() => onClickEditMembers(role)}>
<Icon {...iconEdit} size="0.8em" />
</Button>
</div>
Expand Down
8 changes: 4 additions & 4 deletions mathesar_ui/src/pages/database/settings/roles/Roles.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
$: ({ database, roles, underlyingDatabase, currentRole } =
databaseRouteContext);
$: void roles.runOptimally({ database_id: database.id });
$: void roles.runConservatively({ database_id: database.id });
$: roleList = [...($roles.resolvedValue?.values() ?? [])];
let targetRole: Role | undefined = undefined;
Expand Down Expand Up @@ -93,8 +93,8 @@
<RoleRow
{role}
rolesMap={$roles.resolvedValue}
{modifyMembersForRole}
{handleRoleChangeSideEffects}
onClickEditMembers={modifyMembersForRole}
onDrop={handleRoleChangeSideEffects}
/>
{/each}
</GridTable>
Expand All @@ -113,7 +113,7 @@
parentRole={targetRole}
rolesMap={$roles.resolvedValue}
controller={modifyRoleMembersModalController}
{handleRoleChangeSideEffects}
onSave={({ parentRole }) => handleRoleChangeSideEffects(parentRole)}
/>
{/if}

Expand Down
2 changes: 1 addition & 1 deletion mathesar_ui/src/stores/AsyncStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default class AsyncStore<Props = void, T = unknown>
* - rejected
* - not loading
*/
async runOptimally(props: Props): Promise<AsyncStoreValue<T, string>> {
async runConservatively(props: Props): Promise<AsyncStoreValue<T, string>> {
const value = get(this.value);
if (value.isLoading || value.isOk) {
return value;
Expand Down

0 comments on commit 2c39ff9

Please sign in to comment.