Skip to content

Commit

Permalink
Merge pull request #3573 from owncloud/feature/quick-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Hirt authored Jun 9, 2020
2 parents 0ff758e + a9651d9 commit 089184d
Show file tree
Hide file tree
Showing 19 changed files with 220 additions and 187 deletions.
1 change: 1 addition & 0 deletions apps/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@babel/preset-env": "^7.6.0",
"@babel/register": "^7.6.0",
"babel-loader": "^8.0.6",
"copy-to-clipboard": "^3.3.1",
"core-js": "3.6.4",
"css-loader": "^3.1.0",
"intersection-observer": "^0.7.0",
Expand Down
17 changes: 11 additions & 6 deletions apps/files/src/components/AllFilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</div>
<div
:class="{ 'uk-visible@s': !_sidebarOpen, 'uk-hidden': _sidebarOpen }"
class="uk-text-nowrap uk-text-meta uk-width-small uk-margin-right"
class="uk-text-nowrap uk-text-meta uk-width-small"
>
<sortable-column-header
:aria-label="$gettext('Sort files by updated time')"
Expand All @@ -45,7 +45,7 @@
@click="toggleSort('mdateMoment')"
>
<translate
translate-context="Short column label in files able for the time at which a file was modified"
translate-context="Short column label in files table for the time at which a file was modified"
>Updated</translate
>
</sortable-column-header>
Expand Down Expand Up @@ -91,6 +91,9 @@
{{ formDateFromNow(rowItem.mdate) }}
</div>
</template>
<template #rowActions="{ item: rowItem }">
<quick-actions :actions="app.quickActions" :item="rowItem" />
</template>
<template #noContentMessage>
<no-content-message v-if="!$_isFavoritesList" icon="folder">
<template #message
Expand Down Expand Up @@ -155,11 +158,12 @@ import FileList from './FileList.vue'
import Indicators from './FilesLists/Indicators.vue'
import FileItem from './FileItem.vue'
import NoContentMessage from './NoContentMessage.vue'
import { mapGetters, mapActions, mapState } from 'vuex'
import QuickActions from './FilesLists/QuickActions.vue'
import SortableColumnHeader from './FilesLists/SortableColumnHeader.vue'
import { mapGetters, mapActions, mapState } from 'vuex'
import Mixins from '../mixins'
import FileActions from '../fileactions'
import SortableColumnHeader from './FilesLists/SortableColumnHeader.vue'
import intersection from 'lodash/intersection'
import { shareTypes, userShareTypes } from '../helpers/shareTypes'
import { getParentPaths } from '../helpers/path'
Expand All @@ -171,7 +175,8 @@ export default {
Indicators,
FileItem,
NoContentMessage,
SortableColumnHeader
SortableColumnHeader,
QuickActions
},
mixins: [Mixins, FileActions],
props: {
Expand Down Expand Up @@ -199,7 +204,7 @@ export default {
}
},
computed: {
...mapState(['route']),
...mapState(['route', 'app']),
...mapGetters('Files', [
'loadingFolder',
'activeFiles',
Expand Down
3 changes: 2 additions & 1 deletion apps/files/src/components/Collaborators/SharedFilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
translate-context="Owner table column"
v-text="$gettext('Owner')"
/>
<div class="uk-visible@s uk-text-nowrap uk-text-meta uk-width-small uk-margin-right">
<div class="uk-visible@s uk-text-nowrap uk-text-meta uk-width-small">
<sortable-column-header
:aria-label="$gettext('Sort files by share time')"
:is-active="fileSortField == 'shareTimeMoment'"
Expand All @@ -53,6 +53,7 @@
<translate translate-context="Share time column in files table">Share time</translate>
</sortable-column-header>
</div>
<div class="oc-icon" />
</template>
<template #rowColumns="{ item }">
<div class="uk-text-truncate uk-width-expand">
Expand Down
17 changes: 14 additions & 3 deletions apps/files/src/components/FileList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@
/>
</div>
<slot name="headerColumns" />
<div class="uk-margin-small-right oc-icon" />
<div
v-if="$scopedSlots.rowActions"
class="uk-text-nowrap uk-text-meta uk-text-right uk-width-small"
>
<translate translate-context="Short column label in files table for the actions"
>Actions</translate
>
</div>
</oc-grid>
<div v-if="!loading" id="files-list-container" class="uk-flex-1 uk-overflow-auto">
<RecycleScroller
Expand Down Expand Up @@ -61,7 +68,11 @@
/>
</div>
<slot name="rowColumns" :item="rowItem" :index="index" />
<div class="uk-text-right uk-margin-left uk-margin-small-right">
<div
class="uk-flex uk-flex-middle uk-flex-right"
:class="{ 'uk-width-small': $scopedSlots.rowActions }"
>
<slot name="rowActions" :item="rowItem" />
<oc-button
:id="actionsDropdownButtonId(rowItem.viewId, active)"
class="files-list-row-show-actions"
Expand Down Expand Up @@ -101,7 +112,7 @@ import { mapGetters, mapActions, mapState } from 'vuex'
import { RecycleScroller } from 'vue-virtual-scroller'
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
const RowActionsDropdown = () => import('./FilesLists/RowActionsDropdown.vue')
import RowActionsDropdown from './FilesLists/RowActionsDropdown.vue'
export default {
name: 'FileList',
Expand Down
31 changes: 31 additions & 0 deletions apps/files/src/components/FilesLists/QuickActions.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template>
<div>
<oc-button
v-for="action in actions"
:id="`files-quick-action-${action.id}`"
:key="action.label"
:aria-label="$gettext(action.label)"
variation="raw"
@click.native.stop="action.handler({ item, client: $client, store: $store })"
>
<oc-icon :name="action.icon" aria-hidden="true" size="small" class="uk-flex" />
</oc-button>
</div>
</template>

<script>
export default {
name: 'QuickActions',
props: {
actions: {
type: Object,
required: true
},
item: {
type: Object,
required: true
}
}
}
</script>
3 changes: 2 additions & 1 deletion apps/files/src/components/Trashbin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class="uk-text-nowrap uk-text-meta uk-width-small"
>
<sortable-column-header
class="uk-align-right uk-margin-right"
class="uk-align-right"
:aria-label="$gettext('Sort files by deletion time')"
:is-active="fileSortField === 'deleteTimestampMoment'"
:is-desc="fileSortDirectionDesc"
Expand All @@ -36,6 +36,7 @@
</translate>
</sortable-column-header>
</div>
<div class="oc-icon" />
</template>
<template #rowColumns="{ item }">
<div class="uk-text-truncate uk-width-expand">
Expand Down
8 changes: 7 additions & 1 deletion apps/files/src/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import FileLinkSidebar from './components/FileLinkSidebar.vue'
import PrivateLink from './components/PrivateLink.vue'
import PublicLink from './components/PublicLinks/PublicLink.vue'
import FilesDrop from './components/PublicLinks/FilesDrop.vue'
import translationsJson from '../l10n/translations.json'

import translationsJson from '../l10n/translations.json'
import quickActionsImport from './quickActions'
const store = require('./store')

// just a dummy function to trick gettext tools
Expand Down Expand Up @@ -217,11 +218,16 @@ const routes = [
}
]

// Prepare imported modules to be exported
// If we do not define these constants, the export will be undefined
const translations = translationsJson
const quickActions = quickActionsImport

export default define({
appInfo,
store,
routes,
navItems,
quickActions,
translations
})
49 changes: 49 additions & 0 deletions apps/files/src/quickActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import moment from 'moment'
import copyToClipboard from 'copy-to-clipboard'

// just a dummy function to trick gettext tools
function $gettext(msg) {
return msg
}

function createPublicLink(ctx) {
// FIXME: Translate name
const params = { name: 'Quick action link' }
const capabilities = ctx.store.state.user.capabilities
const expirationDate = capabilities.files_sharing.public.expire_date

if (expirationDate.enabled) {
params.expireDate = moment()
.add(parseInt(expirationDate.days, 10), 'days')
.endOf('day')
.toISOString()
}

return new Promise((resolve, reject) => {
ctx.client.shares
.shareFileWithLink(ctx.item.path, params)
.then(res => {
copyToClipboard(res.shareInfo.url)
ctx.store.dispatch('showMessage', {
title: $gettext('Public link created'),
desc: $gettext(
'Public link has been successfully created and copied into your clipboard.'
),
status: 'success'
})
resolve()
})
.catch(e => {
reject(e)
})
})
}

export default {
publicLink: {
id: 'public-link',
label: $gettext('Create and copy public link'),
icon: 'link',
handler: createPublicLink
}
}
Loading

0 comments on commit 089184d

Please sign in to comment.