Skip to content

Commit

Permalink
Fix: Response area container heights (#2372)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElinorW authored Feb 1, 2023
1 parent 700a64c commit eeca0fb
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/app/services/reducers/dimensions-reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { RESIZE_SUCCESS } from '../redux-constants';
const initialState: IDimensions = {
request: {
width: '100%',
height: '38%'
height: '38vh'
},
response: {
width: '100%',
height: '50%'
height: '50vh'
},
sidebar: {
width: '26%',
Expand Down
9 changes: 7 additions & 2 deletions src/app/views/query-response/adaptive-cards/AdaptiveCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,25 @@ import { classNames } from '../../classnames';
import { Monaco } from '../../common';
import { trackedGenericCopy } from '../../common/copy';
import { CopyButton } from '../../common/copy/CopyButton';
import { convertVhToPx, getResponseHeight } from '../../common/dimensions/dimensions-adjustment';
import { queryResponseStyles } from './../queryResponse.styles';

const AdaptiveCard = (props: any) => {
let adaptiveCard: AdaptiveCardsAPI.AdaptiveCard | null = new AdaptiveCardsAPI.AdaptiveCard();
const dispatch: AppDispatch = useDispatch();

const { body, hostConfig } = props;
const { sampleQuery, queryRunnerStatus: queryStatus, adaptiveCard: card, theme } = useAppSelector((state) => state);
const {dimensions: { response }, responseAreaExpanded,
sampleQuery, queryRunnerStatus: queryStatus, adaptiveCard: card, theme } = useAppSelector((state) => state);
const { data, pending } = card;

const classes = classNames(props);
const currentTheme: ITheme = getTheme();
const textStyle = queryResponseStyles(currentTheme).queryResponseText.root as IStyle;

const responseHeight = getResponseHeight(response.height, responseAreaExpanded);
const height = convertVhToPx(responseHeight, 220);

useEffect(() => {
dispatch(getAdaptiveCard(body, sampleQuery));

Expand Down Expand Up @@ -182,7 +187,7 @@ const AdaptiveCard = (props: any) => {
<Monaco
language='json'
body={data.template}
height={'800px'}
height={height}
/>
</div>
</PivotItem>
Expand Down
7 changes: 5 additions & 2 deletions src/app/views/query-response/graph-toolkit/GraphToolkit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ import { lookupToolkitUrl } from '../../../utils/graph-toolkit-lookup';
import { translateMessage } from '../../../utils/translate-messages';
import { queryResponseStyles } from '../queryResponse.styles';
import { useAppSelector } from '../../../../store';
import { convertVhToPx, getResponseHeight } from '../../common/dimensions/dimensions-adjustment';

const GraphToolkit = () => {
const { sampleQuery } = useAppSelector((state) => state);
const { sampleQuery, dimensions: {response },responseAreaExpanded } = useAppSelector((state) => state);
const { toolkitUrl, exampleUrl } = lookupToolkitUrl(sampleQuery);

const currentTheme: ITheme = getTheme();
const textStyle = queryResponseStyles(currentTheme).queryResponseText.root as IStyle;
const linkStyle = queryResponseStyles(currentTheme).link as IStyle;

const height = convertVhToPx(getResponseHeight(response.height, responseAreaExpanded), 155);

if (toolkitUrl && exampleUrl) {
return (
Expand All @@ -35,7 +38,7 @@ const GraphToolkit = () => {
</Link>
.
</MessageBar>
<iframe width='100%' height='400px' src={toolkitUrl} title={translateMessage('Graph toolkit')} />
<iframe width='100%' height={height} src={toolkitUrl} title={translateMessage('Graph toolkit')} />
</>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/views/query-response/headers/ResponseHeaders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ResponseHeaders = () => {
useAppSelector((state) => state);
const { headers } = graphResponse;

const height = convertVhToPx(getResponseHeight(response.height, responseAreaExpanded), 100);
const height = convertVhToPx(getResponseHeight(response.height, responseAreaExpanded), 135);

const handleCopy = async () => trackedGenericCopy(JSON.stringify(headers), RESPONSE_HEADERS_COPY_BUTTON, sampleQuery)

Expand Down
9 changes: 8 additions & 1 deletion src/app/views/query-response/queryResponse.styles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { ITheme } from '@fluentui/react';
import { useAppSelector } from '../../../store';
import { convertVhToPx, getResponseHeight } from '../common/dimensions/dimensions-adjustment';

export const queryResponseStyles = (theme: ITheme) => {
const { dimensions: { response }, responseAreaExpanded} =
useAppSelector((state) => state);

const height = convertVhToPx(getResponseHeight( response.height, responseAreaExpanded), 175);

return {
dot: {
height: '8px',
Expand All @@ -21,7 +28,7 @@ export const queryResponseStyles = (theme: ITheme) => {
color: `${theme.palette.blueMid} !important`
},
card: {
height: '450px',
height,
overflowY: 'auto'
},
copyIcon: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/views/query-response/response/Response.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Response = () => {
const { body, headers } = graphResponse;
const dispatch: AppDispatch = useDispatch();

const height = convertVhToPx(getResponseHeight(response.height, responseAreaExpanded), 100);
const height = convertVhToPx(getResponseHeight(response.height, responseAreaExpanded), 135);

const contentDownloadUrl = body?.contentDownloadUrl;
const throwsCorsError = body?.throwsCorsError;
Expand Down
2 changes: 1 addition & 1 deletion src/app/views/query-response/snippets/snippets-helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function Snippet(props: ISnippetProps) {
const snippet = (!loadingState && data) ? data[language] : null;

const responseHeight = getResponseHeight(response.height, responseAreaExpanded);
const height = convertVhToPx(responseHeight, 140);
const height = convertVhToPx(responseHeight, 240);

const dispatch: AppDispatch = useDispatch();

Expand Down

0 comments on commit eeca0fb

Please sign in to comment.