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

UI: Handle deprecation router service from host #28281

Closed
Closed
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1d0f084
don't update the passed object directly
hashishaw Sep 4, 2024
e43dc68
replace hasRecordForId with peekRecord -- ember-data:deprecate-has-re…
hashishaw Sep 4, 2024
14681aa
fix deprecation ember-data:deprecate-has-record-for-id
hashishaw Sep 4, 2024
e14c6bf
update deprecation workflow
hashishaw Sep 4, 2024
118232d
config-ui engine - fix ember-engines.deprecation-router-service-from-…
hashishaw Sep 4, 2024
77e21db
open-api-explorer engine - fix ember-engines.deprecation-router-servi…
hashishaw Sep 4, 2024
9db8452
replication engine - fix ember-engines.deprecation-router-service-fro…
hashishaw Sep 4, 2024
501325f
kmip engine - fix ember-engines.deprecation-router-service-from-host
hashishaw Sep 4, 2024
b3c5348
k8s engine - fix ember-engines.deprecation-router-service-from-host
hashishaw Sep 4, 2024
5f073cf
ldap engine - fix ember-engines.deprecation-router-service-from-host
hashishaw Sep 4, 2024
e667a7e
kv engine - fix ember-engines.deprecation-router-service-from-host
hashishaw Sep 4, 2024
aafa633
pki engine - fix ember-engines.deprecation-router-service-from-host
hashishaw Sep 4, 2024
72737c4
sync engine - fix ember-engines.deprecation-router-service-from-host
hashishaw Sep 4, 2024
aa24601
remove todo
hashishaw Sep 4, 2024
775a9db
add engine-transition-to helper with tests
hashishaw Sep 5, 2024
7f5e9ee
update linked-block, fix sync engine
hashishaw Sep 5, 2024
d9a9f84
fix kmip transitions
hashishaw Sep 5, 2024
3f072f5
fix kv transition-to
hashishaw Sep 5, 2024
8d2c010
fix ldap transition-to
hashishaw Sep 5, 2024
812a5d8
fix pki transition-to
hashishaw Sep 5, 2024
9e83e8d
remove resolved deprecation from workflow
hashishaw Sep 5, 2024
8116b13
Revert "remove resolved deprecation from workflow"
hashishaw Sep 6, 2024
88c513f
rollback using app-router in replication
hashishaw Sep 6, 2024
4634e6c
Merge branch 'main' into ui/VAULT-30635/handle-ember-cli-deprecations
hashishaw Sep 10, 2024
ec281bb
Merge branch 'main' into ui/VAULT-30635/handle-ember-cli-deprecations
hashishaw Sep 11, 2024
e30ff7c
Merge branch 'ui/VAULT-30635/handle-ember-cli-deprecations' into ui/V…
hashishaw Sep 11, 2024
8cd1a8a
Merge branch 'main' into ui/VAULT-30635/deprecation-router-service-fr…
hashishaw Sep 17, 2024
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
2 changes: 1 addition & 1 deletion ui/app/adapters/named-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class NamedPathAdapter extends ApplicationAdapter {
const [store, { modelName }, snapshot] = arguments;
const name = snapshot.attr('name');
// throw error if user attempts to create a record with same name, otherwise POST request silently overrides (updates) the existing model
if (store.hasRecordForId(modelName, name)) {
if (store.peekRecord({ type: modelName, id: name }) !== null) {
throw new Error(`A record already exists with the name: ${name}`);
} else {
return this._saveRecord(...arguments);
Expand Down
26 changes: 17 additions & 9 deletions ui/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ export default class App extends Application {
engines = {
'config-ui': {
dependencies: {
services: ['auth', 'flash-messages', 'namespace', 'router', 'store', 'version', 'custom-messages'],
services: [
'auth',
'flash-messages',
'namespace',
{ 'app-router': 'router' },
'store',
'version',
'custom-messages',
],
},
},
'open-api-explorer': {
dependencies: {
services: ['auth', 'flash-messages', 'namespace', 'router', 'version'],
services: ['auth', 'flash-messages', 'namespace', { 'app-router': 'router' }, 'version'],
},
},
replication: {
Expand All @@ -30,7 +38,7 @@ export default class App extends Application {
'flash-messages',
'namespace',
'replication-mode',
'router',
'router', // TODO: resolve
'store',
'version',
'-portal',
Expand All @@ -49,7 +57,7 @@ export default class App extends Application {
'flash-messages',
'namespace',
'path-help',
'router',
{ 'app-router': 'router' },
'store',
'version',
'secret-mount-path',
Expand All @@ -61,15 +69,15 @@ export default class App extends Application {
},
kubernetes: {
dependencies: {
services: ['router', 'store', 'secret-mount-path', 'flash-messages'],
services: [{ 'app-router': 'router' }, 'store', 'secret-mount-path', 'flash-messages'],
externalRoutes: {
secrets: 'vault.cluster.secrets.backends',
},
},
},
ldap: {
dependencies: {
services: ['router', 'store', 'secret-mount-path', 'flash-messages', 'auth'],
services: [{ 'app-router': 'router' }, 'store', 'secret-mount-path', 'flash-messages', 'auth'],
externalRoutes: {
secrets: 'vault.cluster.secrets.backends',
},
Expand All @@ -83,7 +91,7 @@ export default class App extends Application {
'download',
'flash-messages',
'namespace',
'router',
{ 'app-router': 'router' },
'secret-mount-path',
'store',
'version',
Expand All @@ -102,7 +110,7 @@ export default class App extends Application {
'flash-messages',
'namespace',
'path-help',
'router',
{ 'app-router': 'router' },
'secret-mount-path',
'store',
'version',
Expand All @@ -116,7 +124,7 @@ export default class App extends Application {
},
sync: {
dependencies: {
services: ['flash-messages', 'flags', 'router', 'store', 'version'],
services: ['flash-messages', 'flags', { 'app-router': 'router' }, 'store', 'version'],
externalRoutes: {
kvSecretOverview: 'vault.cluster.secrets.backend.kv.secret.index',
clientCountOverview: 'vault.cluster.clients',
Expand Down
3 changes: 2 additions & 1 deletion ui/app/controllers/vault/cluster/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export default Controller.extend(DEFAULTS, {
}),

actions: {
initCluster(data) {
initCluster(payload) {
const data = { ...payload };
const isCloudSeal = !!this.model.sealType && this.model.sealType !== 'shamir';
if (data.secret_shares) {
const shares = parseInt(data.secret_shares, 10);
Expand Down
3 changes: 2 additions & 1 deletion ui/app/initializers/deprecation-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export function initialize() {
registerDeprecationHandler((message, options, next) => {
// filter deprecations that are scheduled to be removed in a specific version
// when upgrading or addressing deprecation warnings be sure to update this or remove if not needed
if (options?.until.includes('5.0') && options?.id.startsWith('ember-data')) {
if (options?.until.includes('6.0')) {
// ignore all deprecations for 6+
return;
}
next(message, options);
Expand Down
7 changes: 6 additions & 1 deletion ui/app/models/auth-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
import Model, { belongsTo } from '@ember-data/model';

export default Model.extend({
backend: belongsTo('auth-method', { inverse: 'authConfigs', readOnly: true, async: false }),
backend: belongsTo('auth-method', {
inverse: 'authConfigs',
readOnly: true,
async: false,
as: 'auth-config',
}),
});
21 changes: 10 additions & 11 deletions ui/config/deprecation-workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@

/* global self */
self.deprecationWorkflow = self.deprecationWorkflow || {};
//self.deprecationWorkflow.config = {
//throwOnUnhandled: true
//}
self.deprecationWorkflow.config = {
throwOnUnhandled: false,
};

self.deprecationWorkflow.config = {
// current output from deprecationWorkflow.flushDeprecations();
// deprecations that will not be removed until 5.0.0 are filtered by deprecation-filter initializer rather than silencing below
workflow: [
{ handler: 'silence', matchId: 'ember-data:model-save-promise' },
{ handler: 'silence', matchId: 'ember-engines.deprecation-camelized-engine-names' },
{ handler: 'silence', matchId: 'ember-engines.deprecation-router-service-from-host' },
{ handler: 'silence', matchId: 'ember-modifier.use-modify' },
{ handler: 'silence', matchId: 'ember-modifier.no-element-property' },
{ handler: 'silence', matchId: 'ember-modifier.no-args-property' },
{ handler: 'silence', matchId: 'ember-cli-mirage-config-routes-only-export' },
{ handler: 'silence', matchId: 'setting-on-hash' },
// ember-data
{ handler: 'silence', matchId: 'ember-data:deprecate-early-static' },
{ handler: 'silence', matchId: 'ember-data:deprecate-model-reopen' },
{ handler: 'silence', matchId: 'ember-data:deprecate-promise-proxies' },
{ handler: 'silence', matchId: 'ember-data:no-a-with-array-like' },
{ handler: 'silence', matchId: 'ember-data:deprecate-promise-many-array-behaviors' },
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { isAfter } from 'date-fns';
*/

export default class MessagesList extends Component {
@service router;
@service('app-router') router;
@service store;
@service flashMessages;
@service customMessages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import errorMessage from 'vault/utils/error-message';

export default class MessageDetails extends Component {
@service store;
@service router;
@service('app-router') router;
@service flashMessages;
@service customMessages;
@service namespace;
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/config-ui/addon/components/messages/page/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import errorMessage from 'vault/utils/error-message';

export default class MessagesList extends Component {
@service store;
@service router;
@service('app-router') router;
@service flashMessages;
@service namespace;
@service customMessages;
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/config-ui/addon/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class ConfigUiEngine extends Engine {
modulePrefix = modulePrefix;
Resolver = Resolver;
dependencies = {
services: ['auth', 'store', 'flash-messages', 'namespace', 'router', 'version', 'custom-messages'],
services: ['auth', 'store', 'flash-messages', 'namespace', 'app-router', 'version', 'custom-messages'],
};
}

Expand Down
14 changes: 13 additions & 1 deletion ui/lib/core/addon/components/linked-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,20 @@ import { encodePath } from 'vault/utils/path-encoding-helpers';
*/

export default class LinkedBlockComponent extends Component {
@service('app-router') appRouter;
@service router;

transitionTo(...args) {
// when this component is used within an engine
// appRouter will be available and should be used
// otherwise we use the regular router service
if (this.appRouter) {
this.appRouter.transitionTo(...args);
} else {
this.router.transitionTo(...args);
}
}

@action
onClick(event) {
if (!this.args.disabled) {
Expand Down Expand Up @@ -56,7 +68,7 @@ export default class LinkedBlockComponent extends Component {
targetRoute = `${this.args.linkPrefix}.${targetRoute}`;
this.args.params[0] = targetRoute;
}
this.router.transitionTo(...params);
this.transitionTo(...params);
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions ui/lib/core/addon/helpers/engine-transition-to.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/

import Helper from '@ember/component/helper';
import { service } from '@ember/service';

// this is a helper specifically for routable engines, and assumes that the parent's router is mounted as `app-router`.
export default class EngineTransitionTo extends Helper {
@service('app-router') router;

compute(positional, { external = false }) {
if (external) {
return () => this.router.transitionToExternal(...positional);
}
return () => this.router.transitionTo(...positional);
}
}
1 change: 1 addition & 0 deletions ui/lib/core/app/helpers/engine-transition-to.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably need the copyright head on this file.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'core/helpers/engine-transition-to';
2 changes: 1 addition & 1 deletion ui/lib/kmip/addon/controllers/credentials/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { action } from '@ember/object';

export default class CredentialsShowController extends Controller {
@service flashMessages;
@service router;
@service('app-router') router;

@action
async revokeCredentials() {
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/kmip/addon/controllers/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { action } from '@ember/object';

export default class RoleController extends Controller {
@service flashMessages;
@service router;
@service('app-router') router;

@action
async deleteRole() {
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/kmip/addon/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Eng = Engine.extend({
'flash-messages',
'namespace',
'path-help',
'router',
'app-router',
'store',
'version',
'secret-mount-path',
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/kmip/addon/templates/configure.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
</PageHeader>
<EditForm
@model={{this.model}}
@onSave={{transition-to "vault.cluster.secrets.backend.kmip.configuration"}}
@onSave={{engine-transition-to "vault.cluster.secrets.backend.kmip.configuration"}}
@cancelLinkParams={{array "configuration"}}
/>
2 changes: 1 addition & 1 deletion ui/lib/kmip/addon/templates/credentials/generate.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PageHeader>
<EditForm
@model={{this.model}}
@onSave={{transition-to "vault.cluster.secrets.backend.kmip.credentials.show" this.model.id}}
@onSave={{engine-transition-to "vault.cluster.secrets.backend.kmip.credentials.show" this.model.id}}
@callOnSaveAfterRender={{true}}
@successMessage={{concat "Successfully generated credentials from role:" this.role "!"}}
@cancelLinkParams={{array "credentials.index"}}
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/kmip/addon/templates/role/edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
</PageHeader>
<EditFormKmipRole
@model={{this.model}}
@onSave={{transition-to "vault.cluster.secrets.backend.kmip.role" this.scope this.role}}
@onSave={{engine-transition-to "vault.cluster.secrets.backend.kmip.role" this.scope this.role}}
@cancelLinkParams={{array "role" this.scope this.role}}
/>
2 changes: 1 addition & 1 deletion ui/lib/kmip/addon/templates/scope/roles/create.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
<EditFormKmipRole
@model={{this.model}}
@mode="create"
@onSave={{transition-to "vault.cluster.secrets.backend.kmip.scope.roles" this.scope}}
@onSave={{engine-transition-to "vault.cluster.secrets.backend.kmip.scope.roles" this.scope}}
@cancelLinkParams={{array "scope.roles" this.scope}}
/>
2 changes: 1 addition & 1 deletion ui/lib/kmip/addon/templates/scopes/create.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
</PageHeader>
<EditForm
@model={{this.model}}
@onSave={{transition-to "vault.cluster.secrets.backend.kmip.scopes.index"}}
@onSave={{engine-transition-to "vault.cluster.secrets.backend.kmip.scopes.index"}}
@cancelLinkParams={{array "scopes.index"}}
/>
2 changes: 1 addition & 1 deletion ui/lib/kubernetes/addon/components/page/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import errorMessage from 'vault/utils/error-message';
* @param {object} model - config model that contains kubernetes configuration
*/
export default class ConfigurePageComponent extends Component {
@service router;
@service('app-router') router;
@service store;

@tracked inferredState;
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/kubernetes/addon/components/page/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import timestamp from 'vault/utils/timestamp';
*/
export default class CredentialsPageComponent extends Component {
@service store;
@service router;
@service('app-router') router;

@tracked ttl = '';
@tracked clusterRoleBinding = false;
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/kubernetes/addon/components/page/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { action } from '@ember/object';
*/

export default class OverviewPageComponent extends Component {
@service router;
@service('app-router') router;

@tracked selectedRole = null;
@tracked roleOptions = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import errorMessage from 'vault/utils/error-message';
*/

export default class CreateAndEditRolePageComponent extends Component {
@service router;
@service('app-router') router;
@service flashMessages;

@tracked roleRulesTemplates;
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/kubernetes/addon/components/page/role/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import errorMessage from 'vault/utils/error-message';
*/

export default class RoleDetailsPageComponent extends Component {
@service router;
@service('app-router') router;
@service flashMessages;

get extraFields() {
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/kubernetes/addon/components/page/roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import keys from 'core/utils/key-codes';
*/
export default class RolesPageComponent extends Component {
@service flashMessages;
@service router;
@service('app-router') router;
@tracked query;
@tracked roleToDelete = null;

Expand Down
2 changes: 1 addition & 1 deletion ui/lib/kubernetes/addon/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class KubernetesEngine extends Engine {
modulePrefix = modulePrefix;
Resolver = Resolver;
dependencies = {
services: ['router', 'store', 'secret-mount-path', 'flash-messages'],
services: ['app-router', 'store', 'secret-mount-path', 'flash-messages'],
externalRoutes: ['secrets'],
};
}
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/kubernetes/addon/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Route from '@ember/routing/route';
import { service } from '@ember/service';

export default class KubernetesRoute extends Route {
@service router;
@service('app-router') router;

redirect() {
this.router.transitionTo('vault.cluster.secrets.backend.kubernetes.overview');
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/kubernetes/addon/routes/roles/role/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Route from '@ember/routing/route';
import { service } from '@ember/service';

export default class KubernetesRoleRoute extends Route {
@service router;
@service('app-router') router;

redirect() {
this.router.transitionTo('vault.cluster.secrets.backend.kubernetes.roles.role.details');
Expand Down
Loading
Loading