Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to ember 3.20 #57

Merged
merged 1 commit into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

root = true


[*]
end_of_line = lf
charset = utf-8
Expand Down
58 changes: 32 additions & 26 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,56 @@
'use strict'

module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2018,
sourceType: "module"
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true
}
},
plugins: ["ember"],
extends: ["eslint:recommended", "plugin:ember/recommended"],
plugins: [
'ember'
],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
],
env: {
browser: true
},
rules: {},
rules: {
semi: ["error", "never"]
},
overrides: [
// node files
{
files: [
".eslintrc.js",
".template-lintrc.js",
"ember-cli-build.js",
"index.js",
"testem.js",
"blueprints/*/index.js",
"config/**/*.js",
"tests/dummy/config/**/*.js"
'.eslintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'index.js',
'testem.js',
'blueprints/*/index.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
],
excludedFiles: [
"addon/**",
"addon-test-support/**",
"app/**",
"tests/dummy/app/**"
'addon/**',
'addon-test-support/**',
'app/**',
'tests/dummy/app/**'
],
parserOptions: {
sourceType: "script"
sourceType: 'script'
},
env: {
browser: false,
node: true
},
plugins: ["node"],
rules: Object.assign(
{},
require("eslint-plugin-node").configs.recommended.rules,
{
// add your custom rules and overrides for node files here
}
)
plugins: ['node'],
extends: ['plugin:node/recommended']
}
]
};
}
10 changes: 0 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,3 @@
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
9 changes: 6 additions & 3 deletions .template-lintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict';
'use strict'

module.exports = {
extends: 'recommended'
};
extends: 'octane',
rules: {
'no-action': 0
}
}
29 changes: 14 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ node_js:
# so that your addon works for all apps
- "10"

sudo: false
dist: trusty
dist: xenial

addons:
chrome: stable
Expand All @@ -26,42 +25,42 @@ branches:
- /^v\d+\.\d+\.\d+/

jobs:
fail_fast: true
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary

include:
# runs linting and tests with current locked deps

- stage: "Tests"
name: "Tests"
install:
- yarn install --non-interactive
script:
- yarn lint:hbs
- yarn lint:js
- yarn test
- yarn lint
- yarn test:ember

- name: "Floating Dependencies"
- stage: "Additional Tests"
name: "Floating Dependencies"
install:
- yarn install --no-lockfile --non-interactive
script:
- yarn test
- yarn test:ember

# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- stage: "Additional Tests"
env: EMBER_TRY_SCENARIO=ember-lts-3.4
- env: EMBER_TRY_SCENARIO=ember-lts-3.8
- env: EMBER_TRY_SCENARIO=ember-lts-3.12
- env: EMBER_TRY_SCENARIO=ember-lts-3.16
- env: EMBER_TRY_SCENARIO=ember-lts-3.20
- env: EMBER_TRY_SCENARIO=ember-release
- env: EMBER_TRY_SCENARIO=ember-beta
- env: EMBER_TRY_SCENARIO=ember-canary
- env: EMBER_TRY_SCENARIO=ember-default-with-jquery
- env: EMBER_TRY_SCENARIO=ember-classic

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH

install:
- yarn install --no-lockfile --non-interactive
- yarn install --non-interactive

script:
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO
22 changes: 11 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

## Installation

- `git clone <repository-url>`
- `cd my-addon`
- `yarn install`
* `git clone <repository-url>`
* `cd ember-feature-controls`
* `yarn install`

## Linting

- `yarn lint:hbs`
- `yarn lint:js`
- `yarn lint:js -- --fix`
* `yarn lint:hbs`
* `yarn lint:js`
* `yarn lint:js --fix`

## Running tests

- `ember test` – Runs the test suite on the current Ember version
- `ember test --server` – Runs the test suite in "watch mode"
- `ember try:each` – Runs the test suite against multiple Ember versions
* `ember test` – Runs the test suite on the current Ember version
* `ember test --server` – Runs the test suite in "watch mode"
* `ember try:each` – Runs the test suite against multiple Ember versions

## Running the dummy application

- `ember serve`
- Visit the dummy application at [http://localhost:4200](http://localhost:4200).
* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).

For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
92 changes: 46 additions & 46 deletions addon/components/feature-controls.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Component from "@ember/component";
import layout from "../templates/components/feature-controls";
import { inject as service } from "@ember/service";
import { set, get } from "@ember/object";
import { assign } from "@ember/polyfills";
import { storageFor } from "ember-local-storage";
import config from "ember-get-config";
import windowUtil from "ember-feature-controls/utils/window";
import Component from "@ember/component"
import layout from "../templates/components/feature-controls"
import { inject as service } from "@ember/service"
import { set } from "@ember/object"
import { assign } from "@ember/polyfills"
import { storageFor } from "ember-local-storage"
import config from "ember-get-config"
import windowUtil from "ember-feature-controls/utils/window"

const { featureFlags, featureControls } = config;
const { featureFlags, featureControls } = config

export default Component.extend({
layout,
Expand All @@ -19,87 +19,87 @@ export default Component.extend({
featureControls,
featureFlags,
init() {
this._super(...arguments);
this.refresh();
this._super(...arguments)
this.refresh()
},
_normalizeFlag(key) {
return get(this, "features._normalizeFlag")(key);
return this.features._normalizeFlag(key)
},
// Refresh the state of the feature flags list component
refresh() {
// Take the existing flags from the config and put them in a list of default values
let featureFlags = this.get("featureFlags");
let defaults = {};
let featureFlags = this.featureFlags
let defaults = {}
for (let key in featureFlags) {
defaults[this._normalizeFlag(key)] = featureFlags[key];
defaults[this._normalizeFlag(key)] = featureFlags[key]
}
// Model is a local copy of the list of flags register for features service, used to compute properties on the full list
let model = (get(this, "features.flags") || []).map(key => {
let model = (this.features.flags || []).map(key => {
let meta =
((featureControls && this.get("featureControls.metadata")) || []).find(
((featureControls && this.featureControls.metadata) || []).find(
obj => {
return this._normalizeFlag(obj.key) === key;
return this._normalizeFlag(obj.key) === key
}
) || {};
) || {}
if (meta.hide === true) {
return undefined;
return undefined
}
let isFlagLS =
this.get("featureControls.useLocalStorage") &&
this.get(`featuresLS.${key}`) !== undefined;
this.featureControls.useLocalStorage &&
this.get(`featuresLS.${key}`) !== undefined
let featureFlag = {
key,
isEnabled: isFlagLS
? this.get(`featuresLS.${key}`)
: get(this, "features").isEnabled(key),
: this.features.isEnabled(key),
default: defaults[key] || false
};
return assign({}, meta, featureFlag);
});
set(this, "model", model.filter(item => item !== undefined));
}
return assign({}, meta, featureFlag)
})
set(this, "model", model.filter(item => item !== undefined))
},
reset() {
// Reset the flags from the features service to the default value in the config
let featureFlags = this.get("featureFlags");
let featureFlags = this.featureFlags
Object.keys(featureFlags).forEach(key => {
this.updateFeature(this._normalizeFlag(key), featureFlags[key]);
});
this.updateFeature(this._normalizeFlag(key), featureFlags[key])
})
// If we use local storage then we want to clear the stored data
if (this.get("featureControls.useLocalStorage")) {
this.get("featuresLS").reset();
if (this.featureControls.useLocalStorage) {
this.featuresLS.reset()
}
},
updateFeature(key, isEnabled) {
if (isEnabled) {
get(this, "features").enable(key);
this.features.enable(key)
} else {
get(this, "features").disable(key);
this.features.disable(key)
}
// Update the local model accordingly
let model = get(this, "model");
let model = this.model
let modelFlag = model.find(obj => {
return obj.key === key;
});
return obj.key === key
})
if (modelFlag) {
set(modelFlag, "isEnabled", isEnabled);
set(this, "model", model);
set(modelFlag, "isEnabled", isEnabled)
set(this, "model", model)
if (modelFlag.reload) {
windowUtil.reload();
windowUtil.reload()
}
}
},
actions: {
refresh() {
this.refresh();
this.refresh()
},
reset() {
this.reset();
this.reset()
},
doToggleFeature(key, checkboxState) {
this.updateFeature(key, !checkboxState);
if (this.get("featureControls.useLocalStorage")) {
this.set(`featuresLS.${key}`, !checkboxState);
this.updateFeature(key, !checkboxState)
if (this.featureControls.useLocalStorage) {
this.set(`featuresLS.${key}`, !checkboxState)
}
}
}
});
})
Loading