Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[full-ci] Resolve alias links #7405

Merged
merged 5 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog/unreleased/enhancement-internal-links
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Enhancement: Resolve internal links

Public links with the role "internal" can now be resolved.
Note: Internal links to shares can not be resolved as of now. This will follow in a subsequent PR.

https://github.com/owncloud/web/pull/7405
https://github.com/owncloud/web/issues/7304
https://github.com/owncloud/web/issues/6844
7 changes: 7 additions & 0 deletions changelog/unreleased/enhancement-private-links
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Resolve private links

Private links can now be resolved.
Note: Private links to shares in oCIS can not be resolved as of now. This will follow in a subsequent PR.

https://github.com/owncloud/web/pull/7405
https://github.com/owncloud/web/issues/7707
4 changes: 4 additions & 0 deletions deployments/examples/ocis_web/config/ocis/proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ policies:
endpoint: /ocs/v[12].php/config
backend: http://localhost:9140
unprotected: true
- type: regex
endpoint: /ocs/v[12].php/apps/files_sharing/api/v1/tokeninfo/unprotected
backend: http://localhost:9140
unprotected: true
- endpoint: /ocs/
backend: http://localhost:9140
- type: query
Expand Down
44 changes: 23 additions & 21 deletions packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/>
<details-and-edit
v-if="quicklink"
:available-role-options="availableRoleOptions"
:available-role-options="getAvailableRoleOptions(quicklink)"
:can-rename="false"
:expiration-date="expirationDate"
:is-folder-share="highlightedFile.isFolder"
Expand Down Expand Up @@ -52,7 +52,7 @@
>
<name-and-copy :link="link" />
<details-and-edit
:available-role-options="availableRoleOptions"
:available-role-options="getAvailableRoleOptions(link)"
:can-rename="true"
:expiration-date="expirationDate"
:is-folder-share="highlightedFile.isFolder"
Expand Down Expand Up @@ -89,7 +89,7 @@
>
<name-and-copy :link="link" />
<details-and-edit
:available-role-options="availableRoleOptions"
:available-role-options="getAvailableRoleOptions(link)"
:expiration-date="expirationDate"
:is-folder-share="true"
:is-modifiable="false"
Expand Down Expand Up @@ -231,23 +231,6 @@ export default defineComponent({
}
},

availableRoleOptions() {
if (this.incomingParentShare.value && this.canCreatePublicLinks) {
return LinkShareRoles.filterByBitmask(
parseInt(this.incomingParentShare.value.permissions),
this.highlightedFile.isFolder,
this.hasPublicLinkEditing,
this.hasPublicLinkAliasSupport
)
}

return LinkShareRoles.list(
this.highlightedFile.isFolder,
this.hasPublicLinkEditing,
this.hasPublicLinkAliasSupport
)
},

passwordEnforced() {
return (
this.capabilities.files_sharing.public.password?.enforced_for || {
Expand Down Expand Up @@ -384,7 +367,7 @@ export default defineComponent({

isPasswordEnforcedFor(link) {
const currentRole = LinkShareRoles.getByBitmask(
parseInt(link.permissions),
link.permissions,
link.indirect || this.highlightedFile.isFolder
)

Expand Down Expand Up @@ -593,6 +576,25 @@ export default defineComponent({
status: 'danger'
})
}
},

getAvailableRoleOptions(link) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a type to link?

if (this.share?.incoming && this.canCreatePublicLinks) {
return LinkShareRoles.filterByBitmask(
parseInt(this.share.permissions),
this.highlightedFile.isFolder,
this.hasPublicLinkEditing,
this.hasPublicLinkAliasSupport,
!!link.password
)
}

return LinkShareRoles.list(
this.highlightedFile.isFolder,
this.hasPublicLinkEditing,
this.hasPublicLinkAliasSupport,
!!link.password
)
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@
<oc-button
:id="`files-role-${roleOption.label.toLowerCase()}`"
:class="{
selected: parseInt(link.permissions) === roleOption.bitmask(false),
'oc-background-primary-gradient':
parseInt(link.permissions) === roleOption.bitmask(false)
selected: link.permissions === roleOption.bitmask(false),
'oc-background-primary-gradient': link.permissions === roleOption.bitmask(false)
}"
appearance="raw"
:variation="
parseInt(link.permissions) === roleOption.bitmask(false) ? 'inverse' : 'passive'
"
:variation="link.permissions === roleOption.bitmask(false) ? 'inverse' : 'passive'"
justify-content="space-between"
class="oc-p-s"
@click="
Expand All @@ -58,10 +55,7 @@
</span>
</span>
<span class="oc-flex">
<oc-icon
v-if="parseInt(link.permissions) === roleOption.bitmask(false)"
name="check"
/>
<oc-icon v-if="link.permissions === roleOption.bitmask(false)" name="check" />
</span>
</oc-button>
</li>
Expand Down Expand Up @@ -183,7 +177,11 @@ import { basename } from 'path'
import { DateTime } from 'luxon'
import { mapActions, mapGetters } from 'vuex'
import { createLocationSpaces } from '../../../../router'
import { LinkShareRoles } from 'web-client/src/helpers/share'
import {
linkRoleInternalFile,
linkRoleInternalFolder,
LinkShareRoles
} from 'web-client/src/helpers/share'
import { defineComponent } from '@vue/runtime-core'
import { formatDateFromDateTime, formatRelativeDateFromDateTime } from 'web-pkg/src/helpers'
import { SpaceResource } from 'web-client/src/helpers'
Expand Down Expand Up @@ -239,15 +237,15 @@ export default defineComponent({
},
computed: {
...mapGetters('runtime/spaces', ['spaces']),
currentLinkRole() {
return LinkShareRoles.getByBitmask(this.link.permissions, this.isFolderShare)
},
JammingBen marked this conversation as resolved.
Show resolved Hide resolved
currentLinkRoleDescription() {
return LinkShareRoles.getByBitmask(
parseInt(this.link.permissions),
this.isFolderShare
).description(false)
return this.currentLinkRole.description(false)
},

currentLinkRoleLabel() {
return LinkShareRoles.getByBitmask(parseInt(this.link.permissions), this.isFolderShare).label
return this.currentLinkRole.label
},

editOptions() {
Expand Down Expand Up @@ -317,7 +315,7 @@ export default defineComponent({
})
}
}
if (!this.isPasswordEnforced && !this.link.password) {
if (!this.isPasswordEnforced && !this.link.password && !this.isAliasLink) {
result.push({
id: 'add-password',
title: this.$gettext('Add password'),
Expand Down Expand Up @@ -390,6 +388,10 @@ export default defineComponent({

passwortProtectionTooltip() {
return this.$gettext('This link is password-protected')
},

isAliasLink() {
return [linkRoleInternalFolder, linkRoleInternalFile].includes(this.currentLinkRole)
}
},
watch: {
Expand Down
5 changes: 3 additions & 2 deletions packages/web-app-files/src/helpers/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,9 @@ export function buildSpaceShare(s, storageId): Share {

function _buildLink(link): Share {
let description = ''
const permissions = parseInt(link.permissions)

const role = LinkShareRoles.getByBitmask(parseInt(link.permissions), link.item_type === 'folder')
const role = LinkShareRoles.getByBitmask(permissions, link.item_type === 'folder')
if (role) {
description = role.label
}
Expand All @@ -382,7 +383,7 @@ function _buildLink(link): Share {
token: link.token as string,
url: link.url,
path: link.path,
permissions: link.permissions,
permissions,
description,
quicklink,
stime: link.stime,
Expand Down
2 changes: 0 additions & 2 deletions packages/web-app-files/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import App from './App.vue'
import Favorites from './views/Favorites.vue'
import FilesDrop from './views/FilesDrop.vue'
import PrivateLink from './views/PrivateLink.vue'
import SharedWithMe from './views/shares/SharedWithMe.vue'
import SharedWithOthers from './views/shares/SharedWithOthers.vue'
import SharedViaLink from './views/shares/SharedViaLink.vue'
Expand Down Expand Up @@ -94,7 +93,6 @@ export default {
App,
Favorites,
FilesDrop,
PrivateLink,
SearchResults,
Shares: {
SharedViaLink,
Expand Down
6 changes: 1 addition & 5 deletions packages/web-app-files/src/router/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import VueRouter, { RouteConfig, Route, Location, RouteMeta } from 'vue-router'
import { createLocationSpaces } from './spaces'
import { createLocationShares } from './shares'
import { createLocationCommon } from './common'
import { createLocationOperations } from './operations'
import { createLocationPublic } from './public'
import { isLocationActive as isLocationActiveNoCompat } from './utils'
import { createLocationTrash } from './trash'
Expand Down Expand Up @@ -90,10 +89,7 @@ export const buildRoutes = (): RouteConfig[] =>
},
{
path: '/private-link/:fileId',
meta: {
auth: false
},
redirect: (to) => createLocationOperations('files-operations-resolver-private-link', to)
redirect: (to) => ({ name: 'resolvePrivateLink', params: { fileId: to.params.fileId } })
},
{
path: '/public-link/:token',
Expand Down
8 changes: 0 additions & 8 deletions packages/web-app-files/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import {
createLocationCommon
} from './common'
import { buildRoutes as buildDeprecatedRoutes, isLocationActive } from './deprecated'
import {
buildRoutes as buildOperationsRoutes,
createLocationOperations,
isLocationOperationsActive
} from './operations'
import {
buildRoutes as buildPublicRoutes,
createLocationPublic,
Expand Down Expand Up @@ -45,7 +40,6 @@ const buildRoutes = (components: RouteComponents): RouteConfig[] => [
...buildSharesRoutes(components),
...buildPublicRoutes(components),
...buildSpacesRoutes(components),
...buildOperationsRoutes(components),
...buildTrashRoutes(components),
...buildDeprecatedRoutes()
]
Expand All @@ -54,9 +48,7 @@ export {
createLocationCommon,
createLocationShares,
createLocationSpaces,
createLocationOperations,
createLocationPublic,
isLocationOperationsActive,
isLocationCommonActive,
isLocationSharesActive,
isLocationSpacesActive,
Expand Down
25 changes: 0 additions & 25 deletions packages/web-app-files/src/router/operations.ts

This file was deleted.

Loading