1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 06:24:19 +00:00

🔧 Display errors in a few more pages

This commit is contained in:
Steffo 2021-05-24 05:23:17 +02:00
parent 00b805f644
commit ece4f8d842
Signed by: steffo
GPG key ID: 6965406171929D01
4 changed files with 29 additions and 6 deletions

View file

@ -7,6 +7,7 @@ import BoxUserList from "../components/interactive/BoxUserList"
import useBackendViewset from "../hooks/useBackendViewset"
import { useParams } from "react-router"
import ContextUser from "../contexts/ContextUser"
import BoxAlert from "../components/base/BoxAlert"
export default function PageShare({ className, ...props }) {
@ -18,7 +19,8 @@ export default function PageShare({ className, ...props }) {
resources: authorizations,
createResource: createAuthorization,
destroyResource: destroyAuthorization,
running: authBvRunning
running: authBvRunning,
error: authBvError,
} = useBackendViewset(
`/api/v1/repositories/${id}/authorizations/`,
"email",
@ -35,7 +37,8 @@ export default function PageShare({ className, ...props }) {
const {
resources: users,
running: usersBvRunning
running: usersBvRunning,
error: usersBvError,
} = useBackendViewset(
"/api/v1/users/",
"email",
@ -85,6 +88,12 @@ export default function PageShare({ className, ...props }) {
header={strings.sharingWith}
running={usersBvRunning && authBvRunning}
/>
{authBvError ?
<BoxAlert color={"Red"} className={Style.Error}>{strings[authBvError?.data?.code ?? "errorUnknownError"]}</BoxAlert>
: null}
{usersBvError ?
<BoxAlert color={"Red"} className={Style.Error}>{strings[usersBvError?.data?.code ?? "errorUnknownError"]}</BoxAlert>
: null}
</div>
)
}

View file

@ -4,8 +4,9 @@
grid-template-areas:
"a"
"b"
"c";
grid-template-rows: auto 1fr 1fr;
"c"
"d";
grid-template-rows: auto 1fr 1fr auto;
grid-template-columns: 1fr;
grid-gap: 10px;
@ -25,3 +26,7 @@
.SharingWith {
grid-area: c;
}
.Error {
grid-area: d;
}

View file

@ -6,6 +6,7 @@ import BoxUserCreate from "../components/interactive/BoxUserCreate"
import useBackendViewset from "../hooks/useBackendViewset"
import BoxUserList from "../components/interactive/BoxUserList"
import ContextLanguage from "../contexts/ContextLanguage"
import BoxAlert from "../components/base/BoxAlert"
export default function PageUsers({ children, className, ...props }) {
@ -20,6 +21,9 @@ export default function PageUsers({ children, className, ...props }) {
</BoxHeader>
<BoxUserCreate className={Style.CreateUser} createUser={bv.createResource} running={bv.running}/>
<BoxUserList className={Style.UserList} users={bv.resources} destroyUser={bv.destroyResource} running={bv.running}/>
{bv.error ?
<BoxAlert className={Style.Error} color={"red"}>{strings[bv.error?.data?.code ?? "errorUnknownError"]}</BoxAlert>
: null}
</div>
)
}

View file

@ -4,8 +4,9 @@
grid-template-areas:
"a"
"b"
"c";
grid-template-rows: auto 1fr auto;
"c"
"e";
grid-template-rows: auto 1fr auto auto;
grid-template-columns: 1fr;
grid-gap: 10px;
@ -25,3 +26,7 @@
.CreateUser {
grid-area: c;
}
.Error {
grid-area: e;
}