Skip to content

Commit

Permalink
Merge pull request #6003 from cernbox/up_app_provider
Browse files Browse the repository at this point in the history
Improvements for app provider
  • Loading branch information
Pascal Wengerter authored Dec 13, 2021
2 parents 5c43bc6 + 834dd67 commit 72cacbd
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 19 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-no-context-menu-app-provider
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Show context menu for all file extensions

The context menu was failing to build for file extensions that did not have a match in the apps from the app provider.

https://github.com/owncloud/web/issues/6002
https://github.com/owncloud/web/pull/6003
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-no-scroll-app-provider
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Do not scroll on apps open in app provider

Apps opened from the app provider were taking more than the window size, prompting the use of the scrollbar.

https://github.com/owncloud/web/issues/5960
https://github.com/owncloud/web/pull/6003
5 changes: 5 additions & 0 deletions changelog/unreleased/enhancement-app-provider-feedback
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Show errors when failing to open app in app provider

The error message provided by wopi is now displayed to the user, giving some context on why it failed to open a file.

https://github.com/owncloud/web/pull/6003
16 changes: 10 additions & 6 deletions packages/web-app-external/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<template>
<main
class="uk-height-viewport"
class="uk-height-1-1"
:class="{
'uk-flex uk-flex-center uk-flex-middle': loading || loadingError
}"
>
<h1 class="oc-invisible-sr" v-text="pageTitle" />
<loading-screen v-if="loading" />
<error-screen v-else-if="loadingError" />
<error-screen v-else-if="loadingError" :message="errorMessage" />
<iframe
v-if="appUrl && method === 'GET'"
:src="appUrl"
class="uk-width-1-1 uk-height-viewport"
class="uk-width-1-1 uk-height-1-1"
:title="iFrameTitle"
/>
<div v-if="appUrl && method === 'POST' && formParameters">
<div v-if="appUrl && method === 'POST' && formParameters" class="uk-height-1-1">
<form :action="appUrl" target="app-iframe" method="post">
<input ref="subm" type="submit" :value="formParameters" class="oc-hidden" />
<div v-for="(item, key, index) in formParameters" :key="index">
<input :name="key" :value="item" type="hidden" />
</div>
</form>
<iframe name="app-iframe" class="uk-width-1-1 uk-height-viewport" :title="iFrameTitle" />
<iframe name="app-iframe" class="uk-width-1-1 uk-height-1-1" :title="iFrameTitle" />
</div>
</main>
</template>
Expand Down Expand Up @@ -60,6 +60,7 @@ export default {
data: () => ({
loading: false,
loadingError: false,
errorMessage: false,
appUrl: '',
method: '',
formParameters: {}
Expand Down Expand Up @@ -123,11 +124,14 @@ export default {
})
if (response.status !== 200) {
const err = await response.json()
this.errorMessage = err.message
this.loading = false
this.loadingError = true
console.error('Error fetching app information', response.status, response.message)
console.error('Error fetching app information', response.status, this.errorMessage)
return
}
const data = await response.json()
if (!data.app_url || !data.method) {
Expand Down
19 changes: 18 additions & 1 deletion packages/web-app-external/src/components/ErrorScreen.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
<template>
<div class="uk-text-center">
<oc-icon size="xxlarge" name="warning" />
<p v-translate>Error when loading the application</p>
<h1 v-translate class="oc-text-lead">Error when loading the application</h1>
<p v-if="message">{{ message }}</p>
</div>
</template>

<script>
export default {
name: 'ErrorScreen',
props: {
/**
* error message
*/
message: {
default: '',
type: String,
required: false
}
}
}
</script>
20 changes: 10 additions & 10 deletions packages/web-app-external/tests/unit/__snapshots__/app.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`The app provider extension should be able to load an iFrame via get 1`] = `
<main class="uk-height-viewport">
<main class="uk-height-1-1">
<h1 class="oc-invisible-sr">"exampleApp" app page</h1>
<!----> <iframe src="https://example.test/d12ab86/loe009157-MzBw" title="&quot;exampleApp&quot; app content area" class="uk-width-1-1 uk-height-viewport"></iframe>
<!----> <iframe src="https://example.test/d12ab86/loe009157-MzBw" title="&quot;exampleApp&quot; app content area" class="uk-width-1-1 uk-height-1-1"></iframe>
<!---->
</main>
`;

exports[`The app provider extension should be able to load an iFrame via post 1`] = `
<main class="uk-height-viewport">
<main class="uk-height-1-1">
<h1 class="oc-invisible-sr">"exampleApp" app page</h1>
<!---->
<!---->
<div>
<div class="uk-height-1-1">
<form action="https://example.test/d12ab86/loe009157-MzBw" target="app-iframe" method="post"><input type="submit" class="oc-hidden" value="[object Object]">
<div><input name="access_token" type="hidden" value="asdfsadfsadf"></div>
<div><input name="access_token_ttl" type="hidden" value="123456"></div>
</form> <iframe name="app-iframe" title="&quot;exampleApp&quot; app content area" class="uk-width-1-1 uk-height-viewport"></iframe>
</form> <iframe name="app-iframe" title="&quot;exampleApp&quot; app content area" class="uk-width-1-1 uk-height-1-1"></iframe>
</div>
</main>
`;
exports[`The app provider extension should fail for unauthenticated users 1`] = `
<main class="uk-height-viewport uk-flex uk-flex-center uk-flex-middle">
<main class="uk-height-1-1 uk-flex uk-flex-center uk-flex-middle">
<h1 class="oc-invisible-sr">"exampleApp" app page</h1>
<errorscreen-stub></errorscreen-stub>
<loadingscreen-stub></loadingscreen-stub>
<!---->
<!---->
</main>
`;
exports[`The app provider extension should show a loading spinner while loading 1`] = `
<main class="uk-height-viewport uk-flex uk-flex-center uk-flex-middle">
<main class="uk-height-1-1 uk-flex uk-flex-center uk-flex-middle">
<h1 class="oc-invisible-sr">"exampleApp" app page</h1>
<loadingscreen-stub></loadingscreen-stub>
<!---->
Expand All @@ -41,9 +41,9 @@ exports[`The app provider extension should show a loading spinner while loading
`;
exports[`The app provider extension should show a meaningful message if an error occurs during loading 1`] = `
<main class="uk-height-viewport uk-flex uk-flex-center uk-flex-middle">
<main class="uk-height-1-1 uk-flex uk-flex-center uk-flex-middle">
<h1 class="oc-invisible-sr">"exampleApp" app page</h1>
<errorscreen-stub></errorscreen-stub>
<loadingscreen-stub></loadingscreen-stub>
<!---->
<!---->
</main>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
exports[`The external app error screen component displays an icon and a paragraph 1`] = `
<div class="uk-text-center">
<ocicon-stub size="xxlarge" name="warning"></ocicon-stub>
<p data-msgid="Error when loading the application" data-current-language="en_US">Error when loading the application</p>
<h1 class="oc-text-lead" data-msgid="Error when loading the application" data-current-language="en_US">Error when loading the application</h1>
<!---->
</div>
`;
6 changes: 5 additions & 1 deletion packages/web-app-files/src/mixins/fileActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,12 @@ export default {
return []
}

const filteredMimeTypes = this.mimeTypes.find((t) => t.mime_type === mimeType)
if (filteredMimeTypes === undefined) {
return []
}
const { app_providers: appProviders = [], default_application: defaultApplication } =
this.mimeTypes.find((t) => t.mime_type === mimeType)
filteredMimeTypes

return appProviders.map((app) => {
const label = this.$gettext('Open in %{ appName }')
Expand Down

0 comments on commit 72cacbd

Please sign in to comment.