Skip to content

Commit

Permalink
Revert "fixes #780 deprecated array types in schema were not annotated"
Browse files Browse the repository at this point in the history
This reverts commit 3910292.
  • Loading branch information
mrin9 committed Jul 27, 2022
1 parent d3a9bf6 commit 3ca2c82
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 36 deletions.
30 changes: 11 additions & 19 deletions src/components/schema-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,7 @@ export default class SchemaTable extends LitElement {
${this.generateTree(
this.data['::type'] === 'array' ? this.data['::props'] : this.data,
this.data['::type'],
this.data?.['::array-type'] || '',
'',
this.data?.['::description'] || '',
0,
0,
this.data['::readwrite'] ? this.data['::readwrite'] : '',
this.data?.['::deprecated'] === 'deprecated',
this.data['::array-type'],
)}`
: ''
}
Expand All @@ -129,7 +123,7 @@ export default class SchemaTable extends LitElement {
`;
}

generateTree(data, dataType = 'object', arrayType = '', key = '', description = '', schemaLevel = 0, indentLevel = 0, readOrWrite = '', isDeprecated = false) {
generateTree(data, dataType = 'object', arrayType = '', key = '', description = '', schemaLevel = 0, indentLevel = 0, readOrWrite = '') {
if (this.schemaHideReadOnly === 'true') {
if (dataType === 'array') {
if (readOrWrite === 'readonly') {
Expand Down Expand Up @@ -204,8 +198,8 @@ export default class SchemaTable extends LitElement {
return html`
${newSchemaLevel >= 0 && key
? html`
<div class='tr ${newSchemaLevel <= this.schemaExpandLevel ? 'expanded' : 'collapsed'} ${data['::type']}' data-obj='${keyLabel}' title="${isDeprecated ? 'Deprecated' : ''}">
<div class="td key ${isDeprecated ? 'deprecated' : ''}" style='padding-left:${leftPadding}px'>
<div class='tr ${newSchemaLevel <= this.schemaExpandLevel ? 'expanded' : 'collapsed'} ${data['::type']}' data-obj='${keyLabel}' title="${data['::deprecated'] ? 'Deprecated' : ''}">
<div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style='padding-left:${leftPadding}px'>
${(keyLabel || keyDescr)
? html`
<span
Expand All @@ -220,8 +214,8 @@ export default class SchemaTable extends LitElement {
${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION')
? html`<span class="xxx-of-key" style="margin-left:-6px">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>`
: keyLabel.endsWith('*')
? html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${isDeprecated ? '✗' : ''} ${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>`
: html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${isDeprecated ? '✗' : ''} ${keyLabel === '::props' ? '' : keyLabel}</span>`
? html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${data['::deprecated'] ? '✗' : ''} ${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>`
: html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${data['::deprecated'] ? '✗' : ''} ${keyLabel === '::props' ? '' : keyLabel}</span>`
}
${data['::type'] === 'xxx-of' && dataType === 'array' ? html`<span style="color:var(--primary-color)">ARRAY</span>` : ''}
</div>
Expand All @@ -247,7 +241,7 @@ export default class SchemaTable extends LitElement {
}
<div class='object-body'>
${Array.isArray(data) && data[0]
? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, '', data['::deprecated'] || false)}`
? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, '')}`
: html`
${Object.keys(data).map((dataKey) => html`
${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite', '::dataTypeLabel'].includes(dataKey)
Expand All @@ -261,7 +255,6 @@ export default class SchemaTable extends LitElement {
newSchemaLevel,
newIndentLevel,
data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
data[dataKey]['::deprecated'] || false,
)}`
: ''
: html`${this.generateTree(
Expand All @@ -273,7 +266,6 @@ export default class SchemaTable extends LitElement {
newSchemaLevel,
newIndentLevel,
data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
data[dataKey]['::deprecated'] || false,
)}`
}
`)}
Expand All @@ -295,7 +287,7 @@ export default class SchemaTable extends LitElement {
let dataTypeHtml = '';
if (dataType === 'array') {
dataTypeHtml = html`
<div class='td key-type ${dataTypeCss} ${isDeprecated ? 'deprecated' : ''}' title="${readOrWrite === 'readonly' ? 'Read-Only' : readOrWriteOnly === 'writeonly' ? 'Write-Only' : ''}">
<div class='td key-type ${dataTypeCss}' title="${readOrWrite === 'readonly' ? 'Read-Only' : readOrWriteOnly === 'writeonly' ? 'Write-Only' : ''}">
[${type}] ${readOrWrite === 'readonly' ? '🆁' : readOrWrite === 'writeonly' ? '🆆' : ''}
</div>`;
} else {
Expand All @@ -305,9 +297,9 @@ export default class SchemaTable extends LitElement {
</div>`;
}
return html`
<div class = "tr primitive" title="${isDeprecated || deprecated === 'deprecated' ? 'Deprecated' : ''}">
<div class="td key ${isDeprecated ? 'deprecated' : ''} ${deprecated}" style='padding-left:${leftPadding}px'>
${isDeprecated || deprecated === 'deprecated' ? html`<span style='color:var(--red);'></span>` : ''}
<div class = "tr primitive" title="${deprecated ? 'Deprecated' : ''}">
<div class="td key ${deprecated}" style='padding-left:${leftPadding}px'>
${deprecated ? html`<span style='color:var(--red);'></span>` : ''}
${keyLabel?.endsWith('*')
? html`
<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span>
Expand Down
25 changes: 8 additions & 17 deletions src/components/schema-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,14 @@ export default class SchemaTree extends LitElement {
this.data['::type'] === 'array' ? this.data['::props'] : this.data,
this.data['::type'],
this.data['::array-type'] || '',
this.data?.['::array-type'] || '',
'',
this.data?.['::description'] || '',
0,
0,
this.data['::readwrite'] ? this.data['::readwrite'] : '',
this.data?.['::deprecated'] === 'deprecated',
)}`
: html`<span class='mono-font' style='color:var(--red)'> Schema not found </span>`
}
</div>
`;
}

generateTree(data, dataType = 'object', arrayType = '', key = '', description = '', schemaLevel = 0, indentLevel = 0, readOrWrite = '', isDeprecated = false) {
generateTree(data, dataType = 'object', arrayType = '', key = '', description = '', schemaLevel = 0, indentLevel = 0, readOrWrite = '') {
if (this.schemaHideReadOnly === 'true') {
if (dataType === 'array') {
if (readOrWrite === 'readonly') {
Expand Down Expand Up @@ -230,15 +223,15 @@ export default class SchemaTree extends LitElement {
}
if (typeof data === 'object') {
return html`
<div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type']?.startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}" title="${isDeprecated ? 'Deprecated' : ''}">
<div class="td key ${isDeprecated ? 'deprecated' : ''}" style='min-width:${minFieldColWidth}px'>
<div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type']?.startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}" title="${data['::deprecated'] ? 'Deprecated' : ''}">
<div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style='min-width:${minFieldColWidth}px'>
${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION')
? html`<span class='key-label xxx-of-key'> ${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>`
: keyLabel === '::props' || keyLabel === '::ARRAY~OF'
? ''
: schemaLevel > 0
? html`<span class="key-label" title="${readOrWrite === 'readonly' ? 'Read-Only' : readOrWrite === 'writeonly' ? 'Write-Only' : ''}">
${isDeprecated ? '✗' : ''}
${data['::deprecated'] ? '✗' : ''}
${keyLabel.replace(/\*$/, '')}${keyLabel.endsWith('*') ? html`<span style="color:var(--red)">*</span>` : ''}${readOrWrite === 'readonly' ? html` 🆁` : readOrWrite === 'writeonly' ? html` 🆆` : readOrWrite}:
</span>`
: ''
Expand All @@ -250,7 +243,7 @@ export default class SchemaTree extends LitElement {
</div>
<div class='inside-bracket ${data['::type'] || 'no-type-info'}' style='padding-left:${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' ? 0 : leftPadding}px;'>
${Array.isArray(data) && data[0]
? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, data[0]['::readwrite'], data['::deprecated'] || false)}`
? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, data[0]['::readwrite'])}`
: html`
${Object.keys(data).map((dataKey) => html`
${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite', '::dataTypeLabel'].includes(dataKey)
Expand All @@ -264,7 +257,6 @@ export default class SchemaTree extends LitElement {
newSchemaLevel,
newIndentLevel,
data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
data[dataKey]['::deprecated'] || false,
)}`
: ''
: html`${this.generateTree(
Expand All @@ -276,7 +268,6 @@ export default class SchemaTree extends LitElement {
newSchemaLevel,
newIndentLevel,
data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
data[dataKey]['::deprecated'] || false,
)}`
}
`)}
Expand Down Expand Up @@ -319,9 +310,9 @@ export default class SchemaTree extends LitElement {
}

return html`
<div class = "tr primitive" title="${isDeprecated || deprecated === 'deprecated' ? 'Deprecated' : ''}">
<div class="td key ${isDeprecated || deprecated === 'deprecated' ? 'deprecated' : ''} ${deprecated}" style='min-width:${minFieldColWidth}px'>
${isDeprecated || deprecated === 'deprecated' ? html`<span style='color:var(--red);'></span>` : ''}
<div class = "tr primitive" title="${deprecated ? 'Deprecated' : ''}">
<div class="td key ${deprecated}" style='min-width:${minFieldColWidth}px'>
${deprecated ? html`<span style='color:var(--red);'></span>` : ''}
${keyLabel.endsWith('*')
? html`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>:`
: key.startsWith('::OPTION')
Expand Down

0 comments on commit 3ca2c82

Please sign in to comment.