Skip to content

Commit 8e6d725

Browse files
committed
standalone routes: rename username to namespace
1 parent d38784b commit 8e6d725

File tree

9 files changed

+43
-45
lines changed

9 files changed

+43
-45
lines changed

src/components/legacy-namespace-list/legacy-namespace-item.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function LegacyNamespaceListItem({
2929
} = useContext();
3030
const { id, avatar_url, name, summary_fields } = namespace;
3131

32-
const namespace_url = formatPath(Paths.legacyNamespace, {
32+
const namespace_url = formatPath(Paths.standaloneNamespace, {
3333
namespaceid: id,
3434
});
3535

src/components/legacy-role-list/legacy-role-item.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export function LegacyRoleListItem({ role, show_thumbnail }: LegacyRoleProps) {
3535
} = role;
3636
const latest = versions[0];
3737

38-
const role_url = formatPath(Paths.legacyRole, {
39-
username: namespace.name,
38+
const role_url = formatPath(Paths.standaloneRole, {
39+
namespace: namespace.name,
4040
name,
4141
});
4242
const release_date = latest?.release_date || modified;

src/containers/ansible-role/namespace-detail.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class AnsibleRoleNamespaceDetail extends React.Component<
222222
> {
223223
static contextType = AppContext;
224224

225-
// This is the details page for a legacy namespace
225+
// This is the details page for a standalone namespace
226226

227227
constructor(props) {
228228
super(props);
@@ -246,8 +246,7 @@ class AnsibleRoleNamespaceDetail extends React.Component<
246246
}
247247

248248
componentDidMount() {
249-
const namespaceid = this.props.routeParams.namespaceid;
250-
LegacyNamespaceAPI.get(namespaceid)
249+
LegacyNamespaceAPI.get(this.props.routeParams.namespaceid)
251250
.then((response) =>
252251
this.setState({
253252
loading: false,
@@ -284,7 +283,7 @@ class AnsibleRoleNamespaceDetail extends React.Component<
284283
);
285284
}
286285

287-
const namespace_url = formatPath(Paths.legacyNamespace, {
286+
const namespace_url = formatPath(Paths.standaloneNamespace, {
288287
namespaceid: namespace.id,
289288
});
290289

src/containers/ansible-role/role-detail.tsx

+10-14
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class AnsibleRoleDetail extends React.Component<RouteProps, RoleState> {
201201
constructor(props) {
202202
super(props);
203203

204-
const { username: namespace, name } = props.routeParams;
204+
const { namespace, name } = props.routeParams;
205205
this.state = {
206206
activeItem: 'install',
207207
alerts: [],
@@ -243,14 +243,8 @@ class AnsibleRoleDetail extends React.Component<RouteProps, RoleState> {
243243
}
244244

245245
render() {
246-
const {
247-
activeItem,
248-
alerts,
249-
loading,
250-
name,
251-
namespace: namespaceName,
252-
role,
253-
} = this.state;
246+
const { activeItem, alerts, loading, name, role } = this.state;
247+
254248
if (loading) {
255249
return <LoadingPageWithHeader />;
256250
}
@@ -270,7 +264,7 @@ class AnsibleRoleDetail extends React.Component<RouteProps, RoleState> {
270264
'/' +
271265
encodeURIComponent(role.github_repo);
272266
const namespace = role.summary_fields.namespace;
273-
const namespace_url = formatPath(Paths.legacyNamespace, {
267+
const namespace_url = formatPath(Paths.standaloneNamespace, {
274268
namespaceid: namespace.id,
275269
});
276270
let release_date = null;
@@ -379,16 +373,18 @@ class AnsibleRoleDetail extends React.Component<RouteProps, RoleState> {
379373
const breadcrumbs = [
380374
{
381375
name: t`Roles`,
382-
url: formatPath(Paths.legacyRoles),
376+
url: formatPath(Paths.standaloneRoles),
383377
},
384378
{
385379
name: namespace.name,
386-
url: formatPath(Paths.legacyNamespace, { namespaceid: namespace.id }),
380+
url: formatPath(Paths.standaloneNamespace, {
381+
namespaceid: namespace.id,
382+
}),
387383
},
388384
{
389385
name,
390-
url: formatPath(Paths.legacyRole, {
391-
username: namespace.name,
386+
url: formatPath(Paths.standaloneRole, {
387+
namespace: namespace.name,
392388
name,
393389
}),
394390
},

src/containers/not-found/dispatch.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ export const Dispatch = ({ location, navigate }: RouteProps) => {
7979
const {
8080
name,
8181
summary_fields: {
82-
namespace: { name: username },
82+
namespace: { name: namespace },
8383
},
8484
} = roles[0];
8585

8686
navigate(
87-
formatPath(Paths.legacyRole, {
88-
username,
87+
formatPath(Paths.standaloneRole, {
88+
namespace,
8989
name,
9090
}),
9191
);
@@ -161,7 +161,7 @@ export const Dispatch = ({ location, navigate }: RouteProps) => {
161161
title={t`No matching roles found.`}
162162
description={
163163
<Link
164-
to={formatPath(Paths.legacyRoles)}
164+
to={formatPath(Paths.standaloneRoles)}
165165
>{t`Show all roles`}</Link>
166166
}
167167
/>
@@ -177,7 +177,7 @@ export const Dispatch = ({ location, navigate }: RouteProps) => {
177177
))}
178178
</DataList>
179179
<Link
180-
to={formatPath(Paths.legacyRoles)}
180+
to={formatPath(Paths.standaloneRoles)}
181181
>{t`Show all roles`}</Link>
182182
</>
183183
)}

src/containers/search/multi-search.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,12 @@ export const MultiSearch = (props: RouteProps) => {
283283
title={t`Roles`}
284284
showAllLink={
285285
<Link
286-
to={formatPath(Paths.legacyRoles)}
286+
to={formatPath(Paths.standaloneRoles)}
287287
>{t`Show all roles`}</Link>
288288
}
289289
showMoreLink={
290290
<Link
291-
to={formatPath(Paths.legacyRoles, {}, { keywords })}
291+
to={formatPath(Paths.standaloneRoles, {}, { keywords })}
292292
>{t`Show more roles`}</Link>
293293
}
294294
>
@@ -306,12 +306,12 @@ export const MultiSearch = (props: RouteProps) => {
306306
title={t`Role namespaces`}
307307
showAllLink={
308308
<Link
309-
to={formatPath(Paths.legacyNamespaces)}
309+
to={formatPath(Paths.standaloneNamespaces)}
310310
>{t`Show all role namespaces`}</Link>
311311
}
312312
showMoreLink={
313313
<Link
314-
to={formatPath(Paths.legacyNamespaces, {}, { keywords })}
314+
to={formatPath(Paths.standaloneNamespaces, {}, { keywords })}
315315
>{t`Show more role namespaces`}</Link>
316316
}
317317
>
@@ -408,7 +408,7 @@ export const MultiSearch = (props: RouteProps) => {
408408
emptyStateTitle={t`No matching roles found.`}
409409
showAllLink={
410410
<Link
411-
to={formatPath(Paths.legacyRoles)}
411+
to={formatPath(Paths.standaloneRoles)}
412412
>{t`Show all roles`}</Link>
413413
}
414414
/>
@@ -421,7 +421,7 @@ export const MultiSearch = (props: RouteProps) => {
421421
emptyStateTitle={t`No matching role namespaces found.`}
422422
showAllLink={
423423
<Link
424-
to={formatPath(Paths.legacyNamespaces)}
424+
to={formatPath(Paths.standaloneNamespaces)}
425425
>{t`Show all role namespaces`}</Link>
426426
}
427427
/>

src/loaders/standalone/menu.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ function standaloneMenu() {
9999
},
100100
[
101101
menuItem(t`Roles`, {
102-
url: formatPath(Paths.legacyRoles),
102+
url: formatPath(Paths.standaloneRoles),
103103
alternativeUrls: [formatPath(Paths.compatLegacyRoles)],
104104
}),
105105
menuItem(t`Role Namespaces`, {
106-
url: formatPath(Paths.legacyNamespaces),
106+
url: formatPath(Paths.standaloneNamespaces),
107107
alternativeUrls: [formatPath(Paths.compatLegacyNamespaces)],
108108
}),
109109
],

src/loaders/standalone/routes.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,13 @@ export class StandaloneRoutes extends React.Component<IRoutesProps> {
212212
},
213213

214214
// roles ...
215-
{ component: AnsibleRoleNamespaceDetail, path: Paths.legacyNamespace },
216-
{ component: AnsibleRoleNamespaceList, path: Paths.legacyNamespaces },
217-
{ component: AnsibleRoleDetail, path: Paths.legacyRole },
218-
{ component: AnsibleRoleList, path: Paths.legacyRoles },
215+
{
216+
component: AnsibleRoleNamespaceDetail,
217+
path: Paths.standaloneNamespace,
218+
},
219+
{ component: AnsibleRoleNamespaceList, path: Paths.standaloneNamespaces },
220+
{ component: AnsibleRoleDetail, path: Paths.standaloneRole },
221+
{ component: AnsibleRoleList, path: Paths.standaloneRoles },
219222
// ... but still support legacy urls
220223
{
221224
component: AnsibleRoleNamespaceDetail,

src/paths.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ export enum Paths {
9090
login = '/login',
9191
logout = '/logout',
9292
landingPage = '/',
93-
legacyRole = '/standalone/roles/:username/:name',
94-
legacyRoles = '/standalone/roles/',
95-
legacyNamespace = '/standalone/namespaces/:namespaceid',
96-
legacyNamespaces = '/standalone/namespaces/',
93+
standaloneRole = '/standalone/roles/:namespace/:name',
94+
standaloneRoles = '/standalone/roles',
95+
standaloneNamespace = '/standalone/namespaces/:namespaceid',
96+
standaloneNamespaces = '/standalone/namespaces',
9797
searchByRepo = '/repo/:repo',
9898
myCollectionsByRepo = '/repo/:repo/my-namespaces/:namespace',
9999
collectionByRepo = '/repo/:repo/:namespace/:collection',
@@ -127,10 +127,10 @@ export enum Paths {
127127
collections = '/collections',
128128

129129
// for compatibility with old beta routes, remove later
130-
compatLegacyRole = '/legacy/roles/:username/:name',
131-
compatLegacyRoles = '/legacy/roles/',
130+
compatLegacyRole = '/legacy/roles/:namespace/:name',
131+
compatLegacyRoles = '/legacy/roles',
132132
compatLegacyNamespace = '/legacy/namespaces/:namespaceid',
133-
compatLegacyNamespaces = '/legacy/namespaces/',
133+
compatLegacyNamespaces = '/legacy/namespaces',
134134
}
135135

136136
export const namespaceBreadcrumb = () =>

0 commit comments

Comments
 (0)