Use custom event for file manager events
This commit is contained in:
1 parent
553bf604b3
commit
6a45a485e9
8 files changed
+119
-106
No files matched your search
@@ -2,6 +2,7 @@
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import { fs_encode_path, fs_node_icon } from "filesystem/FilesystemAPI"
|
||||
import type { FSNavigator } from "filesystem/FSNavigator";
|
||||
import { FileAction } from "./FileManagerLib";
|
||||
|
||||
let dispatch = createEventDispatcher()
|
||||
|
||||
@@ -15,8 +16,8 @@ export let hide_edit = false
|
||||
{#each $nav.children as child, index (child.path)}
|
||||
<a
|
||||
href={"/d"+fs_encode_path(child.path)}
|
||||
on:click|preventDefault={e => dispatch("node_click", {index: index, original: e})}
|
||||
on:contextmenu={e => dispatch("node_context", {index: index, original: e})}
|
||||
on:click={e => dispatch("file", {index: index, action: FileAction.Click, original: e})}
|
||||
on:contextmenu={e => dispatch("file", {index: index, action: FileAction.Context, original: e})}
|
||||
class="node"
|
||||
class:node_selected={child.fm_selected}
|
||||
class:hidden={child.name.startsWith(".") && !show_hidden}
|
||||
@@ -28,7 +29,7 @@ export let hide_edit = false
|
||||
{#if child.id}
|
||||
<a
|
||||
href="/d/{child.id}"
|
||||
on:click|preventDefault|stopPropagation={e => {dispatch("node_share_click", {index: index, original: e})}}
|
||||
on:click={e => dispatch("file", {index: index, action: FileAction.Share, original: e})}
|
||||
class="button flat action_button"
|
||||
>
|
||||
<i class="icon" title="This file / directory is shared. Click to open public link">share</i>
|
||||
@@ -36,10 +37,20 @@ export let hide_edit = false
|
||||
{/if}
|
||||
|
||||
{#if $nav.permissions.write && !hide_edit}
|
||||
<button class="action_button flat" on:click|preventDefault|stopPropagation={e => dispatch("node_settings", {index: index, original: e})}>
|
||||
<button
|
||||
class="action_button flat"
|
||||
on:click={e => dispatch("file", {index: index, action: FileAction.Edit, original: e})}
|
||||
>
|
||||
<i class="icon">edit</i>
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<button
|
||||
class="action_button flat"
|
||||
on:click={e => dispatch("file", {index: index, action: FileAction.Download, original: e})}
|
||||
>
|
||||
<i class="icon">save</i>
|
||||
</button>
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user