From ec4ae09bf6d46a1ac8407ab37930d3292cb01d71 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Fri, 10 Mar 2023 12:45:04 -0800 Subject: [PATCH] refactor: move node-share to app --- src/App.vue | 9 ++++++--- src/components/Sidebar.vue | 1 + src/components/modal/NodeShareModal.vue | 20 ++++--------------- src/components/top-matter/FolderTopMatter.vue | 16 ++++++++++----- src/main.ts | 1 + 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/App.vue b/src/App.vue index 4422e7cf..4e64aab9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -46,7 +46,8 @@ - + + @@ -68,7 +69,8 @@ import Settings from "./components/Settings.vue"; import FirstStart from "./components/FirstStart.vue"; import Metadata from "./components/Metadata.vue"; import Sidebar from "./components/Sidebar.vue"; -import EditMetadata from "./components/modal/EditMetadataModal.vue"; +import EditMetadataModal from "./components/modal/EditMetadataModal.vue"; +import NodeShareModal from "./components/modal/NodeShareModal.vue"; import ImageMultiple from "vue-material-design-icons/ImageMultiple.vue"; import FolderIcon from "vue-material-design-icons/Folder.vue"; @@ -95,7 +97,8 @@ export default defineComponent({ Settings, FirstStart, Sidebar, - EditMetadata, + EditMetadataModal, + NodeShareModal, ImageMultiple, FolderIcon, diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index 8e191b00..1b6e9c8a 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -150,6 +150,7 @@ aside.app-sidebar { // Prevent sidebar from becoming too big aside.app-sidebar { max-width: 360px !important; + position: fixed !important; @media (max-width: 512px) { max-width: unset !important; diff --git a/src/components/modal/NodeShareModal.vue b/src/components/modal/NodeShareModal.vue index 1288e3f4..fb17bec5 100644 --- a/src/components/modal/NodeShareModal.vue +++ b/src/components/modal/NodeShareModal.vue @@ -91,7 +91,6 @@ import { API } from "../../services/API"; import CloseIcon from "vue-material-design-icons/Close.vue"; import LinkIcon from "vue-material-design-icons/LinkVariant.vue"; -import { IPhoto } from "../../types"; type IShare = { id: string; @@ -132,24 +131,13 @@ export default defineComponent({ }, created() { - subscribe("update:share", this.refreshUrls); - }, - - beforeDestroy() { - unsubscribe("update:share", this.refreshUrls); + globalThis.shareNodeLink = (path: string) => { + this.filename = path; + this.open(); + }; }, methods: { - openFolder() { - this.filename = utils.getFolderRoutePath(this.config_foldersPath); - this.open(); - }, - - openPhoto(photo: IPhoto) { - this.filename = photo.filename; - this.open(); - }, - open() { this.show = true; globalThis.mSidebar.setTab("sharing"); diff --git a/src/components/top-matter/FolderTopMatter.vue b/src/components/top-matter/FolderTopMatter.vue index 5eef2a08..736b92db 100644 --- a/src/components/top-matter/FolderTopMatter.vue +++ b/src/components/top-matter/FolderTopMatter.vue @@ -32,7 +32,7 @@ {{ t("memories", "Share folder") }} @@ -40,8 +40,6 @@ - - @@ -49,6 +47,7 @@ import { defineComponent } from "vue"; import { TopMatterFolder, TopMatterType } from "../../types"; +import UserConfig from "../../mixins/UserConfig"; const NcBreadcrumbs = () => import("@nextcloud/vue/dist/Components/NcBreadcrumbs"); const NcBreadcrumb = () => @@ -57,7 +56,7 @@ import NcActions from "@nextcloud/vue/dist/Components/NcActions"; import NcActionButton from "@nextcloud/vue/dist/Components/NcActionButton"; import NcActionRouter from "@nextcloud/vue/dist/Components/NcActionRouter"; -import NodeShareModal from "../modal/NodeShareModal.vue"; +import * as utils from "../../services/Utils"; import HomeIcon from "vue-material-design-icons/Home.vue"; import ShareIcon from "vue-material-design-icons/ShareVariant.vue"; @@ -72,13 +71,14 @@ export default defineComponent({ NcActions, NcActionButton, NcActionRouter, - NodeShareModal, HomeIcon, ShareIcon, TimelineIcon, FoldersIcon, }, + mixins: [UserConfig], + data: () => ({ topMatter: null as TopMatterFolder | null, recursive: false, @@ -119,6 +119,12 @@ export default defineComponent({ this.recursive = false; } }, + + share() { + globalThis.shareNodeLink( + utils.getFolderRoutePath(this.config_foldersPath) + ); + }, }, }); diff --git a/src/main.ts b/src/main.ts index 40d6baa8..6bf34e6c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -23,6 +23,7 @@ declare global { var OCP: Nextcloud.v24.OCP; var editMetadata: (photos: IPhoto[], sections?: number[]) => void; + var shareNodeLink: (path: string) => void; var mSidebar: { open: (filename: IFileInfo) => void;