-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2061 from undb-io/release/v1.0.0-87
Release version v1.0.0-87
- Loading branch information
Showing
69 changed files
with
1,124 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
apps/frontend/src/lib/components/blocks/view/set-as-default-view.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<script lang="ts"> | ||
import * as AlertDialog from "$lib/components/ui/alert-dialog" | ||
import { isModalOpen, SET_DEFAULT_VIEW, toggleModal, closeModal } from "$lib/store/modal.store" | ||
import { trpc } from "$lib/trpc/client" | ||
import { getTable, viewId } from "$lib/store/table.store" | ||
import { createMutation } from "@tanstack/svelte-query" | ||
import { derived } from "svelte/store" | ||
import { invalidateAll } from "$app/navigation" | ||
import { toast } from "svelte-sonner" | ||
import { goto } from "$app/navigation" | ||
const table = getTable() | ||
let view = derived([table, viewId], ([$table, $viewId]) => $table.views.getViewById($viewId)) | ||
const setAsDefaultViewMutation = createMutation({ | ||
mutationFn: trpc.table.view.setDefault.mutate, | ||
async onSuccess(data, variables, context) { | ||
closeModal(SET_DEFAULT_VIEW) | ||
await invalidateAll() | ||
toast.success("View set as default") | ||
await goto(`/t/${$table.id.value}`) | ||
}, | ||
onError(error, variables, context) { | ||
toast.error(error.message) | ||
}, | ||
}) | ||
</script> | ||
|
||
<AlertDialog.Root open={$isModalOpen(SET_DEFAULT_VIEW)} onOpenChange={() => toggleModal(SET_DEFAULT_VIEW)}> | ||
<AlertDialog.Content> | ||
<AlertDialog.Header> | ||
<AlertDialog.Title>Set {$view.name.value} as default view</AlertDialog.Title> | ||
<AlertDialog.Description>The original view will be replaced.</AlertDialog.Description> | ||
</AlertDialog.Header> | ||
<AlertDialog.Footer> | ||
<AlertDialog.Cancel>Cancel</AlertDialog.Cancel> | ||
<AlertDialog.Action | ||
disabled={$setAsDefaultViewMutation.isPending} | ||
on:click={() => $setAsDefaultViewMutation.mutate({ tableId: $table.id.value, viewId: $viewId })} | ||
> | ||
Continue | ||
</AlertDialog.Action> | ||
</AlertDialog.Footer> | ||
</AlertDialog.Content> | ||
</AlertDialog.Root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/command-handlers/src/handlers/set-default-view.command-handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { SetDefaultViewCommand } from "@undb/commands" | ||
import { commandHandler } from "@undb/cqrs" | ||
import { singleton } from "@undb/di" | ||
import type { ICommandHandler } from "@undb/domain" | ||
import { createLogger } from "@undb/logger" | ||
import { TableIdVo, injectTableRepository, type ITableRepository } from "@undb/table" | ||
|
||
@commandHandler(SetDefaultViewCommand) | ||
@singleton() | ||
export class SetDefaultViewCommandHandler implements ICommandHandler<SetDefaultViewCommand, any> { | ||
public readonly logger = createLogger(SetDefaultViewCommandHandler.name) | ||
constructor( | ||
@injectTableRepository() | ||
private readonly repo: ITableRepository, | ||
) {} | ||
|
||
async execute(command: SetDefaultViewCommand): Promise<any> { | ||
const table = (await this.repo.findOneById(new TableIdVo(command.tableId))).unwrap() | ||
|
||
const spec = table.$setDefaultView(command) | ||
|
||
if (spec.isSome()) { | ||
await this.repo.updateOneById(table, spec) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Command, type CommandProps } from "@undb/domain" | ||
import { setDefaultViewDTO, tableId } from "@undb/table" | ||
import { z } from "@undb/zod" | ||
|
||
export const setDefaultViewCommand = setDefaultViewDTO.merge(z.object({ tableId: tableId })) | ||
|
||
export type ISetDefaultViewCommand = z.infer<typeof setDefaultViewCommand> | ||
|
||
export class SetDefaultViewCommand extends Command { | ||
public readonly tableId: string | ||
public readonly viewId: string | ||
|
||
constructor(props: CommandProps<ISetDefaultViewCommand>) { | ||
super(props) | ||
this.tableId = props.tableId | ||
this.viewId = props.viewId | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.