Skip to content

Commit

Permalink
refactor: central dialog variable, remove entity context
Browse files Browse the repository at this point in the history
  • Loading branch information
safwansamsudeen committed Jan 16, 2025
1 parent e58299d commit 7712542
Show file tree
Hide file tree
Showing 19 changed files with 134 additions and 204 deletions.
19 changes: 1 addition & 18 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

<template v-else>
<!-- Main container no scroll -->
<div
class="flex w-screen h-screen antialiased overflow-hidden"
@contextmenu="handleDefaultContext($event)"
>
<div class="flex w-screen h-screen antialiased overflow-hidden">
<!-- Main container with scroll -->
<div class="h-full w-full flex flex-col">
<SearchPopup
Expand Down Expand Up @@ -138,19 +135,6 @@ export default {
await initTelemetry()
},
methods: {
handleDefaultContext(event) {
if (this.$route.meta.documentPage) {
return
} else if (
this.$store.state.entityInfo[0]?.mime_type ===
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" &&
this.$route.name === "File"
) {
return
} else {
return event.preventDefault()
}
},
async currentPageEmitTrigger() {
this.emitter.emit("fetchFolderContents")
},
Expand Down Expand Up @@ -216,7 +200,6 @@ export default {
url: "drive.utils.users.drive_user_level",
cache: "is_admin",
onSuccess(data) {
console.log(data)
this.$store.state.user.role = data
},
onError(error) {
Expand Down
34 changes: 0 additions & 34 deletions frontend/src/components/DriveToolBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,32 +97,6 @@
</div>
</div>
</div>
<div v-if="multi" class="flex gap-3">
<Button
v-for="(item, index) in actionItems.filter((i) => i.important)"
:key="index"
:loading="actionLoading"
:disabled="actionLoading"
@click="item.onClick"
>
<FeatherIcon
v-if="typeof item.icon === 'string'"
:name="item.icon"
class="h-4 w-4"
:class="
item.label === 'Unfavourite'
? 'stroke-yellow-500 fill-yellow-500'
: ''
"
/>
<component
:is="item.icon"
v-else
class="h-4 w-auto text-gray-800"
:class="item.danger ? 'text-red-500' : ''"
/>
</Button>
</div>
<div class="ml-auto flex gap-x-1 items-center">
<Dropdown
v-if="columnHeaders"
Expand Down Expand Up @@ -219,18 +193,10 @@ export default {
Unknown,
},
props: {
multi: {
type: Boolean,
default: false,
},
breadcrumbs: {
type: Array,
default: null,
},
actionItems: {
type: Array,
default: null,
},
columnHeaders: {
type: Array,
default: null,
Expand Down
16 changes: 7 additions & 9 deletions frontend/src/components/EmptyEntityContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default {
type: Array,
default: null,
},
entityContext: {
event: {
type: Object,
default: null,
},
Expand Down Expand Up @@ -83,21 +83,19 @@ export default {
document.querySelector("#currentPage").classList.remove("disable-scroll")
},
calculateY() {
if (this.entityContext.y >= this.parentHeight - this.childHeight) {
if (this.event.y >= this.parentHeight - this.childHeight) {
return (this.$refs.emptyContextMenu.style.top =
this.entityContext.y - this.childHeight + "px")
this.event.y - this.childHeight + "px")
} else {
return (this.$refs.emptyContextMenu.style.top =
this.entityContext.y + "px")
return (this.$refs.emptyContextMenu.style.top = this.event.y + "px")
}
},
calculateX() {
if (this.entityContext.x >= this.parentWidth - this.childWidth) {
if (this.event.x >= this.parentWidth - this.childWidth) {
return (this.$refs.emptyContextMenu.style.left =
this.entityContext.x - this.childWidth + "px")
this.event.x - this.childWidth + "px")
} else {
return (this.$refs.emptyContextMenu.style.left =
this.entityContext.x + "px")
return (this.$refs.emptyContextMenu.style.left = this.event.x + "px")
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/GeneralDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default {
},
open: {
get() {
return this.modelValue
return this.modelValue === this.for
},
set(value) {
this.$emit("update:modelValue", value)
Expand Down
16 changes: 6 additions & 10 deletions frontend/src/components/ListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
v-for="row in group.rows"
:key="row.name"
:row="row"
@dblclick="() => openEntity(row)"
@dblclick="openFile(row)"
>
<template #="{ column, item }">
<ListRowItem
Expand Down Expand Up @@ -116,9 +116,8 @@ import { useInfiniteScroll } from "@vueuse/core"
import { useStore } from "vuex"
import { useRoute } from "vue-router"
import { ref, computed, h } from "vue"
import { toggleFav } from "@/resources/files"
import { toast, toastError } from "@/utils/toasts.js"
import Folder from "./MimeIcons/Folder.vue"
import { openEntity } from "@/utils/files"
const store = useStore()
const route = useRoute()
Expand All @@ -128,10 +127,6 @@ const props = defineProps({
type: Object,
default: null,
},
selectedEntities: {
type: Array,
default: null,
},
overrideCanLoadMore: {
type: Boolean,
default: false,
Expand Down Expand Up @@ -203,7 +198,6 @@ const selectedColumns = [
].filter((k) => (k.enabled ? k.enabled(route.name) : true))
const emit = defineEmits([
"openEntity",
"showEntityContext",
"showEmptyEntityContext",
"fetchFolderContents",
Expand All @@ -217,8 +211,10 @@ useInfiniteScroll(container, () => emit("updateOffset"), {
canLoadMore: () => props.overrideCanLoadMore,
})
const openEntity = () =>
store.commit("setEntityInfo", [entity]) && emit("openEntity", entity)
function openFile(entity) {
store.commit("setEntityInfo", [entity])
openEntity(entity)
}
function handleAction(selectedItems, action) {
store.commit("setEntityInfo", selectedItems)
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/MoveDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ const store = useStore()
const currentFolder = ref(store.state.homeFolderID)
const emit = defineEmits(["update:modelValue", "success"])
const props = defineProps({
modelValue: {
type: String,
required: true,
},
entity: {
type: Object,
required: false,
Expand All @@ -166,7 +170,7 @@ const props = defineProps({
const open = computed({
get() {
return props.modelValue
return props.modelValue === "m"
},
set(newValue) {
emit("update:modelValue", newValue)
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ export default {
data() {
return {
previewEntity: null,
showPreview: false,
showNewFolderDialog: false,
showRenameDialog: false,
newEntityOptions: [
Expand Down Expand Up @@ -287,7 +286,6 @@ export default {
computed: {
isButtonDisabled() {
if (document.getElementById("headlessui-portal-root")) {
console.log("TRUE")
return true
}
console.log(document.getElementById("headlessui-portal-root"))
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/NewFolderDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default {
computed: {
open: {
get() {
return this.modelValue
return this.modelValue === "f"
},
set(value) {
this.$emit("update:modelValue", value)
Expand Down
Loading

0 comments on commit 7712542

Please sign in to comment.