-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6659 from owncloud/spaces-context-menus
Refactor spaces context menus
- Loading branch information
Showing
30 changed files
with
570 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Enhancement: Spaces context menus | ||
|
||
Spaces context menus have been adjusted visibly to match the other available context menus. | ||
Also, the corresponding component has been abstracted in the course of this. This cleans up a lot of (duplicated) code across the spaces views and makes future adjustments easier. | ||
|
||
https://github.com/owncloud/web/pull/6659 | ||
https://github.com/owncloud/web/issues/6634 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
packages/web-app-files/src/components/ContextActionMenu.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<template> | ||
<div id="oc-files-context-menu"> | ||
<oc-list | ||
v-for="(section, sectionIndex) in menuSections" | ||
:id="`oc-files-context-actions-${section.name}`" | ||
:key="`section-${section.name}-list`" | ||
class="oc-files-context-actions" | ||
:class="getSectionClasses(sectionIndex)" | ||
> | ||
<action-menu-item | ||
v-for="(action, actionIndex) in section.items" | ||
:key="`section-${section.name}-action-${actionIndex}`" | ||
:action="action" | ||
:items="items" | ||
class="oc-files-context-action oc-px-s oc-rounded" | ||
/> | ||
</oc-list> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import ActionMenuItem from './ActionMenuItem.vue' | ||
export default { | ||
name: 'ContextActionMenu', | ||
components: { ActionMenuItem }, | ||
props: { | ||
menuSections: { | ||
type: Array, | ||
required: true | ||
}, | ||
// items can e.g. be currentFolder (breadcrumbs) or selectedResources (resourceTable) | ||
items: { | ||
type: Array, | ||
required: true | ||
} | ||
}, | ||
methods: { | ||
getSectionClasses(index) { | ||
const classes = [] | ||
if (!this.menuSections.length) { | ||
return classes | ||
} | ||
if (index < this.menuSections.length - 1) { | ||
classes.push('oc-pb-s') | ||
} | ||
if (index > 0) { | ||
classes.push('oc-pt-s') | ||
} | ||
if (index < this.menuSections.length - 1) { | ||
classes.push('oc-files-context-actions-border') | ||
} | ||
return classes | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss"> | ||
.oc-files-context-actions { | ||
text-align: left; | ||
white-space: normal; | ||
> li { | ||
padding: 6px; | ||
&:hover { | ||
background-color: var(--oc-color-background-hover); | ||
} | ||
a, | ||
button, | ||
span { | ||
color: var(--oc-color-swatch-passive-default) !important; | ||
display: inline-flex; | ||
font-weight: normal !important; | ||
gap: 10px; | ||
justify-content: flex-start; | ||
vertical-align: top; | ||
width: 100%; | ||
text-align: left; | ||
&:hover { | ||
color: var(--oc-color-swatch-passive-default); | ||
text-decoration: none !important; | ||
} | ||
} | ||
} | ||
&-border { | ||
border-bottom: 1px solid var(--oc-color-border); | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 176 additions & 0 deletions
176
packages/web-app-files/src/components/Spaces/SpaceContextActions.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
<template> | ||
<div> | ||
<context-action-menu :menu-sections="menuSections" :items="items" /> | ||
<quota-modal | ||
v-if="quotaModalIsOpen" | ||
:cancel="closeQuotaModal" | ||
:space="quotaModalSelectedSpace" | ||
/> | ||
<readme-content-modal | ||
v-if="readmeContentModalIsOpen" | ||
:cancel="closeReadmeContentModal" | ||
:space="items[0]" | ||
/> | ||
<input | ||
id="space-image-upload-input" | ||
ref="spaceImageInput" | ||
type="file" | ||
name="file" | ||
multiple | ||
tabindex="-1" | ||
accept="image/*" | ||
@change="$_uploadImage_uploadImageSpace" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import ContextActionMenu from '../ContextActionMenu.vue' | ||
import QuotaModal from './QuotaModal.vue' | ||
import ReadmeContentModal from './ReadmeContentModal.vue' | ||
import Delete from '../../mixins/spaces/actions/delete' | ||
import Rename from '../../mixins/spaces/actions/rename' | ||
import Restore from '../../mixins/spaces/actions/restore' | ||
import ShowDetails from '../../mixins/spaces/actions/showDetails' | ||
import EditDescription from '../../mixins/spaces/actions/editDescription' | ||
import EditQuota from '../../mixins/spaces/actions/editQuota' | ||
import DeletedFiles from '../../mixins/spaces/actions/deletedFiles' | ||
import Disable from '../../mixins/spaces/actions/disable' | ||
import ShowMembers from '../../mixins/spaces/actions/showMembers' | ||
import UploadImage from '../../mixins/spaces/actions/uploadImage' | ||
import EditReadmeContent from '../../mixins/spaces/actions/editReadmeContent' | ||
import { isLocationSpacesActive } from '../../router' | ||
export default { | ||
name: 'SpaceContextActions', | ||
components: { ContextActionMenu, QuotaModal, ReadmeContentModal }, | ||
mixins: [ | ||
Rename, | ||
Delete, | ||
EditDescription, | ||
EditQuota, | ||
DeletedFiles, | ||
Disable, | ||
ShowDetails, | ||
ShowMembers, | ||
Restore, | ||
UploadImage, | ||
EditReadmeContent | ||
], | ||
props: { | ||
items: { | ||
type: Array, | ||
required: true | ||
} | ||
}, | ||
computed: { | ||
quotaModalSelectedSpace() { | ||
return this.$data.$_editQuota_selectedSpace | ||
}, | ||
quotaModalIsOpen() { | ||
return this.$data.$_editQuota_modalOpen | ||
}, | ||
readmeContentModalIsOpen() { | ||
return this.$data.$_editReadmeContent_modalOpen | ||
}, | ||
menuSections() { | ||
const sections = [] | ||
if (this.menuItemsMembers.length) { | ||
sections.push({ | ||
name: 'members', | ||
items: this.menuItemsMembers | ||
}) | ||
} | ||
if (this.menuItemsPrimaryActions.length) { | ||
sections.push({ | ||
name: 'primaryActions', | ||
items: this.menuItemsPrimaryActions | ||
}) | ||
} | ||
if (this.menuItemsSecondaryActions.length) { | ||
sections.push({ | ||
name: 'secondaryActions', | ||
items: this.menuItemsSecondaryActions | ||
}) | ||
} | ||
if (this.menuItemsTrashBin.length) { | ||
sections.push({ | ||
name: 'trashBin', | ||
items: this.menuItemsTrashBin | ||
}) | ||
} | ||
if (this.menuItemsSidebar.length) { | ||
sections.push({ | ||
name: 'sidebar', | ||
items: this.menuItemsSidebar | ||
}) | ||
} | ||
return sections | ||
}, | ||
filterParams() { | ||
return { | ||
resources: this.items | ||
} | ||
}, | ||
menuItemsMembers() { | ||
const fileHandlers = [...this.$_showMembers_items] | ||
return [...fileHandlers].filter((item) => item.isEnabled(this.filterParams)) | ||
}, | ||
menuItemsPrimaryActions() { | ||
const fileHandlers = [ | ||
...this.$_rename_items, | ||
...this.$_editDescription_items, | ||
...this.$_uploadImage_items | ||
] | ||
if ( | ||
isLocationSpacesActive(this.$router, 'files-spaces-project') && | ||
this.$route.params.storageId | ||
) { | ||
fileHandlers.splice(2, 0, ...this.$_editReadmeContent_items) | ||
} | ||
return [...fileHandlers].filter((item) => item.isEnabled(this.filterParams)) | ||
}, | ||
menuItemsSecondaryActions() { | ||
const fileHandlers = [ | ||
...this.$_editQuota_items, | ||
...this.$_disable_items, | ||
...this.$_restore_items, | ||
...this.$_delete_items | ||
] | ||
return [...fileHandlers].filter((item) => item.isEnabled(this.filterParams)) | ||
}, | ||
menuItemsTrashBin() { | ||
const fileHandlers = [...this.$_deletedFiles_items] | ||
return [...fileHandlers].filter((item) => item.isEnabled(this.filterParams)) | ||
}, | ||
menuItemsSidebar() { | ||
const fileHandlers = [...this.$_showDetails_items] | ||
return [...fileHandlers].filter((item) => item.isEnabled(this.filterParams)) | ||
} | ||
}, | ||
methods: { | ||
closeQuotaModal() { | ||
this.$_editQuota_closeModal() | ||
}, | ||
closeReadmeContentModal() { | ||
this.$_editReadmeContent_closeModal() | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss"> | ||
#space-image-upload-input { | ||
position: absolute; | ||
left: -99999px; | ||
} | ||
</style> |
Oops, something went wrong.