Skip to content

Commit

Permalink
Merge pull request #11930 from owncloud/backport-fixes-20241119
Browse files Browse the repository at this point in the history
fix: backport recent fixes from master to stable-11.0
  • Loading branch information
JammingBen authored Nov 19, 2024
2 parents ffffcf3 + 64415c9 commit 91117ef
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Allow create template with different editors

We've fixed a bug where it was not possible to create a template with different editors.

https://github.com/owncloud/web/pull/11923
https://github.com/owncloud/web/issues/11873
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-extension-actions-right-sidebar
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Extension actions in right sidebar

Extension actions (e.g. "Extract here") are now correctly showing in the actions panel of the right sidebar.

https://github.com/owncloud/web/pull/11924
https://github.com/owncloud/web/issues/11898
8 changes: 8 additions & 0 deletions changelog/unreleased/bugfix-fix-order-in-roles-drop-down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugfix: Fix order in roles drop down

We've fixed an issue where the order of roles in the roles drop down was not correct.
Now the roles are sorted as delegated by the backend.

https://github.com/owncloud/web/pull/11916
https://github.com/owncloud/web/pull/11922
https://github.com/owncloud/web/issues/11915
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-unique-request-ids
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Unique request ids

We've fixed an issue where the request ids for upload- and worker-requests were not unique.

https://github.com/owncloud/web/pull/11929
https://github.com/owncloud/web/issues/11925
2 changes: 1 addition & 1 deletion packages/web-app-external/l10n/translations.json

Large diffs are not rendered by default.

27 changes: 15 additions & 12 deletions packages/web-app-external/src/extensions/createFromTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ActionExtension,
ApplicationInformation,
contextRouteNameKey,
contextRouteParamsKey,
contextRouteQueryKey,
Expand All @@ -19,7 +20,9 @@ import { extractNameWithoutExtension, Resource } from '@ownclouders/web-client'
import { useCreateFileHandler } from '../composables'
import { useGettext } from 'vue3-gettext'

export const useActionExtensionCreateFromTemplate = (): ActionExtension => {
export const useActionExtensionCreateFromTemplate = (
appInfo: ApplicationInformation
): ActionExtension => {
const appProviderService = useAppProviderService()
const spacesStore = useSpacesStore()
const clientService = useClientService()
Expand All @@ -32,7 +35,7 @@ export const useActionExtensionCreateFromTemplate = (): ActionExtension => {
const action: FileAction = {
name: 'create-from-template',
category: 'context',
label: () => $gettext('Create from template'),
label: () => $gettext('Create from template via %{ name }', { name: appInfo.name }),
icon: 'swap-box',
hasPriority: true,
isVisible: ({ resources }) => {
Expand All @@ -52,7 +55,11 @@ export const useActionExtensionCreateFromTemplate = (): ActionExtension => {
}

return appProviderService.templateMimeTypes.some(
(mimeType) => mimeType.mime_type === template.mimeType
(mimeType) =>
mimeType.mime_type === template.mimeType &&
mimeType.app_providers.some(
(appProvider) => appProvider.name == appInfo.name && !!appProvider.target_ext
)
)
},
handler: async ({ resources }) => {
Expand All @@ -63,25 +70,21 @@ export const useActionExtensionCreateFromTemplate = (): ActionExtension => {
const templateMimeType = appProviderService.templateMimeTypes.find(
(mimeType) => mimeType.mime_type === template.mimeType
)
const firstApp = templateMimeType.app_providers.find(
(appProvider) => !!appProvider.target_ext
const app = templateMimeType.app_providers.find(
(appProvider) => !!appProvider.target_ext && appProvider.name === appInfo.name
)

let fileName =
extractNameWithoutExtension({
name: template.name,
extension: template.extension
} as Resource) + `.${firstApp.target_ext}`
} as Resource) + `.${app.target_ext}`

try {
const { resource: personalSpaceRoot, children: existingResources } =
await existingResourcesPromise
if (existingResources.some((f) => f.name === fileName)) {
fileName = resolveFileNameDuplicate(
fileName,
firstApp.target_ext,
unref(existingResources)
)
fileName = resolveFileNameDuplicate(fileName, app.target_ext, unref(existingResources))
}

const createdFile = await createFileHandler({
Expand All @@ -90,7 +93,7 @@ export const useActionExtensionCreateFromTemplate = (): ActionExtension => {
currentFolder: personalSpaceRoot
})

const routeName = `external-${firstApp.name.toLowerCase()}-apps`
const routeName = `external-${app.name.toLowerCase()}-apps`
const routeOptions = getEditorRouteOpts(
routeName,
spacesStore.personalSpace,
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-external/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default defineWebApplication({
}
]

const actionCreateFromTemplate = useActionExtensionCreateFromTemplate()
const actionCreateFromTemplate = useActionExtensionCreateFromTemplate(appInfo)
const extensions = computed<Extension[]>(() => {
return [actionCreateFromTemplate]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ import {
computed,
ref,
unref,
Ref
Ref,
watch
} from 'vue'
import { useAbility, useUserStore } from '@ownclouders/web-pkg'
import { Resource } from '@ownclouders/web-client'
Expand Down Expand Up @@ -144,10 +145,12 @@ export default defineComponent({
const availableInternalRoles = inject<Ref<ShareRole[]>>('availableInternalShareRoles')
const availableExternalRoles = inject<Ref<ShareRole[]>>('availableExternalShareRoles')
const availableRoles = computed(() => {
let roles = availableInternalRoles
if (props.isExternal) {
return unref(availableExternalRoles)
roles = availableExternalRoles
}
return unref(availableInternalRoles)
return unref(roles)
})
let initialSelectedRole: ShareRole
Expand Down Expand Up @@ -183,6 +186,16 @@ export default defineComponent({
emit('optionChange', unref(selectedRole))
}
watch(
() => props.isExternal,
() => {
if (!unref(hasExistingShareRole)) {
// when no role exists and the external flag changes, we need to reset the selected role
selectedRole.value = unref(availableRoles)[0]
}
}
)
return {
ability,
user,
Expand Down Expand Up @@ -295,6 +308,7 @@ export default defineComponent({
&:first-child {
margin-top: 0;
}
&:last-child {
margin-bottom: 0;
}
Expand All @@ -312,6 +326,7 @@ export default defineComponent({
}
}
}
&-role-select-btn {
max-width: 100%;
}
Expand Down
14 changes: 12 additions & 2 deletions packages/web-pkg/src/components/SideBar/FileSideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,12 @@ export default defineComponent({
const rolesArray = Object.values(sharesStore.graphRoles)
availableInternalShareRoles.value =
rolesArray.filter((r) => allowedRoles?.map(({ id }) => id).includes(r.id)) || []
allowedRoles?.map((r) => {
return {
...r,
icon: rolesArray.find((role) => role.id === r.id)?.icon
}
}) || []
// load external share roles
if (appsStore.isAppEnabled('open-cloud-mesh')) {
Expand All @@ -243,7 +248,12 @@ export default defineComponent({
)
availableExternalShareRoles.value =
rolesArray.filter((r) => allowedRoles?.map(({ id }) => id).includes(r.id)) || []
allowedRoles?.map((r) => {
return {
...r,
icon: rolesArray.find((role) => role.id === r.id)?.icon
}
}) || []
}
// use cache for indirect shares
Expand Down
18 changes: 17 additions & 1 deletion packages/web-pkg/src/composables/actions/files/useFileActions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import kebabCase from 'lodash-es/kebabCase'
import isNil from 'lodash-es/isNil'
import { isShareSpaceResource } from '@ownclouders/web-client'
import { routeToContextQuery } from '../../appDefaults'
import { isLocationTrashActive } from '../../../router'
Expand Down Expand Up @@ -98,6 +99,13 @@ export const useFileActions = () => {
return contextActionExtensions.map((extension) => extension.action)
})

const extensionActions = computed(() => {
return requestExtensions<ActionExtension>({
id: 'global.files.context-actions',
extensionType: 'action'
}).map((e) => e.action)
})

const editorActions = computed(() => {
if (unref(isEmbedModeEnabled)) {
return []
Expand Down Expand Up @@ -260,7 +268,15 @@ export const useFileActions = () => {
? []
: unref(systemActions).filter(filterCallback)

return [...primaryActions, ...secondaryActions]
return [
...primaryActions,
...secondaryActions,
...unref(extensionActions).filter(
(a) =>
a.isVisible(options as FileActionOptions) &&
(a.category === 'actions' || isNil(a.category))
)
]
}

return {
Expand Down
40 changes: 31 additions & 9 deletions packages/web-pkg/src/composables/upload/useUpload.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,51 @@
import { computed, unref, watch } from 'vue'
import { v4 as uuidV4 } from 'uuid'
import { UppyService } from '../../services/uppy/uppyService'
import { useCapabilityStore } from '../piniaStores'
import { useAuthStore, useCapabilityStore } from '../piniaStores'
import { TusOptions } from '@uppy/tus'
import { XHRUploadOptions } from '@uppy/xhr-upload'
import { UppyFile } from '@uppy/core'
import { useRequestHeaders } from '../requestHeaders'
import { useClientService } from '../clientService'
import { useGettext } from 'vue3-gettext'

interface UploadOptions {
uppyService: UppyService
}

export function useUpload(options: UploadOptions) {
const capabilityStore = useCapabilityStore()
const { headers } = useRequestHeaders()
const authStore = useAuthStore()
const clientService = useClientService()
const language = useGettext()

const isTusSupported = computed(() => capabilityStore.tusMaxChunkSize > 0)

const getHeaders = () => {
const headers: Record<string, string> = {}

if (authStore.publicLinkPassword) {
headers['Authorization'] =
'Basic ' +
Buffer.from(['public', authStore.publicLinkPassword].join(':')).toString('base64')
} else if (authStore.accessToken && !authStore.publicLinkPassword) {
headers['Authorization'] = 'Bearer ' + authStore.accessToken
}

headers['X-Request-ID'] = uuidV4()
headers['Accept-Language'] = language.current
headers['Initiator-ID'] = clientService.initiatorId
return headers
}

const tusOptions = computed<TusOptions>(() => {
const options: TusOptions = {
onBeforeRequest: (req, file) =>
new Promise((resolve) => {
req.setHeader('Authorization', unref(headers).Authorization)
req.setHeader('X-Request-ID', unref(headers)['X-Request-ID'])
req.setHeader('Accept-Language', unref(headers)['Accept-Language'])
req.setHeader('Initiator-ID', unref(headers)['Initiator-ID'])
const headers = getHeaders()
req.setHeader('Authorization', headers.Authorization)
req.setHeader('X-Request-ID', headers['X-Request-ID'])
req.setHeader('Accept-Language', headers['Accept-Language'])
req.setHeader('Initiator-ID', headers['Initiator-ID'])
if (file?.isRemote) {
req.setHeader('x-oc-mtime', (file?.data?.lastModified / 1000).toString())
}
Expand All @@ -37,7 +59,7 @@ export function useUpload(options: UploadOptions) {
// FIXME: remove if cloud upload still works without this
;(options as any)['headers'] = (file: UppyFile) => {
if (!!file.xhrUpload || file?.isRemote) {
return { 'x-oc-mtime': file?.data?.lastModified / 1000, ...unref(headers) }
return { 'x-oc-mtime': file?.data?.lastModified / 1000, ...getHeaders() }
}
}

Expand All @@ -50,7 +72,7 @@ export function useUpload(options: UploadOptions) {
endpoint: '',
headers: (file) => ({
'x-oc-mtime': file?.data?.lastModified / 1000,
...unref(headers)
...getHeaders()
})
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ export const useDeleteWorker = ({
resources,
concurrentRequests,
baseUrl: configStore.serverUrl,
headers: unref(headers)
headers: {
...unref(headers),
'X-Request-ID': undefined // is being generated by the dav client in the worker
}
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ export const usePasteWorker = () => {
data: {
transferData,
baseUrl: configStore.serverUrl,
headers: unref(headers)
headers: {
...unref(headers),
'X-Request-ID': undefined // is being generated by the dav client in the worker
}
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ export const useRestoreWorker = () => {
resources,
missingFolderPaths,
baseUrl: configStore.serverUrl,
headers: unref(headers)
headers: {
...unref(headers),
'X-Request-ID': undefined // is being generated by the dav client in the worker
}
}
})
}
Expand Down

0 comments on commit 91117ef

Please sign in to comment.