Skip to content

Commit

Permalink
CORE-1968 Add dynamic titles to some pages
Browse files Browse the repository at this point in the history
Set the path/file/folder in the page title for the data listing page,
app category name in the app listing page,
team/collection name in the teams/collections pages,
and the search term in the subscriptions and search pages.
  • Loading branch information
psarando committed Oct 26, 2023
1 parent b10e87b commit 9b70981
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 12 deletions.
1 change: 1 addition & 0 deletions public/static/locales/en/collections.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"noCollections": "No $t(featureName_plural)",
"noExternalApps": "Adding Agave/HPC apps is not currently supported",
"noExternalAppsNote": "NOTE: $t(noExternalApps).",
"pageTitle": "Collection - {{name}}",
"remove": "Remove",
"retagApps": "Re-tag Apps",
"retagAppsMessage": "{{name}} currently has apps associated with it. Renaming the $t(featureName) will cause all the currently tagged apps to be re-tagged with the new $t(featureName) name. Do you wish to continue?",
Expand Down
1 change: 1 addition & 0 deletions public/static/locales/en/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"noContent": "No content to display.",
"ok": "OK",
"own": "Own",
"pageTitle": "Data - {{path}}",
"path": "Path",
"pathCopied": "Path copied.",
"pathCopyError": "Unable to copy path.",
Expand Down
1 change: 1 addition & 0 deletions public/static/locales/en/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"noResults": "No results to display.",
"own": "Own",
"owner": "Owner",
"pageTitle": "Search - {{searchTerm}}",
"path": "Path",
"pathPlaceholder": "/iplant/home/me",
"permissions": "Permissions",
Expand Down
1 change: 1 addition & 0 deletions public/static/locales/en/subscriptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"noSubscriptions": "No subscriptions",
"noUsages": "No usages",
"paid": "Paid",
"pageTitle": "Subscriptions - {{searchTerm}}",
"planName": "Plan Name",
"quota": "Quota",
"quotas": "Quotas",
Expand Down
1 change: 1 addition & 0 deletions public/static/locales/en/teams.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"myTeams": "My Teams",
"name": "Name",
"noTeams": "No teams",
"pageTitle": "Team - {{name}}",
"privilege": "Privilege",
"publicTeam": "Public Team",
"publicTeamHelp": "Making your team public allows your team to be discoverable to other CyVerse users who are not members of your team. Allowing users to discover your team will enable them to view the team and request to join. A team can be updated from public to private and vice versa any time.",
Expand Down
12 changes: 10 additions & 2 deletions src/pages/admin/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,16 @@ export default function Subscriptions() {
}
}

export async function getServerSideProps({ locale }) {
const title = i18n.t("subscriptions");
export async function getServerSideProps(context) {
const {
locale,
query: { searchTerm },
} = context;

let title = i18n.t("subscriptions");
if (searchTerm) {
title = i18n.t("subscriptions:pageTitle", { searchTerm });
}

return {
props: {
Expand Down
10 changes: 8 additions & 2 deletions src/pages/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ export default function Apps() {
}

export async function getServerSideProps(context) {
const { locale } = context;
const title = i18n.t("apps");
const { locale, query } = context;

let selectedCategory;
if (query.selectedCategory) {
selectedCategory = JSON.parse(query.selectedCategory).name;
}

const title = selectedCategory || i18n.t("apps");

return {
props: {
Expand Down
11 changes: 9 additions & 2 deletions src/pages/collections/[collectionName].js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ export default function EditCollection() {
);
}

export async function getServerSideProps({ locale }) {
const title = i18n.t("collections:featureName");
export async function getServerSideProps(context) {
const {
locale,
params: { collectionName },
} = context;

const title = i18n.t("collections:pageTitle", {
name: collectionName,
});

return {
props: {
Expand Down
13 changes: 11 additions & 2 deletions src/pages/data/ds/[...pathItems].js
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,17 @@ export default function DataStore() {
);
}

export async function getServerSideProps({ locale }) {
const title = i18n.t("data");
export async function getServerSideProps(context) {
const {
locale,
params: { pathItems },
} = context;

// Display the full path up to 3 items deep, otherwise only the last item.
const path =
pathItems.length <= 3 ? "/" + pathItems.join("/") : pathItems.at(-1);

const title = i18n.t("data:pageTitle", { path });

return {
props: {
Expand Down
12 changes: 10 additions & 2 deletions src/pages/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,16 @@ export default function Search() {
);
}

export async function getServerSideProps({ locale }) {
const title = i18n.t("search");
export async function getServerSideProps(context) {
const {
locale,
query: { searchTerm },
} = context;

let title = i18n.t("search");
if (searchTerm) {
title = i18n.t("search:pageTitle", { searchTerm });
}

return {
props: {
Expand Down
9 changes: 7 additions & 2 deletions src/pages/teams/[teamName].js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ export default function EditTeam() {
);
}

export async function getServerSideProps({ locale }) {
const title = i18n.t("teams");
export async function getServerSideProps(context) {
const {
locale,
params: { teamName },
} = context;

const title = i18n.t("teams:pageTitle", { name: teamName });

return {
props: {
Expand Down

0 comments on commit 9b70981

Please sign in to comment.