This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
forked from GSA/fedramp-automation
/
ValidatorPage.tsx
176 lines (173 loc) · 6.52 KB
/
ValidatorPage.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import React from 'react';
import { useActions, useAppState } from '../hooks';
import { onFileInputChangeGetFile } from '../../util/file-input';
import { colorTokenForRole } from '../../util/styles';
import { SchematronReport } from './SchematronReport';
export const ValidatorPage = () => {
const { sourceRepository, schematron } = useAppState();
const actions = useActions();
return (
<div className="grid-row grid-gap">
<div className="mobile:grid-col-12 tablet:grid-col-4">
<label className="usa-label" htmlFor="file-input-specific">
FedRAMP OSCAL SSP document
</label>
<span className="usa-hint" id="file-input-specific-hint">
Select XML file
</span>
<input
id="file-input-specific"
className="usa-file-input"
type="file"
name="file-input-specific"
aria-describedby="file-input-specific-hint"
accept=".xml"
onChange={onFileInputChangeGetFile(fileDetails => {
actions.validator.setXmlContents({
fileName: fileDetails.name,
xmlContents: fileDetails.text,
});
})}
disabled={schematron.validator.current === 'PROCESSING'}
/>
<div className="margin-y-1">
<div className="usa-hint">
Or use an example file, brought to you by FedRAMP:
</div>
<ul>
{sourceRepository.sampleSSPs.map((sampleSSP, index) => (
<li key={index}>
<button
className="usa-button usa-button--unstyled"
onClick={() => actions.validator.setXmlUrl(sampleSSP.url)}
disabled={schematron.validator.current === 'PROCESSING'}
>
{sampleSSP.displayName}
</button>
</li>
))}
</ul>
</div>
{
<form className="usa-form">
<fieldset className="usa-fieldset">
<legend className="usa-legend usa-legend">
Select an assertion view
</legend>
<div className="usa-radio">
{schematron.filterOptions.assertionViews.map(assertionView => (
<div key={assertionView.id}>
<input
className="usa-radio__input usa-radio__input--tile"
id={`assertion-view-${assertionView.id}`}
type="radio"
name="assertion-view"
value={assertionView.id}
checked={
schematron.filter.assertionViewId === assertionView.id
}
onChange={() =>
actions.schematron.setFilterAssertionView(
assertionView.id,
)
}
/>
<label
className="usa-radio__label"
htmlFor={`assertion-view-${assertionView.id}`}
>
{assertionView.title}
</label>
</div>
))}
</div>
<div className="usa-search usa-search--small" role="search">
<label className="usa-sr-only" htmlFor="search-field">
Search
</label>
<div className="usa-input-group">
<div className="usa-input-prefix" aria-hidden="true">
<svg
aria-hidden="true"
role="img"
focusable="false"
className="usa-icon"
>
<use
xmlnsXlink="http://www.w3.org/1999/xlink"
xlinkHref={actions.getAssetUrl(
'uswds/img/sprite.svg#search',
)}
/>
</svg>
</div>
<input
id="search-field"
type="search"
className="usa-input"
autoComplete="off"
onChange={event => {
let text = '';
if (event && event.target) {
text = event.target.value;
}
actions.schematron.setFilterText(text);
}}
placeholder="Search text..."
/>
</div>
</div>
<div className="usa-radio">
{schematron.filterOptions.roles.map((filterRole, index) => (
<div
key={index}
className={`bg-${colorTokenForRole(filterRole)}-lighter`}
>
<input
className="usa-radio__input usa-radio__input--tile"
id={`role-${filterRole}`}
type="radio"
name="role"
value={filterRole}
checked={schematron.filter.role === filterRole}
onChange={() =>
actions.schematron.setFilterRole(filterRole)
}
/>
<label
className="usa-radio__label"
htmlFor={`role-${filterRole}`}
>
<svg
aria-hidden="true"
role="img"
focusable="false"
className="usa-icon usa-icon--size-3 margin-right-1 margin-bottom-neg-2px"
>
<use
xmlnsXlink="http://www.w3.org/1999/xlink"
xlinkHref={actions.getAssetUrl(
`uswds/img/sprite.svg#${colorTokenForRole(
filterRole,
)}`,
)}
/>
</svg>
{filterRole || '<not specified>'}
</label>
</div>
))}
</div>
</fieldset>
</form>
}
</div>
<div className="mobile:grid-col-12 tablet:grid-col-8">
<SchematronReport />
{schematron.validator.current === 'PROCESSING' && (
<div className="loader" />
)}
</div>
</div>
);
};