reinstitutes api migration reversions (#31347)

This commit is contained in:
Jordan Reimer 2025-07-22 11:57:24 -06:00 committed by GitHub
parent 1fb006633b
commit c7102065c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 13 additions and 34 deletions

View File

@ -24,7 +24,6 @@ export default class App extends Application {
'version',
'custom-messages',
'api',
'store',
'capabilities',
],
},

View File

@ -23,10 +23,6 @@ export default class AuthRoute extends ClusterRouteBase {
@service store;
@service version;
get adapter() {
return this.store.adapterFor('application');
}
beforeModel() {
return super.beforeModel().then(() => {
return this.version.fetchFeatures();
@ -90,8 +86,8 @@ export default class AuthRoute extends ClusterRouteBase {
async fetchLoginSettings() {
try {
// TODO update with api service when api-client is updated
const response = await this.adapter.ajax(
const adapter = this.store.adapterFor('application');
const response = await adapter.ajax(
'/v1/sys/internal/ui/default-auth-methods',
'GET',
this.api.buildHeaders({ token: '' })
@ -113,13 +109,11 @@ export default class AuthRoute extends ClusterRouteBase {
async fetchMounts() {
try {
const { data } = await this.adapter.ajax(
'/v1/sys/internal/ui/mounts',
'GET',
const resp = await this.api.sys.internalUiListEnabledVisibleMounts(
this.api.buildHeaders({ token: '' })
);
// return a falsy value if the object is empty
return isEmptyValue(data.auth) ? null : data.auth;
return isEmptyValue(resp.auth) ? null : resp.auth;
} catch {
// catch error if there's a problem fetching mount data (i.e. invalid namespace)
return null;

View File

@ -30,7 +30,6 @@ export default class VaultClusterDashboardRoute extends Route.extend(ClusterRout
async model() {
const clusterModel = this.modelFor('vault.cluster');
const adapter = this.store.adapterFor('application');
const hasChroot = clusterModel?.hasChrootNamespace;
const replication =
hasChroot || clusterModel.replicationRedacted
@ -41,10 +40,9 @@ export default class VaultClusterDashboardRoute extends Route.extend(ClusterRout
};
const requests = [
this.getVaultConfiguration(hasChroot),
adapter.ajax('/v1/sys/internal/ui/mounts', 'GET').catch(() => ({})),
this.api.sys.internalUiListEnabledVisibleMounts().catch(() => ({})),
];
const [vaultConfiguration, { data }] = await Promise.all(requests);
const secret = data.secret;
const [vaultConfiguration, { secret }] = await Promise.all(requests);
const secretsEngines = this.api
.responseObjectToArray(secret, 'path')
.map((engine) => new SecretsEngineResource(engine));

View File

@ -8,16 +8,12 @@ import { service } from '@ember/service';
import SecretsEngineResource from 'vault/resources/secrets/engine';
import type ApiService from 'vault/services/api';
import type Store from '@ember-data/store';
export default class SecretsBackends extends Route {
@service declare readonly api: ApiService;
@service declare readonly store: Store;
async model() {
const adapter = this.store.adapterFor('application');
const { data } = await adapter.ajax('/v1/sys/internal/ui/mounts', 'GET');
const secret = data.secret;
const { secret } = await this.api.sys.internalUiListEnabledVisibleMounts();
return this.api.responseObjectToArray(secret, 'path').map((engine) => new SecretsEngineResource(engine));
}
}

View File

@ -25,7 +25,6 @@ export default class ConfigUiEngine extends Engine {
'version',
'custom-messages',
'api',
'store',
'capabilities',
],
};

View File

@ -8,23 +8,20 @@ import { service } from '@ember/service';
export default class LoginSettingsRoute extends Route {
@service api;
@service store;
async model() {
const adapter = this.store.adapterFor('application');
try {
const { data } = await adapter.ajax('/v1/sys/config/ui/login/default-auth', 'GET', {
data: { list: true },
});
const data = await this.api.sys.uiLoginDefaultAuthList(true);
const loginRules = this.api.keyInfoToArray(data);
return { loginRules };
} catch (e) {
if (e.httpStatus === 404) {
// If no login settings exist, return an empty array to render the empty state
// If no login settings exist, return an empty array to render the empty state
const error = await this.api.parseError(e);
if (error.status === 404) {
return { loginRules: [] };
}
// Otherwise fallback to the standard error template
throw e;
throw error;
}
}
}

View File

@ -15,7 +15,6 @@ import type RouterService from '@ember/routing/router-service';
import type ApiService from 'vault/services/api';
import type PaginationService from 'vault/services/pagination';
import type FlashMessageService from 'vault/services/flash-messages';
import type Store from '@ember-data/store';
import type { SearchSelectOption } from 'vault/app-types';
interface Args {
@ -27,7 +26,6 @@ export default class DestinationSyncPageComponent extends Component<Args> {
@service declare readonly api: ApiService;
@service declare readonly flashMessages: FlashMessageService;
@service declare readonly pagination: PaginationService;
@service declare readonly store: Store;
constructor(owner: unknown, args: Args) {
super(owner, args);
@ -50,11 +48,9 @@ export default class DestinationSyncPageComponent extends Component<Args> {
// unable to use built-in fetch functionality of SearchSelect since we need to filter by kv type
async fetchMounts() {
const adapter = this.store.adapterFor('application');
const mounts = [];
try {
const { data } = await adapter.ajax('/v1/sys/internal/ui/mounts', 'GET');
const secret = data.secret;
const { secret } = await this.api.sys.internalUiListEnabledVisibleMounts();
if (secret) {
for (const path in secret) {
const { type, options } = secret[path as keyof typeof secret];