|
@@ -7,30 +7,70 @@
|
|
|
traverseEntries,
|
|
traverseEntries,
|
|
|
selectEntry,
|
|
selectEntry,
|
|
|
} from "$lib/state.svelte";
|
|
} from "$lib/state.svelte";
|
|
|
|
|
+ import { REQUEST_METHODS } from "$lib/types";
|
|
|
import Self from "./SidebarEntry.svelte";
|
|
import Self from "./SidebarEntry.svelte";
|
|
|
import { setSetting } from "$lib/settings.svelte";
|
|
import { setSetting } from "$lib/settings.svelte";
|
|
|
import * as DropdownMenu from "./ui/dropdown-menu/index";
|
|
import * as DropdownMenu from "./ui/dropdown-menu/index";
|
|
|
import { Button } from "./ui/button";
|
|
import { Button } from "./ui/button";
|
|
|
import DropdownMenuItem from "./ui/dropdown-menu/dropdown-menu-item.svelte";
|
|
import DropdownMenuItem from "./ui/dropdown-menu/dropdown-menu-item.svelte";
|
|
|
|
|
+ import { Badge } from "$lib/components/ui/badge/index.js";
|
|
|
import { ChevronDown, ChevronRight } from "@lucide/svelte";
|
|
import { ChevronDown, ChevronRight } from "@lucide/svelte";
|
|
|
|
|
|
|
|
const isSelected = $derived(_state.entry?.id === id);
|
|
const isSelected = $derived(_state.entry?.id === id);
|
|
|
const isParentSelected = $derived(_state.entry?.parent_id === id);
|
|
const isParentSelected = $derived(_state.entry?.parent_id === id);
|
|
|
|
|
+
|
|
|
|
|
+ function onCtrlClick(e) {
|
|
|
|
|
+ if (!e.ctrlKey) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (_state.indexes[id].open) {
|
|
|
|
|
+ traverseEntries(id, (entry) => {
|
|
|
|
|
+ entry.open = false;
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ traverseEntries(id, (entry) => {
|
|
|
|
|
+ entry.open = true;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function onRequestClick(e) {
|
|
|
|
|
+ e.stopPropagation();
|
|
|
|
|
+
|
|
|
|
|
+ if (onCtrlClick(e)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ selectEntry(id);
|
|
|
|
|
+ onSelect();
|
|
|
|
|
+ setSetting("lastEntry", _state.indexes[id]);
|
|
|
|
|
+ }
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
-<div class="p-0 m-0" style={`margin-left: ${level}rem`}>
|
|
|
|
|
|
|
+<div
|
|
|
|
|
+ class="pl-1 ml-1 border-l border-secondary"
|
|
|
|
|
+ style={`margin-left: ${level}px`}
|
|
|
|
|
+>
|
|
|
<div
|
|
<div
|
|
|
- class="border-l m-0 flex items-center transition-colors"
|
|
|
|
|
|
|
+ class="w-full flex items-center transition-colors"
|
|
|
class:bg-primary={isSelected}
|
|
class:bg-primary={isSelected}
|
|
|
class:bg-secondary={isParentSelected}
|
|
class:bg-secondary={isParentSelected}
|
|
|
>
|
|
>
|
|
|
{#if _state.indexes[id]!!.type === "Collection"}
|
|
{#if _state.indexes[id]!!.type === "Collection"}
|
|
|
|
|
+ <!-- COLLECTION TOGGLE OPEN -->
|
|
|
|
|
+
|
|
|
{#if _state.indexes[id]!!.open}
|
|
{#if _state.indexes[id]!!.open}
|
|
|
<Button
|
|
<Button
|
|
|
class="rounded-none cursor-pointer w-fit px-1"
|
|
class="rounded-none cursor-pointer w-fit px-1"
|
|
|
variant="ghost"
|
|
variant="ghost"
|
|
|
size="icon-sm"
|
|
size="icon-sm"
|
|
|
- onclick={() => {
|
|
|
|
|
|
|
+ onclick={(e) => {
|
|
|
|
|
+ if (onCtrlClick(e)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
_state.indexes[id].open = !_state.indexes[id].open;
|
|
_state.indexes[id].open = !_state.indexes[id].open;
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
@@ -41,38 +81,31 @@
|
|
|
class="rounded-none cursor-pointer w-fit px-1"
|
|
class="rounded-none cursor-pointer w-fit px-1"
|
|
|
variant="ghost"
|
|
variant="ghost"
|
|
|
size="icon-sm"
|
|
size="icon-sm"
|
|
|
- onclick={() => {
|
|
|
|
|
|
|
+ onclick={(e) => {
|
|
|
|
|
+ if (onCtrlClick(e)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
_state.indexes[id].open = !_state.indexes[id].open;
|
|
_state.indexes[id].open = !_state.indexes[id].open;
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
<ChevronRight />
|
|
<ChevronRight />
|
|
|
</Button>
|
|
</Button>
|
|
|
{/if}
|
|
{/if}
|
|
|
|
|
+ {:else if _state.indexes[id]!!.type === "Request"}
|
|
|
|
|
+ <p
|
|
|
|
|
+ onclick={(e) => onRequestClick(e)}
|
|
|
|
|
+ class={`cursor-pointer scale-75 text-xs text-center
|
|
|
|
|
+ ${REQUEST_METHODS.find((m) => m.method === _state.indexes[id].method)?.textColor}`}
|
|
|
|
|
+ >
|
|
|
|
|
+ {_state.indexes[id]!!.method}
|
|
|
|
|
+ </p>
|
|
|
{/if}
|
|
{/if}
|
|
|
|
|
|
|
|
<p
|
|
<p
|
|
|
- class="w-full cursor-pointer py-1"
|
|
|
|
|
|
|
+ class="w-full cursor-pointer py-1 ml-1"
|
|
|
onclick={(e) => {
|
|
onclick={(e) => {
|
|
|
- e.stopPropagation();
|
|
|
|
|
-
|
|
|
|
|
- if (e.ctrlKey) {
|
|
|
|
|
- if (_state.indexes[id].open) {
|
|
|
|
|
- traverseEntries(id, (entry) => {
|
|
|
|
|
- entry.open = false;
|
|
|
|
|
- });
|
|
|
|
|
- } else {
|
|
|
|
|
- traverseEntries(id, (entry) => {
|
|
|
|
|
- entry.open = true;
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- selectEntry(id);
|
|
|
|
|
- onSelect();
|
|
|
|
|
- setSetting("lastEntry", _state.indexes[id]);
|
|
|
|
|
|
|
+ onRequestClick(e);
|
|
|
}}
|
|
}}
|
|
|
- class:ml-2={_state.indexes[id].type === "Request"}
|
|
|
|
|
>
|
|
>
|
|
|
{_state.indexes[id].name ||
|
|
{_state.indexes[id].name ||
|
|
|
_state.indexes[id].type + "(" + _state.indexes[id].id + ")"}
|
|
_state.indexes[id].type + "(" + _state.indexes[id].id + ")"}
|
|
@@ -103,7 +136,7 @@
|
|
|
|
|
|
|
|
{#if _state.indexes[id].open && _state.children[id]?.length > 0}
|
|
{#if _state.indexes[id].open && _state.children[id]?.length > 0}
|
|
|
{#each _state.children[id] as child}
|
|
{#each _state.children[id] as child}
|
|
|
- <Self id={child} level={level + 0.1} {onSelect} />
|
|
|
|
|
|
|
+ <Self id={child} level={level + 2} {onSelect} />
|
|
|
{/each}
|
|
{/each}
|
|
|
{/if}
|
|
{/if}
|
|
|
</div>
|
|
</div>
|