| 1 |
/** |
| 2 |
* The CryptX settings screen. |
| 3 |
* |
| 4 |
* Everything this file knows about the options comes from the schema the REST |
| 5 |
* route hands over. Adding an option means adding it to SettingsSchema.php -- |
| 6 |
* there is deliberately no second list of fields here that could fall behind. |
| 7 |
*/ |
| 8 |
|
| 9 |
import { createRoot, StrictMode } from '@wordpress/element'; |
| 10 |
import { __ } from '@wordpress/i18n'; |
| 11 |
|
| 12 |
import App from './components/App'; |
| 13 |
import './index.css'; |
| 14 |
|
| 15 |
document.addEventListener( 'DOMContentLoaded', () => { |
| 16 |
const container = document.getElementById( 'cryptx-settings-root' ); |
| 17 |
|
| 18 |
if ( ! container ) { |
| 19 |
return; |
| 20 |
} |
| 21 |
|
| 22 |
// The container carries the "loading" fallback that PHP printed. Clearing |
| 23 |
// it here rather than in PHP means the fallback stays visible for people |
| 24 |
// whose browser never gets this far. |
| 25 |
container.textContent = ''; |
| 26 |
container.setAttribute( 'aria-busy', 'false' ); |
| 27 |
container.setAttribute( 'aria-label', __( 'CryptX settings', 'cryptx' ) ); |
| 28 |
|
| 29 |
// Two screens, one application. The site screen edits this site; the |
| 30 |
// network screen edits what a newly created site starts with. PHP says |
| 31 |
// which, because PHP is what knows which menu entry was opened. |
| 32 |
const scope = |
| 33 |
container.getAttribute( 'data-cryptx-scope' ) === 'network' |
| 34 |
? 'network' |
| 35 |
: 'site'; |
| 36 |
|
| 37 |
createRoot( container ).render( |
| 38 |
<StrictMode> |
| 39 |
<App scope={ scope } /> |
| 40 |
</StrictMode> |
| 41 |
); |
| 42 |
} ); |
| 43 |
|