-
Notifications
You must be signed in to change notification settings - Fork 132
Expand file tree
/
Copy pathRightSideActions.vue
More file actions
126 lines (114 loc) 路 2.63 KB
/
Copy pathRightSideActions.vue
File metadata and controls
126 lines (114 loc) 路 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<template>
<div class="right-side-actions">
<div class="user-avatar__icon user-avatar__icon--with-avatar"
:style="avatarUrl ? { backgroundImage: `url(${avatarUrl})` } : null">
</div>
<a :download="basename"
:href="fullPathToFile">
<NcButton class="download__button"
type="primary">
Download
</NcButton>
</a>
<NcActions>
<NcActionButton icon="icon-edit"
:close-after-click="true"
@click="showSidebar">
Open sidebar
</NcActionButton>
<NcActionButton icon="icon-delete"
:close-after-click="true"
@click="onDelete">
Delete
</NcActionButton>
</NcActions>
</div>
</template>
<script>
import axios from '@nextcloud/axios'
import { getCurrentUser } from '@nextcloud/auth'
import NcActions from '@nextcloud/vue/dist/Components/NcActions'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton'
import NcButton from '@nextcloud/vue/dist/Components/NcButton'
import { getRootPath } from '../../helpers/files.js'
import { getAvatarUrl } from '../../helpers'
export default {
name: 'RightSideActions',
components: {
NcActions,
NcActionButton,
NcButton,
},
props: {
basename: {
type: String,
default: null,
},
relativePath: {
type: String,
default: '',
},
},
computed: {
avatarUrl() {
let currentUser = getCurrentUser()
return currentUser ? getAvatarUrl(currentUser?.uid, 44) : null
},
fullPathToFile() {
return getRootPath() + this.relativePath
}
},
methods: {
async onDelete() {
try {
const url = this.fullPathToFile
await axios.delete(url)
this.closeEditor()
} catch (error) {
showError(error)
}
},
async showSidebar() {
// Open the sidebar sharing tab
if (OCA?.Files?.Sidebar) {
await OCA.Files.Sidebar.open(this.relativePath)
}
},
}
}
</script>
<style scoped lang="scss">
$clickable-area: 35px;
$usericon-padding: 10px;
.right-side-actions {
display: flex;
}
.user-avatar__icon {
position: relative;
top: 5px;
width: $clickable-area;
min-width: $clickable-area;
height: $clickable-area;
margin: 0 5px !important;
border-radius: $clickable-area;
background-color: var(--color-background-darker);
background-repeat: no-repeat;
background-position: center;
background-size: $clickable-area - 2 * $usericon-padding;
&--with-avatar {
color: inherit;
background-size: cover;
}
}
.download__button {
border: 1px solid white !important;
}
</style>
<style lang="scss">
// It makes the app right sidebar appear under the Menubar instead
// of Hiding a part of it
// The value used is the max-length of the Menubar
#app-sidebar-vue {
top: 44px !important;
}
</style>