Skip to content

Commit

Permalink
chore(modeler): drop in-app file association behavior
Browse files Browse the repository at this point in the history
Associating files is now provided by installer.

Related to #787
  • Loading branch information
nikku committed Jun 5, 2018
1 parent 98a3a90 commit 67d7b15
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 220 deletions.
92 changes: 0 additions & 92 deletions app/lib/platform/windows/file-associations.js

This file was deleted.

79 changes: 1 addition & 78 deletions app/lib/platform/windows/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
'use strict';

var dialog = require('electron').dialog;

var FileAssociations = require('./file-associations');

var FILE_ASSOCIATION_KEY = 'fileAssociation';

function WindowsPlatform(app, config) {

// setup file associations + deferred open file
// specified via command-line
app.on('app:client-ready', function() {
checkFileAssociations(app, config);
});

/**
* Adding recent open files.
*/
Expand All @@ -26,70 +15,4 @@ function WindowsPlatform(app, config) {
});
}

module.exports = WindowsPlatform;


/**
* Check application file associations and
* initialize/update as needed.
*
* @param {ElectronApp} app
* @param {Config} config
*/
function checkFileAssociations(app, config) {

var executablePath = app.getPath('exe');

var userChoice = config.get(FILE_ASSOCIATION_KEY);

needsAssociation(userChoice, function(err, associate) {

if (err) {
return console.error('[file association] failed to check', err);
}

if (associate) {

associateEditor(executablePath, function(err) {
if (err) {
return console.error('[file association] failed to associate', err);
}
});
}

config.set(FILE_ASSOCIATION_KEY, associate);
});
}


function needsAssociation(existingChoice, done) {

if (existingChoice !== undefined) {
return done(null, existingChoice);
} else {
suggestFileAssociation(done);
}
}

function associateEditor(executablePath, done) {

try {
FileAssociations.register(executablePath);
} catch (e) {
return done(e);
}

done(null);
}

function suggestFileAssociation(done) {
dialog.showMessageBox({
type: 'question',
buttons: [ 'Yes', 'No' ],
title: 'Camunda Modeler',
message: 'Do you want to associate your .bpmn, .dmn and .cmmn files to the Camunda Modeler?'
}, function(answer) {
// return true, if the user agreed
done(null, answer === 0);
});
}
module.exports = WindowsPlatform;
50 changes: 0 additions & 50 deletions app/test/spec/platform/windows/file-associations-spec.js

This file was deleted.

0 comments on commit 67d7b15

Please sign in to comment.