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

Fix: create onenote page #708

Merged
merged 14 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from 9 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
12 changes: 8 additions & 4 deletions src/app/services/actions/query-action-creator-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,16 @@ const makeRequest = (httpVerb: string, scopes: string[]): Function => {

if (query.sampleHeaders && query.sampleHeaders.length > 0) {
query.sampleHeaders.forEach(header => {

// We are relying on the graph client to set the content type header.
// We are relying on the graph client to set the 'application/json' content type header.
thewahome marked this conversation as resolved.
Show resolved Hide resolved
thewahome marked this conversation as resolved.
Show resolved Hide resolved
if (header.name.toLowerCase() === 'content-type') {
return;
if (header.value !== 'application/json') {
sampleHeaders[header.name] = header.value;
} else {
return;
thewahome marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
sampleHeaders[header.name] = header.value;
}
sampleHeaders[header.name] = header.value;
});
}

Expand Down
3 changes: 1 addition & 2 deletions src/app/views/query-runner/request/Request.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class Request extends Component<IRequestComponent, any> {
handleOnEditorChange,
sampleBody,
mode,
mobileScreen,
intl: { messages },
}: any = this.props;

Expand Down Expand Up @@ -62,7 +61,7 @@ export class Request extends Component<IRequestComponent, any> {
itemIcon='AuthenticatorApp'
onRenderItemLink={this.getTooltipDisplay}
title={messages['Access Token']}
headerText={ messages['Access Token']}>
headerText={messages['Access Token']}>
<Auth />
</PivotItem>
);
Expand Down
11 changes: 9 additions & 2 deletions src/app/views/sidebar/sample-queries/SampleQueries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
styled,
TooltipHost
} from 'office-ui-fabric-react';
import React, { ChangeEvent, Component } from 'react';
import React, { Component } from 'react';
import { FormattedMessage, injectIntl } from 'react-intl';
import { connect } from 'react-redux';
import { bindActionCreators, Dispatch } from 'redux';
Expand All @@ -35,6 +35,7 @@ import { getStyleFor } from '../../../utils/badge-color';
import { substituteTokens } from '../../../utils/token-helpers';
import { classNames } from '../../classnames';
import { sidebarStyles } from '../Sidebar.styles';
import { isJsonString } from './sample-query-utils';

export class SampleQueries extends Component<ISampleQueriesProps, any> {

Expand Down Expand Up @@ -259,7 +260,13 @@ export class SampleQueries extends Component<ISampleQueriesProps, any> {
}
telemetry.trackEvent(RUN_QUERY_EVENT, sampleQuery);
} else {
sampleQuery.sampleBody = (sampleQuery.sampleBody) ? JSON.parse(sampleQuery.sampleBody) : undefined;
if (sampleQuery.sampleBody) {
thewahome marked this conversation as resolved.
Show resolved Hide resolved
if (isJsonString(sampleQuery.sampleBody)) {
sampleQuery.sampleBody = JSON.parse(sampleQuery.sampleBody);
}
} else {
sampleQuery.sampleBody = undefined;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need this based on the if above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making this more concise

}
if (selectedQuery.tip) { displayTipMessage(actions, selectedQuery); }
}
actions.setSampleQuery(sampleQuery);
Expand Down
11 changes: 11 additions & 0 deletions src/app/views/sidebar/sample-queries/sample-query-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function isJsonString(str: string) {
thewahome marked this conversation as resolved.
Show resolved Hide resolved
try {
const parsedString = JSON.parse(str);
if (parsedString && typeof parsedString === 'object') {
return true;
}
} catch (e) {
return false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be good to log out here for debugging purposes.

}
return true;
}