Skip to content

Commit

Permalink
Fixed eclipse-theia#5110: made "open source" only visible when it is …
Browse files Browse the repository at this point in the history
…available

Signed-off-by: fangnx <[email protected]>
  • Loading branch information
fangnx committed May 22, 2019
1 parent f39185a commit ec37310
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/mini-browser/src/browser/mini-browser-open-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ export class MiniBrowserOpenHandler extends NavigatableWidgetOpenHandler<MiniBro
};
}

protected canOpenSource(widget: Widget): boolean {
const extension = widget.title.label.toString().split('.').pop();
if (extension) {
return ['jpg', 'jpeg', 'png', 'bmp', 'gif', 'pdf'].indexOf(extension.toLocaleLowerCase()) === -1;
}
return false;
}

registerCommands(commands: CommandRegistry): void {
commands.registerCommand(MiniBrowserCommands.PREVIEW, {
execute: widget => this.preview(widget),
Expand All @@ -176,7 +184,7 @@ export class MiniBrowserOpenHandler extends NavigatableWidgetOpenHandler<MiniBro
commands.registerCommand(MiniBrowserCommands.OPEN_SOURCE, {
execute: widget => this.openSource(widget),
isEnabled: widget => !!this.getSourceUri(widget),
isVisible: widget => !!this.getSourceUri(widget)
isVisible: widget => !!this.getSourceUri(widget) && this.canOpenSource(widget)
});
commands.registerCommand(MiniBrowserCommands.OPEN_URL, {
execute: (arg?: string) => this.openUrl(arg)
Expand Down

0 comments on commit ec37310

Please sign in to comment.