Skip to content

Commit 605378c

Browse files
committed
Add selection for handlers when no handler found
1 parent 9bcb252 commit 605378c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

client/core/files.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ define([
7676
});
7777
};
7878

79+
// Select to open a file with any handler
80+
var openFileWith = function(file) {
81+
var choices = {};
82+
_.each(handlers, function(handler) {
83+
choices[handler.id] = handler.name;
84+
});
85+
return dialogs.select("Can't open this file", "Sorry, No handler has been found to open this file. Try to find and install an addon to manage this file or select one of these handlers:", choices).then(function(value) {
86+
var handler = handlers[value];
87+
return Q(handler.open(file));
88+
});
89+
};
90+
7991
// Open a file
8092
var openFile = function(file) {
8193
if (_.isString(file)) {
@@ -89,8 +101,7 @@ define([
89101

90102
var possibleHandlers = getHandlers(file);
91103
if (_.size(possibleHandlers) == 0) {
92-
dialogs.alert("Can't open this file", "Sorry, No handler has been found to open this file. Try to find and install an addon to manage this file.");
93-
return Q.reject(new Error("No handler for this file"));
104+
return openFileWith(file);
94105
}
95106

96107
if (_.size(possibleHandlers) == 1) {

0 commit comments

Comments
 (0)