mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 05:07:22 +01:00
* Fix profile modal tab navigation URLs for both own and other users profiles
- Add routes for /user/profile, /user/stats, and /user/achievements
- Update selectPage() to properly update URLs when switching tabs
- Own profile uses /user/{tab} format
- Other users' profiles use /profile/{userId}#{tab} format
- Parse hash fragments when navigating to other users' profile tabs
- Ensure direct navigation to tab URLs opens correct tab
* Fix undefined userId
* Server now matches usernames case insensitively like client
- Preserves original capitalization in mention text
- Fixes profile links not working with wrong case mentions
* lint fixes
* g1g1 width auto sizing w/padding
* Challenge participants spacing & text sizing fix
* Fix inconsistent profile URL format between own and other users' profiles
- Update profile tab navigation to use consistent URL format for all users
- Redirect old /user/* routes to new format for backward compatibility
- Update all navigation points (dropdown menu, notifications) to use new URLs
* Update End Challenge modal
- Replace dropdown with searchable input (384x32px) for winner selection
- Add visual badge state with gems icons for challenge completion
- Update Delete Challenge flow with refund info and proper styling
- Add close button (X) with opacity hover effect
- Enhance Award Winner button with gem icon and dynamic prize display
- Apply conditional styling based on winner selection state
- Update text colors: Maroon/50 for delete warning, Gray/100 for "OR" text
- Add proper translations for gem/gems and refund description
* lint error fixes
* end challenge modal fixes
* lint fix
* Use existing closeX component, minor UI fixes to close challenge modal
* fix lint
* Delete icon color to match text on close challenge modal
use color field to set delete icon color
* Highlight username on close challenge modal color updates
- Background color on hover: purple-600
- Text color on hover: purple-300
- Changed transition from just background-color to all so both color changes animate smoothly
* Fix strings
* Refactor g1g1 notifications from database-driven to event-based system
Changed g1g1 (gift one get one) notifications to display automatically during event periods instead of requiring database storage. Notifications now appear based on event calendar dates and use sessionStorage for dismissal state.
- Display g1g1 notification when event is active in worldState
- Store dismissal state in sessionStorage with event-specific keys
- Remove dependency on user.notifications database array
- Maintain identical user experience and appearance
* Update prize card to match participants card on challenges
* End Challenge modal UI tweaks
* Prevent false mention highlights
Prevent false mention highlights when a user's display name matches another user's username. The purple mention indicator now only appears for actual @username mentions.
* lint fixes
* Remove mention highlight
* Mention highlighting to only highlight w/username mentions
* Update G1G1 Notification
- Updated text styling for title & description
- Updated button styling
- Updated close button
* lint fix
* Add updated G1G1 notification SVGs
* Don't highlight display name w/mention
* g1g1 UI updates
- Fix sizing of gift SVGs (96px tall)
- Update button to use button element and styles <button class="btn btn-secondary mx-auto">
- Fixed positioning, color, and hover state of close icon (default white 50% opacity, hover 75% opacity)
* Fix g1g1 close icon hover state
Fix hover state of close icon (default white 50% opacity, hover 75% opacity)
* g1g1 close hover state fix
* End challenge UI updates
- Fix modal title positioning
- Fix close icon positioning
- Fix spacing between title and gem graphic
- Fix spacing between label and input field
- Fix search icon position, change input hint to "@Username"
- Set search results text align start/left with 16px starting padding.
- Fix Award Button state
* remove trailing space
* Fix exit hover state on g1g1
* fix g1g1 close icon (directly render close icon)
* new line
* Update z-index of g1g1 close button
* add display name support for mention highlighting
mention highlights now trigger for both username and display name mentions.
* Override default close button color (gray -> white)
(Also revert the renderWithMentions change)
* Fix mention display name test (& fix lint)
* Revert display name mention, strictly only username
Mentions work w/username only (works w/case insensitive as well)
* Improved case-insensitive username matching
* add close-white.svg, replace close.svg on g1g1
* find mentions that match the current user's username (case-insensitive)
* fix lint errors
* end challenge modal UI updates
* Don't change gem color on update
* disabled state button match button.scss syling
* remove padding from g1g1 close
* Directly use button.scss on end challenge modal
* Update disabled state for button.scss
* explicitly set close challenge modal button disabled/enabled state
* fix trailing space
* Add font details (and fix text color) for button disabled state
* Update award winner button min-height & padding
* button.scss button disabled styling updates
* Remove redundant disabled override on award winner button
* lint
* Use single gifts svg, and apply transform to flip horizontally
Remove unneeded gifts_end.svg
* Replaced the hardcoded #1A1B1D color with the $black from colors.scss
* Removed the 0.5em padding w/p-2
* added v-once to the refund text element
* Converted the line-height values from pixel values to multipliers
429 lines
15 KiB
JavaScript
429 lines
15 KiB
JavaScript
import Vue from 'vue';
|
|
import VueRouter from 'vue-router';
|
|
import * as Analytics from '@/libs/analytics';
|
|
import getStore from '@/store';
|
|
import handleRedirect from './handleRedirect';
|
|
|
|
import { PAGES } from '@/libs/consts';
|
|
import { STATIC_ROUTES } from './static-routes';
|
|
import { USER_ROUTES } from './user-routes';
|
|
import { DEPRECATED_ROUTES } from '@/router/deprecated-routes';
|
|
|
|
// NOTE: when adding a page make sure to implement the `common:setTitle` action
|
|
|
|
const RegisterLoginReset = () => import(/* webpackChunkName: "auth" */'@/components/auth/registerLoginReset');
|
|
const Logout = () => import(/* webpackChunkName: "auth" */'@/components/auth/logout');
|
|
|
|
// Hall
|
|
const HallPage = () => import(/* webpackChunkName: "hall" */'@/components/hall/index');
|
|
const PatronsPage = () => import(/* webpackChunkName: "hall" */'@/components/hall/patrons');
|
|
const HeroesPage = () => import(/* webpackChunkName: "hall" */'@/components/hall/heroes');
|
|
|
|
// Admin Pages
|
|
const AdminContainerPage = () => import(/* webpackChunkName: "admin-panel" */'@/components/admin/container');
|
|
const AdminPanelPage = () => import(/* webpackChunkName: "admin-panel" */'@/components/admin/admin-panel');
|
|
const AdminPanelUserPage = () => import(/* webpackChunkName: "admin-panel" */'@/components/admin/admin-panel/user-support');
|
|
const AdminPanelSearchPage = () => import(/* webpackChunkName: "admin-panel" */'@/components/admin/admin-panel/search');
|
|
const GroupAdminPage = () => import(/* webpackChunkName: "admin-panel" */'@/components/admin/groups');
|
|
const GroupAdminGroupPage = () => import(/* webpackChunkName: "admin-panel" */'@/components/admin/groups/group-support');
|
|
const BlockerPage = () => import(/* webpackChunkName: "admin-panel" */'@/components/admin/blocker');
|
|
|
|
// Tasks
|
|
const UserTasks = () => import(/* webpackChunkName: "userTasks" */'@/components/tasks/user');
|
|
|
|
// Inventory
|
|
const InventoryContainer = () => import(/* webpackChunkName: "inventory" */'@/components/inventory/index');
|
|
const ItemsPage = () => import(/* webpackChunkName: "inventory" */'@/components/inventory/items/index');
|
|
const EquipmentPage = () => import(/* webpackChunkName: "inventory" */'@/components/inventory/equipment/index');
|
|
const StablePage = () => import(/* webpackChunkName: "inventory" */'@/components/inventory/stable/index');
|
|
|
|
// Guilds & Parties
|
|
const GroupPage = () => import(/* webpackChunkName: "guilds" */ '@/components/groups/group');
|
|
const GroupPlansAppPage = () => import(/* webpackChunkName: "guilds" */ '@/components/static/groupPlans');
|
|
const LookingForParty = () => import(/* webpackChunkName: "guilds" */ '@/components/groups/lookingForParty');
|
|
|
|
// Group Plans
|
|
const GroupPlanIndex = () => import(/* webpackChunkName: "group-plans" */ '@/components/group-plans/index');
|
|
const GroupPlanTaskInformation = () => import(/* webpackChunkName: "group-plans" */ '@/components/group-plans/taskInformation');
|
|
const GroupPlanBilling = () => import(/* webpackChunkName: "group-plans" */ '@/components/group-plans/billing');
|
|
|
|
const MessagesIndex = () => import(/* webpackChunkName: "private-messages" */ '@/pages/private-messages/index.vue');
|
|
|
|
// Challenges
|
|
const ChallengeIndex = () => import(/* webpackChunkName: "challenges" */ '@/components/challenges/index');
|
|
const MyChallenges = () => import(/* webpackChunkName: "challenges" */ '@/components/challenges/myChallenges');
|
|
const FindChallenges = () => import(/* webpackChunkName: "challenges" */ '@/components/challenges/findChallenges');
|
|
const ChallengeDetail = () => import(/* webpackChunkName: "challenges" */ '@/components/challenges/challengeDetail');
|
|
|
|
// Shops
|
|
const ShopsContainer = () => import(/* webpackChunkName: "shops" */'@/components/shops/index');
|
|
const MarketPage = () => import(/* webpackChunkName: "shops-market" */'@/components/shops/market/index');
|
|
const QuestsPage = () => import(/* webpackChunkName: "shops-quest" */'@/components/shops/quests/index');
|
|
const CustomizationsPage = () => import(/* webpackChunkName: "shops-customizations" */'@/components/shops/customizations/index');
|
|
const SeasonalPage = () => import(/* webpackChunkName: "shops-seasonal" */'@/components/shops/seasonal/index');
|
|
const TimeTravelersPage = () => import(/* webpackChunkName: "shops-timetravelers" */'@/components/shops/timeTravelers/index');
|
|
|
|
Vue.use(VueRouter);
|
|
|
|
const router = new VueRouter({
|
|
mode: 'history',
|
|
base: '/',
|
|
linkActiveClass: 'active',
|
|
// When navigating to another route always scroll to the top
|
|
// To customize the behavior see https://router.vuejs.org/en/advanced/scroll-behavior.html
|
|
scrollBehavior () {
|
|
return { x: 0, y: 0 };
|
|
},
|
|
// meta defaults: requiresLogin true, privilegeNeeded empty
|
|
// NOTE: when adding a new route entry make sure to implement the `common:setTitle` action
|
|
// in the route component to set a specific subtitle for the page.
|
|
routes: [
|
|
{ name: 'logout', path: '/logout', component: Logout },
|
|
{
|
|
name: 'resetPassword', path: '/reset-password', component: RegisterLoginReset, meta: { requiresLogin: false },
|
|
}, {
|
|
name: 'forgotPassword', path: '/forgot-password', component: RegisterLoginReset, meta: { requiresLogin: false },
|
|
},
|
|
{ name: 'tasks', path: '/', component: UserTasks },
|
|
{
|
|
name: 'userProfile',
|
|
path: '/profile/:userId',
|
|
props: true,
|
|
},
|
|
{ name: 'profile', path: '/user/profile' },
|
|
{ name: 'stats', path: '/user/stats' },
|
|
{ name: 'achievements', path: '/user/achievements' },
|
|
{
|
|
path: '/inventory',
|
|
component: InventoryContainer,
|
|
children: [
|
|
{ name: 'items', path: 'items', component: ItemsPage },
|
|
{ name: 'equipment', path: 'equipment', component: EquipmentPage },
|
|
{ name: 'stable', path: 'stable', component: StablePage },
|
|
],
|
|
},
|
|
{
|
|
path: '/shops',
|
|
component: ShopsContainer,
|
|
children: [
|
|
{ name: 'market', path: 'market', component: MarketPage },
|
|
{ name: 'quests', path: 'quests', component: QuestsPage },
|
|
{ name: 'customizations', path: 'customizations', component: CustomizationsPage },
|
|
{ name: 'seasonal', path: 'seasonal', component: SeasonalPage },
|
|
{ name: 'time', path: 'time', component: TimeTravelersPage },
|
|
],
|
|
},
|
|
{ name: 'party', path: '/party', component: GroupPage },
|
|
{ name: 'lookingForParty', path: '/looking-for-party', component: LookingForParty },
|
|
{ name: 'groupPlan', path: '/group-plans', component: GroupPlansAppPage },
|
|
{
|
|
name: 'groupPlanDetail',
|
|
path: '/group-plans/:groupId',
|
|
component: GroupPlanIndex,
|
|
props: true,
|
|
children: [
|
|
{
|
|
name: 'groupPlanDetailTaskInformation',
|
|
path: '/group-plans/:groupId/task-information',
|
|
component: GroupPlanTaskInformation,
|
|
props: true,
|
|
},
|
|
{
|
|
name: 'groupPlanDetailInformation',
|
|
path: '/group-plans/:groupId/information',
|
|
component: GroupPage,
|
|
props: true,
|
|
},
|
|
{
|
|
name: 'groupPlanBilling',
|
|
path: '/group-plans/:groupId/billing',
|
|
component: GroupPlanBilling,
|
|
props: true,
|
|
},
|
|
],
|
|
},
|
|
DEPRECATED_ROUTES,
|
|
{ path: PAGES.PRIVATE_MESSAGES, name: 'privateMessages', component: MessagesIndex },
|
|
{
|
|
name: 'challenges',
|
|
path: '/challenges',
|
|
component: ChallengeIndex,
|
|
children: [
|
|
{
|
|
name: 'myChallenges',
|
|
path: 'myChallenges',
|
|
component: MyChallenges,
|
|
},
|
|
{
|
|
name: 'findChallenges',
|
|
path: 'findChallenges',
|
|
component: FindChallenges,
|
|
},
|
|
{
|
|
name: 'challenge',
|
|
path: ':challengeId',
|
|
component: ChallengeDetail,
|
|
props: true,
|
|
},
|
|
],
|
|
},
|
|
USER_ROUTES,
|
|
STATIC_ROUTES,
|
|
{
|
|
path: '/hall',
|
|
component: HallPage,
|
|
children: [
|
|
{ name: 'patrons', path: 'patrons', component: PatronsPage },
|
|
{ name: 'contributors', path: 'contributors', component: HeroesPage },
|
|
],
|
|
},
|
|
|
|
{
|
|
name: 'adminSection',
|
|
path: '/admin',
|
|
component: AdminContainerPage,
|
|
meta: {
|
|
privilegeNeeded: [ // any one of these is enough to give access
|
|
'userSupport',
|
|
'accessControl',
|
|
],
|
|
},
|
|
children: [
|
|
{
|
|
name: 'adminPanel',
|
|
path: 'panel',
|
|
component: AdminPanelPage,
|
|
meta: {
|
|
privilegeNeeded: [ // any one of these is enough to give access
|
|
'userSupport',
|
|
],
|
|
},
|
|
children: [
|
|
{
|
|
name: 'adminPanelSearch',
|
|
path: 'search/:userIdentifier',
|
|
component: AdminPanelSearchPage,
|
|
meta: {
|
|
privilegeNeeded: [
|
|
'userSupport',
|
|
],
|
|
},
|
|
},
|
|
{
|
|
name: 'adminPanelUser',
|
|
path: ':userIdentifier',
|
|
component: AdminPanelUserPage,
|
|
meta: {
|
|
privilegeNeeded: [
|
|
'userSupport',
|
|
],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'groupAdmin',
|
|
path: 'groups',
|
|
component: GroupAdminPage,
|
|
meta: {
|
|
privilegeNeeded: [ // any one of these is enough to give access
|
|
'groupSupport',
|
|
],
|
|
},
|
|
children: [
|
|
{
|
|
name: 'groupAdminGroup',
|
|
path: ':groupId',
|
|
component: GroupAdminGroupPage,
|
|
meta: {
|
|
privilegeNeeded: [
|
|
'groupsSupport',
|
|
],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'blockers',
|
|
path: 'blockers',
|
|
component: BlockerPage,
|
|
meta: {
|
|
privilegeNeeded: [ // any one of these is enough to give access
|
|
'accessControl',
|
|
],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
|
|
// Only used to handle some redirects
|
|
// See router.beforeEach
|
|
{ path: '/static/tavern-and-guilds', redirect: '/static/faq/tavern-and-guilds' },
|
|
{ path: '/redirect/:redirect', name: 'redirect' },
|
|
{ path: '*', redirect: { name: 'notFound' } },
|
|
],
|
|
});
|
|
|
|
const store = getStore();
|
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
const { isUserLoggedIn, isUserLoaded } = store.state;
|
|
const routeRequiresLogin = to.meta.requiresLogin !== false;
|
|
const routePrivilegeNeeded = to.meta.privilegeNeeded;
|
|
|
|
if (to.name === 'redirect') return handleRedirect(to, from, next);
|
|
|
|
if (!isUserLoggedIn && routeRequiresLogin) {
|
|
// Redirect to the login page unless the user is trying to reach the
|
|
// root of the website, in which case show the home page.
|
|
// Pass the requested page as a query parameter to redirect later.
|
|
|
|
const redirectTo = to.path === '/' ? 'home' : 'login';
|
|
return next({
|
|
name: redirectTo,
|
|
query: redirectTo === 'login' ? {
|
|
redirectTo: to.path,
|
|
} : to.query,
|
|
});
|
|
}
|
|
|
|
// Keep the redirectTo query param when going from login to register
|
|
// !to.query.redirectTo is to avoid entering a loop of infinite redirects
|
|
if (to.name === 'register' && !to.query.redirectTo && from.name === 'login' && from.query.redirectTo) {
|
|
return next({
|
|
name: 'register',
|
|
query: {
|
|
redirectTo: from.query.redirectTo,
|
|
},
|
|
});
|
|
}
|
|
|
|
if (isUserLoggedIn && (to.name === 'login' || to.name === 'register')) {
|
|
return next({ name: 'tasks' });
|
|
}
|
|
|
|
if (routePrivilegeNeeded) {
|
|
// Redirect non-admin users when trying to access a page.
|
|
if (!isUserLoaded) await store.dispatch('user:fetch');
|
|
if (!store.state.user.data.permissions.fullAccess) {
|
|
const userHasPriv = routePrivilegeNeeded.some(
|
|
privName => store.state.user.data.permissions[privName],
|
|
);
|
|
if (!userHasPriv) return next({ name: 'tasks' });
|
|
}
|
|
}
|
|
|
|
if (to.name === 'party') {
|
|
router.app.$root.$emit('update-party');
|
|
}
|
|
|
|
if (to.name === 'lookingForParty') {
|
|
Analytics.track({
|
|
hitType: 'event',
|
|
eventName: 'View Find Members',
|
|
eventAction: 'View Find Members',
|
|
eventCategory: 'behavior',
|
|
}, { trackOnClient: true });
|
|
}
|
|
|
|
// Redirect old guild urls
|
|
if (to.hash.indexOf('#/options/groups/guilds/') !== -1) {
|
|
const splits = to.hash.split('/');
|
|
const guildId = splits[4];
|
|
|
|
return next({
|
|
name: 'guild',
|
|
params: {
|
|
groupId: guildId,
|
|
},
|
|
});
|
|
}
|
|
|
|
// Redirect from Guild link to Group Plan where possible
|
|
if (to.name === 'guild') {
|
|
await store.dispatch('guilds:getGroupPlans');
|
|
const { groupPlans } = store.state;
|
|
const groupPlanIds = groupPlans.data.map(groupPlan => groupPlan._id);
|
|
if (groupPlanIds.indexOf(to.params.groupId) !== -1) {
|
|
return next({
|
|
name: 'groupPlanDetailInformation',
|
|
params: {
|
|
groupId: to.params.groupId,
|
|
},
|
|
});
|
|
}
|
|
}
|
|
|
|
// Redirect old challenge urls
|
|
if (to.hash.indexOf('#/options/groups/challenges/') !== -1) {
|
|
const splits = to.hash.split('/');
|
|
const challengeId = splits[4];
|
|
|
|
return next({
|
|
name: 'challenge',
|
|
params: {
|
|
challengeId,
|
|
},
|
|
});
|
|
}
|
|
|
|
if ((to.name === 'userProfile')) {
|
|
let startingPage = 'profile';
|
|
if (to.params.startingPage !== undefined) {
|
|
startingPage = to.params.startingPage;
|
|
}
|
|
// Check if there's a hash in the URL for stats or achievements
|
|
if (to.hash === '#stats' || to.hash === '#achievements') {
|
|
startingPage = to.hash.substring(1);
|
|
}
|
|
if (from.name === null) {
|
|
store.state.postLoadModal = `profile/${to.params.userId}`;
|
|
return next({ name: 'tasks' });
|
|
}
|
|
router.app.$emit('habitica:show-profile', {
|
|
userId: to.params.userId,
|
|
startingPage,
|
|
fromPath: from.path,
|
|
toPath: to.path,
|
|
});
|
|
|
|
return null;
|
|
}
|
|
|
|
if (to.name === 'tasks' && to.query.openGemsModal === 'true') {
|
|
store.state.postLoadModal = 'buy-gems';
|
|
return next({ name: 'tasks' });
|
|
}
|
|
|
|
if ((to.name === 'stats' || to.name === 'achievements' || to.name === 'profile') && from.name !== null) {
|
|
const userId = store.state.user.data._id;
|
|
let redirectPath = `/profile/${userId}`;
|
|
if (to.name === 'stats') {
|
|
redirectPath += '#stats';
|
|
} else if (to.name === 'achievements') {
|
|
redirectPath += '#achievements';
|
|
}
|
|
router.app.$emit('habitica:show-profile', {
|
|
userId,
|
|
startingPage: to.name,
|
|
fromPath: from.path,
|
|
toPath: redirectPath,
|
|
});
|
|
return null;
|
|
}
|
|
|
|
if (from.name === 'userProfile' || from.name === 'stats' || from.name === 'achievements' || from.name === 'profile') {
|
|
router.app.$root.$emit('bv::hide::modal', 'profile');
|
|
}
|
|
|
|
return next();
|
|
});
|
|
|
|
router.afterEach((to, from) => {
|
|
if (from.name === 'chatSunsetFaq') {
|
|
document.body.style.background = '#f9f9f9';
|
|
}
|
|
});
|
|
|
|
export default router;
|