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: image content types #637

Merged
merged 3 commits into from
Jul 17, 2020
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
2 changes: 1 addition & 1 deletion src/app/services/actions/query-action-creator-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function isImageResponse(contentType: string) {
if (!contentType) { return false; }
return (
contentType === 'application/octet-stream' ||
contentType.substr(0, 6) === 'image/'
contentType.includes('image/')
);
}

Expand Down
8 changes: 6 additions & 2 deletions src/app/services/actions/query-action-creators.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { MessageBarType } from 'office-ui-fabric-react';

import { ContentType } from '../../../types/enums';
import { IHistoryItem } from '../../../types/history';
import { IQuery } from '../../../types/query-runner';
import { writeHistoryData } from '../../views/sidebar/history/history-utils';
import { anonymousRequest, authenticatedRequest, parseResponse, queryResponse } from './query-action-creator-util';
import {
anonymousRequest, authenticatedRequest,
isImageResponse, parseResponse, queryResponse
} from './query-action-creator-util';
import { setQueryResponseStatus } from './query-status-action-creator';
import { addHistoryItem } from './request-history-action-creators';

Expand Down Expand Up @@ -83,7 +87,7 @@ async function createHistory(response: Response, respHeaders: any, query: IQuery
const responseHeaders = { ...respHeaders };
const contentType = respHeaders['content-type'];

if (contentType === ContentType.Image) {
if (isImageResponse(contentType)) {
result = {
message: 'Run the query to view the image'
};
Expand Down
15 changes: 8 additions & 7 deletions src/app/views/query-response/pivot-items/pivot-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';
import { ThemeContext } from '../../../../themes/theme-context';
import { ContentType, Mode } from '../../../../types/enums';
import { IQuery } from '../../../../types/query-runner';
import { isImageResponse } from '../../../services/actions/query-action-creator-util';
import { lookupTemplate } from '../../../utils/adaptive-cards-lookup';
import { Image, Monaco } from '../../common';
import { genericCopy } from '../../common/copy';
Expand Down Expand Up @@ -112,14 +113,14 @@ function displayResultComponent(headers: any, body: any, verb: string) {
case ContentType.XML:
return <Monaco body={formatXml(body)} verb={verb} language='xml' />;

case ContentType.Image:
return <Image
styles={{ padding: '10px' }}
body={body}
alt='profile image'
/>;

default:
if (isImageResponse(contentType)) {
return <Image
styles={{ padding: '10px' }}
body={body}
alt='profile image'
/>;
}
return <Monaco body={body} verb={verb} language={language} />;
}
}
Expand Down