Skip to content

Commit fd7aac3

Browse files
OPH-86 | When not logged in and direct link it show a white page (#121)
* feat: open mocklogin when no acmidm When no acmidm open the mocklogin page Refs: oph-86 * feat: login on process route Refs: oph-86 * feat: add copy icon next to process title When rpessed the current url is been copied Refs: oph-86 * feat: when passing on a process id that cannot be found it will show the error page Refs: oph-86 * Update toaster texts --------- Co-authored-by: Martijn Bogaert <martijn.bogaert@sirus.be>
1 parent c3bb6ea commit fd7aac3

File tree

5 files changed

+83
-10
lines changed

5 files changed

+83
-10
lines changed

app/controllers/processes/process/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,22 @@ export default class ProcessesProcessIndexController extends Controller {
108108
this.diagrams = undefined;
109109
this.latestDiagram = undefined;
110110
}
111+
112+
@action
113+
copyUrl() {
114+
try {
115+
navigator.clipboard.writeText(window.location.href);
116+
this.toaster.success('Link naar proces gekopieerd', undefined, {
117+
timeOut: 5000,
118+
});
119+
} catch (error) {
120+
this.toaster.error(
121+
'Er liep iets mis bij het kopiëren van de link naar het proces',
122+
undefined,
123+
{
124+
timeOut: 5000,
125+
},
126+
);
127+
}
128+
}
111129
}

app/routes/auth/login.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import Route from '@ember/routing/route';
2-
import { inject as service } from '@ember/service';
2+
3+
import { service } from '@ember/service';
4+
35
import ENV from 'frontend-openproceshuis/config/environment';
46

57
export default class AuthLoginRoute extends Route {
68
@service session;
9+
@service router;
710

811
beforeModel() {
912
if (this.session.prohibitAuthentication('index')) {
10-
window.location.replace(buildLoginUrl(ENV.acmidm));
13+
if (isValidAcmidmConfig(ENV.acmidm)) {
14+
window.location.replace(buildLoginUrl(ENV.acmidm));
15+
} else {
16+
this.router.replaceWith('mock-login');
17+
}
1118
}
1219
}
1320
}
@@ -22,3 +29,12 @@ function buildLoginUrl({ authUrl, clientId, authRedirectUrl, scope }) {
2229

2330
return loginUrl.href;
2431
}
32+
33+
function isValidAcmidmConfig(acmidmConfig) {
34+
return Object.values(acmidmConfig).every(
35+
(value) =>
36+
typeof value === 'string' &&
37+
value.trim() !== '' &&
38+
!value.startsWith('{{'),
39+
);
40+
}

app/routes/processes/process.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,35 @@ import ENV from 'frontend-openproceshuis/config/environment';
44

55
export default class ProcessesProcessRoute extends Route {
66
@service store;
7+
@service router;
8+
@service session;
9+
10+
beforeModel(transition) {
11+
if (!this.session.isAuthenticated) {
12+
this.session.requireAuthentication(transition, 'auth.login');
13+
}
14+
}
715

816
async model(params) {
9-
const query = {
10-
reload: true,
11-
include:
12-
'process-statistics,files,publisher,publisher.primary-site,publisher.primary-site.contacts,publisher.classification,ipdc-products,information-assets',
13-
'filter[files][:not:status]': ENV.resourceStates.archived,
14-
};
15-
return await this.store.findRecord('process', params.id, query);
17+
try {
18+
const process = await this.store.findRecord('process', params.id, {
19+
'filter[files][:not:status]': ENV.resourceStates.archived,
20+
include: [
21+
'process-statistics',
22+
'files',
23+
'publisher',
24+
'publisher.primary-site',
25+
'publisher.primary-site.contacts',
26+
'publisher.classification',
27+
'ipdc-products',
28+
'information-assets',
29+
].join(','),
30+
reload: true,
31+
});
32+
33+
return process;
34+
} catch (error) {
35+
throw new Error(`Er werd geen process met id "${params.id}" gevonden.`);
36+
}
1637
}
1738
}

app/templates/processes/error.hbs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{page-title "Process niet gevonden"}}
2+
3+
<LayoutDetail>
4+
<Oops
5+
@title="Het lijkt erop dat het proces waarnaar je zoekt niet bestaat of niet meer beschikbaar is."
6+
@content="Controleer even of je de juiste link gebruikt of neem contact op met de beheerder indien je denkt dat dit een fout is."
7+
@image="/assets/images/page-not-found.svg"
8+
/>
9+
{{outlet}}
10+
</LayoutDetail>

app/templates/processes/process/index.hbs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@
1111
{{else}}
1212
<PageHeader>
1313
<:title>
14-
{{this.process.title}}
14+
<div class="au-u-flex au-u-flex--vertical-center">
15+
{{this.process.title}}
16+
<AuButton
17+
class="au-u-padding-left-small"
18+
@icon="link"
19+
@skin="link"
20+
@hideText={{true}}
21+
{{on "click" this.copyUrl}}
22+
/></div>
1523
</:title>
1624
<:action>
1725
<AuPill @icon="clock-rewind">Laatst aangepast op

0 commit comments

Comments
 (0)