/** * One settings tab: the fields that belong to it, grouped into sections. * * Two tabs carry something that is not a setting: Appearance shows the preview, * because seeing the result answers the question faster than reading about it, * and Advanced offers to replace the encryption secrets, because that is an * action and belongs where somebody would look for it. */ import { Card, CardBody, CardHeader } from '@wordpress/components'; import Field, { isVisible } from './Field'; import Preview from './Preview'; import Secrets from './Secrets'; const APPEARANCE_TAB = 'appearance'; const ADVANCED_TAB = 'advanced'; export default function SettingsTab( { tab, fields, values, onChange, rotatedAt, isNetwork = false, } ) { const forThisTab = fields.filter( ( field ) => field.tab === tab && isVisible( field, values ) ); // Sections keep their order of first appearance in the schema, so the // schema file reads in the same order as the screen. const sections = []; forThisTab.forEach( ( field ) => { const existing = sections.find( ( section ) => section.title === field.section ); if ( existing ) { existing.fields.push( field ); } else { sections.push( { title: field.section, fields: [ field ] } ); } } ); return (