From 78cf349290e6d49ada1af12aa62e1d0a501951c5 Mon Sep 17 00:00:00 2001 From: Nina Doschek Date: Thu, 21 Jan 2021 10:14:01 +0100 Subject: [PATCH] Address review comments #3 - Add PropertyViewContribution to 'Views' and 'Menus' api-tests Signed-off-by: Nina Doschek --- examples/api-tests/src/menus.spec.js | 2 ++ examples/api-tests/src/views.spec.js | 4 +++- .../src/browser/property-view-widget-provider.ts | 2 +- .../resource-property-data-service.ts | 2 +- .../resource-property-view-tree-widget.tsx | 7 ++++--- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/examples/api-tests/src/menus.spec.js b/examples/api-tests/src/menus.spec.js index 420af7e1cf259..1361dd4a8da26 100644 --- a/examples/api-tests/src/menus.spec.js +++ b/examples/api-tests/src/menus.spec.js @@ -38,6 +38,7 @@ describe('Menus', function () { const { OutputContribution } = require('@theia/output/lib/browser/output-contribution'); const { PluginFrontendViewContribution } = require('@theia/plugin-ext/lib/main/browser/plugin-frontend-view-contribution'); const { ProblemContribution } = require('@theia/markers/lib/browser/problem/problem-contribution'); + const { PropertyViewContribution } = require('@theia/property-view/lib/browser/property-view-contribution'); const { SearchInWorkspaceFrontendContribution } = require('@theia/search-in-workspace/lib/browser/search-in-workspace-frontend-contribution'); const { HostedPluginSupport } = require('@theia/plugin-ext/lib/hosted/browser/hosted-plugin'); @@ -67,6 +68,7 @@ describe('Menus', function () { container.get(OutputContribution), container.get(PluginFrontendViewContribution), container.get(ProblemContribution), + container.get(PropertyViewContribution), container.get(SearchInWorkspaceFrontendContribution) ]) { it(`should toggle '${contribution.viewLabel}' view`, async () => { diff --git a/examples/api-tests/src/views.spec.js b/examples/api-tests/src/views.spec.js index 7e494c0cc8be5..31c86e72da297 100644 --- a/examples/api-tests/src/views.spec.js +++ b/examples/api-tests/src/views.spec.js @@ -25,6 +25,7 @@ describe('Views', function () { const { ScmContribution } = require('@theia/scm/lib/browser/scm-contribution'); const { OutlineViewContribution } = require('@theia/outline-view/lib/browser/outline-view-contribution'); const { ProblemContribution } = require('@theia/markers/lib/browser/problem/problem-contribution'); + const { PropertyViewContribution } = require('@theia/property-view/lib/browser/property-view-contribution'); const { HostedPluginSupport } = require('@theia/plugin-ext/lib/hosted/browser/hosted-plugin'); /** @type {import('inversify').Container} */ @@ -34,6 +35,7 @@ describe('Views', function () { const scmContribution = container.get(ScmContribution); const outlineContribution = container.get(OutlineViewContribution); const problemContribution = container.get(ProblemContribution); + const propertyViewContribution = container.get(PropertyViewContribution); const pluginService = container.get(HostedPluginSupport); before(() => Promise.all([ @@ -44,7 +46,7 @@ describe('Views', function () { })() ])); - for (const contribution of [navigatorContribution, scmContribution, outlineContribution, problemContribution]) { + for (const contribution of [navigatorContribution, scmContribution, outlineContribution, problemContribution, propertyViewContribution]) { it(`should toggle ${contribution.viewLabel}`, async function () { let view = await contribution.closeView(); if (view) { diff --git a/packages/property-view/src/browser/property-view-widget-provider.ts b/packages/property-view/src/browser/property-view-widget-provider.ts index 327b83c1b2fc2..2d12833909a5d 100644 --- a/packages/property-view/src/browser/property-view-widget-provider.ts +++ b/packages/property-view/src/browser/property-view-widget-provider.ts @@ -82,7 +82,7 @@ export abstract class DefaultPropertyViewWidgetProvider implements PropertyViewW } provideWidget(selection: Object | undefined): Promise { - return Promise.reject(); + throw new Error('not implemented'); } updateContentWidget(selection: Object | undefined): void { diff --git a/packages/property-view/src/browser/resource-property-view/resource-property-data-service.ts b/packages/property-view/src/browser/resource-property-view/resource-property-data-service.ts index 75c93d5d9b825..1c4770f98f8ed 100644 --- a/packages/property-view/src/browser/resource-property-view/resource-property-data-service.ts +++ b/packages/property-view/src/browser/resource-property-view/resource-property-data-service.ts @@ -55,7 +55,7 @@ export class ResourcePropertyDataService implements PropertyDataService { } else if (this.isMonacoEditorSelection(selection)) { return this.getFileStat((selection as MonacoEditor).uri); } - return Promise.reject(); + return undefined; } } diff --git a/packages/property-view/src/browser/resource-property-view/resource-property-view-tree-widget.tsx b/packages/property-view/src/browser/resource-property-view/resource-property-view-tree-widget.tsx index 96ed04a3f727b..a44272291b093 100644 --- a/packages/property-view/src/browser/resource-property-view/resource-property-view-tree-widget.tsx +++ b/packages/property-view/src/browser/resource-property-view/resource-property-view-tree-widget.tsx @@ -82,7 +82,7 @@ export class ResourcePropertyViewTreeWidget extends TreeWidget implements Proper if (this.updateNeeded(selection)) { this.currentSelection = selection; if (propertyDataService) { - propertyDataService.providePropertyData(selection).then((fileStatObject: FileStat) => { + propertyDataService.providePropertyData(selection).then((fileStatObject?: FileStat) => { this.fillPropertiesTree(fileStatObject); }); } @@ -90,8 +90,8 @@ export class ResourcePropertyViewTreeWidget extends TreeWidget implements Proper } private fillPropertiesTree(fileStatObject?: FileStat): void { - this.propertiesTree.clear(); if (fileStatObject) { + this.propertiesTree.clear(); const infoNode = this.createCategoryNode('info', 'Info'); this.propertiesTree.set('info', infoNode); @@ -104,8 +104,8 @@ export class ResourcePropertyViewTreeWidget extends TreeWidget implements Proper infoNode.children.push(this.createResultLineNode('lastModification', 'Last modified', this.getLastModificationString(fileStatObject), infoNode)); infoNode.children.push(this.createResultLineNode('created', 'Created', this.getCreationTimeString(fileStatObject), infoNode)); infoNode.children.push(this.createResultLineNode('size', 'Size', this.getSizeString(fileStatObject), infoNode)); + this.refreshModelChildren(); } - this.refreshModelChildren(); } private getLocationString(fileStat: FileStat): string { @@ -175,6 +175,7 @@ export class ResourcePropertyViewTreeWidget extends TreeWidget implements Proper } else if (ResourcePropertiesItemNode.is(node)) { return this.renderItemNode(node); } + return undefined; } protected renderExpandableNode(node: ResourcePropertiesCategoryNode): React.ReactNode {