Skip to content

Commit 951b8bf

Browse files
committed
chore: Migrate to Node API
Signed-off-by: Louis Chemineau <[email protected]>
1 parent 41fd1fb commit 951b8bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1305
-1065
lines changed

package-lock.json

+122-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"scripts": {
2626
"build": "vite --mode production build",
2727
"postbuild": "build-js/npm-post-build.sh",
28-
"dev": "vite --mode development build",
29-
"watch": "vite --mode development build --watch",
28+
"dev": "export NODE_ENV=development; vite --mode development build",
29+
"watch": "export NODE_ENV=development; vite --mode development build --watch",
3030
"test": "TZ=CET NODE_ENV=test vitest run",
3131
"test:coverage": "TZ=CET NODE_ENV=test vitest --coverage run",
3232
"lint": "eslint --ext .js,.vue src",
@@ -65,6 +65,7 @@
6565
"leaflet": "^1.9.4",
6666
"leaflet-defaulticon-compatibility": "^0.1.2",
6767
"path-posix": "^1.0.0",
68+
"pinia": "^3.0.2",
6869
"qs": "^6.14.0",
6970
"url-parse": "^1.5.10",
7071
"vue": "^2.7.14",

src/PhotosPublic.vue

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
<template>
77
<NcContent app-name="photos">
8+
<!--
9+
Needed for isPublicShare to return true
10+
https://github.com/nextcloud-libraries/nextcloud-sharing/blob/15f38dfdeb2c72501008e5ae89d3eb424b83aed5/lib/publicShare.ts#L12-L20
11+
-->
12+
<input id="isPublic"
13+
type="hidden"
14+
name="isPublic"
15+
value="1">
816
<NcAppContent>
917
<router-view />
1018

src/components/Actions/ActionDownload.vue

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</template>
1414

1515
<script lang='ts'>
16-
import { mapGetters } from 'vuex'
16+
import type { PropType } from 'vue'
1717

1818
import { generateUrl } from '@nextcloud/router'
1919
import { NcActionLink } from '@nextcloud/vue'
@@ -32,26 +32,26 @@ export default {
3232
},
3333

3434
selectedFileIds: {
35-
type: Array,
35+
type: Array as PropType<string[]>,
3636
required: true,
3737
},
3838
},
3939

4040
computed: {
41-
...mapGetters([
42-
'files',
43-
]),
41+
files() {
42+
return this.$store.state.files.files
43+
},
4444

4545
downloadUrl() {
4646
const params = new URLSearchParams()
47-
const filePaths = this.fileNames.map(fileName => '/' + fileName.split('/').splice(3).join('/'))
48-
params.append('files', JSON.stringify(filePaths))
47+
params.append('files', JSON.stringify(this.paths))
4948

49+
// TODO: FIX ME
5050
return generateUrl(`/apps/files/ajax/download.php?${params}`)
5151
},
5252

53-
fileNames() {
54-
return this.selectedFileIds.map(fileId => this.files[fileId].filename)
53+
paths() {
54+
return this.selectedFileIds.map(fileId => this.files[fileId].path)
5555
},
5656
},
5757
}

src/components/Actions/ActionFavorite.vue

+13-15
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
</template>
2121

2222
<script lang='ts'>
23-
import { mapActions, mapGetters } from 'vuex'
23+
import { defineComponent, type PropType } from 'vue'
2424
import Star from 'vue-material-design-icons/Star.vue'
2525

2626
import { NcActionButton } from '@nextcloud/vue'
27+
import { translate as t } from '@nextcloud/l10n'
2728

28-
export default {
29+
export default defineComponent({
2930
name: 'ActionFavorite',
3031
components: {
3132
Star,
@@ -34,35 +35,32 @@ export default {
3435

3536
props: {
3637
selectedFileIds: {
37-
type: Array,
38+
type: Array as PropType<string[]>,
3839
required: true,
3940
},
4041
},
4142

4243
computed: {
43-
...mapGetters([
44-
'files',
45-
]),
44+
files() {
45+
return this.$store.state.files.files
46+
},
4647

47-
/** @return {boolean} */
4848
shouldFavoriteSelection() {
4949
// Favorite all selection if at least one file is not in the favorites.
50-
return this.selectedFileIds.some((fileId) => this.files[fileId].favorite === 0)
50+
return this.selectedFileIds.some((fileId) => this.files[fileId].attributes.favorite === 0)
5151
},
5252
},
5353

5454
methods: {
55-
...mapActions([
56-
'toggleFavoriteForFiles',
57-
]),
58-
5955
async favoriteSelection() {
60-
await this.toggleFavoriteForFiles({ fileIds: this.selectedFileIds, favoriteState: 1 })
56+
await this.$store.dispatch('toggleFavoriteForFiles', { fileIds: this.selectedFileIds, favoriteState: 1 })
6157
},
6258

6359
async unFavoriteSelection() {
64-
await this.toggleFavoriteForFiles({ fileIds: this.selectedFileIds, favoriteState: 0 })
60+
await this.$store.dispatch('toggleFavoriteForFiles', { fileIds: this.selectedFileIds, favoriteState: 0 })
6561
},
62+
63+
t,
6664
},
67-
}
65+
})
6866
</script>

0 commit comments

Comments
 (0)