Skip to content

Commit c75ee70

Browse files
Copilotcubap
andauthored
Display permission error instead of blank page in transcription interfaces (#369)
* Initial plan * Add permission error display for transcription interfaces Co-authored-by: cubap <1119165+cubap@users.noreply.github.com> * Refactor permission error to shared utility function Co-authored-by: cubap <1119165+cubap@users.noreply.github.com> * Update renderPermissionError.js --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: cubap <1119165+cubap@users.noreply.github.com> Co-authored-by: cubap <cubap@slu.edu>
1 parent 7a69889 commit c75ee70

3 files changed

Lines changed: 90 additions & 2 deletions

File tree

components/simple-transcription/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import '../../components/workspace-tools/index.js'
44
import '../../components/transcription-block/index.js'
55
import vault from '../../js/vault.js'
66
import CheckPermissions from "../../components/check-permissions/checkPermissions.js"
7+
import { renderPermissionError } from "../../utilities/renderPermissionError.js"
78

89
export default class SimpleTranscriptionInterface extends HTMLElement {
910
#page
@@ -101,7 +102,7 @@ export default class SimpleTranscriptionInterface extends HTMLElement {
101102

102103
async authgate() {
103104
if (!CheckPermissions.checkViewAccess("ANY", "CONTENT")) {
104-
this.remove()
105+
this.renderPermissionError()
105106
return
106107
}
107108
this.render()
@@ -118,6 +119,10 @@ export default class SimpleTranscriptionInterface extends HTMLElement {
118119
this.updateLines()
119120
}
120121

122+
renderPermissionError() {
123+
renderPermissionError(this.shadowRoot, TPEN.screen?.projectInQuery ?? '')
124+
}
125+
121126
render() {
122127
this.shadowRoot.innerHTML = `
123128
<style>

interfaces/transcription/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import vault from '../../js/vault.js'
66
import '../../components/line-image/index.js'
77
import CheckPermissions from "../../components/check-permissions/checkPermissions.js"
88
import { orderPageItemsByColumns } from "../../utilities/columnOrdering.js"
9+
import { renderPermissionError } from "../../utilities/renderPermissionError.js"
910
export default class TranscriptionInterface extends HTMLElement {
1011
#page
1112
#canvas
@@ -32,7 +33,7 @@ export default class TranscriptionInterface extends HTMLElement {
3233

3334
async authgate() {
3435
if (!CheckPermissions.checkViewAccess("ANY", "CONTENT")) {
35-
this.remove()
36+
this.renderPermissionError()
3637
return
3738
}
3839
this.render()
@@ -43,6 +44,10 @@ export default class TranscriptionInterface extends HTMLElement {
4344
this.updateLines()
4445
}
4546

47+
renderPermissionError() {
48+
renderPermissionError(this.shadowRoot, TPEN.screen?.projectInQuery ?? '')
49+
}
50+
4651
render() {
4752
this.shadowRoot.innerHTML = `
4853
<style>

utilities/renderPermissionError.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* Utility function to render a permission error message.
3+
* Used by interfaces when a user lacks the required permissions.
4+
* @param {HTMLElement} shadowRoot - The shadow root to render the error in
5+
* @param {string} projectInQuery - The project ID from the query string
6+
*/
7+
export function renderPermissionError(shadowRoot, projectInQuery = '') {
8+
shadowRoot.innerHTML = `
9+
<style>
10+
.error-container {
11+
display: flex;
12+
flex-direction: column;
13+
align-items: center;
14+
justify-content: center;
15+
height: 100vh;
16+
padding: 2rem;
17+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
18+
background-color: #f8f9fa;
19+
}
20+
.error-content {
21+
max-width: 600px;
22+
text-align: center;
23+
background: white;
24+
padding: 3rem;
25+
border-radius: 8px;
26+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
27+
}
28+
.error-title {
29+
color: #d63031;
30+
font-size: 2rem;
31+
margin-bottom: 1rem;
32+
}
33+
.error-message {
34+
color: #2d3436;
35+
font-size: 1.1rem;
36+
line-height: 1.6;
37+
margin-bottom: 1.5rem;
38+
}
39+
.error-link {
40+
background-color: #00b894;
41+
color: white;
42+
padding: 0.75rem 1.5rem;
43+
text-decoration: none;
44+
border-radius: 5px;
45+
display: inline-block;
46+
margin: 0.5rem;
47+
font-weight: bold;
48+
transition: background-color 0.3s;
49+
}
50+
.error-link:hover {
51+
background-color: #00a383;
52+
}
53+
.error-link.secondary {
54+
background-color: #0984e3;
55+
}
56+
.error-link.secondary:hover {
57+
background-color: #0770c7;
58+
}
59+
</style>
60+
<div class="error-container">
61+
<div class="error-content">
62+
<h1 class="error-title">Permission Denied</h1>
63+
<p class="error-message">
64+
You do not have the appropriate permissions to view this transcription interface.
65+
</p>
66+
<div>
67+
<a href="/project?projectID=${projectInQuery}" class="error-link">
68+
Back to Project
69+
</a>
70+
<a href="/" class="error-link secondary">
71+
Go to Home
72+
</a>
73+
</div>
74+
<img src="/assets/logo/logo-350w.png" alt="Permission Denied Illustration" style="margin-top: 1.5rem; max-width: 100%; height: auto;" />
75+
</div>
76+
</div>
77+
`
78+
}

0 commit comments

Comments
 (0)