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

[full-ci] Fix Vue 3 warnings #8285

Merged
merged 8 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions changelog/unreleased/change-update-vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ https://github.com/owncloud/web/pull/8256
https://github.com/owncloud/web/pull/8257
https://github.com/owncloud/web/pull/8258
https://github.com/owncloud/web/pull/8282
https://github.com/owncloud/web/pull/8289
https://github.com/owncloud/web/pull/8287
https://github.com/owncloud/web/pull/8285
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@
"ejs": "3.1.8",
"eslint": "8.31.0",
"flush-promises": "1.0.2",
"focus-trap": "6.9.4",
"focus-trap-vue": "1.1.1",
"git-repo-info": "2.1.1",
"jest": "29.3.1",
"jest-axe": "5.0.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
"depcheck": "^1.3.1",
"file-loader": "^6.2.0",
"filesize": "^9.0.11",
"focus-trap": "^6.4.0",
"focus-trap-vue": "^1.1.1",
"focus-trap": "^7.2.0",
"focus-trap-vue": "^4.0.1",
"fuse.js": "^6.4.6",
"glob": "^8.0.3",
"html-loader": "^1.3.2",
Expand Down Expand Up @@ -126,8 +126,8 @@
"peerDependencies": {
"@popperjs/core": "^2.4.0",
"filesize": "^9.0.11",
"focus-trap": "^6.4.0",
"focus-trap-vue": "^1.1.1",
"focus-trap": "^7.2.0",
"focus-trap-vue": "^4.0.1",
"fuse.js": "^6.4.6",
"luxon": "^3.0.1",
"postcss-import": "^12.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/design-system/src/components/OcButton/OcButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
v-bind="additionalAttributes"
:aria-label="ariaLabel"
:class="$_ocButton_buttonClass"
:disabled="disabled"
v-on="handlers"
>
<!-- @slot Content of the button -->
Expand Down Expand Up @@ -159,7 +158,8 @@ export default defineComponent({
...(this.href && { href: this.href }),
...(this.target && { target: this.target }),
...(this.to && { to: this.to }),
...(this.type === 'button' && { type: this.submit })
...(this.type === 'button' && { type: this.submit }),
...(this.type === 'button' && { disabled: this.disabled })
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('OcCheckbox', () => {
const checkbox = wrapper.find(checkboxSelector)
expect((checkbox.element as any).checked).toBeFalsy()
await checkbox.setValue(true)
expect(wrapper.emitted('input')).toBeTruthy()
expect(wrapper.emitted('update:modelValue')).toBeTruthy()
expect((checkbox.element as any).checked).toBeTruthy()
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default defineComponent({
name: 'OcCheckbox',
status: 'ready',
release: '1.0.0',
compatConfig: { MODE: 3 },
props: {
/**
* Id for the checkbox. If it's empty, a generated one will be used.
Expand All @@ -47,7 +48,7 @@ export default defineComponent({
* Can be any type, but most common is boolean for singular checkbox use, or array when used in a group of checkboxes.
**/
// eslint-disable-next-line vue/require-prop-types
value: {
modelValue: {
required: false,
default: false
},
Expand Down Expand Up @@ -99,14 +100,14 @@ export default defineComponent({
default: false
}
},
emits: ['click'],
emits: ['click', 'update:modelValue'],
computed: {
model: {
get() {
return this.value
return this.modelValue
},
set: function (value) {
this.$emit('input', value)
this.$emit('update:modelValue', value)
this.setChecked(value)
}
},
Expand Down
6 changes: 3 additions & 3 deletions packages/design-system/src/components/OcImage/OcImage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ describe('OcImage', () => {
it('should set the provided alt for image', () => {
expect(wrapper.attributes('alt')).toBe('test alt text')
})
it('should disable aria hidden property', () => {
expect(wrapper.attributes('aria-hidden')).toBe(undefined)
it('should set aria hidden property to "false"', () => {
expect(wrapper.attributes('aria-hidden')).toBe('false')
})
})
describe('when alt is not set', () => {
it('should disable aria hidden property', () => {
it('should set aria hidden property to "true"', () => {
const wrapper = getWrapper()
expect(wrapper.attributes('aria-hidden')).toBe('true')
})
Expand Down
2 changes: 1 addition & 1 deletion packages/design-system/src/components/OcImage/OcImage.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<img :src="src" :alt="alt" :aria-hidden="!alt" :title="title" :loading="loadingType" />
<img :src="src" :alt="alt" :aria-hidden="`${!alt}`" :title="title" :loading="loadingType" />
</template>
<script lang="ts">
import { defineComponent } from 'vue'
Expand Down
3 changes: 2 additions & 1 deletion packages/design-system/src/components/OcModal/OcModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
:disabled="inputDisabled"
:fix-message-line="true"
:selection-range="inputSelectionRange"
@input="inputOnInput"
@update:modelValue="inputOnInput"
@keydown.enter.prevent="confirm"
/>
<p v-else key="modal-message" class="oc-modal-body-message" v-text="message" />
Expand Down Expand Up @@ -334,6 +334,7 @@ export default defineComponent({
default: null
}
},
emits: ['cancel', 'confirm', 'confirm-secondary', 'input', 'checkbox-changed'],
data() {
return {
userInputValue: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

exports[`OcModal displays input 1`] = `
<div aria-labelledby="oc-modal-title" class="oc-modal-background">
<focus-trap-stub active="true" allowoutsideclick="true" escapedeactivates="true" initialfocus="[Function]" returnfocusondeactivate="true">
<focus-trap-stub active="true" allowoutsideclick="true" delayinitialfocus="true" escapedeactivates="true" initialfocus="[Function]" returnfocusondeactivate="true">
<div aria-modal="true" class="oc-modal oc-modal-passive" role="dialog" tabindex="0">
<div class="oc-modal-title">
<!--v-if-->
<h2 id="oc-modal-title">Create new folder</h2>
</div>
<div class="oc-modal-body">
<oc-text-input-stub class="oc-modal-body-input" clearbuttonaccessiblelabel="" fixmessageline="true" id="oc-textinput-1" label="Folder name" type="text" value="New folder"></oc-text-input-stub>
<oc-text-input-stub class="oc-modal-body-input" clearbuttonaccessiblelabel="" fixmessageline="true" id="oc-textinput-1" label="Folder name" modelvalue="New folder" type="text"></oc-text-input-stub>
<!--v-if-->
<!--v-if-->
<div class="oc-modal-body-actions oc-flex oc-flex-right">
Expand All @@ -25,7 +25,7 @@ exports[`OcModal displays input 1`] = `

exports[`OcModal hides icon if not specified 1`] = `
<div aria-labelledby="oc-modal-title" class="oc-modal-background">
<focus-trap-stub active="true" allowoutsideclick="true" escapedeactivates="true" initialfocus="[Function]" returnfocusondeactivate="true">
<focus-trap-stub active="true" allowoutsideclick="true" delayinitialfocus="true" escapedeactivates="true" initialfocus="[Function]" returnfocusondeactivate="true">
<div aria-modal="true" class="oc-modal oc-modal-passive" role="dialog" tabindex="0">
<div class="oc-modal-title">
<!--v-if-->
Expand All @@ -48,7 +48,7 @@ exports[`OcModal hides icon if not specified 1`] = `

exports[`OcModal matches snapshot 1`] = `
<div aria-labelledby="oc-modal-title" class="oc-modal-background">
<focus-trap-stub active="true" allowoutsideclick="true" escapedeactivates="true" initialfocus="[Function]" returnfocusondeactivate="true">
<focus-trap-stub active="true" allowoutsideclick="true" delayinitialfocus="true" escapedeactivates="true" initialfocus="[Function]" returnfocusondeactivate="true">
<div aria-modal="true" class="oc-modal oc-modal-passive" role="dialog" tabindex="0">
<div class="oc-modal-title">
<oc-icon-stub accessiblelabel="" color="" filltype="fill" name="info" size="medium" type="span" variation="passive"></oc-icon-stub>
Expand All @@ -71,7 +71,7 @@ exports[`OcModal matches snapshot 1`] = `

exports[`OcModal overrides props message with slot 1`] = `
<div aria-labelledby="oc-modal-title" class="oc-modal-background">
<focus-trap-stub active="true" allowoutsideclick="true" escapedeactivates="true" initialfocus="[Function]" returnfocusondeactivate="true">
<focus-trap-stub active="true" allowoutsideclick="true" delayinitialfocus="true" escapedeactivates="true" initialfocus="[Function]" returnfocusondeactivate="true">
<div aria-modal="true" class="oc-modal oc-modal-passive" role="dialog" tabindex="0">
<div class="oc-modal-title">
<!--v-if-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default defineComponent({
validator: (value) => value > 0
}
},
emits: ['close'],
computed: {
classes() {
return `oc-notification-message-${this.status}`
Expand Down
8 changes: 4 additions & 4 deletions packages/design-system/src/components/OcRadio/OcRadio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ describe('OcRadio', () => {
it('should emit input event if checked', async () => {
const wrapper = getWrapper()
const radioInput = wrapper.find(radioElementSelector)
expect(wrapper.emitted('input')).toBeFalsy()
expect(wrapper.emitted('update:modelValue')).toBeFalsy()
await radioInput.setValue(true)
expect((radioInput.element as any).checked).toBeTruthy()
expect(wrapper.emitted('input')).toBeTruthy()
expect(wrapper.emitted('update:modelValue')).toBeTruthy()
})
it('should not emit input event if disabled', async () => {
const wrapper = getWrapper({ disabled: true })
const radioInput = wrapper.find(radioElementSelector)
expect(wrapper.emitted('input')).toBeFalsy()
expect(wrapper.emitted('update:modelValue')).toBeFalsy()
await radioInput.trigger('click')
expect((radioInput.element as any).checked).toBeFalsy()
expect(wrapper.emitted('input')).toBeFalsy()
expect(wrapper.emitted('update:modelValue')).toBeFalsy()
})
})
describe('input options', () => {
Expand Down
10 changes: 6 additions & 4 deletions packages/design-system/src/components/OcRadio/OcRadio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
type="radio"
name="radio"
:class="classes"
:aria-checked="(option === value).toString()"
:aria-checked="(option === modelValue).toString()"
:value="option"
:disabled="disabled"
/>
Expand All @@ -26,6 +26,7 @@ export default defineComponent({
name: 'OcRadio',
status: 'ready',
release: '1.0.0',
compatConfig: { MODE: 3 },
props: {
/**
* Id for the radio. If it's empty, a generated one will be used.
Expand All @@ -51,7 +52,7 @@ export default defineComponent({
* Can be any type.
**/
// eslint-disable-next-line vue/require-prop-types
value: {
modelValue: {
required: false,
default: false
},
Expand Down Expand Up @@ -94,13 +95,14 @@ export default defineComponent({
validator: (size) => /(small|medium|large)/.test(size)
}
},
emits: ['update:modelValue'],
computed: {
model: {
get() {
return this.value
return this.modelValue
},
set(value) {
this.$emit('input', value)
this.$emit('update:modelValue', value)
}
},
classes() {
Expand Down
32 changes: 29 additions & 3 deletions packages/design-system/src/components/OcSelect/OcSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
ref="select"
:disabled="disabled"
:filter="filter"
:loading="loading"
:searchable="searchable"
:clearable="clearable"
class="oc-select"
style="background: transparent"
v-bind="additionalAttributes"
Expand Down Expand Up @@ -38,8 +41,7 @@ export default defineComponent({
name: 'OcSelect',
status: 'ready',
release: '4.3.0',

compatConfig: { COMPONENT_V_MODEL: false },
compatConfig: { MODE: 3 },
components: { VueSelect },

inheritAttrs: true,
Expand Down Expand Up @@ -100,9 +102,33 @@ export default defineComponent({
optionLabel: {
type: String,
default: null
},
/**
* Determines if the select field is searchable
*/
searchable: {
type: Boolean,
required: false,
default: true
},
/**
* Determines if the select field is clearable
*/
clearable: {
type: Boolean,
required: false,
default: false
},
/**
* Determines if the select field loading
*/
loading: {
type: Boolean,
required: false,
default: false
}
},
emits: ['update:modelValue'],
emits: ['search:input', 'update:modelValue'],

computed: {
additionalAttributes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ describe('OcSwitch', () => {

await wrapper.find('[data-testid="oc-switch-btn"]').trigger('click')

expect(wrapper.emitted().change[0][0]).toEqual(true)
expect(wrapper.emitted('update:checked')[0][0]).toEqual(true)

await wrapper.find('[data-testid="oc-switch-btn"]').trigger('click')

expect(wrapper.emitted().change[0][0]).toEqual(true)
expect(wrapper.emitted('update:checked')[0][0]).toEqual(true)
})
})
10 changes: 3 additions & 7 deletions packages/design-system/src/components/OcSwitch/OcSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ export default defineComponent({
name: 'OcSwitch',
status: 'ready',
release: '1.0.0',
model: {
prop: 'checked',
event: 'change'
},
props: {
/**
* Value of the switch
Expand Down Expand Up @@ -57,15 +53,15 @@ export default defineComponent({
default: () => uniqueId('oc-switch-label-')
}
},

emits: ['update:checked'],
methods: {
toggle() {
/**
* Change event
* @event change
* @event update:checked
* @type {boolean}
*/
this.$emit('change', !this.checked)
this.$emit('update:checked', !this.checked)
}
}
})
Expand Down
1 change: 1 addition & 0 deletions packages/design-system/src/components/OcTable/OcTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export default defineComponent({
},
emits: [
EVENT_ITEM_DROPPED,
EVENT_ITEM_DRAGGED,
EVENT_THEAD_CLICKED,
EVENT_TROW_CLICKED,
EVENT_TROW_MOUNTED,
Expand Down
3 changes: 2 additions & 1 deletion packages/design-system/src/components/OcTag/OcTag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export default defineComponent({
}
},

emits: ['click'],

computed: {
$_ocTag_class() {
const classes = ['oc-tag', `oc-tag-${getSizeClass(this.size)}`]
Expand All @@ -73,7 +75,6 @@ export default defineComponent({
return classes
}
},

methods: {
$_ocTag_click(event) {
/**
Expand Down
Loading