show path of selected item in filebrowser
This commit is contained in:
Vendored
+1
@@ -525,6 +525,7 @@ body[showing-chat] #chat-page-wrapper {
|
|||||||
.file-browser code {
|
.file-browser code {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
font-size: .9rem;
|
||||||
}
|
}
|
||||||
@media (min-width: 640px) {
|
@media (min-width: 640px) {
|
||||||
.file-browser > div {
|
.file-browser > div {
|
||||||
|
|||||||
Vendored
+23
-6
@@ -1143,6 +1143,13 @@
|
|||||||
///
|
///
|
||||||
connectButtonAudioLabel: "connect"
|
connectButtonAudioLabel: "connect"
|
||||||
},
|
},
|
||||||
|
fileBrowser: {
|
||||||
|
noItemSelected: "No item selected",
|
||||||
|
notAFile: "(not a file)",
|
||||||
|
contentEmpty: "(empty)",
|
||||||
|
path: "Path",
|
||||||
|
content: "Content"
|
||||||
|
},
|
||||||
chatPage: {
|
chatPage: {
|
||||||
closeChatAudioLabe: "close chat",
|
closeChatAudioLabe: "close chat",
|
||||||
chatSettingsAudioLabel: "chat settings",
|
chatSettingsAudioLabel: "chat settings",
|
||||||
@@ -2129,16 +2136,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/View/Components/fileBrowser.tsx
|
// src/View/Components/fileBrowser.tsx
|
||||||
function FileBrowser(storageModel2, selectedPath) {
|
function FileBrowser(storageModel2, selectedPath, didMakeChanges) {
|
||||||
const fileContent = createProxyState([selectedPath], () => {
|
const fileContentToShow = createProxyState([selectedPath], () => {
|
||||||
const path = StorageModel.stringToPathComponents(selectedPath.value);
|
const path = StorageModel.stringToPathComponents(selectedPath.value);
|
||||||
const content = storageModel2.restore(path);
|
const content = storageModel2.restore(path);
|
||||||
return content || "";
|
return (content ?? translations.fileBrowser.notAFile) || translations.fileBrowser.contentEmpty;
|
||||||
});
|
});
|
||||||
const selectedFileName = createProxyState(
|
const selectedFileName = createProxyState(
|
||||||
[selectedPath],
|
[selectedPath],
|
||||||
() => StorageModel.getFileNameFromString(selectedPath.value) ?? PATH_COMPONENT_SEPARATOR
|
() => StorageModel.getFileNameFromString(selectedPath.value) ?? PATH_COMPONENT_SEPARATOR
|
||||||
);
|
);
|
||||||
|
const detailView = createProxyState([selectedPath], () => {
|
||||||
|
if (selectedPath.value == PATH_COMPONENT_SEPARATOR)
|
||||||
|
return /* @__PURE__ */ createElement("span", { class: "secondary" }, translations.fileBrowser.noItemSelected);
|
||||||
|
return /* @__PURE__ */ createElement("div", { class: "flex-column gap" }, /* @__PURE__ */ createElement("div", { class: "tile flex-no" }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("b", null, translations.fileBrowser.path), /* @__PURE__ */ createElement("span", { class: "break-all", "subscribe:innerText": selectedPath }))), /* @__PURE__ */ createElement("div", { class: "tile flex-no" }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("b", null, translations.fileBrowser.content), /* @__PURE__ */ createElement("code", { "subscribe:innerText": fileContentToShow }))));
|
||||||
|
});
|
||||||
const view = /* @__PURE__ */ createElement("div", { class: "file-browser" }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("div", { class: "scroll-area" }, DirectoryItemList(
|
const view = /* @__PURE__ */ createElement("div", { class: "file-browser" }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("div", { class: "scroll-area" }, DirectoryItemList(
|
||||||
storageModel2,
|
storageModel2,
|
||||||
PATH_COMPONENT_SEPARATOR,
|
PATH_COMPONENT_SEPARATOR,
|
||||||
@@ -2149,7 +2161,7 @@
|
|||||||
class: "ellipsis",
|
class: "ellipsis",
|
||||||
"subscribe:innerText": selectedFileName
|
"subscribe:innerText": selectedFileName
|
||||||
}
|
}
|
||||||
), /* @__PURE__ */ createElement("span", { class: "icon" }, "arrow_forward")))), /* @__PURE__ */ createElement("div", { class: "scroll-area" }, /* @__PURE__ */ createElement("code", { "subscribe:innerText": fileContent })));
|
), /* @__PURE__ */ createElement("span", { class: "icon" }, "arrow_forward")))), /* @__PURE__ */ createElement("div", { class: "scroll-area", "children:set": detailView }));
|
||||||
function scrollToDetails() {
|
function scrollToDetails() {
|
||||||
view.scrollLeft = view.scrollWidth;
|
view.scrollLeft = view.scrollWidth;
|
||||||
}
|
}
|
||||||
@@ -2160,7 +2172,8 @@
|
|||||||
function StorageModal(storageViewModel2) {
|
function StorageModal(storageViewModel2) {
|
||||||
return /* @__PURE__ */ createElement("div", { class: "modal", "toggle:open": storageViewModel2.isShowingStorageModal }, /* @__PURE__ */ createElement("div", { style: "max-width: 64rem" }, /* @__PURE__ */ createElement("main", { class: "padding-0" }, FileBrowser(
|
return /* @__PURE__ */ createElement("div", { class: "modal", "toggle:open": storageViewModel2.isShowingStorageModal }, /* @__PURE__ */ createElement("div", { style: "max-width: 64rem" }, /* @__PURE__ */ createElement("main", { class: "padding-0" }, FileBrowser(
|
||||||
storageViewModel2.storageModel,
|
storageViewModel2.storageModel,
|
||||||
storageViewModel2.selectedPath
|
storageViewModel2.selectedPath,
|
||||||
|
storageViewModel2.didMakeChanges
|
||||||
)), /* @__PURE__ */ createElement("button", { "on:click": storageViewModel2.hideStorageModal }, translations.general.closeButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "close"))));
|
)), /* @__PURE__ */ createElement("button", { "on:click": storageViewModel2.hideStorageModal }, translations.general.closeButton, /* @__PURE__ */ createElement("span", { class: "icon" }, "close"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2169,12 +2182,16 @@
|
|||||||
storageModel;
|
storageModel;
|
||||||
// state
|
// state
|
||||||
isShowingStorageModal = new State(false);
|
isShowingStorageModal = new State(false);
|
||||||
selectedPath = new State("\\");
|
selectedPath = new State(PATH_COMPONENT_SEPARATOR);
|
||||||
|
didMakeChanges = new State(false);
|
||||||
// view methods
|
// view methods
|
||||||
showStorageModal = () => {
|
showStorageModal = () => {
|
||||||
this.isShowingStorageModal.value = true;
|
this.isShowingStorageModal.value = true;
|
||||||
};
|
};
|
||||||
hideStorageModal = () => {
|
hideStorageModal = () => {
|
||||||
|
if (this.didMakeChanges.value == true) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
this.isShowingStorageModal.value = false;
|
this.isShowingStorageModal.value = false;
|
||||||
};
|
};
|
||||||
// init
|
// init
|
||||||
|
|||||||
@@ -45,6 +45,8 @@
|
|||||||
.file-browser code {
|
.file-browser code {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
|
font-size: .9rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 640px) {
|
@media (min-width: 640px) {
|
||||||
|
|||||||
@@ -7,16 +7,21 @@ import StorageModel, {
|
|||||||
} from "../../Model/storageModel";
|
} from "../../Model/storageModel";
|
||||||
|
|
||||||
import { DirectoryItemList } from "./directoryItemList";
|
import { DirectoryItemList } from "./directoryItemList";
|
||||||
|
import { translations } from "../translations";
|
||||||
|
|
||||||
export function FileBrowser(
|
export function FileBrowser(
|
||||||
storageModel: StorageModel,
|
storageModel: StorageModel,
|
||||||
selectedPath: React.State<string>
|
selectedPath: React.State<string>,
|
||||||
|
didMakeChanges: React.State<boolean>
|
||||||
) {
|
) {
|
||||||
// state
|
// state
|
||||||
const fileContent = React.createProxyState([selectedPath], () => {
|
const fileContentToShow = React.createProxyState([selectedPath], () => {
|
||||||
const path = StorageModel.stringToPathComponents(selectedPath.value);
|
const path = StorageModel.stringToPathComponents(selectedPath.value);
|
||||||
const content = storageModel.restore(path);
|
const content = storageModel.restore(path);
|
||||||
return content || "";
|
return (
|
||||||
|
(content ?? translations.fileBrowser.notAFile) ||
|
||||||
|
translations.fileBrowser.contentEmpty
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectedFileName = React.createProxyState(
|
const selectedFileName = React.createProxyState(
|
||||||
@@ -27,6 +32,30 @@ export function FileBrowser(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// view
|
// view
|
||||||
|
const detailView = React.createProxyState([selectedPath], () => {
|
||||||
|
if (selectedPath.value == PATH_COMPONENT_SEPARATOR)
|
||||||
|
return (
|
||||||
|
<span class="secondary">{translations.fileBrowser.noItemSelected}</span>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class="flex-column gap">
|
||||||
|
<div class="tile flex-no">
|
||||||
|
<div>
|
||||||
|
<b>{translations.fileBrowser.path}</b>
|
||||||
|
<span class="break-all" subscribe:innerText={selectedPath}></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="tile flex-no">
|
||||||
|
<div>
|
||||||
|
<b>{translations.fileBrowser.content}</b>
|
||||||
|
<code subscribe:innerText={fileContentToShow}></code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
const view = (
|
const view = (
|
||||||
<div class="file-browser">
|
<div class="file-browser">
|
||||||
<div>
|
<div>
|
||||||
@@ -47,9 +76,7 @@ export function FileBrowser(
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="scroll-area">
|
<div class="scroll-area" children:set={detailView}></div>
|
||||||
<code subscribe:innerText={fileContent}></code>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import * as React from "bloatless-react";
|
import * as React from "bloatless-react";
|
||||||
|
|
||||||
import { DirectoryItemList } from "../Components/directoryItemList";
|
|
||||||
import { FileBrowser } from "../Components/fileBrowser";
|
import { FileBrowser } from "../Components/fileBrowser";
|
||||||
import StorageModel from "../../Model/storageModel";
|
|
||||||
import StorageViewModel from "../../ViewModel/storageViewModel";
|
import StorageViewModel from "../../ViewModel/storageViewModel";
|
||||||
import { translations } from "../translations";
|
import { translations } from "../translations";
|
||||||
|
|
||||||
@@ -13,7 +11,8 @@ export function StorageModal(storageViewModel: StorageViewModel) {
|
|||||||
<main class="padding-0">
|
<main class="padding-0">
|
||||||
{FileBrowser(
|
{FileBrowser(
|
||||||
storageViewModel.storageModel,
|
storageViewModel.storageModel,
|
||||||
storageViewModel.selectedPath
|
storageViewModel.selectedPath,
|
||||||
|
storageViewModel.didMakeChanges
|
||||||
)}
|
)}
|
||||||
</main>
|
</main>
|
||||||
<button on:click={storageViewModel.hideStorageModal}>
|
<button on:click={storageViewModel.hideStorageModal}>
|
||||||
|
|||||||
@@ -62,6 +62,15 @@ const englishTranslations = {
|
|||||||
connectButtonAudioLabel: "connect",
|
connectButtonAudioLabel: "connect",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
fileBrowser: {
|
||||||
|
noItemSelected: "No item selected",
|
||||||
|
notAFile: "(not a file)",
|
||||||
|
contentEmpty: "(empty)",
|
||||||
|
|
||||||
|
path: "Path",
|
||||||
|
content: "Content",
|
||||||
|
},
|
||||||
|
|
||||||
chatPage: {
|
chatPage: {
|
||||||
closeChatAudioLabe: "close chat",
|
closeChatAudioLabe: "close chat",
|
||||||
chatSettingsAudioLabel: "chat settings",
|
chatSettingsAudioLabel: "chat settings",
|
||||||
|
|||||||
@@ -1,22 +1,26 @@
|
|||||||
import * as React from "bloatless-react";
|
import * as React from "bloatless-react";
|
||||||
|
|
||||||
import StorageModel from "../Model/storageModel";
|
import StorageModel, { PATH_COMPONENT_SEPARATOR } from "../Model/storageModel";
|
||||||
|
|
||||||
export default class StorageViewModel {
|
export default class StorageViewModel {
|
||||||
storageModel: StorageModel;
|
storageModel: StorageModel;
|
||||||
|
|
||||||
// state
|
// state
|
||||||
isShowingStorageModal: React.State<boolean> = new React.State(false);
|
isShowingStorageModal: React.State<boolean> = new React.State(false);
|
||||||
selectedPath: React.State<string> = new React.State("\\");
|
selectedPath: React.State<string> = new React.State(PATH_COMPONENT_SEPARATOR);
|
||||||
|
didMakeChanges: React.State<boolean> = new React.State(false);
|
||||||
|
|
||||||
// view methods
|
// view methods
|
||||||
showStorageModal = (): void => {
|
showStorageModal = (): void => {
|
||||||
this.isShowingStorageModal.value = true;
|
this.isShowingStorageModal.value = true;
|
||||||
}
|
};
|
||||||
|
|
||||||
hideStorageModal = (): void => {
|
hideStorageModal = (): void => {
|
||||||
|
if (this.didMakeChanges.value == true) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
this.isShowingStorageModal.value = false;
|
this.isShowingStorageModal.value = false;
|
||||||
}
|
};
|
||||||
|
|
||||||
// init
|
// init
|
||||||
constructor(storageModel: StorageModel) {
|
constructor(storageModel: StorageModel) {
|
||||||
|
|||||||
Reference in New Issue
Block a user