style: 💄 Update if curly brace statements (#3023)

This commit is contained in:
Zhihe Li authored and GitHub committed 2025-10-13 10:53:21 -04:00
1 parent bf134072e5
commit 35ccaeba56
24 files changed
+51 -27

No files matched your search

+1
View File
@@ -26,6 +26,7 @@ module.exports = {
browser: true,
},
rules: {
curly: ['error', 'multi-line', 'consistent'],
'ember/no-get': 'off',
'ember/no-get-with-default': 'off',
'ember/no-computed-properties-in-native-classes': 'off',
+2 -1
View File
@@ -59,10 +59,11 @@ export default class RoleAbility extends ModelAbility {
const type = this.model.constructor.modelName;
const typeIsValid =
type === 'user' || type === 'group' || type === 'managed-group';
if (!typeIsValid)
if (!typeIsValid) {
throw new InvalidRolePrincipalTypeError(
`Expected a role principal of type 'user', 'group', or 'managed-group'. Got '${type}'.`,
);
}
return this.can.can(`read ${type}`, this.model);
}
}
+2 -1
View File
@@ -98,8 +98,9 @@ export default class AccountSerializer extends ApplicationSerializer {
serialized.attributes = {};
}
// New record case
if (password && snapshot?.record?.isNew)
if (password && snapshot?.record?.isNew) {
serialized.attributes.password = password;
}
// Set password custom method
if (snapshot?.adapterOptions?.method === 'set-password') {
serialized = this.serializeForSetPassword(snapshot, password);
@@ -28,8 +28,9 @@ export default class CredentialStoreSerializer extends ApplicationSerializer {
if (
!serialized.attributes?.client_certificate_key &&
serialized.attributes?.client_certificate
)
) {
delete serialized.attributes.client_certificate_key;
}
}
return serialized;
}
@@ -76,9 +76,10 @@ export default class StorageBucketSerializer extends ApplicationSerializer {
// This deletes any fields that don't belong to the record's credential type
if (options.isNestedAttribute && json.attributes) {
// The key must be included in the fieldsByType list above
if (!fieldsByCredentialType[credentialType].includes(key))
if (!fieldsByCredentialType[credentialType].includes(key)) {
// API requires these fields to be null
json.attributes[key] = null;
}
}
//json.secrets is only present, if there are any updates to the secret fields
+4 -2
View File
@@ -33,16 +33,18 @@ export default class TargetSerializer extends ApplicationSerializer {
const injectedApplicationCredentialSourceIDs =
snapshot?.adapterOptions?.injectedApplicationCredentialSourceIDs;
if (brokeredCredentialSourceIDs)
if (brokeredCredentialSourceIDs) {
serialized = this.serializeWithBrokeredCredentialSources(
snapshot,
brokeredCredentialSourceIDs,
);
if (injectedApplicationCredentialSourceIDs)
}
if (injectedApplicationCredentialSourceIDs) {
serialized = this.serializeWithInjectedApplicationCredentialSources(
snapshot,
injectedApplicationCredentialSourceIDs,
);
}
if (isNew && serialized?.with_aliases) {
// API expects scope id along with every alias value
+2 -1
View File
@@ -18,8 +18,9 @@ export default class UserSerializer extends ApplicationSerializer {
serialize(snapshot) {
let serialized = super.serialize(...arguments);
const accountIDs = snapshot?.adapterOptions?.accountIDs;
if (accountIDs)
if (accountIDs) {
serialized = this.serializewithAccounts(snapshot, accountIDs);
}
return serialized;
}
+2 -1
View File
@@ -542,10 +542,11 @@ function routes() {
session.update({
status: pickRandomStatusString(),
});
if (session.id.split('-').pop() % 2)
if (session.id.split('-').pop() % 2) {
session.update({
userId: 'authenticateduser',
});
}
});
}
if (recursive && scope_id === 'global') {
+1
View File
@@ -26,6 +26,7 @@ module.exports = {
browser: true,
},
rules: {
curly: ['error', 'multi-line', 'consistent'],
'ember/no-get': 'off',
'ember/no-get-with-default': 'off',
'ember/no-computed-properties-in-native-classes': 'off',
+1
View File
@@ -26,6 +26,7 @@ module.exports = {
browser: true,
},
rules: {
curly: ['error', 'multi-line', 'consistent'],
'ember/no-get': 'off',
'ember/no-get-with-default': 'off',
'ember/no-computed-properties-in-native-classes': 'off',
@@ -129,8 +129,9 @@ class RouteResourceFilter extends EmberObject {
const filterKey = `filter-${name}`;
// If the route has no query params specified yet, declare them.
if (!Object.keys(routeClass.queryParams).length)
if (!Object.keys(routeClass.queryParams).length) {
routeClass.queryParams = {};
}
// If the route has no resource filters list specified yet, create one.
if (!routeClass.resourceFilterParams) routeClass.resourceFilterParams = [];
+1
View File
@@ -26,6 +26,7 @@ module.exports = {
browser: true,
},
rules: {
curly: ['error', 'multi-line', 'consistent'],
'ember/no-jquery': 'error',
'ember/no-new-mixins': 0,
'ember/no-get': 'off',
+1
View File
@@ -20,6 +20,7 @@ module.exports = {
es2021: true,
},
rules: {
curly: ['error', 'multi-line', 'consistent'],
'no-empty-pattern': ['error', { allowObjectPatternsAsParameters: true }],
},
overrides: [
+8 -9
View File
@@ -60,16 +60,15 @@ export class OrgsPage extends BaseResourcePage {
async chooseScopeFromDropdown(fromScope, toScope) {
await this.page
.getByRole('button', { name: fromScope, exact: true })
.click()
await this.page
.getByRole('option', { name: toScope, exact: true })
.click()
.click();
await this.page.getByRole('option', { name: toScope, exact: true }).click();
await expect(
this.page.getByRole('button', { name: toScope, exact: true })
).toBeVisible()
if (toScope != 'Global')
this.page.getByRole('button', { name: toScope, exact: true }),
).toBeVisible();
if (toScope !== 'Global') {
await expect(
this.page.getByRole('link', { name: toScope, exact: true })
).toBeVisible()
this.page.getByRole('link', { name: toScope, exact: true }),
).toBeVisible();
}
}
}
+4 -2
View File
@@ -44,12 +44,14 @@ export class TargetsPage extends BaseResourcePage {
await this.page.getByLabel('Name').fill(targetName);
await this.page.getByLabel('Description').fill('This is an automated test');
if (targetType) {
if (targetTypeLabel)
if (targetTypeLabel) {
await this.page
.getByRole('group', { name: 'Type' })
.getByLabel(targetTypeLabel)
.click();
else throw new Error(`Unsupported target type: ${targetType}`);
} else {
throw new Error(`Unsupported target type: ${targetType}`);
}
}
if (address) await this.page.getByLabel('Target Address').fill(address);
if (port) await this.page.getByLabel('Default Port').fill(port);
+1
View File
@@ -26,6 +26,7 @@ module.exports = {
browser: true,
},
rules: {
curly: ['error', 'multi-line', 'consistent'],
'ember/no-get': 'off',
'ember/no-get-with-default': 'off',
'ember/no-computed-properties-in-native-classes': 'off',
@@ -56,10 +56,11 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari
async cancel(credentialLibrary) {
const { isNew } = credentialLibrary;
credentialLibrary.rollbackAttributes();
if (isNew)
if (isNew) {
await this.router.transitionTo(
'scopes.scope.credential-stores.credential-store.credential-libraries',
);
}
}
/**
@@ -56,10 +56,11 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsIndexC
async cancel(credential) {
const { isNew } = credential;
credential.rollbackAttributes();
if (isNew)
if (isNew) {
await this.router.transitionTo(
'scopes.scope.credential-stores.credential-store.credentials',
);
}
}
/**
@@ -40,9 +40,10 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsHostSetCreateAndA
cancel(host) {
const { isNew } = host;
host.rollbackAttributes();
if (isNew)
if (isNew) {
this.router.transitionTo(
'scopes.scope.host-catalogs.host-catalog.host-sets.host-set.hosts',
);
}
}
}
@@ -57,10 +57,11 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsIndexController e
cancel(hostSet) {
const { isNew } = hostSet;
hostSet.rollbackAttributes();
if (isNew)
if (isNew) {
this.router.transitionTo(
'scopes.scope.host-catalogs.host-catalog.host-sets',
);
}
}
/**
@@ -56,8 +56,9 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsIndexController exte
cancel(host) {
const { isNew } = host;
host.rollbackAttributes();
if (isNew)
if (isNew) {
this.router.transitionTo('scopes.scope.host-catalogs.host-catalog.hosts');
}
}
/**
+2 -1
View File
@@ -24,8 +24,9 @@ export default class OnboardingRoute extends Route {
scope_id: 'global',
query: { filters: { scope_id: [{ equals: 'global' }] } },
});
if (!this.session.isAuthenticated || orgs.length)
if (!this.session.isAuthenticated || orgs.length) {
this.router.transitionTo('index');
}
}
/**
@@ -16,8 +16,9 @@ export default class ScopesScopeAuthenticateRoute extends Route {
// =methods
beforeModel() {
if (this.session.isAuthenticated)
if (this.session.isAuthenticated) {
this.router.transitionTo('scopes.scope.index');
}
}
/**
+1
View File
@@ -26,6 +26,7 @@ module.exports = {
browser: true,
},
rules: {
curly: ['error', 'multi-line', 'consistent'],
'ember/no-get': 'off',
'ember/no-get-with-default': 'off',
'ember/no-computed-properties-in-native-classes': 'off',