Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Issue #12421 - Change page title based on the site section being viewed #12627

Merged
merged 21 commits into from Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion website/client/public/index.html
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Habitica - Gamify Your Life</title>
<title>Habitica</title>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, Gamify Your Life can stay in this file

<meta name="description" content="Habitica is a free habit and productivity app that treats your real life like a game. Habitica can help you achieve your goals to become healthy and happy.">
<meta name="keywords" content="Habits,Goals,Todo,Gamification,Health,Fitness,School,Work">
<meta name="smartbanner:title" content="Habitica">
Expand Down
14 changes: 14 additions & 0 deletions website/client/src/components/challenges/challengeDetail.vue
Expand Up @@ -384,6 +384,16 @@ export default {
memberResults: [],
};
},
watch: {
'challenge.name': {
handler (newVal) {
this.$store.dispatch('common:setTitle', {
section: this.$t('challenge'),
subSection: newVal.name,
});
},
},
},
computed: {
...mapState({ user: 'user.data' }),
isMember () {
Expand Down Expand Up @@ -433,6 +443,10 @@ export default {
this.$router.push('/challenges/findChallenges');
return;
}
this.$store.dispatch('common:setTitle', {
subSection: this.challenge.name,
section: this.$t('challenges'),
});
const tasks = await this.$store.dispatch('tasks:getChallengeTasks', { challengeId: this.searchId });
this.tasksByType = {
habit: [],
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/challenges/findChallenges.vue
Expand Up @@ -175,6 +175,10 @@ export default {
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('findChallenges'),
section: this.$t('challenges'),
});
this.loadChallenges();
},
methods: {
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/challenges/myChallenges.vue
Expand Up @@ -218,6 +218,10 @@ export default {
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('myChallenges'),
section: this.$t('challenges'),
});
this.loadChallenges();
},
methods: {
Expand Down
Expand Up @@ -224,7 +224,10 @@ export default {
this.group = await this.$store.dispatch('guilds:getGroup', {
groupId: this.searchId,
});
this.$store.dispatch('common:setTitle', {
subSection: this.group.name,
section: this.$t('group'),
});
const members = await this.$store.dispatch('members:getGroupMembers', { groupId: this.searchId });
this.group.members = members;
Expand Down
6 changes: 6 additions & 0 deletions website/client/src/components/groups/discovery.vue
Expand Up @@ -155,6 +155,12 @@ export default {
return this.guilds.filter(guild => filterGuild(guild, filters, search, user));
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('guildsDiscovery'),
section: this.$t('guilds'),
});
},
methods: {
async updateSearch (eventData) {
// this.search = eventData.searchTerm; @TODO: Probably don't need this anymore
Expand Down
10 changes: 8 additions & 2 deletions website/client/src/components/groups/group.vue
Expand Up @@ -497,15 +497,17 @@ export default {
if (this.isParty) this.searchId = 'party';
if (!this.searchId) this.searchId = this.groupId;
await this.fetchGuild();

this.$store.dispatch('common:setTitle', {
section: this.$t('groupPlans'),
subSection: this.group.name,
});
this.$root.$on('updatedGroup', this.onGroupUpdate);
},
beforeDestroy () {
this.$root.$off('updatedGroup', this.onGroupUpdate);
},
beforeRouteUpdate (to, from, next) {
this.$set(this, 'searchId', to.params.groupId);

next();
},
methods: {
Expand All @@ -515,6 +517,10 @@ export default {
onGroupUpdate (group) {
const updatedGroup = extend(this.group, group);
this.$set(this.group, updatedGroup);
this.$store.dispatch('common:setTitle', {
section: this.$t('groupPlans'),
subSection: group.name,
});
},

/**
Expand Down
3 changes: 3 additions & 0 deletions website/client/src/components/groups/groupPlan.vue
Expand Up @@ -486,6 +486,9 @@ export default {
},
mounted () {
this.activePage = this.PAGES.BENEFITS;
this.$store.dispatch('common:setTitle', {
section: this.$t('groupPlans'),
});
},
methods: {
launchModal () {
Expand Down
6 changes: 6 additions & 0 deletions website/client/src/components/groups/myGuilds.vue
Expand Up @@ -165,6 +165,12 @@ export default {
});
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('myGuilds'),
section: this.$t('guilds'),
});
},
created () {
this.fetchGuilds();
},
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/groups/tavern.vue
Expand Up @@ -843,6 +843,10 @@ export default {
},
},
async mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('tavern'),
section: this.$t('guilds'),
});
this.group = await this.$store.dispatch('guilds:getGroup', { groupId: TAVERN_ID });
},
methods: {
Expand Down
5 changes: 5 additions & 0 deletions website/client/src/components/inventory/equipment/index.vue
Expand Up @@ -440,6 +440,11 @@ export default {
this.costumeMode = getLocalSetting(
CONSTANTS.keyConstants.CURRENT_EQUIPMENT_DRAWER_TAB,
) === CONSTANTS.equipmentDrawerTabValues.COSTUME_TAB;

this.$store.dispatch('common:setTitle', {
subSection: this.$t('equipment'),
section: this.$t('inventory'),
});
},
methods: {
selectDrawerTab (tabName) {
Expand Down
6 changes: 6 additions & 0 deletions website/client/src/components/inventory/items/index.vue
Expand Up @@ -506,6 +506,12 @@ export default {
return this.groups.some(g => g.selected);
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('items'),
section: this.$t('inventory'),
});
},
watch: {
searchText: throttle(function throttleSearch () {
this.searchTextThrottled = this.searchText.toLowerCase();
Expand Down
6 changes: 6 additions & 0 deletions website/client/src/components/inventory/stable/index.vue
Expand Up @@ -675,6 +675,12 @@ export default {
return Object.values(this.viewOptions).some(g => g.selected);
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('stable'),
section: this.$t('inventory'),
});
},
watch: {
searchText: _throttle(function throttleSearch () {
const search = this.searchText.toLowerCase();
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/settings/api.vue
Expand Up @@ -154,6 +154,10 @@ export default {
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
section: this.$t('settings'),
subSection: this.$t('API'),
});
window.addEventListener('message', this.receiveMessage, false);
},
destroy () {
Expand Down
11 changes: 11 additions & 0 deletions website/client/src/components/settings/dataExport.vue
Expand Up @@ -13,3 +13,14 @@
</div>
</div>
</template>

<script>
export default {
mounted () {
this.$store.dispatch('common:setTitle', {
section: this.$t('settings'),
subSection: this.$t('dataExport'),
});
},
};
</script>
4 changes: 4 additions & 0 deletions website/client/src/components/settings/notifications.vue
Expand Up @@ -105,6 +105,10 @@ export default {
...mapState({ user: 'user.data' }),
},
async mounted () {
this.$store.dispatch('common:setTitle', {
section: this.$t('settings'),
subSection: this.$t('notifications'),
});
// If ?unsubFrom param is passed with valid email type,
// automatically unsubscribe users from that email and
// show an alert
Expand Down
6 changes: 6 additions & 0 deletions website/client/src/components/settings/promoCode.vue
Expand Up @@ -87,6 +87,12 @@ export default {
return '/api/v4/coupons';
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
section: this.$t('settings'),
subSection: this.$t('promoCode'),
});
},
methods: {
generateCodes () {
// $http.post(ApiUrl.get() + '/api/v2/coupons/generate/
Expand Down
5 changes: 5 additions & 0 deletions website/client/src/components/settings/site.vue
Expand Up @@ -678,6 +678,11 @@ export default {
this.emailUpdates.newEmail = this.user.auth.local.email || null;
this.localAuth.username = this.user.auth.local.username || null;
this.soundIndex = 0;
this.$store.dispatch('common:setTitle', {
section: this.$t('settings'),
});
hello.init({
facebook: process.env.FACEBOOK_KEY, // eslint-disable-line no-process-env
google: process.env.GOOGLE_CLIENT_ID, // eslint-disable-line no-process-env
Expand Down
6 changes: 6 additions & 0 deletions website/client/src/components/settings/subscription.vue
Expand Up @@ -720,6 +720,12 @@ export default {
return moment(this.user.purchased.plan.dateTerminated).format('MM/DD/YYYY');
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
section: this.$t('settings'),
subSection: this.$t('subscription'),
});
},
methods: {
async applyCoupon (coupon) {
const response = await axios.post(`/api/v4/coupons/validate/${coupon}`);
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/shops/market/index.vue
Expand Up @@ -304,6 +304,10 @@ export default {
}, 250),
},
async mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('market'),
section: this.$t('shops'),
});
await this.$store.dispatch('worldState:getWorldState');
},
methods: {
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/shops/quests/index.vue
Expand Up @@ -544,6 +544,10 @@ export default {
}, 250),
},
async mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('quests'),
section: this.$t('shops'),
});
await this.$store.dispatch('worldState:getWorldState');
},
methods: {
Expand Down
5 changes: 5 additions & 0 deletions website/client/src/components/shops/seasonal/index.vue
Expand Up @@ -517,6 +517,11 @@ export default {
}, 250),
},
async mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('seasonalShop'),
section: this.$t('shops'),
});
this.$root.$on('buyModal::boughtItem', () => {
this.backgroundUpdate = new Date();
});
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/shops/timeTravelers/index.vue
Expand Up @@ -399,6 +399,10 @@ export default {
}, 250),
},
mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('timeTravelers'),
section: this.$t('shops'),
});
this.$root.$on('buyModal::boughtItem', () => {
this.backgroundUpdate = new Date();
});
Expand Down
6 changes: 6 additions & 0 deletions website/client/src/components/static/contact.vue
Expand Up @@ -67,5 +67,11 @@ export default {
goToModForm(this.user);
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
section: this.$t('help'),
subSection: this.$t('contactUs'),
});
},
};
</script>
6 changes: 6 additions & 0 deletions website/client/src/components/static/faq.vue
Expand Up @@ -112,6 +112,12 @@ export default {
// "webFaqStillNeedHelp": "If you have a question that isn't on this list or on the [Wiki FAQ](http://habitica.fandom.com/wiki/FAQ), come ask in the <%= linkStart %>Habitica Help guild<%= linkEnd %>! We're happy to help."
};
},
mounted () {
this.$store.dispatch('common:setTitle', {
section: this.$t('help'),
subSection: this.$t('faq'),
});
},
methods: {
isVisible (heading) {
return this.visible && this.visible === heading;
Expand Down
6 changes: 6 additions & 0 deletions website/client/src/components/static/features.vue
Expand Up @@ -137,6 +137,12 @@ export default {
directives: {
markdown: markdownDirective,
},
mounted () {
this.$store.dispatch('common:setTitle', {
section: this.$t('help'),
jbusa22 marked this conversation as resolved.
Show resolved Hide resolved
subSection: this.$t('features'),
});
},
methods: {
playButtonClick () {
this.$router.push('/register');
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/static/groupPlans.vue
Expand Up @@ -274,6 +274,10 @@ export default {
// Load external scripts after the app has been rendered
setupPayments();
});
this.$store.dispatch('common:setTitle', {
section: this.$t('help'),
subSection: this.$t('groupPlans'),
});
},
methods: {
goToNewGroupPage () {
Expand Down
6 changes: 6 additions & 0 deletions website/client/src/components/static/pressKit.vue
Expand Up @@ -172,5 +172,11 @@ export default {
],
});
},
mounted () {
this.$store.dispatch('common:setTitle', {
section: this.$t('help'),
subSection: this.$t('presskit'),
});
},
};
</script>
5 changes: 5 additions & 0 deletions website/client/src/components/tasks/user.vue
Expand Up @@ -495,6 +495,11 @@ export default {
return tagsByType;
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
section: this.$t('tasks'),
});
},
watch: {
searchText: throttle(function throttleSearch () {
this.searchTextThrottled = this.searchText.toLowerCase();
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/userMenu/profile.vue
Expand Up @@ -833,6 +833,10 @@ export default {
mounted () {
this.loadUser();
this.selectPage(this.startingPage);
this.$store.dispatch('common:setTitle', {
jbusa22 marked this conversation as resolved.
Show resolved Hide resolved
section: this.$t('user'),
subSection: this.$t(this.startingPage),
});
},
methods: {
async loadUser () {
Expand Down