Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions apps/settings/src/components/PersonalInfo/TwitterSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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>
19 changes: 18 additions & 1 deletion cypress/e2e/settings/personal-info.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions dist/settings-vue-settings-personal-info.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-personal-info.js.map

Large diffs are not rendered by default.

Loading