Skip to content

Commit

Permalink
Merge pull request #1871 from undb-io/release/v1.0.0-8
Browse files Browse the repository at this point in the history
Release version v1.0.0-8
  • Loading branch information
nichenqin authored Aug 14, 2024
2 parents 98cf60b + 0309165 commit 53bef8f
Show file tree
Hide file tree
Showing 23 changed files with 173 additions and 45 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog


## v1.0.0-8


### 🩹 Fixes

- Fix invitation ([14e28b5](https://github.com/undb-io/undb/commit/14e28b5))

### ❤️ Contributors

- Nichenqin ([@nichenqin](http://github.com/nichenqin))

## v1.0.0-7

## v1.0.0-6
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ COPY --from=prerelease /usr/src/app/apps/backend/undb .
COPY --from=prerelease /usr/src/app/node_modules ./node_modules
COPY --from=prerelease /usr/src/app/apps/backend/drizzle ./drizzle
COPY --from=prerelease /usr/src/app/apps/backend/assets ./assets
COPY --from=prerelease /usr/src/app/apps/backend/src/modules/mail ./mail
COPY --from=prerelease /usr/src/app/packages ./packages
COPY --from=prerelease /usr/src/app/package.json .
COPY --from=prerelease /usr/src/app/apps/frontend/dist ./dist
Expand Down
1 change: 1 addition & 0 deletions apps/backend/src/modules/auth/auth.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const injectLucia = () => inject(LUCIA_PROVIDER)
const createLuciaWithAdapter = (adapter: Adapter) => {
const lucia = new Lucia(adapter, {
sessionCookie: {
name: "undb_auth_session",
attributes: {
secure: Bun.env.NODE_ENV === "PRODUCTION", // set `Secure` flag in HTTPS
domain: Bun.env.UNDB_COOKIE_DOMAIN,
Expand Down
5 changes: 4 additions & 1 deletion apps/backend/src/modules/mail/templates/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { Template } from "@undb/mail"
import Handlebars from "handlebars"

export async function compile(tpl: Template, data: any) {
const file = Bun.file(`./src/modules/mail/templates/${tpl}.hbs`)
const file =
Bun.env.NODE_ENV === "production"
? Bun.file(`./mail/templates/${tpl}.hbs`)
: Bun.file(`./src/modules/mail/templates/${tpl}.hbs`)
const text = await file.text()
const template = Handlebars.compile(text)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script lang="ts">
import { SquareMousePointer } from "lucide-svelte"
import { InboxIcon } from "lucide-svelte"
import CreateBaseButton from "./create-base-button.svelte"
</script>

<main class="flex h-full flex-col overflow-hidden">
<div class="flex flex-1 -translate-y-20 items-center justify-center rounded-lg border border-dashed shadow-sm">
<div class="flex flex-col items-center gap-2 text-center">
<SquareMousePointer class="text-primary h-10 w-10" />
<h3 class="text-sm font-bold tracking-tight">You have no bases</h3>
<InboxIcon class="text-muted-foreground h-16 w-16" />
<h3 class="text-sm font-bold tracking-tight">There is no base in the space.</h3>
<p class="text-muted-foreground text-sm">You can start create table as soon as you add a base.</p>
<CreateBaseButton />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
import { modal, CREATE_RECORD_MODAL, closeModal } from "$lib/store/modal.store"
import { ScrollArea } from "$lib/components/ui/scroll-area"
import { getTable } from "$lib/store/table.store"
import { useIsMutating } from "@tanstack/svelte-query"
import { LoaderCircleIcon } from "lucide-svelte"
let disabled = false
let dirty = false
const table = getTable()
const isMutating = useIsMutating({
mutationKey: [$table.id.value, "createRecord"],
})
</script>

<Sheet.Root
Expand Down Expand Up @@ -50,7 +56,13 @@

<Sheet.Footer class="border-t px-6 pt-4">
<Button variant="outline" type="button" on:click={() => closeModal(CREATE_RECORD_MODAL)}>Cancel</Button>
<Button type="submit" form="createRecord">Create</Button>
<Button disabled={$isMutating > 0} type="submit" form="createRecord">
{#if $isMutating > 0}
<LoaderCircleIcon class="mr-2 h-5 w-5 animate-spin" />
{/if}
Create
</Button
>
</Sheet.Footer>
</Sheet.Content>
</Sheet.Root>
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
const createRecordMutation = createMutation(
derived([table], ([$table]) => ({
mutationFn: trpc.record.create.mutate,
mutationKey: [ $table.id.value, "createRecord"],
onSuccess: (data) => {
client.invalidateQueries({
queryKey: ["records", $table.id.value],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

{#if field.isSingle}
{#if !Array.isArray(value)}
<OptionPicker options={field.options} bind:value sameWidth />
<OptionPicker disabled={readonly} options={field.options} bind:value sameWidth />
{/if}
{:else if Array.isArray(value) || value === null || value === undefined}
<OptionsPicker options={field.options} bind:value sameWidth />
<OptionsPicker disabled={readonly} options={field.options} bind:value sameWidth />
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import Input from "$lib/components/ui/input/input.svelte"
import { createMutation } from "@tanstack/svelte-query"
import { inviteCommand } from "@undb/commands"
import { UserPlus } from "lucide-svelte"
import { LoaderCircleIcon, UserPlus } from "lucide-svelte"
import { defaults, superForm } from "sveltekit-superforms"
import { zodClient } from "sveltekit-superforms/adapters"
import * as Form from "$lib/components/ui/form/index.js"
Expand Down Expand Up @@ -87,7 +87,12 @@
<Form.FieldErrors />
</Form.Field>

<Form.Button class="mt-4">Inivte</Form.Button>
<Form.Button disabled={$invite.isPending} class="mt-4">
{#if $invite.isPending}
<LoaderCircleIcon class="mr-2 h-5 w-5 animate-spin" />
{/if}
Inivte
</Form.Button>
</form>
</Dialog.Content>
</Dialog.Root>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
role="combobox"
aria-expanded={open}
class={cn("w-full justify-between overflow-hidden", $$restProps.class)}
{...$$restProps}
>
{#if selectedValue}
<Option option={selectedValue} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
role="combobox"
aria-expanded={open}
class={cn("w-full justify-between overflow-hidden", $$restProps.class)}
{...$$restProps}
>
<div class="flex flex-1 items-center gap-1">
{#if selectedValue.length}
Expand Down
84 changes: 61 additions & 23 deletions apps/frontend/src/lib/components/blocks/share/share-button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
import { shareStore } from "$lib/store/share.store"
import { invalidate } from "$app/navigation"
import { Input } from "$lib/components/ui/input"
import { getShareUrl, type IShareTarget } from "@undb/share"
import { getIframe, getShareUrl, type IShareTarget } from "@undb/share"
import { copyToClipboard } from "@svelte-put/copy"
import { toast } from "svelte-sonner"
import { cn } from "$lib/utils"
import { hasPermission } from "$lib/store/space-member.store"
import Textarea from "$lib/components/ui/textarea/textarea.svelte"
export let type: IShareTarget["type"]
export let id: IShareTarget["id"]
Expand Down Expand Up @@ -66,6 +67,17 @@
}, 2000)
toast.success("Copied to clipboard")
}
$: iframe = url ? getIframe(url) : undefined
let iframeCopied = false
const copyIFrame = () => {
copyToClipboard(iframe)
iframeCopied = true
setTimeout(() => {
iframeCopied = false
}, 2000)
toast.success("Copied to clipboard")
}
</script>

{#if $hasPermission("share:enable")}
Expand Down Expand Up @@ -99,33 +111,59 @@
}
}}
/>
{enabled ? "enable" : "disable"}
</Label>
</div>

{#if enabled && share?.id}
<div class="-mx-4 border-t px-4 pt-2">
<div class="flex items-center gap-2">
<Input
value={url}
readonly
class="flex-1 cursor-pointer"
on:click={(e) => {
copy()
e.target.select()
}}
/>
<a role="button" href={url} target="_blank">
<ExternalLinkIcon class="h-4 w-4" />
</a>
<button type="button" on:click={copy}>
{#if copied}
<CopyCheckIcon class="h-4 w-4" />
{:else}
<CopyIcon class="h-4 w-4" />
{/if}
</button>
<div class="-mx-4 space-y-2 border-t px-4 pt-2">
<div class="space-y-2">
<p class="text-xs font-semibold">Share URL</p>
<div class="flex items-center gap-2">
<Input
value={url}
readonly
class="flex-1 cursor-pointer"
on:click={(e) => {
copy()
e.target.select()
}}
/>
<a role="button" href={url} target="_blank">
<ExternalLinkIcon class="h-4 w-4" />
</a>
<button type="button" on:click={copy}>
{#if copied}
<CopyCheckIcon class="h-4 w-4" />
{:else}
<CopyIcon class="h-4 w-4" />
{/if}
</button>
</div>
</div>

{#if iframe}
<div class="space-y-2">
<p class="text-xs font-semibold">IFrame URL</p>
<div class="item-center flex gap-2">
<Textarea
rows={4}
on:click={(e) => {
copyIFrame()
e.target.select()
}}
class="flex-1 cursor-pointer"
value={iframe}
/>
<button type="button" on:click={copyIFrame}>
{#if iframeCopied}
<CopyCheckIcon class="h-4 w-4" />
{:else}
<CopyIcon class="h-4 w-4" />
{/if}
</button>
</div>
</div>
{/if}
</div>
{/if}
</Popover.Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@
CopyPlusIcon,
InboxIcon,
} from "lucide-svelte"
import { CREATE_TABLE_MODAL, DELETE_VIEW, DUPLICATE_VIEW, toggleModal, UPDATE_VIEW } from "$lib/store/modal.store"
import {
CREATE_BASE_MODAL,
CREATE_TABLE_MODAL,
DELETE_VIEW,
DUPLICATE_VIEW,
toggleModal,
UPDATE_VIEW,
} from "$lib/store/modal.store"
import { baseId } from "$lib/store/base.store"
import * as Collapsible from "$lib/components/ui/collapsible"
import { cn } from "$lib/utils"
import CreateViewButton from "../view/create-view-button.svelte"
import { onMount } from "svelte"
import * as DropdownMenu from "$lib/components/ui/dropdown-menu/index.js"
import { hasPermission } from "$lib/store/space-member.store"
import { Button } from "$lib/components/ui/button"
export let tables: GetIndexQuery$result["tables"] = []
export let bases: GetIndexQuery$result["bases"] = []
Expand Down Expand Up @@ -227,6 +235,7 @@
<div class="flex flex-col items-center space-y-4 pt-12">
<InboxIcon class="text-muted-foreground h-16 w-16" />
<p class="text-muted-foreground">No bases</p>
<Button variant="outline" on:click={() => toggleModal(CREATE_BASE_MODAL)}>Create New Base</Button>
</div>
{/if}
</nav>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import autoAnimate from "@formkit/auto-animate"
import { FieldFactory } from "@undb/table/src/modules/schema/fields/field.factory"
import { cn } from "$lib/utils"
import { LoaderCircleIcon } from "lucide-svelte"
const table = getTable()
Expand All @@ -32,9 +33,9 @@
async onSuccess() {
onSuccess()
toast.success("Update field success")
reset()
await invalidate(`table:${$table.id.value}`)
await client.invalidateQueries({ queryKey: ["records", $table.id.value] })
reset()
},
onError(error: Error) {
toast.error(error.message)
Expand Down Expand Up @@ -117,7 +118,10 @@
{/if}
</div>
<div class="flex w-full justify-end border-t pt-4">
<Button type="submit" variant="outline" class="w-full" size="sm">Submit</Button>
<Button disabled={$updateFieldMutation.isPending} type="submit" variant="outline" class="w-full" size="sm">
<LoaderCircleIcon class="mr-2 h-5 w-5 animate-spin" />
Submit</Button
>
</div>
</form>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "undb",
"version": "1.0.0-7",
"version": "1.0.0-8",
"private": true,
"scripts": {
"build": "NODE_ENV=production bun --bun turbo build",
Expand Down
2 changes: 1 addition & 1 deletion packages/authz/src/space-member/space-member.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface ISpaceMemberRepository {
findOne(spec: SpaceMemberComositeSpecification): Promise<Option<SpaceMember>>

insert(member: SpaceMember): Promise<void>
exists(email: string): Promise<boolean>
exists(spec: SpaceMemberComositeSpecification): Promise<boolean>
}

export const SPACE_MEMBER_REPOSITORY = Symbol("ISpaceMemberRepository")
Expand Down
9 changes: 7 additions & 2 deletions packages/authz/src/space-member/space-member.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import {
import { InvitationMailService, type IInvitationMailService } from "./invitation.service"
import { WithEmail, WithInvitedAt, WithRole, WithStatus } from "./invitation.specification"
import { SpaceMember, type ISpaceMemberRole } from "./space-member"
import type { SpaceMemberComositeSpecification } from "./space-member.composite-specification"
import { injectSpaceMemberRepository, type ISpaceMemberRepository } from "./space-member.repository"
import { WithSpaceMemberId, WithSpaceMemberSpaceId } from "./specifications"
import { WithSpaceMemberEmail, WithSpaceMemberId, WithSpaceMemberSpaceId } from "./specifications"

export interface ISpaceMemberService {
createMember(userId: string, spaceId: ISpaceId, role: ISpaceMemberRole): Promise<void>
Expand Down Expand Up @@ -56,7 +57,11 @@ export class SpaceMemberService implements ISpaceMemberService {
}

async invite(dto: InviteDTO, username: string): Promise<void> {
const exists = await this.spaceMemberRepository.exists(dto.email)
const existsSpec = and(
new WithSpaceMemberEmail(dto.email),
new WithSpaceMemberSpaceId(dto.spaceId),
) as Option<SpaceMemberComositeSpecification>
const exists = await this.spaceMemberRepository.exists(existsSpec.unwrap())
if (exists) {
throw new Error("Member already exists")
}
Expand Down
2 changes: 2 additions & 0 deletions packages/authz/src/space-member/space-member.visitor.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import type { ISpecVisitor } from "@undb/domain"
import type { WithSpaceMemberQ } from "./specifications"
import type { WithSpaceMemberBaseId } from "./specifications/space-member-base-id.specification"
import type { WithSpaceMemberEmail } from "./specifications/space-member-email.specification"
import type { WithSpaceMemberId } from "./specifications/space-member-id.specification"
import type { WithSpaceMemberSpaceId } from "./specifications/space-member-space-id.specification"
import type { WithSpaceMemberUserId } from "./specifications/space-member-user-id.specification"

export interface ISpaceMemberVisitor extends ISpecVisitor {
withId(q: WithSpaceMemberId): void
withQ(q: WithSpaceMemberQ): void
withEmail(q: WithSpaceMemberEmail): void
withSpaceId(s: WithSpaceMemberSpaceId): void
withUserId(s: WithSpaceMemberUserId): void
withBaseId(s: WithSpaceMemberBaseId): void
Expand Down
2 changes: 2 additions & 0 deletions packages/authz/src/space-member/specifications/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from "./space-member-email.specification"
export * from "./space-member-id.specification"
export * from "./space-member-q.specification"
export * from "./space-member-space-id.specification"
export * from "./space-member-user-id.specification"
Loading

0 comments on commit 53bef8f

Please sign in to comment.