Skip to content

Commit

Permalink
DOCS-2387: Adds FelixConfig component to CE
Browse files Browse the repository at this point in the history
  • Loading branch information
ctauchen committed Dec 4, 2024
1 parent 7f8c8a6 commit 2f58966
Show file tree
Hide file tree
Showing 8 changed files with 8,607 additions and 545 deletions.
55 changes: 55 additions & 0 deletions calico-enterprise/_includes/components/FelixConfig/TableConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react';
import DOMPurify from 'isomorphic-dompurify';
import styles from './styles.module.css';

const getSanitizedData = ({ fieldData }) => ({
sanitizedDescription: { __html: DOMPurify.sanitize(fieldData.DescriptionHTML) },
sanitizedSchema: { __html: DOMPurify.sanitize(fieldData.StringSchemaHTML) },
});

const TableConfig = ({ fieldData }) => {
const { sanitizedDescription, sanitizedSchema } = getSanitizedData({ fieldData });

return (
<table className={styles.felixTable}>
<thead>
<tr>
<th>Attribute</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Key</td>
<td>
<code>{fieldData.NameConfigFile || 'No Default Value'}</code>
</td>
</tr>
<tr>
<td>Description</td>
<td dangerouslySetInnerHTML={sanitizedDescription} />
</tr>
<tr>
<td>Schema</td>
<td dangerouslySetInnerHTML={sanitizedSchema} />
</tr>
<tr>
<td>Default</td>
<td>
{fieldData.StringDefault === '' ? (
'none'
) : fieldData.GoType === '*v1.Duration' ? (
<>
<code>{fieldData.StringDefault}</code> ({fieldData.ParsedDefault})
</>
) : (
<code>{fieldData.StringDefault}</code>
)}
</td>
</tr>
</tbody>
</table>
);
};

export default TableConfig;
55 changes: 55 additions & 0 deletions calico-enterprise/_includes/components/FelixConfig/TableEnv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react';
import DOMPurify from 'isomorphic-dompurify';
import styles from './styles.module.css';

const getSanitizedData = ({ fieldData }) => ({
sanitizedDescription: { __html: DOMPurify.sanitize(fieldData.DescriptionHTML) },
sanitizedSchema: { __html: DOMPurify.sanitize(fieldData.StringSchemaHTML) },
});

const TableEnv = ({ fieldData }) => {
const { sanitizedDescription, sanitizedSchema } = getSanitizedData({ fieldData });

return (
<table className={styles.felixTable}>
<thead>
<tr>
<th>Attribute</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Key</td>
<td>
<code>{fieldData.NameEnvVar.toUpperCase() || 'No Default Value'}</code>
</td>
</tr>
<tr>
<td>Description</td>
<td dangerouslySetInnerHTML={sanitizedDescription} />
</tr>
<tr>
<td>Schema</td>
<td dangerouslySetInnerHTML={sanitizedSchema} />
</tr>
<tr>
<td>Default</td>
<td>
{fieldData.StringDefault === '' ? (
'none'
) : fieldData.GoType === '*v1.Duration' ? (
<>
<code>{fieldData.StringDefault}</code> ({fieldData.ParsedDefault})
</>
) : (
<code>{fieldData.StringDefault}</code>
)}
</td>
</tr>
</tbody>
</table>
);
};

export default TableEnv;
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';
import DOMPurify from 'isomorphic-dompurify';
import styles from './styles.module.css';

const getSanitizedData = ({ fieldData }) => ({
sanitizedNAMEYAML: { __html: DOMPurify.sanitize(fieldData.NameYAML) },
sanitizedDescription: { __html: DOMPurify.sanitize(fieldData.DescriptionHTML) },
sanitizedSchema: { __html: DOMPurify.sanitize(fieldData.YAMLSchemaHTML) },
});

const TableResource = ({ fieldData }) => {
const { sanitizedNAMEYAML, sanitizedDescription, sanitizedSchema } = getSanitizedData({ fieldData });

return (
<table className={styles.felixTable}>
<thead>
<tr>
<th>Attribute</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Key</td>
<td>
<code dangerouslySetInnerHTML={sanitizedNAMEYAML} />
</td>
</tr>
<tr>
<td>Description</td>
<td dangerouslySetInnerHTML={sanitizedDescription} />
</tr>
<tr>
<td>Schema</td>
<td dangerouslySetInnerHTML={sanitizedSchema} />
</tr>
<tr>
<td>Default</td>
<td>{fieldData.YAMLDefault === '' ? 'none' : <code>{fieldData.YAMLDefault}</code>}</td>
</tr>
</tbody>
</table>
);
};

export default TableResource;
Loading

0 comments on commit 2f58966

Please sign in to comment.