Fixed linter errors after eslint upgrade.

pull/6038/head
Akshay Joshi 2023-03-29 17:22:50 +05:30
parent 43449be18c
commit 140494454a
12 changed files with 780 additions and 780 deletions

View File

@ -38,7 +38,7 @@ export default class PrivilegeRoleSchema extends BaseUISchema {
updateSupportedPrivs = (updatedPrivs) => {
this.supportedPrivs = updatedPrivs;
}
};
get baseFields() {
let obj = this;

View File

@ -24,8 +24,8 @@ import clsx from 'clsx';
import PropTypes from 'prop-types';
// Some predefined constants used to calculate image location and its border
let pWIDTH = 100.;
let pHEIGHT = 100.;
let pWIDTH = 100;
let pHEIGHT = 100;
let IMAGE_WIDTH = 50;
let IMAGE_HEIGHT = 50;
let ARROW_WIDTH = 10,

View File

@ -27,8 +27,8 @@ const useStyles = makeStyles((theme)=>({
}));
// Some predefined constants used to calculate image location and its border
let pWIDTH = 100.;
let pHEIGHT = 100.;
let pWIDTH = 100;
let pHEIGHT = 100;
let offsetX = 200,
offsetY = 60;
let xMargin = 25,

View File

@ -78,12 +78,12 @@ export default function StreamingChart({xRange=75, data, options}) {
},
series: [
{},
...data.datasets?.map((datum)=>({
...(data.datasets?.map((datum)=>({
label: datum.label,
stroke: datum.borderColor,
width: options.lineBorderWidth ?? 1,
points: { show: options.showDataPoints ?? false, size: datum.pointHitRadius*2 }
}))
}))??{})
],
scales: {
x: {
@ -116,11 +116,11 @@ export default function StreamingChart({xRange=75, data, options}) {
const initialState = [
Array.from(new Array(xRange).keys()),
...data.datasets?.map((d)=>{
...(data.datasets?.map((d)=>{
let ret = [...d.data];
ret.reverse();
return ret;
}),
})??{}),
];
chartRef.current?.setScale('x', {min: data.datasets[0]?.data?.length-xRange, max: data.datasets[0]?.data?.length-1});

View File

@ -33,10 +33,10 @@ export class FileTreeItem extends React.Component<IItemRendererXProps & IItemRen
}
// ensure this syncs up with what goes in CSS, (em, px, % etc.) and what ultimately renders on the page
public static readonly renderHeight: number = 24
private static readonly itemIdToRefMap: Map<number, HTMLDivElement> = new Map()
private static readonly refToItemIdMap: Map<number, HTMLDivElement> = new Map()
private fileTreeEvent: IFileTreeXTriggerEvents
public static readonly renderHeight: number = 24;
private static readonly itemIdToRefMap: Map<number, HTMLDivElement> = new Map();
private static readonly refToItemIdMap: Map<number, HTMLDivElement> = new Map();
private fileTreeEvent: IFileTreeXTriggerEvents;
constructor(props) {
super(props);
@ -119,7 +119,7 @@ export class FileTreeItem extends React.Component<IItemRendererXProps & IItemRen
this.events.dispatch(FileTreeXEvent.onTreeEvents, window.event, 'added', FileOrDir);
}
FileOrDir._loaded = true;
}
};
public componentWillUnmount() {
if (this.props.decorations) {
@ -143,28 +143,28 @@ export class FileTreeItem extends React.Component<IItemRendererXProps & IItemRen
FileTreeItem.itemIdToRefMap.set(this.props.item.id, r);
FileTreeItem.refToItemIdMap.set(r, this.props.item);
}
}
};
private handleContextMenu = (ev: React.MouseEvent) => {
const { item, itemType, onContextMenu } = this.props;
if (itemType === ItemType.File || itemType === ItemType.Directory) {
onContextMenu(ev, item as FileOrDir);
}
}
};
private handleClick = (ev: React.MouseEvent) => {
const { item, itemType, onClick } = this.props;
if (itemType === ItemType.File || itemType === ItemType.Directory) {
onClick(ev, item as FileEntry, itemType);
}
}
};
private handleDoubleClick = (ev: React.MouseEvent) => {
const { item, itemType, onDoubleClick } = this.props;
if (itemType === ItemType.File || itemType === ItemType.Directory) {
onDoubleClick(ev, item as FileEntry, itemType);
}
}
};
private handleDragStartItem = (e: React.DragEvent) => {
const { item, itemType, events } = this.props;
@ -174,5 +174,5 @@ export class FileTreeItem extends React.Component<IItemRendererXProps & IItemRen
events.dispatch(FileTreeXEvent.onTreeEvents, e, 'dragstart', item);
}
}
}
};
}

View File

@ -19,16 +19,16 @@ import { TreeModelX } from '../TreeModelX';
import AutoSizer from 'react-virtualized-auto-sizer';
export class FileTreeX extends React.Component<IFileTreeXProps> {
private fileTreeHandle: IFileTreeXHandle
private activeFileDec: Decoration
private pseudoActiveFileDec: Decoration
private activeFile: FileOrDir
private pseudoActiveFile: FileOrDir
private wrapperRef: React.RefObject<HTMLDivElement> = React.createRef()
private events: Notificar<FileTreeXEvent>
private disposables: DisposablesComposite
private keyboardHotkeys: KeyboardHotkeys
private fileTreeEvent: IFileTreeXTriggerEvents
private fileTreeHandle: IFileTreeXHandle;
private activeFileDec: Decoration;
private pseudoActiveFileDec: Decoration;
private activeFile: FileOrDir;
private pseudoActiveFile: FileOrDir;
private wrapperRef: React.RefObject<HTMLDivElement> = React.createRef();
private events: Notificar<FileTreeXEvent>;
private disposables: DisposablesComposite;
private keyboardHotkeys: KeyboardHotkeys;
private fileTreeEvent: IFileTreeXTriggerEvents;
constructor(props: IFileTreeXProps) {
super(props);
this.events = new Notificar();
@ -96,7 +96,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
private handleTreeEvent = () => {
this.fileTreeEvent = this.props.onEvent;
}
};
private handleTreeReady = (handle: IFileTreeHandle) => {
const { onReady, model } = this.props;
@ -164,7 +164,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
if (typeof onReady === 'function') {
onReady(this.fileTreeHandle);
}
}
};
private setActiveFile = async (fileOrDirOrPath: FileOrDir | string, ensureVisible, align): Promise<void> => {
const fileH = typeof fileOrDirOrPath === 'string'
@ -187,7 +187,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
await this.fileTreeHandle.ensureVisible(fileH, alignTree);
}
}
}
};
private ensureVisible = async (fileOrDirOrPath: FileOrDir | string): Promise<void> => {
const fileH = typeof fileOrDirOrPath === 'string'
@ -197,7 +197,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
if (fileH) {
await this.fileTreeHandle.ensureVisible(fileH);
}
}
};
private deSelectActiveFile = async (fileOrDirOrPath: FileOrDir | string): Promise<void> => {
const fileH = typeof fileOrDirOrPath === 'string'
@ -209,7 +209,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
this.activeFileDec.removeTarget(this.activeFile);
this.activeFile = null;
}
}
};
private setPseudoActiveFile = async (fileOrDirOrPath: FileOrDir | string): Promise<void> => {
const fileH = typeof fileOrDirOrPath === 'string'
@ -230,7 +230,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
await this.fileTreeHandle.ensureVisible(fileH);
}
this.events.dispatch(FileTreeXEvent.onTreeEvents, window.event, 'selected', fileH);
}
};
private create = async (parentDir, itemData): Promise<void> => {
if (parentDir == undefined || parentDir == null) {
@ -260,13 +260,13 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
const newItem = parentDir._children.find((c) => c._metadata.data.id === itemData.id);
newItem.resolvedPathCache = newItem.parent.path + '/' + newItem._metadata.data.id;
return newItem;
}
};
private update = async (item, itemData): Promise<void> => {
item._metadata.data = itemData;
await this.props.update(item.path, itemData);
this.events.dispatch(FileTreeXEvent.onTreeEvents, window.event, 'updated', item);
}
};
private refresh = async (item): Promise<void> => {
const isOpen = item.isExpanded;
@ -291,7 +291,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
this.hideLoader(ref);
}
}
}
};
private unload = async (item): Promise<void> => {
const isOpen = item.isExpanded;
@ -304,7 +304,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
await this.fileTreeHandle.closeDirectory(item as Directory);
this.changeDirectoryCount(item);
}
}
};
private remove = async (item): Promise<void> => {
const {remove, model } = this.props;
@ -325,7 +325,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
console.warn('Item not found');
}
}
}
};
private first = async (fileOrDirOrPath: FileOrDir | string) => {
const fileH = typeof fileOrDirOrPath === 'string'
@ -338,7 +338,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
return fileH.children[0];
}
return null;
}
};
private parent = async (fileOrDirOrPath: FileOrDir | string) => {
const fileH = typeof fileOrDirOrPath === 'string'
@ -350,7 +350,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
}
return null;
}
};
private hasParent = async (fileOrDirOrPath: FileOrDir | string) => {
@ -363,7 +363,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
}
return false;
}
};
private children = async (fileOrDirOrPath: FileOrDir | string) => {
const fileH = typeof fileOrDirOrPath === 'string'
@ -375,7 +375,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
}
return null;
}
};
private isOpen = async (fileOrDirOrPath: FileOrDir | string) => {
@ -388,7 +388,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
}
return false;
}
};
private isClosed = async (fileOrDirOrPath: FileOrDir | string) => {
const fileH = typeof fileOrDirOrPath === 'string'
@ -400,7 +400,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
}
return false;
}
};
private itemData = async (fileOrDirOrPath: FileOrDir | string) => {
const fileH = typeof fileOrDirOrPath === 'string'
@ -412,7 +412,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
}
return null;
}
};
private setLabel = async(pathOrDir: string | Directory, label: string): Promise<void> => {
const dir = typeof pathOrDir === 'string'
@ -433,7 +433,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
}
}
};
private changeDirectoryCount = async(pathOrDir: string | Directory): Promise<void> => {
const dir = typeof pathOrDir === 'string'
@ -453,7 +453,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
}
}
}
};
private closeDir = async (pathOrDir: string | Directory) => {
const dir = typeof pathOrDir === 'string'
@ -467,7 +467,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
}
}
}
};
private toggleDirectory = async (pathOrDir: string | Directory) => {
const dir = typeof pathOrDir === 'string'
@ -496,7 +496,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
this.events.dispatch(FileTreeXEvent.onTreeEvents, window.event, 'opened', dir);
}
}
}
};
private addIcon = async (pathOrDir: string | Directory, icon) => {
const dir = typeof pathOrDir === 'string'
@ -509,7 +509,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
label$.className = icon.icon;
}
}
};
private addCssClass = async (pathOrDir: string | Directory, cssClass) => {
const dir = typeof pathOrDir === 'string'
@ -525,25 +525,25 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
dir._metadata.data.extraClasses.push(cssClass);
}
}
};
private showLoader = (ref: HTMLDivElement) => {
// get label ref and add loading class
ref.style.background = 'none';
const label$ = ref.querySelector('i.directory-toggle') as HTMLDivElement;
if (label$) label$.classList.add('loading');
}
};
private hideLoader = (ref: HTMLDivElement) => {
// remove loading class.
ref.style.background = 'none';
const label$ = ref.querySelector('i.directory-toggle') as HTMLDivElement;
if (label$) label$.classList.remove('loading');
}
};
private handleBlur = () => {
this.events.dispatch(FileTreeXEvent.OnBlur);
}
};
private handleItemClicked = async (ev: React.MouseEvent, item: FileOrDir, type: ItemType) => {
if (type === ItemType.Directory && ev.target.className.includes('directory-toggle')) {
@ -551,42 +551,42 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
}
await this.setActiveFile(item as FileEntry);
}
};
private handleItemDoubleClicked = async (ev: React.MouseEvent, item: FileOrDir) => {
await this.toggleDirectory(item as Directory);
await this.setActiveFile(item as FileEntry);
}
};
private getItemFromDOM = (clientReact) => {
return FileTreeItem.refToItemIdMap.get(clientReact);
}
};
private getDOMFromItem = (item: FileOrDir) => {
return FileTreeItem.itemIdToRefMap.get(item.id);
}
};
private handleClick = (ev: React.MouseEvent) => {
// clicked in "blank space"
if (ev.currentTarget === ev.target) {
this.setPseudoActiveFile(null);
}
}
};
private handleItemCtxMenu = (ev: React.MouseEvent, item: FileOrDir) => {
return this.props.onContextMenu?.(ev, item);
}
};
private handleKeyDown = (ev: React.KeyboardEvent) => {
return this.keyboardHotkeys.handleKeyDown(ev);
}
};
private onResize = () => {
if (this.wrapperRef.current != null) {
this.resize();
}
}
};
private resize = (scrollX, scrollY) => {
const scrollXPos = scrollX ? scrollX : 0;
@ -594,7 +594,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
const div = this.wrapperRef.current.querySelector('div').querySelector('div') as HTMLDivElement;
div.scroll(scrollXPos, scrollYPos);
}
};
private changeResolvePath = async (item: FileOrDir): Promise<void> => {
// Change the path as per pgAdmin requirement: Item Id wise
@ -606,7 +606,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
entry.resolvedPathCache = entry.parent.path + '/' + entry._metadata.data.id;
}
}
}
};
}
export { IFileTreeXHandle, IFileTreeXProps };

View File

@ -2,7 +2,7 @@ import { TreeModel, IBasicFileSystemHost, Root } from 'react-aspen';
import { DecorationsManager } from 'aspen-decorations';
export class TreeModelX extends TreeModel {
public readonly decorations: DecorationsManager
public readonly decorations: DecorationsManager;
constructor(host: IBasicFileSystemHost, mountPath: string) {
super(host, mountPath);
this.decorations = new DecorationsManager(this.root as Root);

View File

@ -12,7 +12,7 @@ export class KeyboardHotkeys {
'Home': () => this.jumpToFirstItem(),
'End': () => this.jumpToLastItem(),
'Escape': () => this.resetSteppedOrSelectedItem(),
}
};
constructor(private readonly fileTreeX: IFileTreeXHandle) { }
@ -26,17 +26,17 @@ export class KeyboardHotkeys {
this.hotkeyActions[code]();
return true;
}
}
};
private jumpToFirstItem = (): void => {
const { root } = this.fileTreeX.getModel();
this.fileTreeX.setActiveFile(root.getFileEntryAtIndex(0), true);
}
};
private jumpToLastItem = (): void => {
const { root } = this.fileTreeX.getModel();
this.fileTreeX.setActiveFile(root.getFileEntryAtIndex(root.branchSize - 1), true);
}
};
private jumpToNextItem = (): void => {
const { root } = this.fileTreeX.getModel();
@ -55,7 +55,7 @@ export class KeyboardHotkeys {
} else if (idx > -1) {
this.fileTreeX.setActiveFile(root.getFileEntryAtIndex(idx + 1), true);
}
}
};
private jumpToPrevItem = (): void => {
const { root } = this.fileTreeX.getModel();
@ -74,7 +74,7 @@ export class KeyboardHotkeys {
} else if (idx > -1) {
this.fileTreeX.setActiveFile(root.getFileEntryAtIndex(idx - 1), true);
}
}
};
private expandOrJumpToFirstChild(): void {
const currentPseudoActive = this.fileTreeX.getActiveFile();
@ -105,7 +105,7 @@ export class KeyboardHotkeys {
} else if (currentPseudoActive.type === FileType.File) {
this.fileTreeX.setActiveFile(currentPseudoActive as FileEntry, true);
}
}
};
private toggleDirectoryExpand = (): void => {
const currentPseudoActive = this.fileTreeX.getActiveFile();
@ -113,7 +113,7 @@ export class KeyboardHotkeys {
if (currentPseudoActive.type === FileType.Directory) {
this.fileTreeX.toggleDirectory(currentPseudoActive as Directory);
}
}
};
private resetSteppedOrSelectedItem = (): void => {
const currentPseudoActive = this.fileTreeX.getActiveFile();
@ -121,9 +121,9 @@ export class KeyboardHotkeys {
return this.resetSteppedItem();
}
this.fileTreeX.setActiveFile(null);
}
};
private resetSteppedItem = () => {
this.fileTreeX.setActiveFile(null);
}
};
}

View File

@ -25,7 +25,7 @@ export class ManagePreferenceTreeNodes {
this.tree = {};
this.tree[_root] = { name: 'root', type: FileType.Directory, metadata: node };
res();
})
});
public updateNode = (_path, _data) => new Promise((res) => {
const item = this.findNode(_path);
@ -34,7 +34,7 @@ export class ManagePreferenceTreeNodes {
item.metadata.data = _data;
}
res(true);
})
});
public removeNode = async (_path) => {
const item = this.findNode(_path);
@ -68,7 +68,7 @@ export class ManagePreferenceTreeNodes {
if (tmpParentNode !== null && tmpParentNode !== undefined) tmpParentNode.children.push(treeNode);
res(treeNode);
})
});
public readNode = (_path: string) => new Promise<string[]>((res, rej) => {
const temp_tree_path = _path,
@ -112,12 +112,12 @@ export class ManagePreferenceTreeNodes {
self.returnChildrens(node, res);
}
loadData();
})
});
public returnChildrens = (node: any, res: any) =>{
if (node?.children.length > 0) return res(node.children);
else return res(null);
}
};
}

View File

@ -27,7 +27,7 @@ export class ManageTreeNodes {
this.tree = {};
this.tree[_root] = {name: 'root', type: FileType.Directory, metadata: node};
res();
})
});
public updateNode = (_path, _data) => new Promise((res) => {
const item = this.findNode(_path);
@ -36,7 +36,7 @@ export class ManageTreeNodes {
item.metadata.data = _data;
}
res(true);
})
});
public removeNode = async (_path) => {
const item = this.findNode(_path);
@ -69,7 +69,7 @@ export class ManageTreeNodes {
if (tmpParentNode !== null && tmpParentNode !== undefined) tmpParentNode.children.push(treeNode);
res(treeNode);
})
});
public readNode = (_path: string) => new Promise<string[]>((res, rej) => {
let temp_tree_path = _path;
@ -152,7 +152,7 @@ export class ManageTreeNodes {
}
loadData();
})
});
public generate_url = (path: string) => {
let _path = path;
@ -176,7 +176,7 @@ export class ManageTreeNodes {
if(_partitions.length > 0) _parent_path[0] = _partitions[_partitions.length-1];
return _parent_path.reverse().join('/');
}
};
}

View File

@ -311,7 +311,7 @@ class TableNodeWidgetRaw extends React.Component {
toggleShowDetails = (e) => {
e.preventDefault();
this.setState((prevState)=>({show_details: !prevState.show_details}));
}
};
render() {
let tableData = this.props.node.getData() || {};

View File

@ -591,7 +591,7 @@ export class ResultSetUtils {
/* If the raw row objects are available, use to them identify null values */
copiedRowsObjects = JSON.parse(localStorage.getItem('copied-rows'));
} catch {/* Suppress the error */}
for(const [recIdx, rec] of result?.entries()) {
for(const [recIdx, rec] of result?.entries()??[]) {
// Convert 2darray to dict.
let rowObj = {};
for(const col of columns) {