mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-25 01:14:23 +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 {
|
||||
background-color: ${(props) => props.theme.collection.environment.settings.sidebar.bg};
|
||||
border-right: solid 1px ${(props) => props.theme.collection.environment.settings.sidebar.borderRight};
|
||||
min-height: 400px;
|
||||
max-height: 90vh;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.generate-code-item {
|
||||
|
@ -6,56 +6,11 @@ import { isValidUrl } from 'utils/url';
|
||||
import { find, get } from 'lodash';
|
||||
import { findEnvironmentInCollection } from 'utils/collections';
|
||||
import { interpolateUrl, interpolateUrlPathParams } from 'utils/url/index';
|
||||
|
||||
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'
|
||||
}
|
||||
];
|
||||
import { getLanguages } from 'utils/codegenerator/targets';
|
||||
|
||||
const GenerateCodeItem = ({ collection, item, onClose }) => {
|
||||
const languages = getLanguages();
|
||||
|
||||
const environment = findEnvironmentInCollection(collection, collection.activeEnvironmentUid);
|
||||
let envVars = {};
|
||||
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