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/Enable screen reader confirmation feedback #802

Merged
merged 16 commits into from
Jan 20, 2021
Merged
10 changes: 5 additions & 5 deletions src/app/views/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Announced,
IStackTokens, ITheme, styled
} from 'office-ui-fabric-react';
import React, { Component } from 'react';
Expand All @@ -24,6 +25,7 @@ import { logIn } from '../services/graph-client/msal-service';
import { GRAPH_URL } from '../services/graph-constants';
import { parseSampleUrl } from '../utils/sample-url-generation';
import { substituteTokens } from '../utils/token-helpers';
import { translateMessage } from '../utils/translate-messages';
import { appTitleDisplayOnFullScreen, appTitleDisplayOnMobileScreen } from './app-sections/AppTitle';
import { headerMessaging } from './app-sections/HeaderMessaging';
import { statusMessages } from './app-sections/StatusMessages';
Expand Down Expand Up @@ -77,7 +79,7 @@ class App extends Component<IAppProps, IAppState> {
this.state = {
selectedVerb: 'GET',
mobileScreen: false,
hideDialog: true,
hideDialog: true
};
}

Expand Down Expand Up @@ -287,7 +289,6 @@ class App extends Component<IAppProps, IAppState> {
</div>;
}


public render() {
const classes = classNames(this.props);
const { authenticated, graphExplorerMode, queryState, minimised, termsOfUse, sampleQuery,
Expand Down Expand Up @@ -326,13 +327,12 @@ class App extends Component<IAppProps, IAppState> {
sidebarWidth = layout = 'col-xs-12 col-sm-12';
}




return (
// @ts-ignore
<ThemeContext.Provider value={this.props.appTheme}>
<div className={`container-fluid ${classes.app}`}>
<Announced message={!showSidebar ?
translateMessage('Sidebar minimized') : translateMessage('Sidebar maximized')} />
<div className='row'>
{graphExplorerMode === Mode.Complete && (
<div className={sidebarWidth}>
Expand Down
9 changes: 5 additions & 4 deletions src/app/views/query-response/QueryResponse.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Announced,
DefaultButton,
FontSizes,
getId,
Expand Down Expand Up @@ -32,7 +33,7 @@ import './query-response.scss';
class QueryResponse extends Component<
IQueryResponseProps,
IQueryResponseState
> {
> {
constructor(props: any) {
super(props);
this.state = {
Expand Down Expand Up @@ -159,7 +160,7 @@ class QueryResponse extends Component<
/>
</Pivot>
</div>

<Announced message={this.state.showModal ? translateMessage('Response area expanded') : ''} />
{
// @ts-ignore
<Modal
Expand All @@ -175,9 +176,9 @@ class QueryResponse extends Component<
},
}}
iconProps={{ iconName: 'Cancel' }}
ariaLabel='Close popup modal'
ariaLabel={translateMessage('Close expanded response area')}
onClick={this.toggleExpandResponse}
/>;
/>
<Pivot className='pivot-response' onLinkClick={(pivotItem) => onPivotItemClick(sampleQuery, pivotItem)}>
{pivotItems}
</Pivot>
Expand Down
164 changes: 67 additions & 97 deletions src/app/views/query-runner/request/headers/RequestHeaders.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,51 @@
import { PrimaryButton, TextField } from 'office-ui-fabric-react';
import React, { Component } from 'react';
import { Announced, PrimaryButton, TextField } from 'office-ui-fabric-react';
import React, { useState } from 'react';
import { FormattedMessage, injectIntl } from 'react-intl';
import { connect } from 'react-redux';
import { bindActionCreators, Dispatch } from 'redux';
import { useDispatch, useSelector } from 'react-redux';

import { IRequestHeadersProps } from '../../../../../types/request';
import * as queryInputActionCreators from '../../../../services/actions/query-input-action-creators';
import { translateMessage } from '../../../../utils/translate-messages';
import { headerStyles } from './Headers.styles';
import HeadersList from './HeadersList';

class RequestHeaders extends Component<IRequestHeadersProps, any> {
constructor(props: any) {
super(props);
this.state = {
headerName: '',
headerValue: '',
};
}
const RequestHeaders = (props: any) => {
const sampleQuery = useSelector((state: any) => state.sampleQuery);
const [headerName, setHeaderName] = useState('');
const [headerValue, setHeaderValue] = useState('');
const [announcedMessage, setAnnouncedMessage] = useState('');

private handleOnHeaderNameChange = (name?: string) => {
const { intl: { messages } } = props;
const sampleQueryHeaders = sampleQuery.sampleHeaders;
const container: any = headerStyles().container;

const dispatch = useDispatch();

const handleOnHeaderNameChange = (name?: string) => {
if (name) {
this.setState({
headerName: name,
});
setHeaderName(name);
}
};

private handleOnHeaderValueChange = (value?: string) => {
const handleOnHeaderValueChange = (value?: string) => {
if (value) {
this.setState({ headerValue: value });
setHeaderValue(value);
}
};

private handleOnHeaderDelete = (header: any) => {
const { actions, sampleQuery } = this.props;
const handleOnHeaderDelete = (header: any) => {
let headers = [...sampleQuery.sampleHeaders];
headers = headers.filter(head => head.name !== header.name);

const query = sampleQuery;
const query = { ...sampleQuery };
query.sampleHeaders = headers;

if (actions) {
actions.setSampleQuery(query);
}

this.setState(this.state);
dispatch(queryInputActionCreators.setSampleQuery(query));
setAnnouncedMessage(translateMessage('Request Header deleted'));
};

private handleOnHeaderAdd = () => {
if (this.state.headerName !== '') {
const { headerName, headerValue } = this.state;
const { actions } = this.props;
let { sampleHeaders } = this.props.sampleQuery;
const handleOnHeaderAdd = () => {
if (headerName !== '') {
ElinorW marked this conversation as resolved.
Show resolved Hide resolved
let { sampleHeaders } = sampleQuery;
const header = { name: headerName, value: headerValue };

if (!sampleHeaders) {
Expand All @@ -63,76 +57,52 @@ class RequestHeaders extends Component<IRequestHeadersProps, any> {

const newHeaders = [header, ...sampleHeaders];

this.setState({
headerName: '',
headerValue: '',
});
setHeaderName('');
setHeaderValue('');
setAnnouncedMessage(translateMessage('Request Header added'));

if (actions) {
const query = this.props.sampleQuery;
query.sampleHeaders = newHeaders;
actions.setSampleQuery(query);
}
const query = { ...sampleQuery };
query.sampleHeaders = newHeaders;
dispatch(queryInputActionCreators.setSampleQuery(query));
}
};

public render() {
// @ts-ignore
const { sampleQuery, intl: { messages } } = this.props;
const headers = sampleQuery.sampleHeaders;
const container: any = headerStyles().container;

return (
<div style={container}>
<div className='row'>
<div className='col-sm-5'>
<TextField className='header-input'
placeholder={messages.Key}
value={this.state.headerName}
onChange={(event, name) => this.handleOnHeaderNameChange(name)}
/>
</div>
<div className='col-sm-5'>
<TextField
className='header-input'
placeholder={messages.Value}
value={this.state.headerValue}
onChange={(event, value) => this.handleOnHeaderValueChange(value)}
/>
</div>
<div className='col-sm-2 col-md-2'>
<PrimaryButton
style={{ width: '100%' }}
onClick={() => this.handleOnHeaderAdd()}>
<FormattedMessage id='Add' />
</PrimaryButton>
</div>
return (
<div style={container}>
ElinorW marked this conversation as resolved.
Show resolved Hide resolved
<Announced message={announcedMessage} />
<div className='row'>
<div className='col-sm-5'>
<TextField className='header-input'
placeholder={messages.Key}
value={headerName}
onChange={(event, name) => handleOnHeaderNameChange(name)}
/>
</div>
<div className='col-sm-5'>
<TextField
className='header-input'
placeholder={messages.Value}
value={headerValue}
onChange={(event, value) => handleOnHeaderValueChange(value)}
/>
</div>
<div className='col-sm-2 col-md-2'>
<PrimaryButton
style={{ width: '100%' }}
onClick={() => handleOnHeaderAdd()}>
ElinorW marked this conversation as resolved.
Show resolved Hide resolved
<FormattedMessage id='Add' />
</PrimaryButton>
</div>
<hr />
<HeadersList
messages={messages}
handleOnHeaderDelete={(event: any, header: any) => this.handleOnHeaderDelete(header)}
headers={headers}
/>
</div>
);
}
}

function mapDispatchToProps(dispatch: Dispatch): object {
return {
actions: bindActionCreators(
{ ...queryInputActionCreators },
dispatch),
};
}

function mapStateToProps(state: any) {
return {
sampleQuery: state.sampleQuery,
};
}

<hr />
<HeadersList
messages={messages}
handleOnHeaderDelete={(event: any, header: any) => handleOnHeaderDelete(header)}
ElinorW marked this conversation as resolved.
Show resolved Hide resolved
headers={sampleQueryHeaders}
/>
</div>
);
};
// @ts-ignore
const WithIntl = injectIntl(RequestHeaders);
export default connect(mapStateToProps, mapDispatchToProps)(WithIntl);
export default WithIntl;
8 changes: 7 additions & 1 deletion src/messages/GE.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,5 +327,11 @@
"Microsoft Graph API Version option": "Microsoft Graph API Version option",
"Query Sample Input": "Query sample input",
"popup blocked, allow pop-up windows in your browser": "popup blocked, allow pop-up windows in your browser",
"sign in to consent to permissions": "One of the following permissions is required to run the query. Sign in with an account that can consent to the permission you will choose."
"sign in to consent to permissions": "One of the following permissions is required to run the query. Sign in with an account that can consent to the permission you will choose.",
"Request Header deleted": "Request Header deleted",
"Request Header added": "Request Header added",
"Sidebar minimized": "Sidebar minimized",
"Sidebar maximized": "Sidebar maximized",
"Response area expanded": "Response area expanded",
"Close expanded response area": "Close expanded response area"
}