mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 06:55:47 +01:00
Bugfix/link not found (#1296)
Redirect to login page if anonymous tries to access a page without permission Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com> Co-authored-by: Sebastian Sdorra <sebastian.sdorra@cloudogu.com>
This commit is contained in:
committed by
GitHub
parent
bd81d973ec
commit
b4c5f49858
@@ -24,7 +24,7 @@
|
||||
|
||||
import * as types from "./types";
|
||||
|
||||
import { apiClient } from "@scm-manager/ui-components";
|
||||
import { apiClient, MissingLinkError } from "@scm-manager/ui-components";
|
||||
import { Action, IndexResources, Link } from "@scm-manager/ui-types";
|
||||
import { isPending } from "./pending";
|
||||
import { getFailure } from "./failure";
|
||||
@@ -123,6 +123,14 @@ export function getLink(state: object, name: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export function mustGetLink(state: object, name: string) {
|
||||
const link = getLink(state, name);
|
||||
if (link) {
|
||||
return link;
|
||||
}
|
||||
throw new MissingLinkError(`No link in state for link name: '${name}'`);
|
||||
}
|
||||
|
||||
export function getLinkCollection(state: object, name: string): Link[] {
|
||||
// @ts-ignore Right types not available
|
||||
if (state.indexResources.links && state.indexResources.links[name]) {
|
||||
@@ -145,10 +153,18 @@ export function getAvailablePluginsLink(state: object) {
|
||||
return getLink(state, "availablePlugins");
|
||||
}
|
||||
|
||||
export function mustGetAvailablePluginsLink(state: object) {
|
||||
return mustGetLink(state, "availablePlugins");
|
||||
}
|
||||
|
||||
export function getInstalledPluginsLink(state: object) {
|
||||
return getLink(state, "installedPlugins");
|
||||
}
|
||||
|
||||
export function mustGetInstalledPluginsLink(state: object) {
|
||||
return mustGetLink(state, "installedPlugins");
|
||||
}
|
||||
|
||||
export function getPendingPluginsLink(state: object) {
|
||||
return getLink(state, "pendingPlugins");
|
||||
}
|
||||
@@ -169,10 +185,18 @@ export function getUsersLink(state: object) {
|
||||
return getLink(state, "users");
|
||||
}
|
||||
|
||||
export function mustGetUsersLink(state: object) {
|
||||
return mustGetLink(state, "users");
|
||||
}
|
||||
|
||||
export function getRepositoryRolesLink(state: object) {
|
||||
return getLink(state, "repositoryRoles");
|
||||
}
|
||||
|
||||
export function mustGetRepositoryRolesLink(state: object) {
|
||||
return mustGetLink(state, "repositoryRoles");
|
||||
}
|
||||
|
||||
export function getRepositoryVerbsLink(state: object) {
|
||||
return getLink(state, "repositoryVerbs");
|
||||
}
|
||||
@@ -181,10 +205,18 @@ export function getGroupsLink(state: object) {
|
||||
return getLink(state, "groups");
|
||||
}
|
||||
|
||||
export function mustGetGroupsLink(state: object) {
|
||||
return mustGetLink(state, "groups");
|
||||
}
|
||||
|
||||
export function getConfigLink(state: object) {
|
||||
return getLink(state, "config");
|
||||
}
|
||||
|
||||
export function mustGetConfigLink(state: object) {
|
||||
return mustGetLink(state, "config");
|
||||
}
|
||||
|
||||
export function getRepositoriesLink(state: object) {
|
||||
return getLink(state, "repositories");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user