mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-22 07:53:34 +01:00
Support more languages in Generate Code (#2991)
* generate languages for all targets * change target client name * add scroll bar * remove debug log
This commit is contained in:
parent
b3c72b1640
commit
7dd639192c
@ -8,8 +8,9 @@ const StyledWrapper = styled.div`
|
|||||||
.generate-code-sidebar {
|
.generate-code-sidebar {
|
||||||
background-color: ${(props) => props.theme.collection.environment.settings.sidebar.bg};
|
background-color: ${(props) => props.theme.collection.environment.settings.sidebar.bg};
|
||||||
border-right: solid 1px ${(props) => props.theme.collection.environment.settings.sidebar.borderRight};
|
border-right: solid 1px ${(props) => props.theme.collection.environment.settings.sidebar.borderRight};
|
||||||
min-height: 400px;
|
max-height: 90vh;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.generate-code-item {
|
.generate-code-item {
|
||||||
|
@ -6,56 +6,11 @@ import { isValidUrl } from 'utils/url';
|
|||||||
import { find, get } from 'lodash';
|
import { find, get } from 'lodash';
|
||||||
import { findEnvironmentInCollection } from 'utils/collections';
|
import { findEnvironmentInCollection } from 'utils/collections';
|
||||||
import { interpolateUrl, interpolateUrlPathParams } from 'utils/url/index';
|
import { interpolateUrl, interpolateUrlPathParams } from 'utils/url/index';
|
||||||
|
import { getLanguages } from 'utils/codegenerator/targets';
|
||||||
const languages = [
|
|
||||||
{
|
|
||||||
name: 'HTTP',
|
|
||||||
target: 'http',
|
|
||||||
client: 'http1.1'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'JavaScript-Fetch',
|
|
||||||
target: 'javascript',
|
|
||||||
client: 'fetch'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Javascript-jQuery',
|
|
||||||
target: 'javascript',
|
|
||||||
client: 'jquery'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Javascript-axios',
|
|
||||||
target: 'javascript',
|
|
||||||
client: 'axios'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Python-Python3',
|
|
||||||
target: 'python',
|
|
||||||
client: 'python3'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Python-Requests',
|
|
||||||
target: 'python',
|
|
||||||
client: 'requests'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'PHP',
|
|
||||||
target: 'php',
|
|
||||||
client: 'curl'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Shell-curl',
|
|
||||||
target: 'shell',
|
|
||||||
client: 'curl'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Shell-httpie',
|
|
||||||
target: 'shell',
|
|
||||||
client: 'httpie'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const GenerateCodeItem = ({ collection, item, onClose }) => {
|
const GenerateCodeItem = ({ collection, item, onClose }) => {
|
||||||
|
const languages = getLanguages();
|
||||||
|
|
||||||
const environment = findEnvironmentInCollection(collection, collection.activeEnvironmentUid);
|
const environment = findEnvironmentInCollection(collection, collection.activeEnvironmentUid);
|
||||||
let envVars = {};
|
let envVars = {};
|
||||||
if (environment) {
|
if (environment) {
|
||||||
|
23
packages/bruno-app/src/utils/codegenerator/targets.js
Normal file
23
packages/bruno-app/src/utils/codegenerator/targets.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { targets } from 'httpsnippet';
|
||||||
|
|
||||||
|
export const getLanguages = () => {
|
||||||
|
const allLanguages = [];
|
||||||
|
for (const target of Object.values(targets)) {
|
||||||
|
const { key, title } = target.info;
|
||||||
|
const clients = Object.keys(target.clientsById);
|
||||||
|
const languages =
|
||||||
|
(clients.length === 1)
|
||||||
|
? [{
|
||||||
|
name: title,
|
||||||
|
target: key,
|
||||||
|
client: clients[0]
|
||||||
|
}]
|
||||||
|
: clients.map(client => ({
|
||||||
|
name: `${title}-${client}`,
|
||||||
|
target: key,
|
||||||
|
client
|
||||||
|
}));
|
||||||
|
allLanguages.push(...languages);
|
||||||
|
}
|
||||||
|
return allLanguages;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user