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

Bugfix: Remove password buttons when disabled #10096

Merged
merged 3 commits into from
Nov 30, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Remove password buttons on input if disabled

We've removed the password buttons on an input field which is disabled to not confuse the user.

https://github.com/owncloud/web/pull/10096
https://github.com/owncloud/web/issues/10084
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ describe('OcTextInput', () => {
const wrapper2 = getMountedWrapper({ props: { type: 'password' } })
expect(wrapper2.find(selectors.copyPasswordBtn).exists()).toBeFalsy()
})
it('should not exist if the input is disabled', () => {
const wrapper = getMountedWrapper({ props: { type: 'password', disabled: true } })
expect(wrapper.find(selectors.copyPasswordBtn).exists()).toBeFalsy()
})
it('should exist if type is "password" and value entered', async () => {
const wrapper = getMountedWrapper({ props: { type: 'password' } })
await wrapper.find(selectors.inputField).setValue('password')
Expand All @@ -108,6 +112,10 @@ describe('OcTextInput', () => {
const wrapper2 = getMountedWrapper({ props: { type: 'password' } })
expect(wrapper2.find(selectors.showPasswordToggleBtn).exists()).toBeFalsy()
})
it('should not exist if the input is disabled', () => {
const wrapper = getMountedWrapper({ props: { type: 'password', disabled: true } })
expect(wrapper.find(selectors.showPasswordToggleBtn).exists()).toBeFalsy()
})
it('should exist if type is "password" and value entered', async () => {
const wrapper = getMountedWrapper({ props: { type: 'password' } })
await wrapper.find(selectors.inputField).setValue('password')
Expand All @@ -130,6 +138,10 @@ describe('OcTextInput', () => {
const wrapper2 = getMountedWrapper({ props: { type: 'password' } })
expect(wrapper2.find(selectors.generatePasswordBtn).exists()).toBeFalsy()
})
it('should not exist if the input is disabled', () => {
const wrapper = getMountedWrapper({ props: { type: 'password', disabled: true } })
expect(wrapper.find(selectors.generatePasswordBtn).exists()).toBeFalsy()
})
it('should exist if type is "password" and prop "generatePasswordMethod" is provided', () => {
const wrapper = getMountedWrapper({
props: { generatePasswordMethod: jest.fn(), type: 'password' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

exports[`OcTextInput password input field password policy displays error state if password does not match criteria 1`] = `
<div class="">
<label class="oc-label" for="oc-textinput-21"></label>
<label class="oc-label" for="oc-textinput-24"></label>
<div class="oc-position-relative">
<!--v-if-->
<div class="oc-text-input-password-wrapper">
<input aria-invalid="false" class="oc-text-input oc-input oc-rounded" id="oc-textinput-21" type="password">
<input aria-invalid="false" class="oc-text-input oc-input oc-rounded" id="oc-textinput-24" type="password">
<button class="oc-button oc-rounded oc-button-s oc-button-justify-content-center oc-button-gap-m oc-button-passive oc-button-passive-raw oc-text-input-show-password-toggle oc-px-s oc-background-default" type="button">
<!--v-if-->
<!-- @slot Content of the button -->
Expand Down Expand Up @@ -43,11 +43,11 @@ exports[`OcTextInput password input field password policy displays error state i

exports[`OcTextInput password input field password policy displays success state if password matches criteria 1`] = `
<div class="">
<label class="oc-label" for="oc-textinput-22"></label>
<label class="oc-label" for="oc-textinput-25"></label>
<div class="oc-position-relative">
<!--v-if-->
<div class="oc-text-input-password-wrapper">
<input aria-invalid="false" class="oc-text-input oc-input oc-rounded" id="oc-textinput-22" type="password">
<input aria-invalid="false" class="oc-text-input oc-input oc-rounded" id="oc-textinput-25" type="password">
<button class="oc-button oc-rounded oc-button-s oc-button-justify-content-center oc-button-gap-m oc-button-passive oc-button-passive-raw oc-text-input-show-password-toggle oc-px-s oc-background-default" type="button">
<!--v-if-->
<!-- @slot Content of the button -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
ref="passwordInput"
v-model="password"
:type="showPassword ? 'text' : 'password'"
:disabled="disabled"
@input="onPasswordEntered"
/>
<oc-button
v-if="password"
v-if="password && !disabled"
v-oc-tooltip="$gettext('Show password')"
class="oc-text-input-show-password-toggle oc-px-s oc-background-default"
appearance="raw"
Expand All @@ -24,7 +25,7 @@
<oc-icon size="small" :name="showPassword ? 'eye-off' : 'eye'" />
</oc-button>
<oc-button
v-if="password"
v-if="password && !disabled"
v-oc-tooltip="$gettext('Copy password')"
class="oc-text-input-copy-password-button oc-px-s oc-background-default"
appearance="raw"
Expand All @@ -34,7 +35,7 @@
<oc-icon size="small" :name="copyPasswordIcon" />
</oc-button>
<oc-button
v-if="generatePasswordMethod"
v-if="generatePasswordMethod && !disabled"
v-oc-tooltip="$gettext('Generate password')"
class="oc-text-input-generate-password-button oc-px-s oc-background-default"
appearance="raw"
Expand Down Expand Up @@ -105,6 +106,11 @@ export default defineComponent({
type: Boolean,
required: false,
default: false
},
disabled: {
type: Boolean,
required: false,
default: false
}
},
emits: ['passwordChallengeCompleted', 'passwordChallengeFailed', 'passwordGenerated'],
Expand Down