UX: Default user facing routes to `/g` instead of `/groups`. (#7042)

UX: Default user facing routes to /g instead of /groups. (#7042)

diff --git a/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 b/app/assets/javascripts/admin/controllers/admin-user-index.js.es6
index 78f8ef1..8c3b95b 100644
--- a/app/assets/javascripts/admin/controllers/admin-user-index.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-user-index.js.es6
@@ -48,7 +48,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
     return automaticGroups
       .map(group => {
         const name = Ember.String.htmlSafe(group.name);
-        return `<a href="/groups/${name}">${name}</a>`;
+        return `<a href="/g/${name}">${name}</a>`;
       })
       .join(", ");
   },
diff --git a/app/assets/javascripts/discourse/components/group-card-contents.js.es6 b/app/assets/javascripts/discourse/components/group-card-contents.js.es6
index 763d8fe..2a73474 100644
--- a/app/assets/javascripts/discourse/components/group-card-contents.js.es6
+++ b/app/assets/javascripts/discourse/components/group-card-contents.js.es6
@@ -35,7 +35,7 @@ export default Ember.Component.extend(CardContentsBase, CleansUp, {
 
   @computed("group")
   groupPath(group) {
-    return `${Discourse.BaseUri}/groups/${group.name}`;
+    return `${Discourse.BaseUri}/g/${group.name}`;
   },
 
   _showCallback(username, $target) {
diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6
index 4d299ef..7ef2397 100644
--- a/app/assets/javascripts/discourse/controllers/composer.js.es6
+++ b/app/assets/javascripts/discourse/controllers/composer.js.es6
@@ -547,18 +547,19 @@ export default Ember.Controller.extend({
       ) {
         groups.forEach(group => {
           let body;
+          const groupLink = Discourse.getURL(`/g/${group.name}/members`);
 
           if (group.max_mentions < group.user_count) {
             body = I18n.t("composer.group_mentioned_limit", {
               group: "@" + group.name,
               max: group.max_mentions,
-              group_link: Discourse.getURL(`/groups/${group.name}/members`)
+              group_link: groupLink
             });
           } else {
             body = I18n.t("composer.group_mentioned", {
               group: "@" + group.name,
               count: group.user_count,
-              group_link: Discourse.getURL(`/groups/${group.name}/members`)
+              group_link: groupLink
             });
           }
 
diff --git a/app/assets/javascripts/discourse/initializers/url-redirects.js.es6 b/app/assets/javascripts/discourse/initializers/url-redirects.js.es6
index 56febf3..dad0137 100644
--- a/app/assets/javascripts/discourse/initializers/url-redirects.js.es6
+++ b/app/assets/javascripts/discourse/initializers/url-redirects.js.es6
@@ -10,6 +10,8 @@ export default {
     // URL rewrites (usually due to refactoring)
     DiscourseURL.rewrite(/^\/category\//, "/c/");
     DiscourseURL.rewrite(/^\/group\//, "/groups/");
+    DiscourseURL.rewrite(/^\/groups$/, "/g");
+    DiscourseURL.rewrite(/^\/groups\//, "/g/");
     DiscourseURL.rewrite(/\/private-messages\/$/, "/messages/");
     DiscourseURL.rewrite(/^\/users$/, "/u");
     DiscourseURL.rewrite(/^\/users\//, "/u/");
diff --git a/app/assets/javascripts/discourse/lib/link-mentions.js.es6 b/app/assets/javascripts/discourse/lib/link-mentions.js.es6
index c58797d..16bc730 100644
--- a/app/assets/javascripts/discourse/lib/link-mentions.js.es6
+++ b/app/assets/javascripts/discourse/lib/link-mentions.js.es6
@@ -16,7 +16,7 @@ function replaceSpan($e, username, opts) {
       extraClass = "notify";
     }
     $e.replaceWith(
-      `<a href='${Discourse.getURL("/groups/") +
+      `<a href='${Discourse.getURL("/g/") +
         username}' class='mention-group ${extraClass}' ${extra}>@${username}</a>`
     );
   } else {
diff --git a/app/assets/javascripts/discourse/routes/app-route-map.js.es6 b/app/assets/javascripts/discourse/routes/app-route-map.js.es6
index 1e2e6ad..160a729 100644
--- a/app/assets/javascripts/discourse/routes/app-route-map.js.es6
+++ b/app/assets/javascripts/discourse/routes/app-route-map.js.es6
@@ -60,36 +60,32 @@ export default function() {
     this.route("categoryWithID", { path: "/c/:parentSlug/:slug/:id" });
   });
 
-  this.route("groups", { resetNamespace: true }, function() {
+  this.route("groups", { resetNamespace: true, path: "/g" }, function() {
     this.route("new", { path: "custom/new" });
   });
 
-  this.route(
-    "group",
-    { path: "/groups/:name", resetNamespace: true },
-    function() {
-      this.route("members");
+  this.route("group", { path: "/g/:name", resetNamespace: true }, function() {
+    this.route("members");
 
-      this.route("activity", function() {
-        this.route("posts");
-        this.route("topics");
-        this.route("mentions");
-      });
+    this.route("activity", function() {
+      this.route("posts");
+      this.route("topics");
+      this.route("mentions");
+    });
 
-      this.route("manage", function() {
-        this.route("profile");
-        this.route("membership");
-        this.route("interaction");
-        this.route("members");
-        this.route("logs");
-      });
+    this.route("manage", function() {
+      this.route("profile");
+      this.route("membership");
+      this.route("interaction");
+      this.route("members");
+      this.route("logs");
+    });
 
-      this.route("messages", function() {
-        this.route("inbox");
-        this.route("archive");
-      });
-    }
-  );
+    this.route("messages", function() {
+      this.route("inbox");
+      this.route("archive");
+    });
+  });
 
   // User routes
   this.route("users", { resetNamespace: true, path: "/u" });
diff --git a/app/assets/javascripts/discourse/widgets/header-topic-info.js.es6 b/app/assets/javascripts/discourse/widgets/header-topic-info.js.es6
index 40237b9..f3b136b 100644
--- a/app/assets/javascripts/discourse/widgets/header-topic-info.js.es6
+++ b/app/assets/javascripts/discourse/widgets/header-topic-info.js.es6
@@ -26,7 +26,7 @@ createWidget("topic-header-participant", {
       url = user.get("path");
     } else {
       content = [iconNode("users")];
-      url = Discourse.getURL(`/groups/${group.name}`);
+      url = Discourse.getURL(`/g/${group.name}`);
       content.push(h("span", group.name));
     }
 
diff --git a/app/assets/javascripts/discourse/widgets/post-small-action.js.es6 b/app/assets/javascripts/discourse/widgets/post-small-action.js.es6
index 92cd072..e28658a 100644
--- a/app/assets/javascripts/discourse/widgets/post-small-action.js.es6
+++ b/app/assets/javascripts/discourse/widgets/post-small-action.js.es6
@@ -13,7 +13,7 @@ export function actionDescriptionHtml(actionCode, createdAt, username) {
   var who = "";
   if (username) {
     if (actionCode === "invited_group" || actionCode === "removed_group") {
-      who = `<a class="mention-group" href="/groups/${username}">@${username}</a>`;
+      who = `<a class="mention-group" href="/g/${username}">@${username}</a>`;
     } else {
       who = `<a class="mention" href="${userPath(username)}">@${username}</a>`;
     }
diff --git a/app/assets/javascripts/discourse/widgets/poster-name.js.es6 b/app/assets/javascripts/discourse/widgets/poster-name.js.es6
index 9d21c04..85c98e1 100644
--- a/app/assets/javascripts/discourse/widgets/poster-name.js.es6
+++ b/app/assets/javascripts/discourse/widgets/poster-name.js.es6
@@ -17,7 +17,7 @@ createWidget("poster-name-title", {
   html(attrs) {
     let titleContents = attrs.title;
     if (attrs.primaryGroupName) {
-      const href = Discourse.getURL(`/groups/${attrs.primaryGroupName}`);
+      const href = Discourse.getURL(`/g/${attrs.primaryGroupName}`);
       titleContents = h(
         "a.user-group",
         {
diff --git a/app/assets/javascripts/discourse/widgets/private-message-map.js.es6 b/app/assets/javascripts/discourse/widgets/private-message-map.js.es6
index 200ed33..40b5ce3 100644
--- a/app/assets/javascripts/discourse/widgets/private-message-map.js.es6

[... diff too long, it was truncated ...]

GitHub sha: 46e62c0d

This commit has been mentioned on Discourse Meta. There might be relevant details there:

What happens to old links to groups that are out there? Do we redirect from the server as well?

1 Like

Yeah looks like some redirects are missing:

https://meta.discourse.org/groups should 302 to => https://meta.discourse.org/g

https://meta.discourse.org/groups/trust_level_3 => https://meta.discourse.org/g/trust_level_3

1 Like

@SamSaffron I don’t think we are meant to redirect. Both routes are still supported by on the front end but we default to β€œ/g”.

See Discourse Meta and Categories - Discourse Meta