summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/environments/stores
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-02-09 11:18:21 +0000
committerFilipa Lacerda <filipa@gitlab.com>2017-02-09 11:18:21 +0000
commit6077dea7b1f6fb857f786d86cd7cf9e5204ec9a9 (patch)
tree0cc84619357997fe390d2117acc513ffd7f9ab1e /app/assets/javascripts/environments/stores
parentacb68ae69e382a7bd949386f14d2d27f6cada086 (diff)
downloadgitlab-ce-6077dea7b1f6fb857f786d86cd7cf9e5204ec9a9.tar.gz
Remove store from global namespace, use CSJ instead
Diffstat (limited to 'app/assets/javascripts/environments/stores')
-rw-r--r--app/assets/javascripts/environments/stores/environments_store.js.es6120
1 files changed, 60 insertions, 60 deletions
diff --git a/app/assets/javascripts/environments/stores/environments_store.js.es6 b/app/assets/javascripts/environments/stores/environments_store.js.es6
index c05f353647c..52bd6b94551 100644
--- a/app/assets/javascripts/environments/stores/environments_store.js.es6
+++ b/app/assets/javascripts/environments/stores/environments_store.js.es6
@@ -1,68 +1,68 @@
-/* eslint-disable no-param-reassign */
-(() => {
- window.gl = window.gl || {};
- window.gl.environmentsList = window.gl.environmentsList || {};
+/**
+ * Environments Store.
+ *
+ * Stores received environments, count of stopped environments and count of
+ * available environments.
+ */
+class EnvironmentsStore {
+ constructor() {
+ this.state = {};
+ this.state.environments = [];
+ this.state.stoppedCounter = 0;
+ this.state.availableCounter = 0;
+ this.state.filteredEnvironments = [];
- gl.environmentsList.EnvironmentsStore = {
- state: {},
+ return this;
+ }
- create() {
- this.state.environments = [];
- this.state.stoppedCounter = 0;
- this.state.availableCounter = 0;
- this.state.filteredEnvironments = [];
+ /**
+ *
+ * Stores the received environments.
+ *
+ * Each environment has the following schema
+ * { name: String, size: Number, latest: Object }
+ *
+ * If the `size` is bigger than 1, it means it should be rendered as a folder.
+ * In those cases we add `isFolder` key in order to render it properly.
+ *
+ * @param {Array} environments
+ * @returns {Array}
+ */
+ storeEnvironments(environments = []) {
+ const filteredEnvironments = environments.map((env) => {
+ if (env.size > 1) {
+ return Object.assign({}, env, { isFolder: true });
+ }
- return this;
- },
+ return env;
+ });
- /**
- *
- * Stores the received environments.
- *
- * Each environment has the following schema
- * { name: String, size: Number, latest: Object }
- *
- * If the `size` is bigger than 1, it means it should be rendered as a folder.
- * In those cases we add `isFolder` key in order to render it properly.
- *
- * @param {Array} environments
- * @returns {Array}
- */
- storeEnvironments(environments = []) {
- const filteredEnvironments = environments.map((env) => {
- if (env.size > 1) {
- return Object.assign({}, env, { isFolder: true });
- }
+ this.state.environments = filteredEnvironments;
- return env;
- });
+ return filteredEnvironments;
+ }
- this.state.environments = filteredEnvironments;
+ /**
+ * Stores the number of available environments.
+ *
+ * @param {Number} count = 0
+ * @return {Number}
+ */
+ storeAvailableCount(count = 0) {
+ this.state.availableCounter = count;
+ return count;
+ }
- return filteredEnvironments;
- },
+ /**
+ * Stores the number of closed environments.
+ *
+ * @param {Number} count = 0
+ * @return {Number}
+ */
+ storeStoppedCount(count = 0) {
+ this.state.stoppedCounter = count;
+ return count;
+ }
+}
- /**
- * Stores the number of available environments.
- *
- * @param {Number} count = 0
- * @return {Number}
- */
- storeAvailableCount(count = 0) {
- this.state.availableCounter = count;
- return count;
- },
-
- /**
- * Stores the number of closed environments.
- *
- * @param {Number} count = 0
- * @return {Number}
- */
- storeStoppedCount(count = 0) {
- this.state.stoppedCounter = count;
- return count;
- },
-
- };
-})();
+module.exports = EnvironmentsStore;