From 3db13f6329c53376461b6950c82e84210545941f Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Wed, 26 Nov 2014 13:27:57 -0400 Subject: [PATCH] Move patterns to resin/ui --- lib/actions/app.coffee | 3 +-- lib/actions/device.coffee | 3 +-- lib/actions/environment-variables.coffee | 3 +-- lib/actions/keys.coffee | 3 +-- lib/resin/ui/index.coffee | 1 + lib/{ => resin/ui}/patterns/patterns.coffee | 4 ++-- 6 files changed, 7 insertions(+), 10 deletions(-) rename lib/{ => resin/ui}/patterns/patterns.coffee (78%) diff --git a/lib/actions/app.coffee b/lib/actions/app.coffee index 94c6334e..55e48a31 100644 --- a/lib/actions/app.coffee +++ b/lib/actions/app.coffee @@ -1,7 +1,6 @@ _ = require('lodash') async = require('async') resin = require('../resin') -patterns = require('../patterns/patterns') authHooks = require('../hooks/auth') config = require('../config') @@ -60,7 +59,7 @@ exports.restart = authHooks.failIfNotLoggedIn (id) -> resin.server.post("/application/#{id}/restart", resin.errors.handle) exports.remove = authHooks.failIfNotLoggedIn (id, program) -> - patterns.remove 'application', program.parent.yes, (callback) -> + resin.ui.patterns.remove 'application', program.parent.yes, (callback) -> resin.models.application.remove(id).then -> return callback() .catch(callback) diff --git a/lib/actions/device.coffee b/lib/actions/device.coffee index fcf3333c..4bdd797f 100644 --- a/lib/actions/device.coffee +++ b/lib/actions/device.coffee @@ -1,5 +1,4 @@ resin = require('../resin') -patterns = require('../patterns/patterns') authHooks = require('../hooks/auth') config = require('../config') @@ -19,7 +18,7 @@ exports.list = authHooks.failIfNotLoggedIn (applicationId) -> .catch(resin.errors.handle) exports.remove = authHooks.failIfNotLoggedIn (id, program) -> - patterns.remove 'device', program.parent.yes, (callback) -> + resin.ui.patterns.remove 'device', program.parent.yes, (callback) -> resin.models.device.remove(id).then -> return callback() .catch(callback) diff --git a/lib/actions/environment-variables.coffee b/lib/actions/environment-variables.coffee index 24ff0b80..be686885 100644 --- a/lib/actions/environment-variables.coffee +++ b/lib/actions/environment-variables.coffee @@ -1,5 +1,4 @@ _ = require('lodash') -patterns = require('../patterns/patterns') resin = require('../resin') authHooks = require('../hooks/auth') @@ -23,7 +22,7 @@ exports.list = authHooks.failIfNotLoggedIn (program) -> .catch(resin.errors.handle) exports.remove = authHooks.failIfNotLoggedIn (id, program) -> - patterns.remove 'environment variable', program.parent.yes, (callback) -> + resin.ui.patterns.remove 'environment variable', program.parent.yes, (callback) -> resin.models.environmentVariables.remove(id).then -> return callback() .catch(callback) diff --git a/lib/actions/keys.coffee b/lib/actions/keys.coffee index 9a348dc6..925dda3a 100644 --- a/lib/actions/keys.coffee +++ b/lib/actions/keys.coffee @@ -1,7 +1,6 @@ _ = require('lodash') resin = require('../resin') authHooks = require('../hooks/auth') -patterns = require('../patterns/patterns') helpers = require('../helpers/helpers') config = require('../config') @@ -29,6 +28,6 @@ exports.info = authHooks.failIfNotLoggedIn (id) -> resin.log.out(resin.ui.widgets.table.vertical(key, _.identity, [ 'ID', 'Title', 'Public Key' ])) exports.remove = authHooks.failIfNotLoggedIn (id, program) -> - patterns.remove 'key', program.parent.yes, (callback) -> + resin.ui.patterns.remove 'key', program.parent.yes, (callback) -> resin.server.delete("/user/keys/#{id}", callback) , resin.errors.handle diff --git a/lib/resin/ui/index.coffee b/lib/resin/ui/index.coffee index 9b5eebf1..fe90ba5e 100644 --- a/lib/resin/ui/index.coffee +++ b/lib/resin/ui/index.coffee @@ -1,2 +1,3 @@ module.exports = widgets: require('./widgets/widgets') + patterns: require('./patterns/patterns') diff --git a/lib/patterns/patterns.coffee b/lib/resin/ui/patterns/patterns.coffee similarity index 78% rename from lib/patterns/patterns.coffee rename to lib/resin/ui/patterns/patterns.coffee index 3064a881..b356944e 100644 --- a/lib/patterns/patterns.coffee +++ b/lib/resin/ui/patterns/patterns.coffee @@ -1,5 +1,5 @@ async = require('async') -resin = require('../resin') +widgets = require('../widgets/widgets') exports.remove = (name, confirmAttribute, deleteFunction, outerCallback) -> async.waterfall([ @@ -8,7 +8,7 @@ exports.remove = (name, confirmAttribute, deleteFunction, outerCallback) -> if confirmAttribute return callback(null, true) - resin.ui.widgets.confirmRemoval(name, callback) + widgets.confirmRemoval(name, callback) (confirmed, callback) -> return callback() if not confirmed