Prefer const whenever possible

This commit is contained in:
Dannon Baker
2019-05-20 08:48:38 -04:00
parent 88908aa4a7
commit 444eb6eb37
9 changed files with 27 additions and 27 deletions
@@ -19,7 +19,7 @@ export default {
},
methods: {
getFormatted(value) {
let result = this.stringifyValue(value);
const result = this.stringifyValue(value);
if (this.mask.length) {
return this.masker.resolve(result);
}
@@ -153,7 +153,7 @@ export default {
.finally(() => (this.loading = false));
},
onCreate() {
let newItem = Credential.create({ expanded: true });
const newItem = Credential.create({ expanded: true });
this.addItem(newItem);
},
onSave(item) {
@@ -66,7 +66,7 @@ export default {
},
computed: {
statusClasses() {
let { expanded, valid, dirty, loading } = this.credential;
const { expanded, valid, dirty, loading } = this.credential;
return { loading, expanded, valid, dirty, collapsed: !expanded };
},
variant() {
@@ -87,7 +87,7 @@ export default {
},
methods: {
expand(forceState) {
let expanded = forceState !== undefined ? forceState : !this.expanded;
const expanded = forceState !== undefined ? forceState : !this.expanded;
this.$emit("expand", { expanded });
}
}
@@ -11,7 +11,7 @@ export class AwsConfig extends BaseModel {
}
AwsConfig.setValidator(function(model) {
let errors = {};
const errors = {};
if (!model.role_arn.length) {
errors.role_arn = "Missing role_arn";
}
@@ -13,7 +13,7 @@ export class AzureConfig extends BaseModel {
}
AzureConfig.setValidator(function(model) {
let errors = {};
const errors = {};
if (model.tenant_id.length < 36) {
errors.tenant_id = "Tenant ID too short";
@@ -29,7 +29,7 @@ export class BaseModel {
get state() {
// build state JSON ignoring transient fields
let tFields = this.transientFields;
const tFields = this.transientFields;
return JSON.stringify(this, function(key) {
if (!tFields.has(key)) {
return this[key];
@@ -43,7 +43,7 @@ export class BaseModel {
}
get transientFields() {
let key = this.constructor;
const key = this.constructor;
if (!transients.has(key)) {
transients.set(key, new Set());
}
@@ -57,12 +57,12 @@ export class BaseModel {
// Setting a property name as transient for a class means its
// state will be caclulated without regard to that propety
static setTransient(...fieldNames) {
let klass = this; // this will be a class
const klass = this; // this will be a class
if (!transients.has(klass)) {
transients.set(klass, new Set());
}
let fields = transients.get(klass);
const fields = transients.get(klass);
fieldNames.forEach(fieldName => fields.add(fieldName));
transients.set(klass, fields);
}
@@ -90,7 +90,7 @@ export class BaseModel {
static validate(model) {
if (validators.has(this)) {
let validator = validators.get(this);
const validator = validators.get(this);
return validator(model);
}
throw new Error("Missing validator");
@@ -16,7 +16,7 @@ export class Credential extends BaseModel {
this.loading = false;
// populate props
let options = Object.assign({}, Credential.defaults, props);
const options = Object.assign({}, Credential.defaults, props);
safeAssign(this, options);
// init nested config
@@ -86,7 +86,7 @@ Credential.setTransient("expanded", "loading");
* error messages.
*/
Credential.setValidator(function(model) {
let errors = {};
const errors = {};
if (!model.provider) {
errors.provider = "Provider must be set";
@@ -9,8 +9,8 @@ import { getRootFromIndexLink } from "onload";
const getUrl = path => getRootFromIndexLink() + path;
export async function listCredentials() {
let url = getUrl("api/cloud/authz");
let response = await axios.get(url);
const url = getUrl("api/cloud/authz");
const response = await axios.get(url);
if (response.status != 200) {
throw new Error("Unexpected response from listing.");
}
@@ -18,8 +18,8 @@ export async function listCredentials() {
}
export async function getCredential(id) {
let url = getUrl("api/cloud/authz/${id}");
let response = await axios.get(url);
const url = getUrl("api/cloud/authz/${id}");
const response = await axios.get(url);
if (response.status != 200) {
throw new Error("Unexpected response loading key.");
}
@@ -27,8 +27,8 @@ export async function getCredential(id) {
}
export async function saveCredential(newItem) {
let model = Credential.create(newItem);
let response = await saveOrUpdate(model);
const model = Credential.create(newItem);
const response = await saveOrUpdate(model);
if (response.status != 200) {
throw new Error("Save failure.");
}
@@ -42,10 +42,10 @@ async function saveOrUpdate(model) {
}
export async function deleteCredential(doomed) {
let model = Credential.create(doomed);
const model = Credential.create(doomed);
if (model.id) {
let url = getUrl(`api/cloud/authz/${doomed.id}`);
let response = await axios.delete(url);
const url = getUrl(`api/cloud/authz/${doomed.id}`);
const response = await axios.delete(url);
if (response.status != 200) {
throw new Error("Delete failure.");
}
@@ -59,8 +59,8 @@ let identityProviders;
export async function getIdentityProviders() {
if (!identityProviders) {
let url = getUrl("authnz");
let response = await axios.get(url);
const url = getUrl("authnz");
const response = await axios.get(url);
if (response.status != 200) {
throw new Error("Unable to load identity providers");
}
@@ -85,10 +85,10 @@ export const getAnalysisRouter = Galaxy =>
},
_display_vue_helper: function(component, props = {}) {
let instance = Vue.extend(component);
let container = document.createElement("div");
const instance = Vue.extend(component);
const container = document.createElement("div");
this.page.display(container);
let vm = new instance(props).$mount(container);
const vm = new instance(props).$mount(container);
return vm;
},