Update to svelte 5
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
import { fs_rename, fs_update, type FSNode, type NodeOptions } from "lib/FilesystemAPI";
|
||||
import Modal from "util/Modal.svelte";
|
||||
import BrandingOptions from "./BrandingOptions.svelte";
|
||||
@@ -9,13 +10,18 @@ import AccessControl from "./AccessControl.svelte";
|
||||
import type { FSNavigator } from "filesystem/FSNavigator";
|
||||
import { loading_finish, loading_start } from "lib/Loading";
|
||||
|
||||
export let nav: FSNavigator
|
||||
let file: FSNode = {} as FSNode
|
||||
let options: NodeOptions = {} as NodeOptions
|
||||
let file: FSNode = $state({} as FSNode)
|
||||
let options: NodeOptions = $state({} as NodeOptions)
|
||||
|
||||
let custom_css = ""
|
||||
let custom_css = $state("")
|
||||
|
||||
export let visible: boolean
|
||||
let {
|
||||
nav,
|
||||
visible = $bindable()
|
||||
}: {
|
||||
nav: FSNavigator;
|
||||
visible: boolean;
|
||||
} = $props();
|
||||
|
||||
// Open the edit window. Argument 1 is the file to edit, 2 is whether the file
|
||||
// should be opened after the user finishes editing and 3 is the default tab
|
||||
@@ -54,11 +60,11 @@ export const edit = (f: FSNode, oae = false, open_tab = "") => {
|
||||
visible = true
|
||||
}
|
||||
|
||||
let tab = "file"
|
||||
let open_after_edit = false
|
||||
let tab = $state("file")
|
||||
let open_after_edit = $state(false)
|
||||
|
||||
let new_name = ""
|
||||
let branding_enabled = false
|
||||
let new_name = $state("")
|
||||
let branding_enabled = $state(false)
|
||||
|
||||
const save = async (keep_editing = false) => {
|
||||
console.debug("Saving file", file.path)
|
||||
@@ -106,27 +112,27 @@ const save = async (keep_editing = false) => {
|
||||
|
||||
<Modal bind:visible={visible} title="Edit {file.name}" width="800px" form="edit_form" style="color: var(--body_text_color); {custom_css}">
|
||||
<div class="tab_bar">
|
||||
<button class:button_highlight={tab === "file"} on:click={() => tab = "file"}>
|
||||
<button class:button_highlight={tab === "file"} onclick={() => tab = "file"}>
|
||||
<i class="icon">edit</i>
|
||||
Properties
|
||||
</button>
|
||||
<button class:button_highlight={tab === "share"} on:click={() => tab = "share"}>
|
||||
<button class:button_highlight={tab === "share"} onclick={() => tab = "share"}>
|
||||
<i class="icon">share</i>
|
||||
Sharing
|
||||
</button>
|
||||
{#if $nav.permissions.owner}
|
||||
<button class:button_highlight={tab === "access"} on:click={() => tab = "access"}>
|
||||
<button class:button_highlight={tab === "access"} onclick={() => tab = "access"}>
|
||||
<i class="icon">key</i>
|
||||
Access control
|
||||
</button>
|
||||
{/if}
|
||||
<button class:button_highlight={tab === "branding"} on:click={() => tab = "branding"}>
|
||||
<button class:button_highlight={tab === "branding"} onclick={() => tab = "branding"}>
|
||||
<i class="icon">palette</i>
|
||||
Branding
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form id="edit_form" on:submit|preventDefault={() => save(false)}></form>
|
||||
<form id="edit_form" onsubmit={preventDefault(() => save(false))}></form>
|
||||
|
||||
<div class="tab_content">
|
||||
{#if tab === "file"}
|
||||
@@ -138,7 +144,10 @@ const save = async (keep_editing = false) => {
|
||||
bind:open_after_edit
|
||||
/>
|
||||
{:else if tab === "share"}
|
||||
<SharingOptions bind:file bind:options on:save={() => save(true)} />
|
||||
<SharingOptions
|
||||
bind:file
|
||||
bind:options
|
||||
/>
|
||||
{:else if tab === "access"}
|
||||
<AccessControl bind:options />
|
||||
{:else if tab === "branding"}
|
||||
|
||||
Reference in New Issue
Block a user