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

Vue improvements #2401

Merged
merged 25 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
95e8b7a
maintain aspect ratio of images
powerpaul17 Oct 25, 2023
3a695bc
move NcAppContent into route components & use list slot
powerpaul17 Oct 25, 2023
9568c78
show feed item in content detail
powerpaul17 Oct 25, 2023
5906910
set max width for article view and center it
powerpaul17 Oct 25, 2023
be1ed07
use template component for list/content views
powerpaul17 Oct 26, 2023
ec75eb9
wrap list and details in the corresponding nextcloud components
powerpaul17 Oct 28, 2023
8e49a53
show/hide details according to item selection
powerpaul17 Oct 28, 2023
b87386a
fix article scrolling
powerpaul17 Oct 28, 2023
ebf0bce
use favicon as link to feed item
powerpaul17 Oct 28, 2023
2d9f100
improve feed item list item
powerpaul17 Oct 28, 2023
7408b7d
add changelog entry for frontend improvements
powerpaul17 Oct 28, 2023
3bb457b
linting
powerpaul17 Oct 28, 2023
35587e4
improve changelog entries
powerpaul17 Oct 28, 2023
8280367
add missing nc app content component to explore page
powerpaul17 Oct 29, 2023
921b80f
use type import for PropType
powerpaul17 Oct 29, 2023
8560233
do not import unused component
powerpaul17 Oct 29, 2023
88bbf95
reformat emit definition to satisfy linter
powerpaul17 Oct 29, 2023
e609f8d
use @vue/vue2-jest package instead of vue-jest
powerpaul17 Oct 29, 2023
bfbee86
adapt tests to use new content template component
powerpaul17 Oct 29, 2023
45bc6b2
add note about composition api
powerpaul17 Oct 30, 2023
f4dd375
pass empty array instead of undefined for unread items
powerpaul17 Nov 1, 2023
863e9ac
show empty content component when no article is selected
powerpaul17 Nov 1, 2023
5f38364
remove unnecessary height of app content details component
powerpaul17 Nov 1, 2023
511ac89
move css style into class
powerpaul17 Nov 1, 2023
5410721
remove (now) unsuitable test for folder name/unread count in feed lis…
powerpaul17 Nov 1, 2023
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is mostly based on [Keep a Changelog](https://keepachangelog.com/en/1
# Unreleased
## [25.x.x]
### Changed
- Use Nextcloud vue components for item list and article view
- Fix aspect ratio of article images

### Fixed

Expand Down
548 changes: 82 additions & 466 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"engines": {
"node": "^16.0.0",
"npm": "^8.0.0"
"npm": "^7.0.0 || ^8.0.0"
},
"resolutions": {
"natives": "1.1.3"
Expand All @@ -52,18 +52,15 @@
"@nextcloud/password-confirmation": "^1.0.1",
"@nextcloud/router": "^2.0.0",
"@nextcloud/vue": "^7.8.0",
"vue": "^2.7.0",
"@vue/vue2-jest": "^29.2.6",
"lodash": "^4.17.21",
"vue": "^2.7.0",
"vue-router": "^3.5.3",
"vuex": "^3.6.2"
},
"browserslist": [
"extends @nextcloud/browserslist-config"
],
"engines": {
"node": "^16.0.0",
"npm": "^7.0.0 || ^8.0.0"
},
"devDependencies": {
"@babel/core": "^7.11.1",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
Expand Down Expand Up @@ -128,7 +125,6 @@
"v-click-outside": "^3.2.0",
"vue-color": "^2.8.1",
"vue-eslint-parser": "^9.0.2",
"vue-jest": "^3.0.7",
"vue-loader": "^15.10.1",
"vue-material-design-icons": "^5.1.2",
"vue-multiselect": "^2.1.6",
Expand All @@ -152,7 +148,7 @@
},
"testEnvironment": "jsdom",
"transform": {
".*\\.(vue)$": "vue-jest",
".*\\.(vue)$": "@vue/vue2-jest",
"^.+\\.ts?$": "ts-jest"
},
"transformIgnorePatterns": [
Expand Down
10 changes: 1 addition & 9 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
<div id="news-app">
<div id="content-display" :class="{ playing: playingItem }">
<Sidebar />
<NcAppContent>
<RouterView />
</NcAppContent>
<RouterView />
</div>
<div v-if="playingItem" class="podcast">
<audio controls
Expand All @@ -50,15 +48,13 @@
import Vue from 'vue'
import { mapState } from 'vuex'
import NcContent from '@nextcloud/vue/dist/Components/NcContent.js'
import NcAppContent from '@nextcloud/vue/dist/Components/NcAppContent.js'
import Sidebar from './components/Sidebar.vue'
import { ACTIONS, MUTATIONS } from './store'

export default Vue.extend({
components: {
NcContent,
Sidebar,
NcAppContent,
},
computed: {
playingItem() {
Expand Down Expand Up @@ -120,10 +116,6 @@ export default Vue.extend({
font-size: small;
}

.route-container {
height: 100%;
}

#content-display {
display: flex;
flex-direction: row;
Expand Down
101 changes: 101 additions & 0 deletions src/components/ContentTemplate.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<template>
<NcAppContent :show-details="showDetails"
@update:showDetails="unselectItem()">
<template #list>
<NcAppContentList>
<div class="header">
<slot name="header" />
</div>

<FeedItemDisplayList :items="items"
:fetch-key="fetchKey"
:config="config"
@load-more="emit('load-more')" />
</NcAppContentList>
</template>

<NcAppContentDetails>
<FeedItemDisplay v-if="selectedFeedItem" :item="selectedFeedItem" />
<NcEmptyContent v-else
:title="t('news', 'No article selected')"
:description="t('news', 'Please select an article from the list...')">
<template #icon>
<TextIcon />
</template>
</NcEmptyContent>
</NcAppContentDetails>
</NcAppContent>
</template>

<script setup lang="ts">

/**
* This component uses vue's composition api format,
* for more information, see https://vuejs.org/guide/extras/composition-api-faq.html
*/

import { type PropType, computed, ref, watch } from 'vue'

import itemStore from '../store/item'

import NcAppContent from '@nextcloud/vue/dist/Components/NcAppContent'
import NcAppContentList from '@nextcloud/vue/dist/Components/NcAppContentList'
import NcAppContentDetails from '@nextcloud/vue/dist/Components/NcAppContentDetails'
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent'

import TextIcon from 'vue-material-design-icons/Text.vue'

import { FeedItem } from '../types/FeedItem'

import FeedItemDisplayList from './feed-display/FeedItemDisplayList.vue'
import FeedItemDisplay from './feed-display/FeedItemDisplay.vue'

powerpaul17 marked this conversation as resolved.
Show resolved Hide resolved
defineProps({
powerpaul17 marked this conversation as resolved.
Show resolved Hide resolved
items: {
type: Array as PropType<Array<FeedItem>>,
required: true,
},
fetchKey: {
type: String,
required: true,
},
config: {

Check warning on line 62 in src/components/ContentTemplate.vue

View workflow job for this annotation

GitHub Actions / eslint node

Prop 'config' requires default value to be set

Check warning on line 62 in src/components/ContentTemplate.vue

View workflow job for this annotation

GitHub Actions / eslint

Prop 'config' requires default value to be set
type: Object,
},
})

const emit = defineEmits<{(event: 'load-more'): void}>()

const showDetails = ref(false)

const selectedFeedItem = computed(() => {
return itemStore.getters.selected(itemStore.state)
powerpaul17 marked this conversation as resolved.
Show resolved Hide resolved
})

watch(selectedFeedItem, (newSelectedFeedItem) => {
if (newSelectedFeedItem) {
showDetails.value = true
} else {
showDetails.value = false
}
})

function unselectItem() {

Check warning on line 83 in src/components/ContentTemplate.vue

View workflow job for this annotation

GitHub Actions / eslint node

Missing JSDoc comment

Check warning on line 83 in src/components/ContentTemplate.vue

View workflow job for this annotation

GitHub Actions / eslint

Missing JSDoc comment
itemStore.mutations.SET_SELECTED_ITEM(
itemStore.state,
{ id: undefined },
)
}

</script>

<style scoped>

.header {
padding-left: 50px;
position: absolute;
top: 1em;
font-weight: 700;
}

</style>
4 changes: 4 additions & 0 deletions src/components/feed-display/FeedItemDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@
<img v-else :src="item.mediaThumbnail" alt="">
</div>

<div v-if="item.mediaDescription" class="enclosure description" v-html="item.mediaDescription" />

Check warning on line 88 in src/components/feed-display/FeedItemDisplay.vue

View workflow job for this annotation

GitHub Actions / eslint node

'v-html' directive can lead to XSS attack

Check warning on line 88 in src/components/feed-display/FeedItemDisplay.vue

View workflow job for this annotation

GitHub Actions / eslint

'v-html' directive can lead to XSS attack

<div class="body" :dir="item.rtl && 'rtl'" v-html="item.body" />

Check warning on line 90 in src/components/feed-display/FeedItemDisplay.vue

View workflow job for this annotation

GitHub Actions / eslint node

'v-html' directive can lead to XSS attack

Check warning on line 90 in src/components/feed-display/FeedItemDisplay.vue

View workflow job for this annotation

GitHub Actions / eslint

'v-html' directive can lead to XSS attack
</div>
</div>
</template>
Expand Down Expand Up @@ -208,6 +208,9 @@
padding: 0 50px 50px 50px;
overflow-y: scroll;
height: 100%;
max-width: 1024px;
margin-left: auto;
margin-right: auto;
}

.article video {
Expand Down Expand Up @@ -267,6 +270,7 @@

.article img {
width: 100%;
height: auto;
}

.article h1 {
Expand Down
27 changes: 0 additions & 27 deletions src/components/feed-display/FeedItemDisplayList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
</template>
</template>
</VirtualScroll>

<div v-if="selected !== undefined" class="feed-item-container">
<FeedItemDisplay :item="selected" />
powerpaul17 marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
</div>
</template>
Expand All @@ -58,7 +54,6 @@ import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'

import VirtualScroll from './VirtualScroll.vue'
import FeedItemRow from './FeedItemRow.vue'
import FeedItemDisplay from './FeedItemDisplay.vue'

import { FeedItem } from '../../types/FeedItem'

Expand All @@ -71,7 +66,6 @@ export default Vue.extend({
components: {
VirtualScroll,
FeedItemRow,
FeedItemDisplay,
FilterIcon,
StarIcon,
StarCheckIcon,
Expand Down Expand Up @@ -115,9 +109,6 @@ export default Vue.extend({
}
},
computed: {
selected(): FeedItem | undefined {
return this.$store.getters.selected
},
reachedEnd(): boolean {
return this.mounted && this.$store.state.items.allItemsLoaded[this.fetchKey] === true
},
Expand Down Expand Up @@ -206,30 +197,12 @@ export default Vue.extend({
.feed-item-display-container {
flex-direction: column;
}

.feed-item-container {
flex: 1 1 1000px;
max-height: calc(100vh - 200px)
}
}

@media only screen and (min-width: 768px) {
.feed-item-display-container {
flex-direction: row;
}

.feed-item-container {
width: 50%;
max-height: unset;
}
}

.feed-item-container {
overflow-y: hidden;
-webkit-box-shadow: 1px -1px 5px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 1px -1px 5px 0px rgba(0,0,0,0.75);
box-shadow: 1px -1px 5px 0px rgba(0,0,0,0.75);
border-top: 1px solid var(--color-border);
}

.header {
Expand Down
Loading
Loading