From ece4f8d842e32524fb9e54fecbe945a01cbc4414 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 24 May 2021 05:23:17 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Display=20errors=20in=20a=20few?= =?UTF-8?q?=20more=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nest_frontend/routes/PageShare.js | 13 +++++++++++-- nest_frontend/routes/PageShare.module.css | 9 +++++++-- nest_frontend/routes/PageUsers.js | 4 ++++ nest_frontend/routes/PageUsers.module.css | 9 +++++++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/nest_frontend/routes/PageShare.js b/nest_frontend/routes/PageShare.js index 3ecabf4..1eb4b56 100644 --- a/nest_frontend/routes/PageShare.js +++ b/nest_frontend/routes/PageShare.js @@ -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 ? + {strings[authBvError?.data?.code ?? "errorUnknownError"]} + : null} + {usersBvError ? + {strings[usersBvError?.data?.code ?? "errorUnknownError"]} + : null} ) } diff --git a/nest_frontend/routes/PageShare.module.css b/nest_frontend/routes/PageShare.module.css index f2b083e..474f9e1 100644 --- a/nest_frontend/routes/PageShare.module.css +++ b/nest_frontend/routes/PageShare.module.css @@ -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; +} \ No newline at end of file diff --git a/nest_frontend/routes/PageUsers.js b/nest_frontend/routes/PageUsers.js index 0b256a8..5d9da5f 100644 --- a/nest_frontend/routes/PageUsers.js +++ b/nest_frontend/routes/PageUsers.js @@ -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 }) { + {bv.error ? + {strings[bv.error?.data?.code ?? "errorUnknownError"]} + : null} ) } diff --git a/nest_frontend/routes/PageUsers.module.css b/nest_frontend/routes/PageUsers.module.css index 79b9aad..6731e46 100644 --- a/nest_frontend/routes/PageUsers.module.css +++ b/nest_frontend/routes/PageUsers.module.css @@ -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; +} \ No newline at end of file