Skip to content

Commit 46dfc94

Browse files
authored
Merge pull request #2181 from nextcloud-libraries/backport/2180/stable6
[stable6] fix(filepicker): use proper folder icons
2 parents 28ca002 + b40c0b0 commit 46dfc94

File tree

6 files changed

+92
-39
lines changed

6 files changed

+92
-39
lines changed

.github/workflows/lint-eslint.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud-libraries/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
9+
name: Lint eslint
10+
11+
on: pull_request
12+
13+
permissions:
14+
contents: read
15+
16+
concurrency:
17+
group: lint-eslint-${{ github.head_ref || github.run_id }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
lint:
22+
runs-on: ubuntu-latest
23+
24+
name: eslint
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
29+
with:
30+
persist-credentials: false
31+
32+
- name: Read package.json
33+
uses: nextcloud-libraries/parse-package-engines-action@122ae05d4257008180a514e1ddeb0c1b9d094bdd # v0.1.0
34+
id: versions
35+
36+
- name: Set up node
37+
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
38+
with:
39+
node-version: ${{ steps.versions.outputs.node-version }}
40+
41+
- name: Set up npm
42+
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'
43+
44+
- name: Install dependencies
45+
env:
46+
CYPRESS_INSTALL_BINARY: 0
47+
PUPPETEER_SKIP_DOWNLOAD: true
48+
run: npm ci
49+
50+
- name: Lint
51+
run: npm run lint

lib/components/FilePicker/FileListRow.spec.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import type { VueWrapper } from '@vue/test-utils'
6+
import type { Wrapper } from '@vue/test-utils'
77
import type { ComponentProps } from 'vue-component-type-helpers'
88

99
import { afterEach, describe, expect, it, vi } from 'vitest'
@@ -13,25 +13,27 @@ import { shallowMount } from '@vue/test-utils'
1313
import FileListRow from './FileListRow.vue'
1414
import { nextTick } from 'vue'
1515

16-
type SubmitAction = (wrapper: VueWrapper<any>) => Promise<void>
16+
/* eslint-disable @typescript-eslint/no-explicit-any, jsdoc/require-jsdoc */
17+
18+
type SubmitAction = (wrapper: Wrapper<any>) => Promise<void>
1719
type ElementEvent = { 'update:selected': boolean | undefined, 'enter-directory': Folder | undefined }
1820

19-
async function clickCheckboxAction(wrapper: VueWrapper<any>) {
21+
async function clickCheckboxAction(wrapper: Wrapper<any>) {
2022
wrapper.find('input[type="checkbox"]').trigger('click')
2123
}
2224

23-
async function clickElementAction(wrapper: VueWrapper<any>) {
25+
async function clickElementAction(wrapper: Wrapper<any>) {
2426
wrapper.find('[data-testid="row-name"]').trigger('click')
2527
}
2628

27-
async function pressEnterAction(wrapper: VueWrapper<any>) {
29+
async function pressEnterAction(wrapper: Wrapper<any>) {
2830
wrapper.element.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, key: 'Enter' }))
2931
await nextTick()
3032
}
3133

3234
function testSubmitNode(name: string, propsData: ComponentProps<typeof FileListRow>, eventPayload: ElementEvent, actionCallback: SubmitAction) {
3335
it(name, async () => {
34-
const wrapper = shallowMount(FileListRow, {
36+
const wrapper = shallowMount(FileListRow as any, {
3537
propsData,
3638
stubs: {
3739
NcCheckboxRadioSwitch: {
@@ -113,7 +115,7 @@ describe('FilePicker: FileListRow', () => {
113115
const consoleWarn = vi.spyOn(console, 'warn')
114116
const consoleError = vi.spyOn(console, 'error')
115117

116-
const wrapper = shallowMount(FileListRow, {
118+
const wrapper = shallowMount(FileListRow as any, {
117119
propsData: {
118120
allowPickDirectory: true,
119121
selected: false,
@@ -134,7 +136,7 @@ describe('FilePicker: FileListRow', () => {
134136
})
135137

136138
it('shows checkbox based on `showCheckbox` property', async () => {
137-
const wrapper = shallowMount(FileListRow, {
139+
const wrapper = shallowMount(FileListRow as any, {
138140
propsData: {
139141
allowPickDirectory: true,
140142
selected: false,

lib/components/FilePicker/FilePickerBreadcrumbs.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,17 @@ function validateInput() {
101101
}
102102
103103
switch (error.reason) {
104-
case InvalidFilenameErrorReason.Character:
105-
validity = t('"{char}" is not allowed inside a folder name.', { char: error.segment })
106-
break
107-
case InvalidFilenameErrorReason.ReservedName:
108-
validity = t('"{segment}" is a reserved name and not allowed for folder names.', { segment: error.segment })
109-
break
110-
case InvalidFilenameErrorReason.Extension:
111-
validity = t('Folder names must not end with "{extension}".', { extension: error.segment })
112-
break
113-
default:
114-
validity = t('Invalid folder name.')
104+
case InvalidFilenameErrorReason.Character:
105+
validity = t('"{char}" is not allowed inside a folder name.', { char: error.segment })
106+
break
107+
case InvalidFilenameErrorReason.ReservedName:
108+
validity = t('"{segment}" is a reserved name and not allowed for folder names.', { segment: error.segment })
109+
break
110+
case InvalidFilenameErrorReason.Extension:
111+
validity = t('Folder names must not end with "{extension}".', { extension: error.segment })
112+
break
113+
default:
114+
validity = t('Invalid folder name.')
115115
}
116116
}
117117
if (input) {

lib/components/FilePicker/FilePreview.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<script setup lang="ts">
2424
import type { INode } from '@nextcloud/files'
2525
26-
import { mdiAccountPlus, mdiGroup, mdiLink, mdiLock, mdiNetwork, mdiTag } from '@mdi/js'
26+
import { mdiAccountGroupOutline, mdiAccountPlus, mdiKey, mdiLink, mdiNetworkOutline, mdiTagOutline } from '@mdi/js'
2727
import { FileType } from '@nextcloud/files'
2828
import { ShareType } from '@nextcloud/sharing'
2929
import { computed, ref, toRef } from 'vue'
@@ -57,12 +57,12 @@ const folderDecorationIcon = computed(() => {
5757
5858
// Encrypted folders
5959
if (props.node.attributes?.['is-encrypted'] === 1) {
60-
return mdiLock
60+
return mdiKey
6161
}
6262
6363
// System tags
6464
if (props.node.attributes?.['is-tag']) {
65-
return mdiTag
65+
return mdiTagOutline
6666
}
6767
6868
// Link and mail shared folders
@@ -79,9 +79,9 @@ const folderDecorationIcon = computed(() => {
7979
switch (props.node.attributes?.['mount-type']) {
8080
case 'external':
8181
case 'external-session':
82-
return mdiNetwork
82+
return mdiNetworkOutline
8383
case 'group':
84-
return mdiGroup
84+
return mdiAccountGroupOutline
8585
case 'shared':
8686
return mdiAccountPlus
8787
}

lib/components/PublicAuthPrompt.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
<!-- Form -->
2424
<NcTextField ref="input"
25+
v-model="name"
2526
class="public-auth-prompt__input"
2627
data-cy-public-auth-prompt-dialog-name
2728
:label="t('Name')"
2829
:placeholder="t('Enter your name')"
2930
:required="!cancellable"
30-
v-model="name"
3131
minlength="2"
3232
maxlength="64"
3333
name="name" />
@@ -114,14 +114,14 @@ export default defineComponent({
114114
},
115115
},
116116
117+
emits: ['close'],
118+
117119
setup() {
118120
return {
119121
t,
120122
}
121123
},
122124
123-
emits: ['close'],
124-
125125
data() {
126126
return {
127127
name: '',
@@ -172,7 +172,7 @@ export default defineComponent({
172172
},
173173
immediate: true,
174174
},
175-
175+
176176
name() {
177177
// Check validity of the new name
178178
const newName = this.name.trim?.() || ''

lib/utils/guestNameValidity.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ export function getGuestNameValidity(name: string): string {
3333
}
3434

3535
switch (error.reason) {
36-
case InvalidFilenameErrorReason.Character:
37-
return t('"{char}" is not allowed inside a name.', { char: error.segment })
38-
case InvalidFilenameErrorReason.ReservedName:
39-
return t('"{segment}" is a reserved name and not allowed.', { segment: error.segment })
40-
case InvalidFilenameErrorReason.Extension:
41-
if (error.segment.match(/\.[a-z]/i)) {
42-
return t('"{extension}" is not an allowed name.', { extension: error.segment })
43-
}
44-
return t('Names must not end with "{extension}".', { extension: error.segment })
45-
default:
46-
return t('Invalid name.')
36+
case InvalidFilenameErrorReason.Character:
37+
return t('"{char}" is not allowed inside a name.', { char: error.segment })
38+
case InvalidFilenameErrorReason.ReservedName:
39+
return t('"{segment}" is a reserved name and not allowed.', { segment: error.segment })
40+
case InvalidFilenameErrorReason.Extension:
41+
if (error.segment.match(/\.[a-z]/i)) {
42+
return t('"{extension}" is not an allowed name.', { extension: error.segment })
43+
}
44+
return t('Names must not end with "{extension}".', { extension: error.segment })
45+
default:
46+
return t('Invalid name.')
4747
}
4848
}
4949
}

0 commit comments

Comments
 (0)