From 79d864c3f2cc7e72fdcc957168ce5ed2d0a61686 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Mon, 3 Dec 2018 21:36:59 +0300 Subject: [PATCH 01/24] Move routes to the separate file -> make it testable --- src/boot/after_store.js | 44 +++-------------------------------------- src/boot/routes.js | 42 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 41 deletions(-) create mode 100644 src/boot/routes.js diff --git a/src/boot/after_store.js b/src/boot/after_store.js index a80baaf5e7..3b9b05721a 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -1,21 +1,8 @@ import Vue from 'vue' import VueRouter from 'vue-router' +import routes from './routes' import App from '../App.vue' -import PublicTimeline from '../components/public_timeline/public_timeline.vue' -import PublicAndExternalTimeline from '../components/public_and_external_timeline/public_and_external_timeline.vue' -import FriendsTimeline from '../components/friends_timeline/friends_timeline.vue' -import TagTimeline from '../components/tag_timeline/tag_timeline.vue' -import ConversationPage from '../components/conversation-page/conversation-page.vue' -import Mentions from '../components/mentions/mentions.vue' -import DMs from '../components/dm_timeline/dm_timeline.vue' -import UserProfile from '../components/user_profile/user_profile.vue' -import Settings from '../components/settings/settings.vue' -import Registration from '../components/registration/registration.vue' -import UserSettings from '../components/user_settings/user_settings.vue' -import FollowRequests from '../components/follow_requests/follow_requests.vue' -import OAuthCallback from '../components/oauth_callback/oauth_callback.vue' -import UserSearch from '../components/user_search/user_search.vue' const afterStoreSetup = ({store, i18n}) => { window.fetch('/api/statusnet/config.json') @@ -81,35 +68,10 @@ const afterStoreSetup = ({store, i18n}) => { store.dispatch('disableChat') } - const routes = [ - { name: 'root', - path: '/', - redirect: to => { - return (store.state.users.currentUser - ? store.state.instance.redirectRootLogin - : store.state.instance.redirectRootNoLogin) || '/main/all' - }}, - { path: '/main/all', component: PublicAndExternalTimeline }, - { path: '/main/public', component: PublicTimeline }, - { path: '/main/friends', component: FriendsTimeline }, - { path: '/tag/:tag', component: TagTimeline }, - { name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } }, - { name: '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 }) } - ] - const router = new VueRouter({ mode: 'history', - routes, - scrollBehavior: (to, from, savedPosition) => { + routes: routes(store), + scrollBehavior: (to, _from, savedPosition) => { if (to.matched.some(m => m.meta.dontScroll)) { return false } diff --git a/src/boot/routes.js b/src/boot/routes.js new file mode 100644 index 0000000000..715c2fe811 --- /dev/null +++ b/src/boot/routes.js @@ -0,0 +1,42 @@ +import PublicTimeline from '../components/public_timeline/public_timeline.vue' +import PublicAndExternalTimeline from '../components/public_and_external_timeline/public_and_external_timeline.vue' +import FriendsTimeline from '../components/friends_timeline/friends_timeline.vue' +import TagTimeline from '../components/tag_timeline/tag_timeline.vue' +import ConversationPage from '../components/conversation-page/conversation-page.vue' +import Mentions from '../components/mentions/mentions.vue' +import DMs from '../components/dm_timeline/dm_timeline.vue' +import UserProfile from '../components/user_profile/user_profile.vue' +import Settings from '../components/settings/settings.vue' +import Registration from '../components/registration/registration.vue' +import UserSettings from '../components/user_settings/user_settings.vue' +import FollowRequests from '../components/follow_requests/follow_requests.vue' +import OAuthCallback from '../components/oauth_callback/oauth_callback.vue' +import UserSearch from '../components/user_search/user_search.vue' + +export default (store) => { + return [ + { name: 'root', + path: '/', + redirect: _to => { + return (store.state.users.currentUser + ? store.state.instance.redirectRootLogin + : store.state.instance.redirectRootNoLogin) || '/main/all' + } + }, + { path: '/main/all', component: PublicAndExternalTimeline }, + { path: '/main/public', component: PublicTimeline }, + { path: '/main/friends', component: FriendsTimeline }, + { path: '/tag/:tag', component: TagTimeline }, + { name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } }, + { name: '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 }) } + ] +} From c3c75e07024dc0b0df2d9ddd06fc0ef5d8ff038e Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Wed, 5 Dec 2018 17:57:07 +0300 Subject: [PATCH 02/24] Remove dummy component --- test/unit/specs/Hello.spec.js | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 test/unit/specs/Hello.spec.js diff --git a/test/unit/specs/Hello.spec.js b/test/unit/specs/Hello.spec.js deleted file mode 100644 index d66e39efa8..0000000000 --- a/test/unit/specs/Hello.spec.js +++ /dev/null @@ -1,13 +0,0 @@ -// import Vue from 'vue' -// import Hello from 'src/components/Hello' - -// describe('Hello.vue', () => { -// xit('should render correct contents', () => { -// const vm = new Vue({ -// el: document.createElement('div'), -// render: (h) => h(Hello) -// }) -// expect(vm.$el.querySelector('.hello h1').textContent) -// .to.equal('Welcome to Your Vue.js App') -// }) -// }) From 6532462b95fbea1a19508fcdfa50df02b083b657 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Thu, 6 Dec 2018 04:05:35 +0300 Subject: [PATCH 03/24] Move old routes to /p, use /nickname for user profiles --- package.json | 1 + src/boot/routes.js | 56 +++++++++---------- src/components/chat_panel/chat_panel.vue | 2 +- src/components/nav_panel/nav_panel.vue | 8 +-- src/components/notification/notification.vue | 2 +- .../post_status_form/post_status_form.vue | 2 +- src/components/status/status.vue | 6 +- src/components/user_card/user_card.vue | 2 +- .../user_card_content/user_card_content.vue | 6 +- src/components/user_profile/user_profile.js | 11 +++- .../who_to_follow_panel.vue | 6 +- test/unit/specs/boot/routes.spec.js | 29 ++++++++++ yarn.lock | 13 +++++ 13 files changed, 96 insertions(+), 48 deletions(-) create mode 100644 test/unit/specs/boot/routes.spec.js diff --git a/package.json b/package.json index 18e79e1611..8f2a78a2ae 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "whatwg-fetch": "^2.0.3" }, "devDependencies": { + "@vue/test-utils": "^1.0.0-beta.26", "autoprefixer": "^6.4.0", "babel-core": "^6.0.0", "babel-eslint": "^7.0.0", diff --git a/src/boot/routes.js b/src/boot/routes.js index 715c2fe811..f6a1eff89d 100644 --- a/src/boot/routes.js +++ b/src/boot/routes.js @@ -1,17 +1,17 @@ -import PublicTimeline from '../components/public_timeline/public_timeline.vue' -import PublicAndExternalTimeline from '../components/public_and_external_timeline/public_and_external_timeline.vue' -import FriendsTimeline from '../components/friends_timeline/friends_timeline.vue' -import TagTimeline from '../components/tag_timeline/tag_timeline.vue' -import ConversationPage from '../components/conversation-page/conversation-page.vue' -import Mentions from '../components/mentions/mentions.vue' -import DMs from '../components/dm_timeline/dm_timeline.vue' -import UserProfile from '../components/user_profile/user_profile.vue' -import Settings from '../components/settings/settings.vue' -import Registration from '../components/registration/registration.vue' -import UserSettings from '../components/user_settings/user_settings.vue' -import FollowRequests from '../components/follow_requests/follow_requests.vue' -import OAuthCallback from '../components/oauth_callback/oauth_callback.vue' -import UserSearch from '../components/user_search/user_search.vue' +import PublicTimeline from 'components/public_timeline/public_timeline.vue' +import PublicAndExternalTimeline from 'components/public_and_external_timeline/public_and_external_timeline.vue' +import FriendsTimeline from 'components/friends_timeline/friends_timeline.vue' +import TagTimeline from 'components/tag_timeline/tag_timeline.vue' +import ConversationPage from 'components/conversation-page/conversation-page.vue' +import Mentions from 'components/mentions/mentions.vue' +import DMs from 'components/dm_timeline/dm_timeline.vue' +import UserProfile from 'components/user_profile/user_profile.vue' +import Settings from 'components/settings/settings.vue' +import Registration from 'components/registration/registration.vue' +import UserSettings from 'components/user_settings/user_settings.vue' +import FollowRequests from 'components/follow_requests/follow_requests.vue' +import OAuthCallback from 'components/oauth_callback/oauth_callback.vue' +import UserSearch from 'components/user_search/user_search.vue' export default (store) => { return [ @@ -20,23 +20,23 @@ export default (store) => { redirect: _to => { return (store.state.users.currentUser ? store.state.instance.redirectRootLogin - : store.state.instance.redirectRootNoLogin) || '/main/all' + : store.state.instance.redirectRootNoLogin) || '/p/main/all' } }, - { path: '/main/all', component: PublicAndExternalTimeline }, - { path: '/main/public', component: PublicTimeline }, - { path: '/main/friends', component: FriendsTimeline }, - { path: '/tag/:tag', component: TagTimeline }, - { name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } }, - { name: 'user-profile', path: '/users/:id', component: UserProfile }, + { name: 'public-external-timeline', path: '/p/main/all', component: PublicAndExternalTimeline }, + { name: 'public-timeline', path: '/p/main/public', component: PublicTimeline }, + { name: 'friends', path: '/p/main/friends', component: FriendsTimeline }, + { name: 'tag-timeline', path: '/p/tag/:tag', component: TagTimeline }, + { name: 'conversation', path: '/p/notice/:id', component: ConversationPage, meta: { dontScroll: true } }, + { name: 'user-profile', path: '/:name', 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 }) } + { name: 'settings', path: '/p/settings', component: Settings }, + { name: 'registration', path: '/p/registration', component: Registration }, + { name: 'registration', path: '/p/registration/:token', component: Registration }, + { name: 'friend-requests', path: '/p/friend-requests', component: FollowRequests }, + { name: 'user-settings', path: '/p/user-settings', component: UserSettings }, + { name: 'oauth-callback', path: '/p/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) }, + { name: 'user-search', path: '/p/user-search', component: UserSearch, props: (route) => ({ query: route.query.query }) } ] } diff --git a/src/components/chat_panel/chat_panel.vue b/src/components/chat_panel/chat_panel.vue index 30070d3e1d..e36718186a 100644 --- a/src/components/chat_panel/chat_panel.vue +++ b/src/components/chat_panel/chat_panel.vue @@ -13,7 +13,7 @@
- + {{message.author.username}}
diff --git a/src/components/nav_panel/nav_panel.vue b/src/components/nav_panel/nav_panel.vue index b224c5f31e..c52d1e52fa 100644 --- a/src/components/nav_panel/nav_panel.vue +++ b/src/components/nav_panel/nav_panel.vue @@ -3,7 +3,7 @@
  • - + {{ $t("nav.timeline") }}
  • @@ -18,17 +18,17 @@
  • - + {{ $t("nav.friend_requests") }}
  • - + {{ $t("nav.public_tl") }}
  • - + {{ $t("nav.twkn") }}
  • diff --git a/src/components/notification/notification.vue b/src/components/notification/notification.vue index 13a5c0aa04..401465130b 100644 --- a/src/components/notification/notification.vue +++ b/src/components/notification/notification.vue @@ -28,7 +28,7 @@