mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(settings): allow to clear twitter and fediverse
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
e2291024f0
commit
dabe0ec29f
3 changed files with 28 additions and 4 deletions
|
|
@ -19,7 +19,7 @@ import { NAME_READABLE_ENUM } from '../../constants/AccountPropertyConstants.js'
|
|||
|
||||
import AccountPropertySection from './shared/AccountPropertySection.vue'
|
||||
|
||||
const { fediverse } = loadState<AccountProperties>('settings', 'personalInfoParameters', {})
|
||||
const { fediverse } = loadState<AccountProperties>('settings', 'personalInfoParameters')
|
||||
|
||||
const value = ref({ ...fediverse })
|
||||
const readable = NAME_READABLE_ENUM[fediverse.name]
|
||||
|
|
@ -29,11 +29,18 @@ const readable = NAME_READABLE_ENUM[fediverse.name]
|
|||
* @param text The potential fediverse handle
|
||||
*/
|
||||
function onValidate(text: string): boolean {
|
||||
// allow to clear the value
|
||||
if (text === '') {
|
||||
return true
|
||||
}
|
||||
|
||||
// check its in valid format
|
||||
const result = text.match(/^@?([^@/]+)@([^@/]+)$/)
|
||||
if (result === null) {
|
||||
return false
|
||||
}
|
||||
|
||||
// check its a valid URL
|
||||
try {
|
||||
return URL.parse(`https://${result[2]}/`) !== null
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import { ref } from 'vue'
|
|||
import { NAME_READABLE_ENUM } from '../../constants/AccountPropertyConstants.ts'
|
||||
import AccountPropertySection from './shared/AccountPropertySection.vue'
|
||||
|
||||
const { twitter } = loadState<AccountProperties>('settings', 'personalInfoParameters', {})
|
||||
const { twitter } = loadState<AccountProperties>('settings', 'personalInfoParameters')
|
||||
|
||||
const value = ref({ ...twitter })
|
||||
const readable = NAME_READABLE_ENUM[twitter.name]
|
||||
|
|
@ -29,6 +29,6 @@ const readable = NAME_READABLE_ENUM[twitter.name]
|
|||
* @param text The potential twitter handle
|
||||
*/
|
||||
function onValidate(text: string): boolean {
|
||||
return text.match(/^@?([a-zA-Z0-9_]{2,15})$/) !== null
|
||||
return text === '' || text.match(/^@?([a-zA-Z0-9_]{2,15})$/) !== null
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ describe('Settings: Change personal information', { testIsolation: true }, () =>
|
|||
|
||||
before(() => {
|
||||
// make sure the fediverse check does not do http requests
|
||||
cy.runOccCommand('config:system:set has_internet_connection --value false')
|
||||
cy.runOccCommand('config:system:set has_internet_connection --type bool --value false')
|
||||
// ensure we can set locale and language
|
||||
cy.runOccCommand('config:system:delete force_language')
|
||||
cy.runOccCommand('config:system:delete force_locale')
|
||||
|
|
@ -370,6 +370,23 @@ describe('Settings: Change personal information', { testIsolation: true }, () =>
|
|||
inputForLabel('Phone number').should('have.value', '')
|
||||
})
|
||||
|
||||
it('Can reset social media property', () => {
|
||||
cy.contains('label', 'Fediverse').scrollIntoView()
|
||||
inputForLabel('Fediverse').type('{selectAll}@nextcloud@mastodon.social')
|
||||
handlePasswordConfirmation(user.password)
|
||||
|
||||
cy.wait('@submitSetting')
|
||||
cy.reload()
|
||||
inputForLabel('Fediverse').should('have.value', 'nextcloud@mastodon.social')
|
||||
|
||||
inputForLabel('Fediverse').clear()
|
||||
handlePasswordConfirmation(user.password)
|
||||
|
||||
cy.wait('@submitSetting')
|
||||
cy.reload()
|
||||
inputForLabel('Fediverse').should('have.value', '')
|
||||
})
|
||||
|
||||
it('Can set Website and change its visibility', () => {
|
||||
cy.contains('label', 'Website').scrollIntoView()
|
||||
// Check invalid input
|
||||
|
|
|
|||
Loading…
Reference in a new issue