mirror of
https://github.com/Kong/insomnia.git
synced 2026-04-21 06:37:36 -04:00
1.fix aws secret manager tag
This commit is contained in:
@@ -166,7 +166,7 @@ export function registerElectronHandlers() {
|
||||
.sort((a, b) => fnOrString(a.templateTag.displayName).localeCompare(fnOrString(b.templateTag.displayName)))
|
||||
.map(l => {
|
||||
const actions = l.templateTag.args?.[0];
|
||||
const isEnterprise = l.templateTag.isEnterprise || false;
|
||||
const needsEnterprisePlan = l.templateTag.needsEnterprisePlan || false;
|
||||
const additionalArgs = l.templateTag.args?.slice(1);
|
||||
const hasSubmenu = actions?.options?.length;
|
||||
return {
|
||||
@@ -176,7 +176,7 @@ export function registerElectronHandlers() {
|
||||
click: () => {
|
||||
const tag = `{% ${l.templateTag.name} ${l.templateTag.args?.map(getTemplateValue).join(', ')} %}`;
|
||||
const displayName = l.templateTag.displayName;
|
||||
event.sender.send('context-menu-command', { key, tag, isEnterprise, displayName });
|
||||
event.sender.send('context-menu-command', { key, tag, needsEnterprisePlan, displayName });
|
||||
},
|
||||
} :
|
||||
{
|
||||
@@ -186,7 +186,7 @@ export function registerElectronHandlers() {
|
||||
const additionalTagFields = additionalArgs.length ? ', ' + additionalArgs.map(getTemplateValue).join(', ') : '';
|
||||
const displayName = action.displayName;
|
||||
const tag = `{% ${l.templateTag.name} '${action.value}'${additionalTagFields} %}`;
|
||||
event.sender.send('context-menu-command', { key, tag, isEnterprise, displayName });
|
||||
event.sender.send('context-menu-command', { key, tag, needsEnterprisePlan, displayName });
|
||||
},
|
||||
})),
|
||||
}),
|
||||
|
||||
@@ -549,9 +549,9 @@ export const CodeEditor = memo(forwardRef<CodeEditorHandle, CodeEditorProps>(({
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
const unsubscribe = window.main.on('context-menu-command', (_, { key, tag, nunjucksTag, isEnterprise, displayName }) => {
|
||||
const unsubscribe = window.main.on('context-menu-command', (_, { key, tag, nunjucksTag, needsEnterprisePlan, displayName }) => {
|
||||
if (id === key) {
|
||||
if (isEnterprise && !isEnterprisePlan) {
|
||||
if (needsEnterprisePlan && !isEnterprisePlan) {
|
||||
// show modal if current user is not an enteprise user and the command is an enterprise feature
|
||||
showModal(UpgradeModal, {
|
||||
newPlan: 'enterprise',
|
||||
|
||||
@@ -11,6 +11,7 @@ import type { RenderPurpose } from '../../../common/render';
|
||||
import type { AWSSecretConfig } from '../../../main/ipc/cloud-service-integration/types';
|
||||
import * as models from '../../../models';
|
||||
import type { CloudProviderCredential, CloudProviderName } from '../../../models/cloud-credential';
|
||||
import { vaultEnvironmentMaskValue } from '../../../models/environment';
|
||||
import type { Request, RequestParameter } from '../../../models/request';
|
||||
import type { Response } from '../../../models/response';
|
||||
import type { TemplateTag } from '../../../plugins';
|
||||
@@ -26,7 +27,7 @@ const localTemplatePlugins: { templateTag: PluginTemplateTag }[] = [
|
||||
displayName: 'External Vault',
|
||||
description: 'Link secret from external vault',
|
||||
// external vault is an enterprise feature
|
||||
isEnterprise: true,
|
||||
needsEnterprisePlan: true,
|
||||
args: [
|
||||
{
|
||||
displayName: 'Vault Service Provider',
|
||||
@@ -52,7 +53,6 @@ const localTemplatePlugins: { templateTag: PluginTemplateTag }[] = [
|
||||
},
|
||||
],
|
||||
async run(context, provider: CloudProviderName, credentialId: string, configStr: string) {
|
||||
const defaultMaskValue = '******';
|
||||
if (!provider) {
|
||||
throw new Error('Vault service provider is required');
|
||||
}
|
||||
@@ -111,7 +111,7 @@ const localTemplatePlugins: { templateTag: PluginTemplateTag }[] = [
|
||||
}
|
||||
}
|
||||
}
|
||||
return defaultMaskValue;
|
||||
return vaultEnvironmentMaskValue;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import React, { type FC, useEffect, useState } from 'react';
|
||||
|
||||
import type { RenderPurpose } from '../../../common/render';
|
||||
import { vaultEnvironmentPath } from '../../../models/environment';
|
||||
import { NUNJUCKS_TEMPLATE_GLOBAL_PROPERTY_NAME } from '../../../templating';
|
||||
import { useNunjucks } from '../../context/nunjucks/use-nunjucks';
|
||||
|
||||
interface Props {
|
||||
@@ -8,11 +11,14 @@ interface Props {
|
||||
}
|
||||
|
||||
export const VariableEditor: FC<Props> = ({ onChange, defaultValue }) => {
|
||||
const { handleRender, handleGetRenderContext } = useNunjucks();
|
||||
const [purpose, setPurpose] = useState<RenderPurpose | ''>('');
|
||||
const renderContext = purpose === '' ? {} : { purpose };
|
||||
const { handleRender, handleGetRenderContext } = useNunjucks({ renderContext });
|
||||
const [selected, setSelected] = useState(defaultValue);
|
||||
const [options, setOptions] = useState<{ name: string; value: any }[]>([]);
|
||||
const [preview, setPreview] = useState('');
|
||||
const [error, setError] = useState('');
|
||||
const isVaultVariable = selected && selected.replace('{{', '').replace('}}', '').trim().startsWith(`${NUNJUCKS_TEMPLATE_GLOBAL_PROPERTY_NAME}.${vaultEnvironmentPath}`);
|
||||
|
||||
useEffect(() => {
|
||||
let isMounted = true;
|
||||
@@ -69,6 +75,22 @@ export const VariableEditor: FC<Props> = ({ onChange, defaultValue }) => {
|
||||
</div>
|
||||
)}
|
||||
<div className="form-control form-control--outlined">
|
||||
{isVaultVariable &&
|
||||
<button
|
||||
type="button"
|
||||
style={{
|
||||
zIndex: 10,
|
||||
position: 'relative',
|
||||
}}
|
||||
className="txt-sm pull-right icon inline-block"
|
||||
onClick={() => setPurpose(prevPurpose => prevPurpose === '' ? 'preview' : '')}
|
||||
>
|
||||
{purpose === '' ?
|
||||
<i className="fa-regular fa-eye" /> :
|
||||
<i className="fa-regular fa-eye-slash" />
|
||||
}
|
||||
</button>
|
||||
}
|
||||
<label>
|
||||
Live Preview
|
||||
<textarea className={`${error ? 'danger' : ''}`} value={preview || error} readOnly />
|
||||
|
||||
Reference in New Issue
Block a user