Skip to content

Commit 0bad0e7

Browse files
committed
feat: Link to project using name and version
Signed-off-by: Tobias Trumm <tobias@tobiastrumm.de>
1 parent 85db16b commit 0bad0e7

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/router/index.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,42 @@ function configRoutes() {
213213
permission: 'VIEW_PORTFOLIO',
214214
},
215215
},
216+
{
217+
path: 'projects/:name/:version/*',
218+
name: 'Project By Name and Version',
219+
beforeEnter: (to, from, next) => {
220+
const searchParams = new URLSearchParams({
221+
name: to.params.name,
222+
version: to.params.version,
223+
});
224+
router.app.axios
225+
.get(
226+
`${router.app.$api.BASE_URL}/${router.app.$api.URL_PROJECT_LOOKUP}?${searchParams}`,
227+
)
228+
.then((result) => {
229+
const trailingPathSegments = to.params.pathMatch
230+
? `/${to.params.pathMatch}`
231+
: '';
232+
next({
233+
path: `projects/${result.data.uuid}${trailingPathSegments}`,
234+
replace: true,
235+
});
236+
})
237+
.catch(() => {
238+
next({
239+
name: '404',
240+
replace: true,
241+
});
242+
});
243+
},
244+
meta: {
245+
permission: 'VIEW_PORTFOLIO',
246+
},
247+
},
248+
{
249+
path: 'projects/:name/:version',
250+
redirect: 'projects/:name/:version/',
251+
},
216252
{
217253
path: 'components',
218254
name: 'Component Lookup',

src/shared/api.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"URL_POLICY_VIOLATION": "api/v1/violation",
4242
"URL_POLICY_VIOLATION_ANALYSIS": "api/v1/violation/analysis",
4343
"URL_PROJECT": "api/v1/project",
44+
"URL_PROJECT_LOOKUP": "api/v1/project/lookup",
4445
"URL_REPOSITORY": "api/v1/repository",
4546
"URL_SEARCH": "api/v1/search",
4647
"URL_SERVICE": "api/v1/service",

0 commit comments

Comments
 (0)