From c7102065c8999423f183f7d367d9e4e90ac06266 Mon Sep 17 00:00:00 2001 From: Jordan Reimer Date: Tue, 22 Jul 2025 11:57:24 -0600 Subject: [PATCH] reinstitutes api migration reversions (#31347) --- ui/app/app.js | 1 - ui/app/routes/vault/cluster/auth.js | 14 ++++---------- ui/app/routes/vault/cluster/dashboard.js | 6 ++---- ui/app/routes/vault/cluster/secrets/backends.ts | 6 +----- ui/lib/config-ui/addon/engine.js | 1 - .../config-ui/addon/routes/login-settings/index.js | 13 +++++-------- .../secrets/page/destinations/destination/sync.ts | 6 +----- 7 files changed, 13 insertions(+), 34 deletions(-) diff --git a/ui/app/app.js b/ui/app/app.js index a8f2064b6c..863b96d6b6 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -24,7 +24,6 @@ export default class App extends Application { 'version', 'custom-messages', 'api', - 'store', 'capabilities', ], }, diff --git a/ui/app/routes/vault/cluster/auth.js b/ui/app/routes/vault/cluster/auth.js index 358a94f671..8fdc715c47 100644 --- a/ui/app/routes/vault/cluster/auth.js +++ b/ui/app/routes/vault/cluster/auth.js @@ -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; diff --git a/ui/app/routes/vault/cluster/dashboard.js b/ui/app/routes/vault/cluster/dashboard.js index b4b33386a8..fbaffb4614 100644 --- a/ui/app/routes/vault/cluster/dashboard.js +++ b/ui/app/routes/vault/cluster/dashboard.js @@ -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)); diff --git a/ui/app/routes/vault/cluster/secrets/backends.ts b/ui/app/routes/vault/cluster/secrets/backends.ts index e98382fb41..e6b5f877a1 100644 --- a/ui/app/routes/vault/cluster/secrets/backends.ts +++ b/ui/app/routes/vault/cluster/secrets/backends.ts @@ -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)); } } diff --git a/ui/lib/config-ui/addon/engine.js b/ui/lib/config-ui/addon/engine.js index ddb7d4912c..6f2a9e9de9 100644 --- a/ui/lib/config-ui/addon/engine.js +++ b/ui/lib/config-ui/addon/engine.js @@ -25,7 +25,6 @@ export default class ConfigUiEngine extends Engine { 'version', 'custom-messages', 'api', - 'store', 'capabilities', ], }; diff --git a/ui/lib/config-ui/addon/routes/login-settings/index.js b/ui/lib/config-ui/addon/routes/login-settings/index.js index d3230ed48b..3fca569986 100644 --- a/ui/lib/config-ui/addon/routes/login-settings/index.js +++ b/ui/lib/config-ui/addon/routes/login-settings/index.js @@ -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; } } } diff --git a/ui/lib/sync/addon/components/secrets/page/destinations/destination/sync.ts b/ui/lib/sync/addon/components/secrets/page/destinations/destination/sync.ts index c6c51c1e7e..a088755a6b 100644 --- a/ui/lib/sync/addon/components/secrets/page/destinations/destination/sync.ts +++ b/ui/lib/sync/addon/components/secrets/page/destinations/destination/sync.ts @@ -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 { @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 { // 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];