summaryrefslogtreecommitdiffstats
path: root/src/components/Sidebar.vue
blob: 0b17b77ed4386e757eeacd50a257d0dc49dea48b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<template>
	<NcAppNavigation>
		<AddFeed v-if="showAddFeed" @close="closeShowAddFeed()" />
		<NcAppNavigationNew :text="t('news', 'Subscribe')"
			button-id="new-feed-button"
			button-class="icon-add"
			@click="showShowAddFeed()" />

		<div class="news-navigation">
			<NcAppNavigationNewItem :title="t('news', 'New folder')" @new-item="newFolder">
				<template #icon>
					<PlusCircle :size="16" />
				</template>
			</NcAppNavigationNewItem>

			<NcAppNavigationItem :title="t('news', 'Unread articles')" icon="icon-rss">
				<template #actions>
					<ActionButton icon="icon-checkmark" @click="alert('Edit')">
						t('news','Mark read')
					</ActionButton>
				</template>
				<template #counter>
					<NcCounterBubble>5</NcCounterBubble>
				</template>
			</NcAppNavigationItem>
			<NcAppNavigationItem :title="t('news', 'All articles')" icon="icon-rss">
				<template #actions>
					<NcActionButton icon="icon-checkmark" @click="alert('Edit')">
						t('news','Mark read')
					</NcActionButton>
				</template>
			</NcAppNavigationItem>
			<NcAppNavigationItem :title="t('news', 'Starred')" icon="icon-starred">
				<template #counter>
					<NcCounterBubble>35</NcCounterBubble>
				</template>
			</NcAppNavigationItem>

			<NcAppNavigationItem v-for="folder in folders"
				:key="folder.name"
				:title="folder.name"
				icon="icon-folder"
				:allow-collapse="true">
				<template #default>
					<NcAppNavigationItem v-for="feed in folder.feeds"
						:key="feed.name"
						:title="feed.title">
						<template #icon>
							<img v-if="feed.faviconLink"
								:src="feed.faviconLink"
								alt="feedIcon">
							<div v-if="!feed.faviconLink" class="icon-rss" />
						</template>
						<template #actions>
							<NcActionButton icon="icon-checkmark" @click="alert('Mark read')">
								{{ t("news", "Mark read") }}
							</NcActionButton>
							<NcActionButton icon="icon-pinned" @click="alert('Rename')">
								{{ t("news", "Unpin from top") }}
							</NcActionButton>
							<NcActionButton icon="icon-caret-dark"
								@click="deleteFolder(folder)">
								{{ t("news", "Newest first") }}
							</NcActionButton>
							<NcActionButton icon="icon-caret-dark"
								@click="deleteFolder(folder)">
								{{ t("news", "Oldest first") }}
							</NcActionButton>
							<NcActionButton icon="icon-caret-dark"
								@click="deleteFolder(folder)">
								{{ t("news", "Default order") }}
							</NcActionButton>
							<NcActionButton icon="icon-full-text-disabled"
								@click="deleteFolder(folder)">
								{{ t("news", "Enable full text") }}
							</NcActionButton>
							<NcActionButton icon="icon-full-text-enabled"
								@click="deleteFolder(folder)">
								{{ t("news", "Disable full text") }}
							</NcActionButton>
							<NcActionButton icon="icon-updatemode-default"
								@click="deleteFolder(folder)">
								{{ t("news", "Unread updated") }}
							</NcActionButton>
							<NcActionButton icon="icon-updatemode-unread"
								@click="deleteFolder(folder)">
								{{ t("news", "Ignore updated") }}
							</NcActionButton>
							<NcActionButton icon="icon-icon-rss" @click="deleteFolder(folder)">
								{{ t("news", "Open feed URL") }}
							</NcActionButton>
							<NcActionButton icon="icon-icon-rename"
								@click="deleteFolder(folder)">
								{{ t("news", "Rename") }}
							</NcActionButton>
							<NcActionButton icon="icon-delete" @click="deleteFolder(folder)">
								{{ t("news", "Delete") }}
							</NcActionButton>
						</template>
					</NcAppNavigationItem>
				</template>
				<template v-if="folder.feedCount > 0" #counter>
					<NcCounterBubble>{{ folder.feedCount }}</NcCounterBubble>
				</template>
				<template #actions>
					<NcActionButton icon="icon-checkmark" @click="alert('Mark read')">
						{{ t("news", "Mark read") }}
					</NcActionButton>
					<NcActionButton icon="icon-rename" @click="alert('Rename')">
						{{ t("news", "Rename") }}
					</NcActionButton>
					<NcActionButton icon="icon-delete" @click="deleteFolder(folder)">
						{{ t("news", "Delete") }}
					</NcActionButton>
				</template>
			</NcAppNavigationItem>

			<NcAppNavigationItem :title="t('news', 'Explore')"
				icon="icon-link"
				:to="{ name: 'explore' }">
				<template #counter>
					<NcCounterBubble>35</NcCounterBubble>
				</template>
			</NcAppNavigationItem>
		</div>
	</NcAppNavigation>
</template>

<script>

import NcAppNavigation from '@nextcloud/vue/dist/Components/NcAppNavigation.js'
import NcAppNavigationNew from '@nextcloud/vue/dist/Components/NcAppNavigationNew.js'
import NcAppNavigationItem from '@nextcloud/vue/dist/Components/NcAppNavigationItem.js'
import NcAppNavigationNewItem from '@nextcloud/vue/dist/Components/NcAppNavigationNewItem.js'
// import AppNavigationCounter from '@nextcloud/vue/dist/Components/AppNavigationCounter'
import NcCounterBubble from '@nextcloud/vue/dist/Components/NcCounterBubble.js'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import AddFeed from './AddFeed.vue'
import PlusCircle from 'vue-material-design-icons/PlusCircle.vue'

export default {
	components: {
		NcAppNavigation,
		NcAppNavigationNew,
		NcAppNavigationItem,
		NcAppNavigationNewItem,
		// AppNavigationCounter,
		NcCounterBubble,
		NcActionButton,
		AddFeed,
		PlusCircle,
	},
	data: () => {
		return {
			showAddFeed: false,
		}
	},
	computed: {
		folders() {
			return this.$store.state.folders
		},
	},
	created() {
		// TODO?
	},
	methods: {
		newFolder(value) {
			const folderName = value.trim()
			const folder = { name: folderName }
			this.$store.dispatch('addFolder', { folder })
		},
		deleteFolder(folder) {
			this.$store.dispatch('deleteFolder', { folder })
			window.location.reload(true)
		},
		showShowAddFeed() {
			this.showAddFeed = true
		},
		closeShowAddFeed() {
			this.showAddFeed = false
		},
		alert(msg) {
			window.alert(msg)
		},
	},
}
</script>

<style lang="scss" scoped>
.news-navigation {
	display: flex;
	flex-direction: column;
	padding-left: 10px;
	padding-right: 10px;
	gap: 10px;

	& ::v-deep .app-navigation-input-confirm {
		form {
			gap: 4px;
			align-items: center;
		}

		button.button-vue--icon-only {
			min-height: 36px !important;
			width: 36px !important;
			height: 36px !important;
			min-width: 36px !important;
		}
	}
}
</style>