Skip to content

Commit

Permalink
GUI Metadata: hide "secret" metadata values
Browse files Browse the repository at this point in the history
  • Loading branch information
rodichenko committed Dec 6, 2024
1 parent e1ee2d5 commit 0bbc3f9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 18 deletions.
43 changes: 26 additions & 17 deletions client/src/components/pipelines/browser/Folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ export default class Folder extends localization.LocalizedReactComponent {
if (!metadata) {
return null;
}
const {value} = metadata;
const {value, type} = metadata;
const isSecret = (type || '').toLowerCase() === 'secret';
const ignoredKey = () => {
return Object.values(METADATA_KEYS).includes(key);
};
Expand Down Expand Up @@ -286,14 +287,36 @@ export default class Folder extends localization.LocalizedReactComponent {
};
let metadataValue;
let wrapValue;
if (SpecialTags.hasOwnProperty(key)) {
if (isSecret) {
metadataValue = '*****';
} else if (SpecialTags.hasOwnProperty(key)) {
metadataValue = renderSpecialMetadataComponent();
wrapValue = true;
} else if (isJson(value)) {
metadataValue = renderJSONComponent();
} else {
metadataValue = value;
}
const metadataComponent = (
<div key={key} className={styles.metadataItemContainer}>
<Row className={classNames(
styles.metadataItemKey,
'cp-library-metadata-item-key'
)}>
{key}
</Row>
<Row className={classNames(
styles.metadataItemValue,
{[styles.wrap]: wrapValue},
'cp-library-metadata-item-value'
)}>
{metadataValue}
</Row>
</div>
);
if (isSecret) {
return metadataComponent;
}
return (
<Tooltip key={key} overlay={
<Row>
Expand All @@ -303,21 +326,7 @@ export default class Folder extends localization.LocalizedReactComponent {
</Row>
</Row>
}>
<div key={key} className={styles.metadataItemContainer}>
<Row className={classNames(
styles.metadataItemKey,
'cp-library-metadata-item-key'
)}>
{key}
</Row>
<Row className={classNames(
styles.metadataItemValue,
{[styles.wrap]: wrapValue},
'cp-library-metadata-item-value'
)}>
{metadataValue}
</Row>
</div>
{metadataComponent}
</Tooltip>
);
};
Expand Down
23 changes: 22 additions & 1 deletion client/src/components/special/metadata/Metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ export default class Metadata extends localization.LocalizedReactComponent {
let keyElement;
let valueElement;
const readOnly = this.props.readOnly || this.isReadOnlyTag(metadataItem.key);
const isSecret = (metadataItem.type || '').toLowerCase() === 'secret';
const inputOptions = (field) => {
return {
id: `${field}-input-${metadataItem.key}`,
Expand Down Expand Up @@ -1039,7 +1040,27 @@ export default class Metadata extends localization.LocalizedReactComponent {
? (this.state.editableText || metadataItem.key)
: metadataItem.key;
const dictionary = systemDictionaries.getDictionary(key);
if (dictionary) {
if (isSecret) {
valueElement = (
<tr
key={`${metadataItem.key}_value`}
className={
classNames(
'cp-metadata-item-row'
)
}
>
<td
id={`value-column-${metadataItem.key}`}
colSpan={6}
>
<span style={{display: 'inline-block'}}>
*****
</span>
</td>
</tr>
);
} else if (dictionary) {
valueElement = (
<tr
key={`${metadataItem.key}_value`}
Expand Down

0 comments on commit 0bbc3f9

Please sign in to comment.