Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed Apr 11, 2022
1 parent 41c62d4 commit 0acaf89
Show file tree
Hide file tree
Showing 14 changed files with 352 additions and 464 deletions.
2 changes: 1 addition & 1 deletion packages/web-app-files/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
id="files-sidebar"
ref="filesSidebar"
tabindex="-1"
class="oc-width-1-1 oc-width-1-3@m oc-width-1-4@xl"
class="oc-width-1-1 oc-width-2-5@m oc-width-1-4@xl"
:sidebar-active-panel="sidebarActivePanel"
@beforeDestroy="focusSideBar"
@mounted="focusSideBar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
v-oc-tooltip="label"
:aria-label="label"
appearance="raw"
:variation="copied ? 'success' : 'passive'"
@click="copyValueToClipboard"
>
<span v-text="text" />
Expand Down Expand Up @@ -84,7 +85,7 @@ export default {
<style scoped>
._clipboard-success-animation {
animation-name: _clipboard-success-animation;
animation-duration: 0.5s;
animation-duration: 0.8s;
animation-timing-function: ease-out;
animation-fill-mode: both;
}
Expand Down
41 changes: 12 additions & 29 deletions packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue
Original file line number Diff line number Diff line change
@@ -1,50 +1,37 @@
<template>
<div id="oc-files-file-link" class="oc-position-relative">
<h3 class="oc-text-bold oc-m-rm oc-text-initial" v-text="linksHeading" />
<div
v-show="currentView === VIEW_SHOW"
:key="VIEW_SHOW"
:aria-hidden="currentView !== VIEW_SHOW"
>
<oc-loader v-if="linksLoading" :aria-label="$gettext('Loading list of file links')" />
<template v-else>
<h3 class="oc-text-bold oc-m-rm oc-text-initial" v-text="linksHeading" />
<div v-if="canCreatePublicLinks" class="oc-my-s">
<p v-translate class="oc-text-muted">
Any external person with the respective link can access this resource. No sign-in
required. Assign a password to avoid unintended document exposure.
</p>
<div v-if="canCreatePublicLinks" class="oc-mt-m">
<!-- quicklink emtpy="true" goes here -->
<!-- <hr class="oc-my-s"> -->
<oc-button
id="files-file-link-add"
icon="add"
variation="primary"
appearance="raw"
data-testid="files-link-add-btn"
:aria-label="$_addButtonAriaLabel"
@click="addNewLink"
>
<oc-icon name="add" />
{{ $_addButtonLabel }}
</oc-button>
v-text="$_addButtonLabel"
/>
</div>
<p
v-else
data-testid="files-links-no-reshare-permissions-message"
class="oc-mt-s"
class="oc-mt-m"
v-text="noResharePermsMessage"
/>
<ul class="oc-list oc-list-divider oc-overflow-hidden oc-m-rm">
<li v-for="link in links" :key="link.key">
<oc-list v-if="links.length" class="oc-overflow-hidden oc-my-m">
<li v-for="link in links" :key="link.key" class="oc-py-s">
<list-item :data-testid="`files-link-id-${link.id}`" :link="link" />
</li>
</ul>
<p
v-if="$_noPublicLinks && canCreatePublicLinks"
id="oc-file-links-no-results"
key="oc-file-links-no-results"
v-translate
class="oc-my-rm"
>
No public links
</p>
</oc-list>
</template>
</div>
<div v-if="currentView === VIEW_EDIT" :key="VIEW_EDIT">
Expand Down Expand Up @@ -164,10 +151,6 @@ export default defineComponent({
return allShares.sort(this.linksComparator)
},
$_noPublicLinks() {
return this.links.length === 0
},
$_expirationDate() {
const expireDate = this.capabilities.files_sharing.public.expire_date
Expand All @@ -178,7 +161,7 @@ export default defineComponent({
}
},
$_addButtonLabel() {
return this.$gettext('Public link')
return this.$gettext('Add link')
},
$_addButtonAriaLabel() {
return this.$gettext('Create new public link')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
<template>
<div class="oc-flex oc-flex-between oc-flex-middle oc-pl-s">
<div v-if="canEdit">
<oc-button appearance="raw" gap-size="none">
<span v-text="visibilityHint" />
<oc-icon name="arrow-down-s" />
</oc-button>
<!-- oc-drop goes here -->
</div>
<p v-else class="oc-my-rm" v-text="visibilityHint" />

<div :class="{ 'oc-pr-s': !canEdit }">
<oc-button
v-if="link.indirect"
v-oc-tooltip="viaTooltip"
type="router-link"
class="oc-files-file-link-via"
appearance="raw"
:to="viaRouterParams"
>
<oc-icon name="folder-shared" fill-type="line" />
</oc-button>
<oc-icon
v-if="link.password"
name="lock-password"
fill-type="line"
:aria-label="passwortProtectionTooltip"
v-oc-tooltip="passwortProtectionTooltip"
/>
<oc-icon
v-if="link.expiration"
v-oc-tooltip="expirationDateTooltip"
class="oc-files-public-link-expires"
:data-testid="`files-link-id-${link.id}-expiration-date`"
:aria-label="expirationDateTooltip"
name="calendar"
fill-type="line"
/>
<div v-if="canEdit">
<oc-button appearance="raw">
<oc-icon name="more-2" />
</oc-button>
<!--
<oc-drop>
If has expiryDate
- edit expiryDate
- if expiryDate is not enforced:
remove expiryDate
Else
- add expiryDate
If passwordprotected
- edit password
- if passwordprotected is not enforced:
remove passwordprotected
Else
- add passwordprotected
Remove linkShare
</oc-drop>
-->
</div>
</div>
</div>
</template>

<script>
import { mapActions, mapGetters, mapMutations } from 'vuex'
import { basename } from 'path'
import Mixins from '../../../../mixins'
import { createLocationSpaces, isLocationSpacesActive } from '../../../../router'
import { DateTime } from 'luxon'
import { linkRoleDescriptions } from '../../../../helpers/share'
export default {
name: 'LinkActions',
mixins: [Mixins],
inject: ['currentSpace'],
props: {
link: {
type: Object,
required: true
}
},
computed: {
...mapGetters('Files', ['highlightedFile']),
canEdit() {
console.log('link', this.link)
// TODO: Check if user is allowed to edit links (e.g. spaces shares)
console.log(this.highlightedFile, this.currentSpace)
return false
},
visibilityHint() {
return linkRoleDescriptions[parseInt(this.link.permissions)]
},
editButtonLabel() {
return this.$gettext('Edit public link')
},
viaRouterParams() {
const viaPath = this.link.path
const locationName = isLocationSpacesActive(this.$router, 'files-spaces-project')
? 'files-spaces-project'
: 'files-spaces-personal-home'
return createLocationSpaces(locationName, {
params: {
item: viaPath || '/',
storageId: this.$route.params.storageId
},
query: {
scrollTo: basename(viaPath)
}
})
},
expirationDate() {
return DateTime.fromISO(this.link.expiration)
.setLocale(this.$language.current)
.endOf('day')
.toLocaleString(DateTime.DATETIME_FULL)
},
expirationDateRelative() {
return DateTime.fromISO(this.link.expiration)
.setLocale(this.$language.current)
.endOf('day')
.toRelative()
},
expirationDateTooltip() {
return this.$gettextInterpolate(
this.$gettext('Expires in %{timeToExpiry} (%{expiryDate})'),
{ timeToExpiry: this.expirationDateRelative, expiryDate: this.expirationDate },
true
)
},
viaTooltip() {
if (!this.link.indirect) {
return null
}
return this.$gettextInterpolate(
this.$gettext('Navigate to the parent (%{folderName})'),
{ folderName: basename(this.link.path) },
true
)
},
passwortProtectionTooltip() {
return this.$gettext('This link is password-protected')
},
deleteButtonLabel() {
return this.$gettext('Delete public link')
}
},
methods: {
...mapActions(['showMessage', 'createModal', 'hideModal']),
...mapActions('Files', ['removeLink', 'updateLink']),
...mapMutations('Files', ['TRIGGER_PUBLIC_LINK_EDIT']),
$_removeLink() {
const modal = {
variation: 'danger',
title: this.$gettext('Delete public link'),
message: this.$gettext(
'Are you sure you want to delete this link? Recreating the same link again is not possible.'
),
cancelText: this.$gettext('Cancel'),
confirmText: this.$gettext('Delete'),
onCancel: this.hideModal,
onConfirm: () =>
this.deleteLink({
client: this.$client,
share: this.link,
resource: this.highlightedFile
})
}
this.createModal(modal)
},
$_updateLink() {
this.saving = true
const expireDate = DateTime.fromJSDate(this.expireDate)
.setLocale(this.$language.current)
.endOf('day')
const params = {
expireDate: expireDate.isValid ? expireDate.toFormat("yyyy-MM-dd'T'HH:mm:ssZZZ") : '',
permissions: this.selectedRole.bitmask(false),
name: this.name
}
if (this.password !== null) {
params.password = this.password
}
this.updateLink({
id: this.publicLinkInEdit.id,
client: this.$client,
$gettext: this.$gettext,
params
})
.then(() => {
this.saving = false
this.errors = false
this.$_closeForm()
})
.catch((e) => {
this.saving = false
this.errors = e
})
},
deleteLink({ client, share, resource }) {
let storageId
if (this.highlightedFile.type === 'space') {
storageId = this.highlightedFile.id
} else if (this.$route.params.storageId) {
storageId = this.$route.params.storageId
}
this.hideModal()
this.removeLink({ client, share, resource, storageId })
this.showMessage({
title: this.$gettext('Public link was deleted successfully')
})
}
}
}
</script>
Loading

0 comments on commit 0acaf89

Please sign in to comment.