Merge branch 'restore-routes' into 'develop'
Restore old routes, enable user route as fallback. See merge request pleroma/pleroma-fe!440
This commit is contained in:
commit
1555a5fef3
|
@ -168,6 +168,8 @@ const afterStoreSetup = ({ store, i18n }) => {
|
||||||
store.dispatch('setInstanceOption', { name: 'chatAvailable', value: features.includes('chat') })
|
store.dispatch('setInstanceOption', { name: 'chatAvailable', value: features.includes('chat') })
|
||||||
store.dispatch('setInstanceOption', { name: 'gopherAvailable', value: features.includes('gopher') })
|
store.dispatch('setInstanceOption', { name: 'gopherAvailable', value: features.includes('gopher') })
|
||||||
|
|
||||||
|
store.dispatch('setInstanceOption', { name: 'restrictedNicknames', value: metadata.restrictedNicknames })
|
||||||
|
|
||||||
const suggestions = metadata.suggestions
|
const suggestions = metadata.suggestions
|
||||||
store.dispatch('setInstanceOption', { name: 'suggestionsEnabled', value: suggestions.enabled })
|
store.dispatch('setInstanceOption', { name: 'suggestionsEnabled', value: suggestions.enabled })
|
||||||
store.dispatch('setInstanceOption', { name: 'suggestionsWeb', value: suggestions.web })
|
store.dispatch('setInstanceOption', { name: 'suggestionsWeb', value: suggestions.web })
|
||||||
|
|
|
@ -20,48 +20,24 @@ export default (store) => {
|
||||||
redirect: _to => {
|
redirect: _to => {
|
||||||
return (store.state.users.currentUser
|
return (store.state.users.currentUser
|
||||||
? store.state.instance.redirectRootLogin
|
? store.state.instance.redirectRootLogin
|
||||||
: store.state.instance.redirectRootNoLogin) || '/~/main/all'
|
: store.state.instance.redirectRootNoLogin) || '/main/all'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ name: 'public-external-timeline', path: '/~/main/all', component: PublicAndExternalTimeline },
|
{ name: 'public-external-timeline', path: '/main/all', component: PublicAndExternalTimeline },
|
||||||
{ name: 'public-timeline', path: '/~/main/public', component: PublicTimeline },
|
{ name: 'public-timeline', path: '/main/public', component: PublicTimeline },
|
||||||
{ name: 'friends', path: '/~/main/friends', component: FriendsTimeline },
|
{ name: 'friends', path: '/main/friends', component: FriendsTimeline },
|
||||||
// Beginning of temporary redirects
|
{ name: 'tag-timeline', path: '/tag/:tag', component: TagTimeline },
|
||||||
{ path: '/main/:route',
|
{ name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } },
|
||||||
redirect: to => {
|
{ name: 'external-user-profile', path: '/users/:id', component: UserProfile },
|
||||||
const { params } = to
|
{ name: 'mentions', path: '/users/:username/mentions', component: Mentions },
|
||||||
const route = params.route ? params.route : 'all'
|
{ name: 'dms', path: '/users/:username/dms', component: DMs },
|
||||||
|
{ name: 'settings', path: '/settings', component: Settings },
|
||||||
return { path: `/~/main/${route}` }
|
{ name: 'registration', path: '/registration', component: Registration },
|
||||||
}
|
{ name: 'registration', path: '/registration/:token', component: Registration },
|
||||||
},
|
{ name: 'friend-requests', path: '/friend-requests', component: FollowRequests },
|
||||||
{ path: '/tag/:tag',
|
{ name: 'user-settings', path: '/user-settings', component: UserSettings },
|
||||||
redirect: to => {
|
{ name: 'oauth-callback', path: '/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) },
|
||||||
const { params } = to
|
{ name: 'user-search', path: '/user-search', component: UserSearch, props: (route) => ({ query: route.query.query }) },
|
||||||
|
{ name: 'user-profile', path: '/(users/)?:name', component: UserProfile }
|
||||||
return { path: `/~/tag/${params.tag}` }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ path: '/notice/:id',
|
|
||||||
redirect: to => {
|
|
||||||
const { params } = to
|
|
||||||
|
|
||||||
return { path: `/~/notice/${params.id}` }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// End of temporary redirects
|
|
||||||
{ name: 'tag-timeline', path: '/~/tag/:tag', component: TagTimeline },
|
|
||||||
{ name: 'conversation', path: '/~/notice/:id', component: ConversationPage, meta: { dontScroll: true } },
|
|
||||||
{ name: 'user-profile', path: '/:name', component: UserProfile },
|
|
||||||
{ name: 'external-user-profile', path: '/~/users/:id', component: UserProfile },
|
|
||||||
{ name: 'mentions', path: '/:username/mentions', component: Mentions },
|
|
||||||
{ name: 'dms', path: '/:username/dms', component: DMs },
|
|
||||||
{ name: 'settings', path: '/~/settings', component: Settings },
|
|
||||||
{ name: 'registration', path: '/~/registration', component: Registration },
|
|
||||||
{ name: 'registration', path: '/~/registration/:token', component: Registration },
|
|
||||||
{ name: 'friend-requests', path: '/~/friend-requests', component: FollowRequests },
|
|
||||||
{ name: 'user-settings', path: '/~/user-settings', component: UserSettings },
|
|
||||||
{ name: 'oauth-callback', path: '/~/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) },
|
|
||||||
{ name: 'user-search', path: '/~/user-search', component: UserSearch, props: (route) => ({ query: route.query.query }) }
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ const chatPanel = {
|
||||||
this.collapsed = !this.collapsed
|
this.collapsed = !this.collapsed
|
||||||
},
|
},
|
||||||
userProfileLink (user) {
|
userProfileLink (user) {
|
||||||
return generateProfileLink(user.id, user.screen_name)
|
return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ const LoginForm = {
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
this.$store.commit('setToken', result.access_token)
|
this.$store.commit('setToken', result.access_token)
|
||||||
this.$store.dispatch('loginUser', result.access_token)
|
this.$store.dispatch('loginUser', result.access_token)
|
||||||
this.$router.push('/~/main/friends')
|
this.$router.push({name: 'friends'})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ const Notification = {
|
||||||
this.userExpanded = !this.userExpanded
|
this.userExpanded = !this.userExpanded
|
||||||
},
|
},
|
||||||
userProfileLink (user) {
|
userProfileLink (user) {
|
||||||
return generateProfileLink(user.id, user.screen_name)
|
return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -11,7 +11,7 @@ const oac = {
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
this.$store.commit('setToken', result.access_token)
|
this.$store.commit('setToken', result.access_token)
|
||||||
this.$store.dispatch('loginUser', result.access_token)
|
this.$store.dispatch('loginUser', result.access_token)
|
||||||
this.$router.push('/~/main/friends')
|
this.$router.push({name: 'friends'})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ const registration = {
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
if ((!this.registrationOpen && !this.token) || this.signedIn) {
|
if ((!this.registrationOpen && !this.token) || this.signedIn) {
|
||||||
this.$router.push('/~/main/all')
|
this.$router.push({name: 'root'})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setCaptcha()
|
this.setCaptcha()
|
||||||
|
@ -58,7 +58,7 @@ const registration = {
|
||||||
if (!this.$v.$invalid) {
|
if (!this.$v.$invalid) {
|
||||||
try {
|
try {
|
||||||
await this.signUp(this.user)
|
await this.signUp(this.user)
|
||||||
this.$router.push('/~/main/friends')
|
this.$router.push({name: 'friends'})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Registration failed: ' + error)
|
console.warn('Registration failed: ' + error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,7 +291,7 @@ const Status = {
|
||||||
this.showPreview = false
|
this.showPreview = false
|
||||||
},
|
},
|
||||||
userProfileLink (id, name) {
|
userProfileLink (id, name) {
|
||||||
return generateProfileLink(id, name)
|
return generateProfileLink(id, name, this.$store.state.instance.restrictedNicknames)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
|
@ -33,7 +33,7 @@ const UserCard = {
|
||||||
this.$store.dispatch('removeFollowRequest', this.user)
|
this.$store.dispatch('removeFollowRequest', this.user)
|
||||||
},
|
},
|
||||||
userProfileLink (user) {
|
userProfileLink (user) {
|
||||||
return generateProfileLink(user.id, user.screen_name)
|
return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
userProfileLink (user) {
|
userProfileLink (user) {
|
||||||
return generateProfileLink(user.id, user.screen_name)
|
return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ const UserSettings = {
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === 'success') {
|
if (res.status === 'success') {
|
||||||
this.$store.dispatch('logout')
|
this.$store.dispatch('logout')
|
||||||
this.$router.push('/~/main/all')
|
this.$router.push({name: 'root'})
|
||||||
} else {
|
} else {
|
||||||
this.deleteAccountError = res.error
|
this.deleteAccountError = res.error
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ const WhoToFollowPanel = {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
userProfileLink (id, name) {
|
userProfileLink (id, name) {
|
||||||
return generateProfileLink(id, name)
|
return generateProfileLink(id, name, this.$store.state.instance.restrictedNicknames)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
|
@ -12,8 +12,8 @@ const defaultState = {
|
||||||
logo: '/static/logo.png',
|
logo: '/static/logo.png',
|
||||||
logoMask: true,
|
logoMask: true,
|
||||||
logoMargin: '.2em',
|
logoMargin: '.2em',
|
||||||
redirectRootNoLogin: '/~/main/all',
|
redirectRootNoLogin: '/main/all',
|
||||||
redirectRootLogin: '/~/main/friends',
|
redirectRootLogin: '/main/friends',
|
||||||
showInstanceSpecificPanel: false,
|
showInstanceSpecificPanel: false,
|
||||||
scopeOptionsEnabled: true,
|
scopeOptionsEnabled: true,
|
||||||
formattingOptionsEnabled: false,
|
formattingOptionsEnabled: false,
|
||||||
|
@ -33,6 +33,7 @@ const defaultState = {
|
||||||
pleromaBackend: true,
|
pleromaBackend: true,
|
||||||
emoji: [],
|
emoji: [],
|
||||||
customEmoji: [],
|
customEmoji: [],
|
||||||
|
restrictedNicknames: [],
|
||||||
|
|
||||||
// Feature-set, apparently, not everything here is reported...
|
// Feature-set, apparently, not everything here is reported...
|
||||||
mediaProxyAvailable: false,
|
mediaProxyAvailable: false,
|
||||||
|
|
|
@ -5,7 +5,7 @@ const getOrCreateApp = ({oauth, instance}) => {
|
||||||
const form = new window.FormData()
|
const form = new window.FormData()
|
||||||
|
|
||||||
form.append('client_name', `PleromaFE_${Math.random()}`)
|
form.append('client_name', `PleromaFE_${Math.random()}`)
|
||||||
form.append('redirect_uris', `${window.location.origin}/~/oauth-callback`)
|
form.append('redirect_uris', `${window.location.origin}/oauth-callback`)
|
||||||
form.append('scopes', 'read write follow')
|
form.append('scopes', 'read write follow')
|
||||||
|
|
||||||
return window.fetch(url, {
|
return window.fetch(url, {
|
||||||
|
@ -64,7 +64,7 @@ const getToken = ({app, instance, code}) => {
|
||||||
form.append('client_secret', app.client_secret)
|
form.append('client_secret', app.client_secret)
|
||||||
form.append('grant_type', 'authorization_code')
|
form.append('grant_type', 'authorization_code')
|
||||||
form.append('code', code)
|
form.append('code', code)
|
||||||
form.append('redirect_uri', `${window.location.origin}/~/oauth-callback`)
|
form.append('redirect_uri', `${window.location.origin}/oauth-callback`)
|
||||||
|
|
||||||
return window.fetch(url, {
|
return window.fetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
const generateProfileLink = (id, screenName) => {
|
import { includes } from 'lodash'
|
||||||
|
|
||||||
|
const generateProfileLink = (id, screenName, restrictedNicknames) => {
|
||||||
|
const complicated = (isExternal(screenName) || includes(restrictedNicknames, screenName))
|
||||||
return {
|
return {
|
||||||
name: (isExternal(screenName) ? 'external-user-profile' : 'user-profile'),
|
name: (complicated ? 'external-user-profile' : 'user-profile'),
|
||||||
params: (isExternal(screenName) ? { id } : { name: screenName })
|
params: (complicated ? { id } : { name: screenName })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
"logo": "/static/logo.png",
|
"logo": "/static/logo.png",
|
||||||
"logoMask": true,
|
"logoMask": true,
|
||||||
"logoMargin": ".1em",
|
"logoMargin": ".1em",
|
||||||
"redirectRootNoLogin": "/~/main/all",
|
"redirectRootNoLogin": "/main/all",
|
||||||
"redirectRootLogin": "/~/main/friends",
|
"redirectRootLogin": "/main/friends",
|
||||||
"chatDisabled": false,
|
"chatDisabled": false,
|
||||||
"showInstanceSpecificPanel": false,
|
"showInstanceSpecificPanel": false,
|
||||||
"scopeOptionsEnabled": false,
|
"scopeOptionsEnabled": false,
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe('routes', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('root path', () => {
|
it('root path', () => {
|
||||||
router.push('/~/main/all')
|
router.push('/main/all')
|
||||||
|
|
||||||
const matchedComponents = router.getMatchedComponents()
|
const matchedComponents = router.getMatchedComponents()
|
||||||
|
|
||||||
|
@ -26,4 +26,12 @@ describe('routes', () => {
|
||||||
|
|
||||||
expect(matchedComponents[0].components.hasOwnProperty('UserCardContent')).to.eql(true)
|
expect(matchedComponents[0].components.hasOwnProperty('UserCardContent')).to.eql(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('user\'s profile at /users', () => {
|
||||||
|
router.push('/users/fake-user-name')
|
||||||
|
|
||||||
|
const matchedComponents = router.getMatchedComponents()
|
||||||
|
|
||||||
|
expect(matchedComponents[0].components.hasOwnProperty('UserCardContent')).to.eql(true)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,4 +12,10 @@ describe('generateProfileLink', () => {
|
||||||
name: 'external-user-profile', params: { id: 1 }
|
name: 'external-user-profile', params: { id: 1 }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('returns obj for restricted user', () => {
|
||||||
|
expect(generateProfileLink(1, 'lain', ['lain'])).to.eql({
|
||||||
|
name: 'external-user-profile', params: { id: 1 }
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue