Skip to content

Commit c1f3d70

Browse files
committed
wip
1 parent 26ef7ef commit c1f3d70

File tree

10 files changed

+83
-71
lines changed

10 files changed

+83
-71
lines changed

src/controls/locationPicker/LocationPicker.tsx

+20-20
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import { isEqual } from '@microsoft/sp-lodash-subset';
1313

1414
export class LocationPicker extends React.Component<ILocationPickerProps, ILocationPickerState> {
1515
private _token: string | string[] = null;
16-
private focusRef: any = null;
16+
private focusRef: any = null; // eslint-disable-line @typescript-eslint/no-implicit-any
1717
/**
1818
* Constructor method
1919
*/
2020
constructor(props: ILocationPickerProps) {
2121
super(props);
22-
this.getToken();
22+
this.getToken().then(() => { /* no-op; */}).catch(() => { /* no-op; */});
2323
this.focusRef = React.createRef();
2424
if (props.defaultValue) {
2525
this.state = {
@@ -42,7 +42,7 @@ export class LocationPicker extends React.Component<ILocationPickerProps, ILocat
4242

4343
}
4444

45-
public UNSAFE_componentWillReceiveProps(nextProps: ILocationPickerProps) {
45+
public UNSAFE_componentWillReceiveProps(nextProps: ILocationPickerProps): void {
4646
if (!isEqual(nextProps.defaultValue, this.props.defaultValue)) {
4747
if (nextProps.defaultValue) {
4848
this.setState({ selectedItem: nextProps.defaultValue, currentMode: Mode.view });
@@ -64,7 +64,7 @@ export class LocationPicker extends React.Component<ILocationPickerProps, ILocat
6464
);
6565
}
6666

67-
private onRenderOption = (item: ILocationBoxOption) => {
67+
private onRenderOption = (item: ILocationBoxOption): JSX.Element => {
6868
const {
6969
text,
7070
locationItem
@@ -107,7 +107,7 @@ export class LocationPicker extends React.Component<ILocationPickerProps, ILocat
107107
openOnKeyboardFocus={true}
108108
scrollSelectedToTop={true}
109109
isButtonAriaHidden={true}
110-
onInput={(e) => this.getLocatios(e.target["value"])}
110+
onInput={(e) => this.getLocatios(e.target["value"])} // eslint-disable-line dot-notation
111111
onChange={this.onChange}
112112
errorMessage={errorMessage}
113113
/>;
@@ -212,30 +212,30 @@ export class LocationPicker extends React.Component<ILocationPickerProps, ILocat
212212
return `${address.Street ? address.Street + ", " : ''}${address.City ? address.City + ", " : ""}${address.State ? address.State + ", " : ''}${address.CountryOrRegion || ""}`;
213213
}
214214

215-
private onIconButtonClick = () => {
215+
private onIconButtonClick = (): void => {
216216
this.setState({ currentMode: Mode.empty, selectedItem: null });
217217
if (this.props.onChange) {
218218
this.props.onChange(null);
219219
}
220220
}
221221

222-
private onClick = () => {
222+
private onClick = (): void => {
223223
this.setState({ currentMode: Mode.editView },
224224
() => {
225225
if (this.focusRef.current !== null)
226226
this.focusRef.current.focus();
227227
});
228228
}
229229

230-
private onBlur = (ev) => {
230+
private onBlur = (ev): void => {
231231
try {
232-
if (ev !== null && ev.relatedTarget["title"] !== "Location" && ev.relatedTarget["title"] !== "Clear") {
232+
if (ev !== null && ev.relatedTarget["title"] !== "Location" && ev.relatedTarget["title"] !== "Clear") { // eslint-disable-line dot-notation
233233
this.setState({ currentMode: Mode.view });
234234
}
235-
} catch { }
235+
} catch { /* no-op; */ }
236236
}
237237

238-
private onChange = (ev, option: ILocationBoxOption) => {
238+
private onChange = (ev, option: ILocationBoxOption): void => {
239239
this.setState({ selectedItem: option.locationItem, currentMode: Mode.editView },
240240
() => {
241241
if (this.focusRef.current !== null)
@@ -247,14 +247,14 @@ export class LocationPicker extends React.Component<ILocationPickerProps, ILocat
247247
}
248248
}
249249

250-
private customRenderInitials(props) {
250+
private customRenderInitials(props): JSX.Element {
251251
if (props.imageAlt === "Custom")
252252
return <FontIcon aria-label="Poi" iconName="Poi" style={{ fontSize: "14pt" }} />;
253253
else
254254
return <FontIcon aria-label="EMI" iconName="EMI" style={{ fontSize: "14pt" }} />;
255255
}
256256

257-
private async getToken() {
257+
private async getToken(): Promise<void> {
258258
const requestHeaders: Headers = new Headers();
259259
requestHeaders.append("Content-type", "application/json");
260260
requestHeaders.append("Cache-Control", "no-cache");
@@ -263,14 +263,14 @@ export class LocationPicker extends React.Component<ILocationPickerProps, ILocat
263263
headers: requestHeaders
264264
};
265265

266-
let response: SPHttpClientResponse = await this.props.context.spHttpClient.post(`${this.props.context.pageContext.web.absoluteUrl}/_api/SP.OAuth.Token/Acquire`, SPHttpClient.configurations.v1, spOpts);
267-
let PrimaryQueryResult: any = await response.json();
266+
const response: SPHttpClientResponse = await this.props.context.spHttpClient.post(`${this.props.context.pageContext.web.absoluteUrl}/_api/SP.OAuth.Token/Acquire`, SPHttpClient.configurations.v1, spOpts);
267+
const PrimaryQueryResult: any = await response.json();
268268
this._token = PrimaryQueryResult.access_token;
269269
}
270270

271-
private async getLocatios(searchText) {
271+
private async getLocatios(searchText): Promise<void> {
272272
try {
273-
let optionsForCustomRender: ILocationBoxOption[] = [];
273+
const optionsForCustomRender: ILocationBoxOption[] = [];
274274
const requestHeaders: Headers = new Headers();
275275
requestHeaders.append("Content-type", "application/json");
276276
requestHeaders.append("Cache-Control", "no-cache");
@@ -279,12 +279,12 @@ export class LocationPicker extends React.Component<ILocationPickerProps, ILocat
279279
body: `{"QueryConstraint":{"Query":"${searchText}"},"LocationProvider":32,"BingMarket":"en-IN"}`,
280280
headers: requestHeaders
281281
};
282-
let response1: HttpClientResponse = await this.props.context.httpClient.post("https://outlook.office365.com/SchedulingB2/api/v1.0/me/findmeetinglocations", HttpClient.configurations.v1, spOpts);
283-
let json = await response1.json();
282+
const response1: HttpClientResponse = await this.props.context.httpClient.post("https://outlook.office365.com/SchedulingB2/api/v1.0/me/findmeetinglocations", HttpClient.configurations.v1, spOpts);
283+
const json = await response1.json();
284284

285285

286286
json.MeetingLocations.forEach((v, i) => {
287-
let loc: ILocationPickerItem = v["MeetingLocation"];
287+
const loc: ILocationPickerItem = v["MeetingLocation"];
288288
optionsForCustomRender.push({ text: v.MeetingLocation["DisplayName"], key: i, locationItem: loc });
289289
});
290290

src/controls/map/IMap.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface ICoordinates {
1414
/**
1515
* Address of the location
1616
*/
17-
address?: any; // 20200614 - JJ - address
17+
address?: any; // eslint-disable-line @typescript-eslint/no-explicit-any
1818
}
1919

2020
export enum MapType {
@@ -38,5 +38,5 @@ export interface LocationInfo {
3838
type: string;
3939
importance: number;
4040
icon: string;
41-
address?: any; // 20200614 - JJ - the address data from nominatim
41+
address?: any; // eslint-disable-line @typescript-eslint/no-explicit-any
4242
}

src/controls/map/Map.tsx

+9-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import * as strings from 'ControlStrings';
22
import * as React from 'react';
33
import styles from './Maps.module.scss';
4-
import { IMapProps, ICoordinates, MapType, LocationInfo, IMapState } from '.';
4+
import { IMapProps } from './IMapProps';
5+
import { IMapState } from './IMapState';
6+
import { ICoordinates, MapType, LocationInfo } from './IMap';
57
import { Label } from 'office-ui-fabric-react/lib/components/Label';
68
import { Spinner, SpinnerSize } from 'office-ui-fabric-react/lib/Spinner';
79
import { Icon } from "office-ui-fabric-react/lib/components/Icon";
@@ -33,15 +35,6 @@ export class Map extends React.Component<IMapProps, IMapState> {
3335
};
3436
}
3537

36-
/**
37-
* componentWillMount lifecycle hook
38-
*/
39-
// public componentWillMount(): void {
40-
// this.setState({
41-
// coordinates: this.props.coordinates
42-
// });
43-
// }
44-
4538
/**
4639
* componentWillUpdate lifecycle hook
4740
*/
@@ -70,7 +63,7 @@ export class Map extends React.Component<IMapProps, IMapState> {
7063
private _getWidth(): string {
7164
let widthToReturn: string = this.props.width;
7265
if (widthToReturn) {
73-
let lastChar: string = widthToReturn.substr(widthToReturn.length - 1);
66+
const lastChar: string = widthToReturn.substr(widthToReturn.length - 1);
7467
if (lastChar !== '%') {
7568
widthToReturn = `${widthToReturn}%`;
7669
}
@@ -207,9 +200,9 @@ export class Map extends React.Component<IMapProps, IMapState> {
207200
*/
208201
public render(): React.ReactElement<IMapProps> {
209202
const { mapSource } = this.props;
210-
let width: string = this._getWidth();
211-
let height: number = this._getHeight();
212-
let mapUrl: string = ["BingDraggable", "BingStatic"].indexOf(mapSource) !== -1 ? this._getBingMapUrl(width, height) : this._getMapUrl(); //20200614 - JJ - rudimentary bing map support (draggable/static) with pushpin (static only)
203+
const width: string = this._getWidth();
204+
const height: number = this._getHeight();
205+
const mapUrl: string = ["BingDraggable", "BingStatic"].indexOf(mapSource) !== -1 ? this._getBingMapUrl(width, height) : this._getMapUrl(); //20200614 - JJ - rudimentary bing map support (draggable/static) with pushpin (static only)
213206

214207
return (
215208
<div id="mapsContainer" className={`${styles.mapContainer} ${this.props.mapsClassName ? this.props.mapsClassName : ''}`}>
@@ -243,8 +236,8 @@ export class Map extends React.Component<IMapProps, IMapState> {
243236
) : (
244237
(mapUrl.length > 0 && !this.state.showmessageerror) ? (
245238
<div id="mapsIframe">
246-
<iframe width={width} height={height} scrolling="no" src={mapUrl}></iframe>
247-
{mapSource === "BingStatic" && <Icon iconName="Location" style={{fontSize: "26px", position:"relative", top: (Math.floor(-height/2)), left: "50%", marginTop: "-14px"}} ></Icon>}{/* 20200614 - JJ - rudimentary bing map support (draggable/static) with pushpin (static only)*/}
239+
<iframe width={width} height={height} scrolling="no" src={mapUrl} />
240+
{mapSource === "BingStatic" && <Icon iconName="Location" style={{fontSize: "26px", position:"relative", top: (Math.floor(-height/2)), left: "50%", marginTop: "-14px"}} />}{/* 20200614 - JJ - rudimentary bing map support (draggable/static) with pushpin (static only)*/}
248241
</div>
249242
) : (
250243
<p className={`ms-TextField-errorMessage ${styles.errorMessage} ${this.props.errorMessageClassName ? this.props.errorMessageClassName : ''}`}>

src/controls/modernAudio/ModernAudio.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { IModernAudioProps } from "./IModernAudioProps";
55
import { IconButton } from "office-ui-fabric-react";
66
import { ModernAudioLabelPosition } from './ModernAudioLabelPosition';
77

8-
export const ModernAudio: React.FC<IModernAudioProps> = (props: IModernAudioProps) => {
8+
export const ModernAudio: React.FC<IModernAudioProps> = (props: IModernAudioProps): JSX.Element => {
99
const audioComp = React.useRef<HTMLAudioElement>(new Audio(props.audioUrl));
1010
const [muted, setMuted] = React.useState<boolean>(false);
1111
const [playing, setPlaying] = React.useState<boolean>(false);
@@ -16,13 +16,13 @@ export const ModernAudio: React.FC<IModernAudioProps> = (props: IModernAudioProp
1616

1717
const playAudio = () => {
1818
setPlaying(true);
19-
audioComp.current.play();
19+
audioComp.current.play().then(() => { /* no-op */ }).catch(() => { /* no-op */ });
2020
};
21-
const pauseAudio = () => {
21+
const pauseAudio = (): void => {
2222
setPlaying(false);
2323
audioComp.current.pause();
2424
};
25-
const incVolume = () => {
25+
const incVolume = (): void => {
2626
if (audioComp.current.volume <= 0.9) {
2727
audioComp.current.volume += 0.1;
2828
}
@@ -34,30 +34,30 @@ export const ModernAudio: React.FC<IModernAudioProps> = (props: IModernAudioProp
3434
setMuted(false);
3535
}
3636
};
37-
const decVolume = () => {
37+
const decVolume = (): void => {
3838
audioComp.current.volume -= 0.1;
3939
if (audioComp.current.volume < 0.1) {
4040
audioComp.current.volume = 0;
4141
audioComp.current.muted = true;
4242
setMuted(true);
4343
}
4444
};
45-
const muteAudio = () => {
45+
const muteAudio = (): void => {
4646
audioComp.current.muted = !muted;
4747
setMuted(!muted);
4848
};
4949
return (
5050
<div className={styles.modernAudio}>
5151
{props.labelPosition === ModernAudioLabelPosition.TopLeft &&
52-
props.label !== "" &&
52+
props.label !== "" &&
5353
<div><label>{props.label}</label></div>}
54-
{props.labelPosition === ModernAudioLabelPosition.TopCenter &&
54+
{props.labelPosition === ModernAudioLabelPosition.TopCenter &&
5555
props.label !== "" &&
5656
<div style={{textAlign: "center"}}><label>{props.label}</label></div>}
5757
<div className={styles.audioPanel}>
58-
{props.audioUrl !== "" && <audio ref={audioComp} src={props.audioUrl}></audio>}
58+
{props.audioUrl !== "" && <audio ref={audioComp} src={props.audioUrl} />}
5959
<IconButton iconProps={{ iconName: 'Play' }} className={styles.audioIcon} title={strings.ModernAudioPlay} disabled={playing} onClick={playAudio} />
60-
<IconButton iconProps={{ iconName: 'Pause' }} className={styles.audioIcon} title={strings.ModernAudioPause} disabled={!playing} onClick={pauseAudio} />
60+
<IconButton iconProps={{ iconName: 'Pause' }} className={styles.audioIcon} title={strings.ModernAudioPause} disabled={!playing} onClick={pauseAudio} />
6161
<IconButton iconProps={{ iconName: 'Volume2' }} className={styles.audioIcon} title={strings.ModernAudioIncVol} onClick={incVolume} />
6262
<IconButton iconProps={{ iconName: 'Volume0' }} className={styles.audioIcon} title={strings.ModernAudioDecVol} disabled={muted} onClick={decVolume} />
6363
<IconButton iconProps={{ iconName: 'VolumeDisabled' }} className={styles.audioIcon} title={strings.ModernAudioMute} disabled={muted} onClick={muteAudio} />

src/controls/modernTaxonomyPicker/ModernTaxonomyPicker.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export interface IModernTaxonomyPickerProps {
6363
onRenderActionButton?: (termStoreInfo: ITermStoreInfo, termSetInfo: ITermSetInfo, termInfo?: ITermInfo) => JSX.Element;
6464
}
6565

66-
export function ModernTaxonomyPicker(props: IModernTaxonomyPickerProps) {
66+
export function ModernTaxonomyPicker(props: IModernTaxonomyPickerProps): JSX.Element {
6767
const taxonomyService = useMemo(()=>new SPTaxonomyService(props.context), [props.context]);
6868
const [panelIsOpen, setPanelIsOpen] = React.useState(false);
6969
const initialLoadComplete = React.useRef(false);
@@ -87,15 +87,24 @@ export function ModernTaxonomyPicker(props: IModernTaxonomyPickerProps) {
8787
props.initialValues.map(term => { return { ...term, languageTag: languageTag, termStoreInfo: termStoreInfo } as ITermInfo; }) :
8888
[]);
8989
initialLoadComplete.current = true;
90+
})
91+
.catch(() => {
92+
// no-op;
9093
});
9194
taxonomyService.getTermSetInfo(Guid.parse(props.termSetId))
9295
.then((termSetInfo) => {
9396
setCurrentTermSetInfo(termSetInfo);
97+
})
98+
.catch(() => {
99+
// no-op;
94100
});
95101
if (props.anchorTermId && props.anchorTermId !== Guid.empty.toString()) {
96102
taxonomyService.getTermById(Guid.parse(props.termSetId), props.anchorTermId ? Guid.parse(props.anchorTermId) : Guid.empty)
97103
.then((anchorTermInfo) => {
98104
setCurrentAnchorTermInfo(anchorTermInfo);
105+
})
106+
.catch(() => {
107+
// no-op;
99108
});
100109
}
101110
}, [currentTermStoreInfo?.defaultLanguageTag, props.anchorTermId, props.context.pageContext, props.initialValues, props.termSetId, taxonomyService]);
@@ -212,7 +221,7 @@ export function ModernTaxonomyPicker(props: IModernTaxonomyPickerProps) {
212221
if(props.isPathRendered) {
213222
let currentTermProps = itemProps.item;
214223
while(currentTermProps.parent !== undefined) {
215-
let currentParentLabels = getLabelsForCurrentLanguage(currentTermProps.parent);
224+
const currentParentLabels = getLabelsForCurrentLanguage(currentTermProps.parent);
216225
fullParentPrefixes.push(currentParentLabels[0].name);
217226
currentTermProps = currentTermProps.parent;
218227
}

src/controls/modernTaxonomyPicker/taxonomyPanelContents/TaxonomyPanelContents.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function TaxonomyPanelContents(props: ITaxonomyPanelContentsProps): React
5151
onSelectionChanged: () => {
5252
props.setSelectedPanelOptions((prevOptions) => [...selection.getSelection()]);
5353
forceUpdate();
54-
}, getKey: (term: any) => term.id
54+
}, getKey: (term: any) => term.id // eslint-disable-line @typescript-eslint/no-explicit-any
5555
});
5656
s.setItems(terms);
5757
for (const selectedOption of props.selectedPanelOptions) {

0 commit comments

Comments
 (0)