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

Introduce app top bar #7217

Merged
merged 11 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
6 changes: 6 additions & 0 deletions changelog/unreleased/enhancement-add-app-top-bar-component
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Add app top bar component

We've added a app top bar component for consistency,
which will be used by the apps: preview, text-editor and pdf-viewer.

https://github.com/owncloud/web/pull/7217
18 changes: 5 additions & 13 deletions packages/web-app-pdf-viewer/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@
<loading-screen v-if="loading" />
<error-screen v-else-if="loadingError" />
<div v-else class="oc-height-1-1">
<div class="oc-flex oc-p-s pdf-viewer-tool-bar">
<oc-resource :resource="resource" />
<oc-button id="text-editor-controls-close" size="small" @click="closeApp">
<oc-icon name="close" size="small" />
</oc-button>
</div>
<app-top-bar :resource="resource" @close="closeApp" />
<object class="pdf-viewer oc-width-1-1" :data="blobUrl" type="application/pdf" />
</div>
</main>
</template>
<script>
import { mapGetters } from 'vuex'
import { useAppDefaults } from 'web-pkg/src/composables'
import AppTopBar from 'web-pkg/src/components/AppTopBar.vue'
import ErrorScreen from './components/ErrorScreen.vue'
import LoadingScreen from './components/LoadingScreen.vue'
import { buildResource } from 'files/src/helpers/resources'
Expand All @@ -24,7 +20,8 @@ export default {
name: 'PDFViewer',
components: {
ErrorScreen,
LoadingScreen
LoadingScreen,
AppTopBar
},
setup() {
return {
Expand Down Expand Up @@ -76,11 +73,6 @@ export default {
margin: 0;
padding: 0;
overflow: hidden;
height: calc(100% - 50px);
}

.pdf-viewer-tool-bar {
align-items: center;
justify-content: space-between;
height: calc(100% - 60px);
}
</style>
31 changes: 21 additions & 10 deletions packages/web-app-text-editor/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<template>
<main id="text-editor" class="oc-px-l oc-py-m oc-height-1-1">
<app-bar
:current-file-context="currentFileContext"
:is-loading="isLoading"
:is-dirty="isDirty"
:is-read-only="isReadOnly"
@closeApp="closeApp"
@save="save"
/>
<div v-if="isLoading" class="oc-text-center">
<oc-spinner :aria-label="$gettext('Loading editor content')" />
</div>
<app-top-bar v-else :resource="resource" @close="closeApp">
<template #right>
<oc-button
id="text-editor-controls-save"
:aria-label="$gettext('Save')"
:disabled="isReadOnly || !isDirty"
@click="save"
>
<oc-icon name="save" size="small" />
</oc-button>
</template>
</app-top-bar>
<div class="oc-flex editor-wrapper-height">
<div :class="showPreview ? 'oc-width-1-2' : 'oc-width-1-1'" class="oc-height-1-1">
<oc-textarea
Expand Down Expand Up @@ -36,12 +43,13 @@ import { computed, onMounted, onBeforeUnmount, ref, unref } from '@vue/compositi
import { mapActions } from 'vuex'
import { DavPermission, DavProperty } from 'web-pkg/src/constants'
import { useAppDefaults } from 'web-pkg/src/composables'
import AppBar from './AppBar.vue'
import AppTopBar from 'web-pkg/src/components/AppTopBar.vue'
import { buildResource } from 'files/src/helpers/resources'

export default {
name: 'TextEditor',
components: {
AppBar
AppTopBar
},
beforeRouteLeave(_to, _from, next) {
if (this.isDirty) {
Expand Down Expand Up @@ -76,6 +84,7 @@ export default {
const currentContent = ref()
const currentETag = ref()
const isReadOnly = ref(true)
const resource = ref()

const loadFileTask = useTask(function* () {
const filePath = unref(currentFileContext).path
Expand All @@ -86,6 +95,7 @@ export default {
isReadOnly.value = ![DavPermission.Updateable, DavPermission.FileUpdateable].some(
(p) => response.fileInfo[DavProperty.Permissions].indexOf(p) > -1
)
resource.value = buildResource(response)
})

return yield unref(defaults)
Expand Down Expand Up @@ -206,6 +216,7 @@ export default {
currentContent,
renderedMarkdown,
config,
resource,

// methods
save,
Expand Down
57 changes: 0 additions & 57 deletions packages/web-app-text-editor/src/AppBar.vue

This file was deleted.

42 changes: 42 additions & 0 deletions packages/web-pkg/src/components/AppTopBar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<template>
<div class="oc-flex oc-p-s app-top-bar">
<oc-resource
id="app-top-bar-resource"
:is-path-displayed="true"
:is-thumbnail-displayed="false"
:resource="resource"
/>
<div>
<slot name="right"></slot>
<oc-button
id="app-top-bar-close"
:aria-label="$gettext('Close')"
size="small"
@click="$emit('close')"
>
<oc-icon name="close" size="small" />
</oc-button>
</div>
</div>
</template>

<script lang="ts">
import { defineComponent } from '@vue/runtime-core'

export default defineComponent({
name: 'AppTopBar',
props: {
resource: {
type: Object,
required: true
}
}
})
</script>

<style lang="scss" scoped>
.app-top-bar {
align-items: center;
justify-content: space-between;
}
</style>
2 changes: 1 addition & 1 deletion tests/acceptance/pageObjects/textEditorPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = {
selector: '#text-editor-controls-save'
},
closeButton: {
selector: '#text-editor-controls-close'
selector: '#app-top-bar-close'
},
fileName: {
selector: '#text-editor-file-path'
Expand Down