Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds go to the snippet tabs #1189

Merged
merged 4 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/app/services/actions/snippet-action-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ import { parseSampleUrl } from '../../utils/sample-url-generation';
import {
GET_SNIPPET_ERROR,
GET_SNIPPET_PENDING,
GET_SNIPPET_SUCCESS
GET_SNIPPET_SUCCESS,
} from '../redux-constants';

export function getSnippetSuccess(response: string): IAction {
return {
type: GET_SNIPPET_SUCCESS,
response
response,
};
}

export function getSnippetError(response: object): IAction {
return {
type: GET_SNIPPET_ERROR,
response
response,
};
}

export function getSnippetPending(): any {
return {
type: GET_SNIPPET_PENDING
type: GET_SNIPPET_PENDING,
};
}

Expand All @@ -41,16 +41,23 @@ export function getSnippet(language: string): Function {
}
if (language !== 'csharp') {
snippetsUrl += `?lang=${language}`;
if (language === 'go') {
snippetsUrl += '&generation=openapi';
}
}

dispatch(getSnippetPending());

const method = 'POST';
const headers = {
'Content-Type': 'application/http'
'Content-Type': 'application/http',
};
// eslint-disable-next-line max-len
const body = `${sampleQuery.selectedVerb} /${queryVersion}/${requestUrl + search} HTTP/1.1\r\nHost: graph.microsoft.com\r\nContent-Type: application/json\r\n\r\n${JSON.stringify(sampleQuery.sampleBody)}`;
const body = `${sampleQuery.selectedVerb} /${queryVersion}/${
requestUrl + search
} HTTP/1.1\r\nHost: graph.microsoft.com\r\nContent-Type: application/json\r\n\r\n${JSON.stringify(
sampleQuery.sampleBody
)}`;
const options: IRequestOptions = { method, headers, body };
const obj: any = {};

Expand Down
19 changes: 12 additions & 7 deletions src/app/views/query-response/snippets/Snippets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ import { componentNames, telemetry } from '../../../../telemetry';
import { renderSnippets } from './snippets-helper';

function GetSnippets() {
const supportedLanguages = ['CSharp', 'JavaScript', 'Java', 'Objective-C'];
const supportedLanguages = [
'CSharp',
'JavaScript',
'Java',
'Objective-C',
'Go',
];

return (
<Pivot>
{renderSnippets(supportedLanguages)}
</Pivot>
);
return <Pivot>{renderSnippets(supportedLanguages)}</Pivot>;
}
export const Snippets = telemetry.trackReactComponent(GetSnippets, componentNames.CODE_SNIPPETS_TAB);
export const Snippets = telemetry.trackReactComponent(
GetSnippets,
componentNames.CODE_SNIPPETS_TAB
);