Skip to content

Commit

Permalink
Address lint problems
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Mäder <[email protected]>
  • Loading branch information
tsmaeder committed Aug 16, 2023
1 parent d365b4c commit f862476
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 36 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)
## v1.41.0 -
- [application-package] Quit Electron app when back end fails to start [#12778](https://github.com/eclipse-theia/theia/pull/12778) - Contributed on behalf of STMicroelectronics.

- [vscode] added support for tree checkbox api [#12836](https://github.com/eclipse-theia/theia/pull/12836) - Contributed on behalf of STMicroelectronics
## v1.40.0 - 07/27/2023

- [application-package] bumped the default supported VS Code API from `1.78.0` to `1.79.0` [#12764](https://github.com/eclipse-theia/theia/pull/12764) - Contributed on behalf of STMicroelectronics.
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/browser/tree/tree-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,10 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
aria-label={node.checkboxInfo.accessibilityInformation?.label}
role={node.checkboxInfo.accessibilityInformation?.role}
className='theia-input'
onClick={event => this.toggleChecked(event)} />

onClick={event => this.toggleChecked(event)} />;
}

protected toggleChecked(event: React.MouseEvent<HTMLElement>) {
protected toggleChecked(event: React.MouseEvent<HTMLElement>): void {
const nodeId = event.currentTarget.getAttribute('data-node-id');
if (nodeId) {
const node = this.model.getNode(nodeId);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/browser/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export interface TreeNode {
readonly busy?: number;

/**
* Whether this node is checked.
* Whether this node is checked.
*/
readonly checkboxInfo?: TreeViewItemCheckboxInfo;
}
Expand Down Expand Up @@ -390,7 +390,7 @@ export class TreeImpl implements Tree {
}
}

markAsChecked(node: Mutable<TreeNode>, checked: boolean) {
markAsChecked(node: Mutable<TreeNode>, checked: boolean): void {
node.checkboxInfo!.checked = checked;
this.onDidUpdateEmitter.fire([node]);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ export class DataTransferFileDTO {
}

export interface TreeViewsExt {
$checkStateChanged(treeViewId: string, itemIds: { id: string, checked: boolean }[]): unknown;
$checkStateChanged(treeViewId: string, itemIds: { id: string, checked: boolean }[]): Promise<void>;
$dragStarted(treeViewId: string, treeItemIds: string[], token: CancellationToken): Promise<UriComponents[] | undefined>;
$dragEnd(treeViewId: string): Promise<void>;
$drop(treeViewId: string, treeItemId: string | undefined, dataTransferItems: [string, string | DataTransferFileDTO][], token: CancellationToken): Promise<void>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export class PluginTree extends TreeImpl {
findChildrenToChange(node, nodesToChange);

}
nodesToChange.forEach(n => n.checkboxInfo!.checked = checked)
nodesToChange.forEach(n => n.checkboxInfo!.checked = checked);
this.onDidUpdateEmitter.fire(nodesToChange);
this.proxy?.$checkStateChanged(this.options.id, [{ id: node.id, checked: checked }]);
}
Expand Down Expand Up @@ -532,7 +532,7 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
...attrs,
onMouseLeave: () => source?.cancel(),
onMouseEnter: async event => {
const target = event.currentTarget; // event.currentTarget will be null after awaiting node resolve()
const target = event.currentTarget; // event.currentTarget will be null after awaiting node resolve()
if (configuredTip) {
if (MarkdownString.is(node.tooltip)) {
this.hoverService.requestHover({
Expand Down
12 changes: 5 additions & 7 deletions packages/plugin-ext/src/main/browser/view/tree-views-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,11 @@ export class TreeViewsMainImpl implements TreeViewsMain, Disposable {
}
}

async setChecked(treeViewWidget: TreeViewWidget, changedNodes: TreeViewNode[]) {
this.proxy.$checkStateChanged(treeViewWidget.id, changedNodes.map(node => {
return {
id: node.id,
checked: !!node.checkboxInfo?.checked
}
}));
async setChecked(treeViewWidget: TreeViewWidget, changedNodes: TreeViewNode[]): Promise<void> {
await this.proxy.$checkStateChanged(treeViewWidget.id, changedNodes.map(node => ({
id: node.id,
checked: !!node.checkboxInfo?.checked
})));
}

protected handleTreeEvents(treeViewId: string, treeViewWidget: TreeViewWidget): void {
Expand Down
15 changes: 10 additions & 5 deletions packages/plugin-ext/src/plugin/tree/tree-views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class TreeViewsExtImpl implements TreeViewsExt {
}
});
}
$checkStateChanged(treeViewId: string, itemIds: { id: string; checked: boolean; }[]): unknown {
$checkStateChanged(treeViewId: string, itemIds: { id: string; checked: boolean; }[]): Promise<void> {
return this.getTreeView(treeViewId).checkStateChanged(itemIds);
}
$dragStarted(treeViewId: string, treeItemIds: string[], token: CancellationToken): Promise<UriComponents[] | undefined> {
Expand Down Expand Up @@ -244,7 +244,12 @@ class TreeViewExtImpl<T> implements Disposable {
// make copies of optionally provided MIME types:
const dragMimeTypes = options.dragAndDropController?.dragMimeTypes?.slice();
const dropMimeTypes = options.dragAndDropController?.dropMimeTypes?.slice();
proxy.$registerTreeDataProvider(treeViewId, { manageCheckboxStateManually: options.manageCheckboxStateManually, showCollapseAll: options.showCollapseAll, canSelectMany: options.canSelectMany, dragMimeTypes, dropMimeTypes });
proxy.$registerTreeDataProvider(treeViewId, {
manageCheckboxStateManually: options.manageCheckboxStateManually,
showCollapseAll: options.showCollapseAll,
canSelectMany: options.canSelectMany,
dragMimeTypes, dropMimeTypes
});
this.toDispose.push(Disposable.create(() => this.proxy.$unregisterTreeDataProvider(treeViewId)));
options.treeDataProvider.onDidChangeTreeData?.(() => {
this.pendingRefresh = proxy.$refresh(treeViewId);
Expand Down Expand Up @@ -451,11 +456,11 @@ class TreeViewExtImpl<T> implements Disposable {
checked: treeItem.checkboxState.state === TreeItemCheckboxState.Checked,
tooltip: treeItem.checkboxState.tooltip,
accessibilityInformation: treeItem.accessibilityInformation
}
};
} else {
checkboxInfo = {
checked: treeItem.checkboxState === TreeItemCheckboxState.Checked
}
};
}

const treeViewItem: TreeViewItem = {
Expand Down Expand Up @@ -537,7 +542,7 @@ class TreeViewExtImpl<T> implements Disposable {
}
}

checkStateChanged(items: readonly { id: string; checked: boolean; }[]): void {
async checkStateChanged(items: readonly { id: string; checked: boolean; }[]): Promise<void> {
const transformed: [T, TreeItemCheckboxState][] = [];
items.forEach(item => {
const node = this.nodes.get(item.id);
Expand Down
7 changes: 5 additions & 2 deletions packages/plugin-ext/src/plugin/types-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1908,8 +1908,11 @@ export class TreeItem {

contextValue?: string;

checkboxState?: theia.TreeItemCheckboxState | { readonly state: theia.TreeItemCheckboxState; readonly tooltip?: string; readonly accessibilityInformation?: AccessibilityInformation };

checkboxState?: theia.TreeItemCheckboxState | {
readonly state: theia.TreeItemCheckboxState;
readonly tooltip?: string;
readonly accessibilityInformation?: AccessibilityInformation
};

constructor(label: string | theia.TreeItemLabel, collapsibleState?: theia.TreeItemCollapsibleState)
constructor(resourceUri: URI, collapsibleState?: theia.TreeItemCollapsibleState)
Expand Down
23 changes: 10 additions & 13 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5956,7 +5956,7 @@ export module '@theia/plugin' {
*
* 2. A tree item's parent is checked. The tree item and all of it's siblings will be checked.
* - [ ] Parent
* - [ ] Child 1
* - [ ] Child 1
* - [ ] Child 2
* When the user checks Parent, the tree will look like this:
* - [x] Parent
Expand Down Expand Up @@ -6200,12 +6200,11 @@ export module '@theia/plugin' {
*/
export interface TreeCheckboxChangeEvent<T> {
/**
* The items that were checked or unchecked.
*/
* The items that were checked or unchecked.
*/
readonly items: ReadonlyArray<[T, TreeItemCheckboxState]>;
}


/**
* Represents a Tree view
*/
Expand Down Expand Up @@ -6241,10 +6240,9 @@ export module '@theia/plugin' {
*/
readonly onDidChangeVisibility: Event<TreeViewVisibilityChangeEvent>;


/**
* An event to signal that an element or root has either been checked or unchecked.
*/
* An event to signal that an element or root has either been checked or unchecked.
*/
readonly onDidChangeCheckboxState: Event<TreeCheckboxChangeEvent<T>>;

/**
Expand Down Expand Up @@ -6419,17 +6417,16 @@ export module '@theia/plugin' {
*/
accessibilityInformation?: AccessibilityInformation;


/**
* {@link TreeItemCheckboxState TreeItemCheckboxState} of the tree item.
* {@link TreeDataProvider.onDidChangeTreeData onDidChangeTreeData} should be fired when {@link TreeItem.checkboxState checkboxState} changes.
*/
checkboxState?: TreeItemCheckboxState | { readonly state: TreeItemCheckboxState; readonly tooltip?: string; readonly accessibilityInformation?: AccessibilityInformation };

/**
* @param label A human-readable string describing this item
* @param collapsibleState {@link TreeItemCollapsibleState TreeItemCollapsibleState} of the tree item. Default is [TreeItemCollapsibleState.None](#TreeItemCollapsibleState.None)
*/
* @param label A human-readable string describing this item
* @param collapsibleState {@link TreeItemCollapsibleState TreeItemCollapsibleState} of the tree item. Default is [TreeItemCollapsibleState.None](#TreeItemCollapsibleState.None)
*/
constructor(label: string | TreeItemLabel, collapsibleState?: TreeItemCollapsibleState);

/**
Expand Down Expand Up @@ -6475,8 +6472,8 @@ export module '@theia/plugin' {
}

/**
* Checkbox state of the tree item
*/
* Checkbox state of the tree item
*/
export enum TreeItemCheckboxState {
/**
* Determines an item is unchecked
Expand Down

0 comments on commit f862476

Please sign in to comment.