summaryrefslogtreecommitdiffstats
path: root/install/ui/src/freeipa
diff options
context:
space:
mode:
Diffstat (limited to 'install/ui/src/freeipa')
-rw-r--r--install/ui/src/freeipa/_base/Phase_controller.js39
-rw-r--r--install/ui/src/freeipa/phases.js31
2 files changed, 65 insertions, 5 deletions
diff --git a/install/ui/src/freeipa/_base/Phase_controller.js b/install/ui/src/freeipa/_base/Phase_controller.js
index 951aa51f..471c36a0 100644
--- a/install/ui/src/freeipa/_base/Phase_controller.js
+++ b/install/ui/src/freeipa/_base/Phase_controller.js
@@ -112,7 +112,7 @@ define([
},
/**
- * Add task for a phase.
+ * Adds task for a phase.
*
* At phase execution, tasks are sorted by priority and executed in
* that order.
@@ -134,17 +134,48 @@ define([
},
/**
- * Adds a phase.
+ * Adds a phase
+ *
+ * Possible options:
+ * before: 'name-of-phase'
+ * after: 'name-of-phase'
+ * position: 'position for new phase'
+ *
* @param {String} phase name
+ * @param {Array} tasks
+ * @param {Object} options
*/
- add_phase: function(name, tasks) {
+ add_phase: function(name, tasks, options) {
var phase = {
name: name,
tasks: tasks || []
};
- this.phases.put(name, phase);
+ var position;
+ if (options) {
+ if (options.before) {
+ position = this.phases.get_key_index(options.before);
+ } else if (options.after) {
+ position = this.phases.get_key_index(options.after);
+ if (position === -1) position = this.phases.length;
+ else position++;
+ } else if (options.position) {
+ position = options.position;
+ }
+ }
+
+ this.phases.put(name, phase, position);
+ },
+
+ /**
+ * Checks if phases with given name exists
+ *
+ * @param {String} name
+ * @return {Boolean}
+ */
+ exists: function(name) {
+ return !!this.phases.get(name);
},
constructor: function(spec) {
diff --git a/install/ui/src/freeipa/phases.js b/install/ui/src/freeipa/phases.js
index 15b753a0..e5a23d07 100644
--- a/install/ui/src/freeipa/phases.js
+++ b/install/ui/src/freeipa/phases.js
@@ -54,10 +54,39 @@ define([
controller: new Phase_controller(spec),
/**
- * Registers phase task
+ * Registers a phase task
+ *
+ * @param {String} Phase name
+ * @param {Function} Task handler. Should return promise if async.
+ * @param {Number} Priority of task. Default 10.
*/
on: function(phase_name, handler, priority) {
this.controller.add_task(phase_name, handler, priority);
+ },
+
+ /**
+ * Adds a phase
+ *
+ * Possible options:
+ * before: 'name-of-phase'
+ * after: 'name-of-phase'
+ * position: 'position for new phase'
+ *
+ * @param {String} Phase name
+ * @param {Object} Options
+ */
+ add: function(phase_name, options) {
+ this.controller.add_phase(phase_name, null, options);
+ },
+
+ /**
+ * Checks if phases with given name exists
+ *
+ * @param {String} Name
+ * @return {Boolean}
+ */
+ exists: function(name) {
+ return this.controller.exists(name);
}
};