mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
Mask preview for masked prompt tag (Closes #1412)
This commit is contained in:
parent
c99ee30f46
commit
7c18b629de
@ -48,6 +48,7 @@ describe('init()', () => {
|
||||
'setCookie',
|
||||
'setHeader',
|
||||
'setParameter',
|
||||
'setUrl',
|
||||
'settingDisableRenderRequestBody',
|
||||
'settingEncodeUrl',
|
||||
'settingSendCookies',
|
||||
|
@ -28,6 +28,10 @@ export default class BaseExtension {
|
||||
return this._ext.description || 'no description';
|
||||
}
|
||||
|
||||
getDisablePreview() {
|
||||
return this._ext.disablePreview || (() => false);
|
||||
}
|
||||
|
||||
getArgs() {
|
||||
return this._ext.args || [];
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ export type PluginTemplateTag = {
|
||||
args: Array<PluginArgument>,
|
||||
name: string,
|
||||
displayName: DisplayName,
|
||||
disablePreview: () => boolean,
|
||||
description: string,
|
||||
run: (context: PluginTemplateTagContext, ...arg: Array<any>) => Promise<any> | any,
|
||||
deprecated?: boolean,
|
||||
|
@ -93,6 +93,7 @@ export async function getTagDefinitions(): Promise<Array<NunjucksParsedTag>> {
|
||||
name: ext.getTag(),
|
||||
displayName: ext.getName(),
|
||||
description: ext.getDescription(),
|
||||
disablePreview: ext.getDisablePreview(),
|
||||
args: ext.getArgs(),
|
||||
}));
|
||||
}
|
||||
|
@ -32,6 +32,9 @@ export type NunjucksParsedTag = {
|
||||
name: string,
|
||||
args: Array<NunjucksParsedTagArg>,
|
||||
rawValue?: string,
|
||||
displayName?: string,
|
||||
description?: string,
|
||||
disablePreview?: (Array<NunjucksParsedTagArg>) => boolean,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -278,6 +278,7 @@ class TagEditor extends React.PureComponent<Props, State> {
|
||||
} else if (!activeTagData && !tagDefinition && this.state.activeTagData) {
|
||||
activeTagData = {
|
||||
name: 'custom',
|
||||
displayName: 'Custom',
|
||||
args: [],
|
||||
rawValue: templateUtils.unTokenizeTag(this.state.activeTagData),
|
||||
};
|
||||
@ -598,13 +599,20 @@ class TagEditor extends React.PureComponent<Props, State> {
|
||||
return null;
|
||||
}
|
||||
|
||||
let finalPreview = preview;
|
||||
if (activeTagDefinition && activeTagDefinition.disablePreview) {
|
||||
finalPreview = activeTagDefinition.disablePreview(activeTagData.args)
|
||||
? preview.replace(/./g, '*')
|
||||
: preview;
|
||||
}
|
||||
|
||||
let previewElement;
|
||||
if (error) {
|
||||
previewElement = <textarea className="danger" value={error || 'Error'} readOnly rows={5} />;
|
||||
} else if (rendering) {
|
||||
previewElement = <textarea value="rendering..." readOnly rows={5} />;
|
||||
} else {
|
||||
previewElement = <textarea value={preview || 'error'} readOnly rows={5} />;
|
||||
previewElement = <textarea value={finalPreview || 'error'} readOnly rows={5} />;
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -17,6 +17,7 @@ module.exports.templateTags = [
|
||||
displayName: 'Prompt',
|
||||
name: 'prompt',
|
||||
description: 'prompt user for input',
|
||||
disablePreview: args => args[4] && args[4].value === true,
|
||||
args: [
|
||||
{
|
||||
displayName: 'Title',
|
||||
|
Loading…
Reference in New Issue
Block a user