From 081db3a240ace8c66d073eb185c6982754b69bdb Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Thu, 3 Dec 2020 16:00:22 -0700 Subject: [PATCH] Ember-cli upgrade from ~3.8 to ~3.20 (#9972) * Update ember-cli to ~3.20 * Remove bad optional-feature * Remove ember-fetch dep * re-install ember-fetch * update model fragments pr * update ember model fragments correct package name * update ember composable helpers to solve array helper error * update ember-concurrency * add back engine dependencies, automatically removed during ember-cli-upgrade * make author-form-options component js file otherwise error * for now comment out withTestWaiter * add eslint-node and fix if not with unless in templates * fix linting for tab index of false is now -1 and add type button to all buttons without types * fix href errors for linting, likely have to come back and fix * using eslint fix flag to fix all this.gets * ember modules codemode removed files that had module twice, will fix in next commit * finish codemode ember-data-codemod needed to rename const model * more this.get removal codemode did not work * cont. removal of this.get * stop mixin rules until figure out how to reconfig them all * smaller eslint ignores * get codemode * testing app small fixes to bring it back after all the changes * small changes to eslint * test removal of getProperties * fix issue with baseKey because value could be unknown needed to add a question mark in nested get * smaller linting fixes * get nested fixes * small linting error fixes * small linting changes * working through more small linting changes * another round of linting modifications * liniting fixes * ember module codemod * quinit dom codemod * angle bracket codemod * discovered that components must have js files * ran all codemods this is all that's left * small changes to fix get needs two object, should not have been using get. * fix issue with one input in form field * fun times with set and onChange from oninput * fix issue with model not being passed through on secret-edit-display * fix issue with yarn run test not working, revert without npm run all * linting and small fix when loading without a selectAuthBackend * fix failing test with ui-wizard issue * fix test failure due to model not being asked for correctly with new changes, probably run into this more. * fix issue with component helper and at props specific to wizard * rename log to clilog due to conflict with new eslint rule * small changes for test failures * component helper at fixes * Revert to old component style something with new one broke this and can't figure it out for now * small fishy smelling test fixes will revisit * small test changes * more small test changes, appears upgrade treats spaces differently * comment out code and test that no longer seems relevant but confirm * clean run on component test though still some potential timing issues on ui-console test * fixing one auth test issue and timing issue on enable-test * small mods * fix this conditional check from upgrade * linting fixes after master merge * package updates using yarn upgrade-interactive * update libraries that did not effect any of the test failures. * update ember truth helpers library * settling tests * Fix ui-panel control group output * fix features selection test failures * Fix auth tests (x-vault-token) * fix shared test * fix issue with data null on backend * Revert "Fix auth tests (x-vault-token)" This reverts commit 89cb174b2f1998efa56d9604d14131415ae65d6f. * Fix auth tests (x-vault-token) without updating this.set * Update redirect-to tests * fix wrapped token test * skip some flaky test * fix issue with href and a tags vs buttons * fix linting * updates to get tests running (#10409) * yarn isntall * increasing resource_class * whoops * trying large * back to xlarge * Fix param issue on transform item routes * test fixes * settle on policies (old) test * fix browserstack test warning and skips of test confirmed worked * Fix redirect-to test * skips * fix transformation test and skip some kmip * Skip tests * Add meep marker to remaining failing tests * Skip test with failing component * rever skip on secret-create test * Skip piece of test that fails due to navigation-input * fix settings test where can and skip in others after confirming * fix circle ci test failures * ssh role settle * Fix navigate-input and add settled to test * Remove extra import * secret cubbyhole and alicloud * Add settled to gcpkms test * settles on redirect to test * Bump browserstack test resource to large * Update browserstack resource size to xlarge * update todos * add back in withTestWaiter * try and fix credentials conditional action added comment instead * Update volatile computed properies to get functions * this step was never reached and we never defined secretType anywhere so I removed * add settled to policy old test * Fix navigate-input on policies and leases * replace ssh test with no var hoping that helps and add settled to other failing tests, unskip console tests * kmip, transit, role test remove a skip and add in settled * fix hover copy button, had to remove some testing functionality * Remove private router service * remove skip on control ssh and ui panel, fix search select by restructuring how to read the error * final bit of working through skipped test * Replace clearNonGlobalModels by linking directly to namespace with href-to * Remove unused var * Fix role-ssh id bug by updating form-field-from-model to form-field-group-loop * Fix transit create id would not update * Update option toggle selector for ssh-role * Fix ssh selector * cleanup pt1 * small clean up * cleanup part2 * Fix computed on pricing-metrics-form * small cleanup based on chelseas comments. Co-authored-by: Chelsea Shaw Co-authored-by: Sarah Thompson --- .circleci/config.yml | 4 +- .../config/jobs/test-ui-browserstack.yml | 2 +- .circleci/config/jobs/test-ui.yml | 2 +- ui/.editorconfig | 1 - ui/.eslintrc.js | 25 +- ui/MODULE_REPORT.md | 224 + ui/app/adapters/application.js | 18 +- ui/app/adapters/auth-config/_base.js | 2 +- ui/app/adapters/auth-method.js | 4 +- ui/app/adapters/capabilities.js | 4 +- ui/app/adapters/cluster.js | 6 +- ui/app/adapters/kmip/base.js | 2 +- ui/app/adapters/pki-config.js | 4 +- ui/app/adapters/secret-v2-version.js | 4 +- ui/app/adapters/transit-key.js | 11 +- ui/app/app.js | 24 +- ui/app/components/auth-config-form/config.js | 4 +- ui/app/components/auth-config-form/options.js | 4 +- ui/app/components/auth-form-options.js | 3 + ui/app/components/auth-form.js | 31 +- ui/app/components/auth-info.js | 21 +- ui/app/components/b64-toggle.js | 18 +- ui/app/components/config-pki-ca.js | 28 +- ui/app/components/config-pki.js | 6 +- ui/app/components/console/command-input.js | 8 +- .../components/console/log-error-with-html.js | 3 + ui/app/components/console/log-list.js | 6 +- ui/app/components/console/log-object.js | 2 +- ui/app/components/console/ui-panel.js | 16 +- ui/app/components/control-group-success.js | 10 +- ui/app/components/control-group.js | 32 +- ui/app/components/flash-message.js | 4 +- ui/app/components/generate-credentials.js | 38 +- ui/app/components/generated-item.js | 6 +- ui/app/components/home-link.js | 2 +- ui/app/components/identity/_popup-base.js | 6 +- ui/app/components/identity/edit-form.js | 8 +- ui/app/components/identity/entity-nav.js | 3 + ui/app/components/identity/item-details.js | 4 +- ui/app/components/identity/lookup-input.js | 30 +- ui/app/components/identity/popup-members.js | 4 +- ui/app/components/identity/popup-policy.js | 2 +- ui/app/components/json-editor.js | 2 +- ui/app/components/kv-object-editor.js | 18 +- ui/app/components/license-info.js | 7 +- ui/app/components/mount-accessor-select.js | 8 +- ui/app/components/mount-backend-form.js | 10 +- ui/app/components/namespace-link.js | 8 +- ui/app/components/namespace-picker.js | 30 +- ui/app/components/pgp-file.js | 8 +- ui/app/components/pki-cert-show.js | 2 +- ui/app/components/pricing-metrics-dates.js | 6 +- ui/app/components/radial-progress.js | 10 +- ui/app/components/role-aws-edit.js | 11 +- ui/app/components/role-edit.js | 38 +- ui/app/components/role-ssh-edit.js | 2 +- ui/app/components/secret-edit.js | 8 +- ui/app/components/secret-link.js | 2 +- ui/app/components/shamir-progress.js | 2 +- ui/app/components/splash-page.js | 2 +- ui/app/components/status-menu.js | 8 +- ui/app/components/text-file.js | 8 +- ui/app/components/tool-actions-form.js | 26 +- ui/app/components/transform-edit-base.js | 15 +- ui/app/components/transform-list-item.js | 2 +- ui/app/components/transform-role-edit.js | 10 +- ui/app/components/transformation-edit.js | 15 +- ui/app/components/transit-edit.js | 26 +- ui/app/components/transit-key-actions.js | 33 +- ui/app/components/ui-wizard.js | 33 +- ui/app/components/wizard-content.js | 95 +- .../components/wizard/features-selection.js | 23 +- ui/app/components/wizard/mounts-wizard.js | 32 +- ui/app/components/wrap-ttl.js | 10 +- ui/app/controllers/application.js | 6 +- ui/app/controllers/vault.js | 6 +- ui/app/controllers/vault/cluster.js | 15 +- .../vault/cluster/access/identity/create.js | 2 +- .../vault/cluster/access/identity/index.js | 8 +- .../vault/cluster/access/leases/list.js | 15 +- .../vault/cluster/access/leases/show.js | 6 +- .../vault/cluster/access/methods.js | 6 +- .../vault/cluster/access/namespaces/create.js | 2 +- .../vault/cluster/access/namespaces/index.js | 2 +- ui/app/controllers/vault/cluster/auth.js | 2 +- ui/app/controllers/vault/cluster/init.js | 6 +- .../vault/cluster/policies/create.js | 2 +- .../vault/cluster/policies/index.js | 16 +- .../cluster/secrets/backend/configuration.js | 2 +- .../vault/cluster/secrets/backend/create.js | 2 +- .../vault/cluster/secrets/backend/edit.js | 2 +- .../vault/cluster/secrets/backend/list.js | 11 +- .../vault/cluster/secrets/backend/show.js | 2 +- .../vault/cluster/secrets/backend/sign.js | 8 +- .../vault/cluster/secrets/backends.js | 10 +- .../settings/configure-secret-backend.js | 32 +- .../cluster/settings/mount-secret-backend.js | 2 +- .../vault/cluster/settings/seal.js | 2 +- ui/app/controllers/vault/cluster/unseal.js | 12 +- ui/app/helpers/-date-base.js | 3 +- ui/app/helpers/has-permission.js | 2 +- ui/app/helpers/nav-to-route.js | 2 +- ui/app/lib/attach-capabilities.js | 3 +- ui/app/lib/control-group-error.js | 4 +- ui/app/macros/maybe-query-record.js | 4 +- ui/app/mixins/backend-crumb.js | 2 +- ui/app/mixins/cluster-route.js | 2 +- ui/app/mixins/focus-on-insert.js | 4 +- ui/app/mixins/model-boundary-route.js | 8 +- ui/app/mixins/policy-edit-controller.js | 8 +- ui/app/models/auth-config.js | 5 +- ui/app/models/auth-config/aws/client.js | 4 +- ui/app/models/auth-config/aws/tidy.js | 4 +- ui/app/models/auth-config/azure.js | 6 +- ui/app/models/auth-config/gcp.js | 6 +- ui/app/models/auth-config/github.js | 6 +- ui/app/models/auth-config/jwt.js | 6 +- ui/app/models/auth-config/kubernetes.js | 6 +- ui/app/models/auth-config/ldap.js | 6 +- ui/app/models/auth-config/okta.js | 6 +- ui/app/models/auth-config/radius.js | 6 +- ui/app/models/auth-method.js | 18 +- ui/app/models/aws-credential.js | 16 +- ui/app/models/capabilities.js | 11 +- ui/app/models/cluster.js | 13 +- ui/app/models/control-group-config.js | 5 +- ui/app/models/control-group.js | 6 +- ui/app/models/identity/_base.js | 8 +- ui/app/models/identity/entity-alias.js | 3 +- ui/app/models/identity/entity-merge.js | 3 +- ui/app/models/identity/entity.js | 4 +- ui/app/models/identity/group-alias.js | 4 +- ui/app/models/identity/group.js | 14 +- ui/app/models/kmip/ca.js | 5 +- ui/app/models/kmip/config.js | 8 +- ui/app/models/kmip/credential.js | 7 +- ui/app/models/kmip/role.js | 14 +- ui/app/models/kmip/scope.js | 7 +- ui/app/models/lease.js | 5 +- ui/app/models/license.js | 5 +- ui/app/models/metrics/activity.js | 10 +- ui/app/models/metrics/config.js | 6 +- ui/app/models/mount-config.js | 2 +- ui/app/models/mount-options.js | 2 +- ui/app/models/namespace.js | 8 +- ui/app/models/node.js | 5 +- ui/app/models/path-filter-config.js | 5 +- ui/app/models/pki-ca-certificate-sign.js | 6 +- ui/app/models/pki-ca-certificate.js | 8 +- ui/app/models/pki-certificate-sign.js | 7 +- ui/app/models/pki-certificate.js | 30 +- ui/app/models/pki-config.js | 6 +- ui/app/models/policy.js | 10 +- ui/app/models/policy/egp.js | 4 +- ui/app/models/policy/rgp.js | 4 +- ui/app/models/raft-join.js | 5 +- ui/app/models/replication-attributes.js | 22 +- ui/app/models/replication-mode.js | 5 +- ui/app/models/role-aws.js | 6 +- ui/app/models/role-jwt.js | 5 +- ui/app/models/role-pki.js | 7 +- ui/app/models/role-ssh.js | 24 +- ui/app/models/secret-engine.js | 30 +- ui/app/models/secret-v2-version.js | 6 +- ui/app/models/secret-v2.js | 4 +- ui/app/models/secret.js | 11 +- ui/app/models/server.js | 5 +- ui/app/models/ssh-otp-credential.js | 13 +- ui/app/models/ssh-sign.js | 7 +- ui/app/models/transform.js | 16 +- ui/app/models/transform/alphabet.js | 9 +- ui/app/models/transform/role.js | 8 +- ui/app/models/transform/template.js | 8 +- ui/app/models/transform/transformation.js | 7 - ui/app/models/transit-key.js | 48 +- ui/app/resolver.js | 3 - ui/app/router.js | 14 +- ui/app/routes/application.js | 16 +- ui/app/routes/vault.js | 2 +- ui/app/routes/vault/cluster.js | 35 +- .../cluster/access/control-group-accessor.js | 10 +- .../access/control-groups-configure.js | 10 +- .../vault/cluster/access/control-groups.js | 10 +- .../routes/vault/cluster/access/identity.js | 4 +- .../cluster/access/identity/aliases/show.js | 4 +- .../vault/cluster/access/identity/show.js | 4 +- .../vault/cluster/access/leases/list.js | 2 +- ui/app/routes/vault/cluster/access/method.js | 4 +- .../vault/cluster/access/method/section.js | 5 +- .../vault/cluster/access/namespaces/create.js | 10 +- .../vault/cluster/access/namespaces/index.js | 10 +- ui/app/routes/vault/cluster/auth.js | 10 +- ui/app/routes/vault/cluster/init.js | 4 +- ui/app/routes/vault/cluster/policies.js | 8 +- .../routes/vault/cluster/policies/create.js | 8 +- ui/app/routes/vault/cluster/policies/index.js | 6 +- ui/app/routes/vault/cluster/policy.js | 10 +- .../cluster/replication-dr-promote/details.js | 2 +- .../cluster/replication-dr-promote/index.js | 2 +- .../cluster/secrets/backend/configuration.js | 8 +- .../cluster/secrets/backend/create-root.js | 6 +- .../vault/cluster/secrets/backend/list.js | 4 +- .../cluster/secrets/backend/secret-edit.js | 4 +- .../settings/auth/configure/section.js | 4 +- .../settings/configure-secret-backend.js | 4 +- .../configure-secret-backend/section.js | 4 +- ui/app/routes/vault/cluster/tools/index.js | 2 +- ui/app/routes/vault/cluster/unseal.js | 4 +- ui/app/serializers/application.js | 6 +- ui/app/serializers/cluster.js | 4 +- ui/app/serializers/config.js | 4 +- ui/app/serializers/control-group.js | 4 +- ui/app/serializers/identity/entity.js | 4 +- ui/app/serializers/identity/group.js | 4 +- ui/app/serializers/lease.js | 4 +- ui/app/serializers/node.js | 4 +- ui/app/serializers/path-filter-config.js | 4 +- ui/app/serializers/pki-certificate.js | 4 +- ui/app/serializers/pki-config.js | 4 +- ui/app/serializers/replication-attributes.js | 4 +- ui/app/serializers/secret-v2.js | 4 +- ui/app/serializers/secret.js | 2 +- ui/app/serializers/ssh.js | 4 +- ui/app/serializers/transit-key.js | 8 +- ui/app/services/auth.js | 63 +- ui/app/services/console.js | 18 +- ui/app/services/control-group.js | 12 +- ui/app/services/csp-event.js | 4 +- ui/app/services/namespace.js | 4 +- ui/app/services/path-help.js | 4 +- ui/app/services/permissions.js | 10 +- ui/app/services/replication-mode.js | 2 +- ui/app/services/router.js | 99 - ui/app/services/store.js | 10 +- ui/app/services/version.js | 16 +- ui/app/services/wizard.js | 4 +- ui/app/templates/components/.gitkeep | 0 ui/app/templates/components/alphabet-edit.hbs | 1 + .../components/auth-config-form/config.hbs | 4 +- .../components/auth-form-options.hbs | 4 +- ui/app/templates/components/auth-form.hbs | 10 +- ui/app/templates/components/auth-info.hbs | 4 +- ui/app/templates/components/auth-jwt.hbs | 10 +- .../components/auth-method/configuration.hbs | 6 +- ui/app/templates/components/config-pki-ca.hbs | 24 +- ui/app/templates/components/config-pki.hbs | 4 +- .../components/console/command-input.hbs | 12 +- .../templates/components/console/log-json.hbs | 7 +- .../components/console/output-log.hbs | 2 +- .../templates/components/console/ui-panel.hbs | 12 +- .../components/control-group-success.hbs | 6 +- ui/app/templates/components/control-group.hbs | 10 +- .../components/generate-credentials.hbs | 60 +- .../templates/components/generated-item.hbs | 15 +- .../components/hover-copy-button.hbs | 2 +- .../components/identity/edit-form.hbs | 10 +- .../components/identity/entity-nav.hbs | 18 +- .../identity/item-alias/alias-details.hbs | 44 +- .../identity/item-alias/alias-metadata.hbs | 4 +- .../components/identity/item-aliases.hbs | 12 +- .../components/identity/item-details.hbs | 18 +- .../components/identity/item-groups.hbs | 12 +- .../components/identity/item-members.hbs | 16 +- .../components/identity/item-metadata.hbs | 6 +- .../identity/item-parent-groups.hbs | 6 +- .../components/identity/item-policies.hbs | 12 +- .../components/identity/lookup-input.hbs | 11 +- .../components/identity/popup-alias.hbs | 12 +- .../components/identity/popup-members.hbs | 4 +- .../components/identity/popup-policy.hbs | 12 +- .../templates/components/kv-object-editor.hbs | 23 +- ui/app/templates/components/license-info.hbs | 14 +- .../components/mount-accessor-select.hbs | 4 +- .../components/mount-backend-form.hbs | 14 +- ui/app/templates/components/mount-info.hbs | 16 +- .../templates/components/namespace-link.hbs | 6 +- .../templates/components/namespace-picker.hbs | 8 +- ui/app/templates/components/nav-header.hbs | 4 +- ui/app/templates/components/not-found.hbs | 2 +- ui/app/templates/components/pgp-list.hbs | 2 +- .../templates/components/pki-cert-popup.hbs | 8 +- ui/app/templates/components/pki-cert-show.hbs | 31 +- .../components/pricing-metrics-config.hbs | 12 +- .../components/raft-storage-overview.hbs | 4 +- .../components/raft-storage-restore.hbs | 4 +- ui/app/templates/components/role-aws-edit.hbs | 8 +- ui/app/templates/components/role-pki-edit.hbs | 8 +- ui/app/templates/components/role-ssh-edit.hbs | 8 +- .../components/secret-edit-display.hbs | 12 +- ui/app/templates/components/secret-edit.hbs | 8 +- .../components/secret-list-header.hbs | 89 +- ui/app/templates/components/status-menu.hbs | 12 +- ui/app/templates/components/text-file.hbs | 4 +- .../components/token-expire-warning.hbs | 4 +- .../components/transform-create-form.hbs | 13 +- .../components/transform-edit-form.hbs | 13 +- .../components/transform-role-edit.hbs | 30 +- .../transform-show-transformation.hbs | 20 +- .../components/transform-template-edit.hbs | 1 + .../components/transformation-edit.hbs | 35 +- ui/app/templates/components/transit-edit.hbs | 8 +- .../components/transit-key-action/datakey.hbs | 8 +- .../components/transit-key-action/decrypt.hbs | 16 +- .../components/transit-key-action/encrypt.hbs | 25 +- .../components/transit-key-action/export.hbs | 4 +- .../components/transit-key-action/hmac.hbs | 20 +- .../components/transit-key-action/rewrap.hbs | 21 +- .../components/transit-key-action/sign.hbs | 23 +- .../components/transit-key-action/verify.hbs | 50 +- .../components/transit-key-actions.hbs | 2 +- ui/app/templates/components/ui-wizard.hbs | 32 +- .../templates/components/wizard-content.hbs | 2 +- .../components/wizard/auth-details.hbs | 8 +- .../components/wizard/policies-others.hbs | 4 +- .../components/wizard/secrets-details.hbs | 6 +- .../components/wizard/secrets-display.hbs | 20 +- .../components/wizard/tools-unwrapped.hbs | 4 +- .../components/wizard/tutorial-error.hbs | 6 +- .../components/wizard/tutorial-idle.hbs | 4 +- .../components/wizard/tutorial-paused.hbs | 4 +- .../templates/partials/auth-form/github.hbs | 11 +- ui/app/templates/partials/auth-form/token.hbs | 10 +- .../partials/form-field-from-model.hbs | 18 +- .../partials/form-field-groups-loop.hbs | 9 +- ui/app/templates/partials/role-aws/form.hbs | 10 +- .../partials/role-aws/popup-menu.hbs | 16 +- ui/app/templates/partials/role-aws/show.hbs | 6 +- ui/app/templates/partials/role-pki/form.hbs | 10 +- .../partials/role-pki/popup-menu.hbs | 20 +- ui/app/templates/partials/role-pki/show.hbs | 4 +- ui/app/templates/partials/role-ssh/form.hbs | 34 +- .../partials/role-ssh/popup-menu.hbs | 22 +- ui/app/templates/partials/role-ssh/show.hbs | 6 +- .../partials/secret-backend-settings/aws.hbs | 37 +- .../partials/secret-backend-settings/pki.hbs | 8 +- .../partials/secret-backend-settings/ssh.hbs | 26 +- .../templates/partials/secret-form-create.hbs | 17 +- .../templates/partials/secret-form-edit.hbs | 9 +- .../templates/partials/secret-form-show.hbs | 13 +- .../partials/secret-list/aws-role-item.hbs | 14 +- .../templates/partials/secret-list/item.hbs | 2 +- .../partials/secret-list/pki-cert-item.hbs | 16 +- .../partials/secret-list/pki-role-item.hbs | 15 +- .../partials/secret-list/ssh-role-item.hbs | 14 +- .../transform-transformation-item.hbs | 3 +- ui/app/templates/partials/status/cluster.hbs | 82 +- ui/app/templates/partials/status/user.hbs | 2 +- ui/app/templates/partials/tools/hash.hbs | 15 +- ui/app/templates/partials/tools/lookup.hbs | 20 +- ui/app/templates/partials/tools/random.hbs | 13 +- ui/app/templates/partials/tools/rewrap.hbs | 28 +- ui/app/templates/partials/tools/unwrap.hbs | 36 +- ui/app/templates/partials/tools/wrap.hbs | 25 +- .../partials/transit-form-create.hbs | 11 +- .../templates/partials/transit-form-edit.hbs | 10 +- .../templates/partials/transit-form-show.hbs | 47 +- ui/app/templates/partials/userpass-form.hbs | 21 +- ui/app/templates/vault/cluster/access.hbs | 28 +- .../vault/cluster/access/control-groups.hbs | 2 +- .../templates/vault/cluster/access/error.hbs | 2 +- .../cluster/access/identity/aliases/add.hbs | 2 +- .../cluster/access/identity/aliases/edit.hbs | 2 +- .../cluster/access/identity/aliases/index.hbs | 24 +- .../cluster/access/identity/aliases/show.hbs | 12 +- .../vault/cluster/access/identity/create.hbs | 2 +- .../vault/cluster/access/identity/edit.hbs | 2 +- .../vault/cluster/access/identity/index.hbs | 38 +- .../vault/cluster/access/identity/merge.hbs | 2 +- .../vault/cluster/access/identity/show.hbs | 12 +- .../vault/cluster/access/leases/error.hbs | 10 +- .../vault/cluster/access/leases/index.hbs | 2 +- .../vault/cluster/access/leases/list.hbs | 49 +- .../vault/cluster/access/leases/show.hbs | 37 +- .../vault/cluster/access/method/section.hbs | 10 +- .../vault/cluster/access/methods.hbs | 24 +- .../cluster/access/namespaces/create.hbs | 4 +- .../vault/cluster/access/namespaces/index.hbs | 8 +- ui/app/templates/vault/cluster/error.hbs | 2 +- ui/app/templates/vault/cluster/init.hbs | 38 +- ui/app/templates/vault/cluster/not-found.hbs | 2 +- ui/app/templates/vault/cluster/policies.hbs | 16 +- .../vault/cluster/policies/create.hbs | 40 +- .../vault/cluster/policies/index.hbs | 47 +- ui/app/templates/vault/cluster/policy.hbs | 16 +- .../templates/vault/cluster/policy/edit.hbs | 18 +- .../templates/vault/cluster/policy/error.hbs | 2 +- .../templates/vault/cluster/policy/show.hbs | 11 +- .../replication-dr-promote/details.hbs | 4 +- .../cluster/replication-dr-promote/index.hbs | 4 +- .../cluster/secrets/backend/configuration.hbs | 12 +- .../cluster/secrets/backend/credentials.hbs | 8 +- .../vault/cluster/secrets/backend/list.hbs | 42 +- .../vault/cluster/secrets/backend/sign.hbs | 52 +- .../backend/transit-actions-layout.hbs | 28 +- .../cluster/secrets/backend/versions.hbs | 10 +- .../vault/cluster/secrets/backends.hbs | 20 +- .../vault/cluster/settings/auth/configure.hbs | 7 +- .../settings/configure-secret-backend.hbs | 7 +- .../configure-secret-backend/section.hbs | 4 +- ui/app/templates/vault/cluster/tools/tool.hbs | 13 +- ui/app/templates/vault/error.hbs | 2 +- ui/app/templates/vault/not-found.hbs | 2 +- ui/app/transforms/array.js | 4 +- ui/app/transforms/object.js | 4 +- ui/app/utils/openapi-to-attrs.js | 3 +- ui/blueprints/component/index.js | 1 + ui/blueprints/story/index.js | 1 + ui/config/ember-cli-update.json | 21 + ui/config/optional-features.json | 4 +- ui/config/targets.js | 2 +- ui/ember-cli-build.js | 4 - ui/lib/core/addon/components/alert-banner.js | 6 +- ui/lib/core/addon/components/alert-inline.js | 6 +- .../core/addon/components/confirm-action.js | 2 +- ui/lib/core/addon/components/confirm.js | 2 +- .../core/addon/components/confirm/message.js | 2 +- .../core/addon/components/download-button.js | 14 +- ui/lib/core/addon/components/edit-form.js | 4 +- ui/lib/core/addon/components/form-field.js | 24 +- .../core/addon/components/info-table-row.js | 2 +- .../core/addon/components/key-value-header.js | 97 +- ui/lib/core/addon/components/linked-block.js | 6 +- ui/lib/core/addon/components/list-item.js | 2 +- .../core/addon/components/list-pagination.js | 10 +- ui/lib/core/addon/components/list-view.js | 8 +- ui/lib/core/addon/components/masked-input.js | 12 +- ui/lib/core/addon/components/message-error.js | 19 +- ui/lib/core/addon/components/modal.js | 8 +- ui/lib/core/addon/components/model-wrap.js | 2 +- .../addon/components/namespace-reminder.js | 4 +- .../core/addon/components/navigate-input.js | 24 +- .../addon/components/replication-dashboard.js | 34 +- .../components/replication-mode-summary.js | 35 +- .../core/addon/components/replication-page.js | 20 +- .../components/replication-secondary-card.js | 18 +- .../components/replication-summary-card.js | 12 +- .../components/replication-table-rows.js | 11 +- ui/lib/core/addon/components/shamir-flow.js | 17 +- .../addon/components/shamir-modal-flow.js | 2 +- ui/lib/core/addon/components/string-list.js | 6 +- ui/lib/core/addon/components/toggle-button.js | 10 +- ui/lib/core/addon/components/ttl-form.js | 2 +- ui/lib/core/addon/components/ttl-picker.js | 4 +- ui/lib/core/addon/components/ttl-picker2.js | 15 +- ui/lib/core/addon/components/upgrade-page.js | 2 +- ui/lib/core/addon/helpers/has-feature.js | 4 +- ui/lib/core/addon/helpers/is-active-route.js | 4 +- ui/lib/core/addon/helpers/is-version.js | 2 +- .../core/addon/helpers/set-flash-message.js | 2 +- .../core/addon/mixins/replication-actions.js | 10 +- .../addon/templates/components/box-radio.hbs | 2 +- .../components/confirmation-modal.hbs | 2 + .../addon/templates/components/form-field.hbs | 2 +- .../templates/components/linked-block.hbs | 1 + .../templates/components/masked-input.hbs | 1 + .../core/addon/templates/components/modal.hbs | 2 +- .../components/replication-action-demote.hbs | 1 + .../components/replication-action-disable.hbs | 1 + .../replication-action-generate-token.hbs | 1 + .../components/replication-action-promote.hbs | 3 + .../components/replication-action-recover.hbs | 3 + .../components/replication-action-reindex.hbs | 3 + .../replication-action-update-primary.hbs | 3 + .../components/replication-dashboard.hbs | 4 +- .../components/replication-header.hbs | 8 +- .../components/replication-secondary-card.hbs | 2 +- .../components/shamir-modal-flow.hbs | 1 + .../templates/components/toggle-button.hbs | 4 +- .../templates/components/ttl-picker2.hbs | 2 +- .../templates/components/upgrade-page.hbs | 2 +- ui/lib/core/addon/utils/b64.js | 1 + ui/lib/css/index.js | 1 + .../addon/components/edit-form-kmip-role.js | 6 +- ui/lib/kmip/addon/routes.js | 2 +- .../components/edit-form-kmip-role.hbs | 4 +- ui/lib/kmip/index.js | 1 + ui/lib/open-api-explorer/index.js | 1 + ui/lib/replication/addon/.eslintrc.js | 1 + .../components/replication-secondaries.js | 18 - .../addon/components/replication-summary.js | 18 +- .../addon/controllers/application.js | 16 +- .../mode/secondaries/config-edit.js | 4 +- ui/lib/replication/addon/routes.js | 4 +- .../replication/addon/routes/application.js | 10 +- ui/lib/replication/addon/routes/index.js | 2 +- .../replication/addon/routes/mode/manage.js | 2 +- .../routes/mode/secondaries/config-create.js | 6 +- .../routes/mode/secondaries/config-edit.js | 2 +- .../routes/mode/secondaries/config-show.js | 2 +- .../addon/routes/mode/secondaries/revoke.js | 2 +- .../components/known-secondaries-card.hbs | 1 - .../components/known-secondaries-table.hbs | 2 +- .../components/path-filter-config-list.hbs | 2 +- .../components/replication-summary.hbs | 8 +- ui/lib/replication/index.js | 1 + ui/package.json | 79 +- ui/scripts/start-vault.js | 3 +- ui/testem.js | 16 +- ui/tests/.eslintrc.js | 1 + .../access/identity/_shared-alias-tests.js | 22 +- .../access/identity/_shared-tests.js | 14 +- .../identity/entities/aliases/create-test.js | 4 + .../identity/groups/aliases/create-test.js | 5 + ui/tests/acceptance/auth-list-test.js | 13 + ui/tests/acceptance/auth-test.js | 3 +- ui/tests/acceptance/aws-test.js | 25 +- ui/tests/acceptance/cluster-test.js | 7 +- ui/tests/acceptance/console-test.js | 17 +- .../enterprise-control-groups-test.js | 35 +- ui/tests/acceptance/enterprise-kmip-test.js | 46 +- .../acceptance/enterprise-namespaces-test.js | 8 +- .../acceptance/enterprise-replication-test.js | 92 +- .../acceptance/enterprise-transform-test.js | 39 +- ui/tests/acceptance/policies-acl-old-test.js | 12 +- ui/tests/acceptance/policies/index-test.js | 9 +- ui/tests/acceptance/redirect-to-test.js | 18 +- .../secrets/backend/alicloud/secret-test.js | 6 +- .../secrets/backend/cubbyhole/secret-test.js | 5 +- .../secrets/backend/engines-test.js | 9 +- .../secrets/backend/gcpkms/secrets-test.js | 5 +- .../secrets/backend/kv/secret-test.js | 3 +- .../secrets/backend/pki/cert-test.js | 16 +- .../secrets/backend/pki/role-test.js | 16 +- .../secrets/backend/ssh/role-test.js | 16 +- ui/tests/acceptance/settings-test.js | 5 +- .../acceptance/settings/auth/enable-test.js | 5 +- .../pki/index-test.js | 4 +- .../pki/section-cert-test.js | 24 +- .../pki/section-crl-test.js | 5 +- .../pki/section-tidy-test.js | 5 +- .../pki/section-urls-test.js | 6 +- ui/tests/acceptance/ssh-test.js | 33 +- ui/tests/acceptance/tools-test.js | 24 +- ui/tests/acceptance/transit-test.js | 27 +- ui/tests/acceptance/unseal-test.js | 11 +- ui/tests/acceptance/wrapped-token-test.js | 11 +- .../components/alert-inline-test.js | 2 +- .../integration/components/auth-form-test.js | 9 +- .../integration/components/b64-toggle-test.js | 10 +- .../integration/components/box-radio-test.js | 4 +- .../components/confirmation-modal-test.js | 8 +- .../components/console/log-error-test.js | 2 +- .../components/console/log-list-test.js | 2 +- .../components/console/log-object-test.js | 13 +- .../components/console/ui-panel-test.js | 20 +- .../components/control-group-test.js | 2 +- .../components/empty-state-test.js | 24 +- .../components/features-selection-test.js | 6 +- .../integration/components/form-field-test.js | 4 +- .../components/hover-copy-button-test.js | 12 +- .../components/license-info-test.js | 2 +- ui/tests/integration/components/modal-test.js | 10 +- .../integration/components/pgp-file-test.js | 24 +- .../components/pricing-metrics-config-test.js | 5 +- .../replication-action-generate-token-test.js | 10 +- .../components/replication-actions-test.js | 10 +- .../components/replication-dashboard-test.js | 5 +- .../replication-secondary-card-test.js | 2 +- .../components/search-select-test.js | 46 +- .../integration/components/select-test.js | 8 +- .../components/shamir-flow-test.js | 18 +- .../components/shamir-modal-flow-test.js | 34 +- .../components/string-list-test.js | 36 +- .../components/toggle-button-test.js | 14 +- .../integration/components/toggle-test.js | 6 +- .../components/toolbar-actions-test.js | 2 +- .../toolbar-download-button-test.js | 2 +- .../components/toolbar-filters-test.js | 2 +- .../components/toolbar-link-test.js | 2 +- .../integration/components/toolbar-test.js | 2 +- .../components/transform-edit-base-test.js | 4 +- .../components/transit-key-actions-test.js | 68 +- .../components/upgrade-page-test.js | 54 +- .../integration/components/wrap-ttl-test.js | 8 +- .../helpers/has-permission-test.js | 4 +- ui/tests/integration/services/auth-test.js | 8 +- ui/tests/pages/auth.js | 2 + .../pages/components/hover-copy-button.js | 3 +- .../pages/secrets/backend/ssh/edit-role.js | 2 +- .../backend/transform/transformations.js | 2 +- ui/tests/test-helper.js | 4 +- ui/tests/unit/lib/attach-capabilities-test.js | 4 +- ui/tests/unit/utils/openapi-to-attrs-test.js | 3 +- ui/yarn.lock | 4568 +++++++++++------ 584 files changed, 6266 insertions(+), 5106 deletions(-) create mode 100644 ui/MODULE_REPORT.md create mode 100644 ui/app/components/auth-form-options.js create mode 100644 ui/app/components/console/log-error-with-html.js create mode 100644 ui/app/components/identity/entity-nav.js delete mode 100644 ui/app/models/transform/transformation.js delete mode 100644 ui/app/resolver.js delete mode 100644 ui/app/services/router.js delete mode 100644 ui/app/templates/components/.gitkeep create mode 100644 ui/config/ember-cli-update.json create mode 100644 ui/lib/core/addon/templates/components/linked-block.hbs delete mode 100644 ui/lib/replication/addon/components/replication-secondaries.js diff --git a/.circleci/config.yml b/.circleci/config.yml index a1ba5299f..07f76fa7e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -515,7 +515,7 @@ jobs: - image: docker.mirror.hashicorp.services/node:10-buster shell: /usr/bin/env bash -euo pipefail -c working_directory: /go/src/github.com/hashicorp/vault - resource_class: medium+ + resource_class: xlarge steps: - checkout - restore_cache: @@ -631,7 +631,7 @@ jobs: - image: docker.mirror.hashicorp.services/node:10-buster shell: /usr/bin/env bash -euo pipefail -c working_directory: /go/src/github.com/hashicorp/vault - resource_class: medium+ + resource_class: xlarge steps: - checkout - restore_cache: diff --git a/.circleci/config/jobs/test-ui-browserstack.yml b/.circleci/config/jobs/test-ui-browserstack.yml index 7c582275f..7640f8313 100644 --- a/.circleci/config/jobs/test-ui-browserstack.yml +++ b/.circleci/config/jobs/test-ui-browserstack.yml @@ -1,5 +1,5 @@ executor: node -resource_class: medium+ +resource_class: xlarge steps: - checkout - restore_yarn_cache diff --git a/.circleci/config/jobs/test-ui.yml b/.circleci/config/jobs/test-ui.yml index 8ac1b8186..7826e96a0 100644 --- a/.circleci/config/jobs/test-ui.yml +++ b/.circleci/config/jobs/test-ui.yml @@ -1,5 +1,5 @@ executor: node -resource_class: medium+ +resource_class: xlarge steps: - checkout - restore_yarn_cache diff --git a/ui/.editorconfig b/ui/.editorconfig index e37fb8f67..ab4633928 100644 --- a/ui/.editorconfig +++ b/ui/.editorconfig @@ -4,7 +4,6 @@ root = true - [*] end_of_line = lf charset = utf-8 diff --git a/ui/.eslintrc.js b/ui/.eslintrc.js index ab1af78bd..7d2c1fe58 100644 --- a/ui/.eslintrc.js +++ b/ui/.eslintrc.js @@ -1,10 +1,16 @@ -// env: node +/* eslint-disable no-undef */ + +'use strict'; + module.exports = { parser: 'babel-eslint', root: true, parserOptions: { ecmaVersion: 2018, sourceType: 'module', + ecmaFeatures: { + legacyDecorators: true, + }, }, plugins: ['ember', 'prettier'], extends: ['eslint:recommended', 'plugin:ember/recommended', 'prettier'], @@ -13,13 +19,9 @@ module.exports = { es6: true, }, rules: { - 'no-unused-vars': ['error', { ignoreRestSiblings: true }], - 'prettier/prettier': 'error', - 'ember/no-jquery': 'error', - }, - globals: { - TextEncoderLite: true, - TextDecoderLite: true, + // TODO revisit once figure out how to replace, added during upgrade to 3.20 + 'ember/no-new-mixins': 'off', + 'ember/no-mixins': 'off', }, overrides: [ // node files @@ -41,6 +43,13 @@ module.exports = { browser: false, node: true, }, + plugins: ['node'], + extends: ['plugin:node/recommended'], + rules: { + // this can be removed once the following is fixed + // https://github.com/mysticatea/eslint-plugin-node/issues/77 + 'node/no-unpublished-require': 'off', + }, }, ], }; diff --git a/ui/MODULE_REPORT.md b/ui/MODULE_REPORT.md new file mode 100644 index 000000000..a56586562 --- /dev/null +++ b/ui/MODULE_REPORT.md @@ -0,0 +1,224 @@ +## Module Report +### Unknown Global + +**Global**: `Ember.testing` + +**Location**: `app/components/auth-jwt.js` at line 9 + +```js + +/* eslint-disable ember/no-ember-testing-in-module-scope */ +const WAIT_TIME = Ember.testing ? 0 : 500; +const ERROR_WINDOW_CLOSED = + 'The provider window was closed before authentication was complete. Please click Sign In to try again.'; +``` + +### Unknown Global + +**Global**: `Ember.testing` + +**Location**: `app/components/auth-jwt.js` at line 117 + +```js + exchangeOIDC: task(function*(event, oidcWindow) { + // in non-incognito mode we need to use a timeout because it takes time before oidcState is written to local storage. + let oidcState = Ember.testing + ? event.storageArea.getItem('oidcState') + : (yield timeout(1000).then(() => event.storageArea.getItem('oidcState'))); +``` + +### Unknown Global + +**Global**: `Ember.testing` + +**Location**: `app/routes/vault.js` at line 7 + +```js +import Ember from 'ember'; +/* eslint-disable ember/no-ember-testing-in-module-scope */ +const SPLASH_DELAY = Ember.testing ? 0 : 300; + +export default Route.extend({ +``` + +### Unknown Global + +**Global**: `Ember.testing` + +**Location**: `app/services/auth.js` at line 267 + +```js + checkShouldRenew: task(function*() { + while (true) { + if (Ember.testing) { + return; + } +``` + +### Unknown Global + +**Global**: `Ember.testing` + +**Location**: `lib/core/addon/components/ttl-form.js` at line 82 + +```js + this.set('time', parsedTime); + this.handleChange(); + if (Ember.testing) { + return; + } +``` + +### Unknown Global + +**Global**: `Ember.testing` + +**Location**: `app/routes/vault/cluster.js` at line 78 + +```js + // when testing, the polling loop causes promises to never settle so acceptance tests hang + // to get around that, we just disable the poll in tests + if (Ember.testing) { + return; + } +``` + +### Unknown Global + +**Global**: `Ember.onerror` + +**Location**: `tests/helpers/wait-for-error.js` at line 5 + +```js + +export default function waitForError(opts) { + const orig = Ember.onerror; + + let error = null; +``` + +### Unknown Global + +**Global**: `Ember.onerror` + +**Location**: `tests/helpers/wait-for-error.js` at line 5 + +```js + +export default function waitForError(opts) { + const orig = Ember.onerror; + + let error = null; +``` + +### Unknown Global + +**Global**: `Ember.onerror` + +**Location**: `tests/helpers/wait-for-error.js` at line 8 + +```js + + let error = null; + Ember.onerror = err => { + error = err; + }; +``` + +### Unknown Global + +**Global**: `Ember.onerror` + +**Location**: `tests/helpers/wait-for-error.js` at line 13 + +```js + + return waitUntil(() => error, opts).finally(() => { + Ember.onerror = orig; + }); +} +``` + +### Unknown Global + +**Global**: `Ember.Logger` + +**Location**: `tests/acceptance/not-found-test.js` at line 15 + +```js + + hooks.beforeEach(function() { + loggerError = Ember.Logger.error; + adapterException = Ember.Test.adapter.exception; + Ember.Test.adapter.exception = () => {}; +``` + +### Unknown Global + +**Global**: `Ember.Test` + +**Location**: `tests/acceptance/not-found-test.js` at line 16 + +```js + hooks.beforeEach(function() { + loggerError = Ember.Logger.error; + adapterException = Ember.Test.adapter.exception; + Ember.Test.adapter.exception = () => {}; + Ember.Logger.error = () => {}; +``` + +### Unknown Global + +**Global**: `Ember.Test` + +**Location**: `tests/acceptance/not-found-test.js` at line 17 + +```js + loggerError = Ember.Logger.error; + adapterException = Ember.Test.adapter.exception; + Ember.Test.adapter.exception = () => {}; + Ember.Logger.error = () => {}; + return authPage.login(); +``` + +### Unknown Global + +**Global**: `Ember.Logger` + +**Location**: `tests/acceptance/not-found-test.js` at line 18 + +```js + adapterException = Ember.Test.adapter.exception; + Ember.Test.adapter.exception = () => {}; + Ember.Logger.error = () => {}; + return authPage.login(); + }); +``` + +### Unknown Global + +**Global**: `Ember.Test` + +**Location**: `tests/acceptance/not-found-test.js` at line 23 + +```js + + hooks.afterEach(function() { + Ember.Test.adapter.exception = adapterException; + Ember.Logger.error = loggerError; + return logout.visit(); +``` + +### Unknown Global + +**Global**: `Ember.Logger` + +**Location**: `tests/acceptance/not-found-test.js` at line 24 + +```js + hooks.afterEach(function() { + Ember.Test.adapter.exception = adapterException; + Ember.Logger.error = loggerError; + return logout.visit(); + }); +``` diff --git a/ui/app/adapters/application.js b/ui/app/adapters/application.js index 34172dc93..59a3e660b 100644 --- a/ui/app/adapters/application.js +++ b/ui/app/adapters/application.js @@ -1,16 +1,15 @@ +import AdapterError from '@ember-data/adapter/error'; +import RESTAdapter from '@ember-data/adapter/rest'; import { inject as service } from '@ember/service'; import { assign } from '@ember/polyfills'; import { set } from '@ember/object'; import RSVP from 'rsvp'; -import DS from 'ember-data'; -import AdapterFetch from 'ember-fetch/mixins/adapter-fetch'; -import fetch from 'fetch'; import config from '../config/environment'; const { APP } = config; const { POLLING_URLS, NAMESPACE_ROOT_URLS } = APP; -export default DS.RESTAdapter.extend(AdapterFetch, { +export default RESTAdapter.extend({ auth: service(), namespaceService: service('namespace'), controlGroup: service(), @@ -32,7 +31,7 @@ export default DS.RESTAdapter.extend(AdapterFetch, { }, addHeaders(url, options) { - let token = options.clientToken || this.get('auth.currentToken'); + let token = options.clientToken || this.auth.currentToken; let headers = {}; if (token && !options.unauthenticated) { headers['X-Vault-Token'] = token; @@ -40,8 +39,7 @@ export default DS.RESTAdapter.extend(AdapterFetch, { if (options.wrapTTL) { headers['X-Vault-Wrap-TTL'] = options.wrapTTL; } - let namespace = - typeof options.namespace === 'undefined' ? this.get('namespaceService.path') : options.namespace; + let namespace = typeof options.namespace === 'undefined' ? this.namespaceService.path : options.namespace; if (namespace && !NAMESPACE_ROOT_URLS.some(str => url.includes(str))) { headers['X-Vault-Namespace'] = namespace; } @@ -62,7 +60,7 @@ export default DS.RESTAdapter.extend(AdapterFetch, { let url = intendedUrl; let type = method; let options = passedOptions; - let controlGroup = this.get('controlGroup'); + let controlGroup = this.controlGroup; let controlGroupToken = controlGroup.tokenForUrl(url); // if we have a Control Group token that matches the intendedUrl, // then we want to unwrap it and return the unwrapped response as @@ -86,7 +84,7 @@ export default DS.RESTAdapter.extend(AdapterFetch, { } const [resp] = args; if (resp && resp.warnings) { - let flash = this.get('flashMessages'); + let flash = this.flashMessages; resp.warnings.forEach(message => { flash.info(message); }); @@ -115,7 +113,7 @@ export default DS.RESTAdapter.extend(AdapterFetch, { handleResponse(status, headers, payload, requestData) { const returnVal = this._super(...arguments); // ember data errors don't have the status code, so we add it here - if (returnVal instanceof DS.AdapterError) { + if (returnVal instanceof AdapterError) { set(returnVal, 'httpStatus', status); set(returnVal, 'path', requestData.url); } diff --git a/ui/app/adapters/auth-config/_base.js b/ui/app/adapters/auth-config/_base.js index f2cd6780e..dce952208 100644 --- a/ui/app/adapters/auth-config/_base.js +++ b/ui/app/adapters/auth-config/_base.js @@ -14,7 +14,7 @@ export default ApplicationAdapter.extend({ buildURL(modelName, id, snapshot) { const backendId = id ? id : snapshot.belongsTo('backend').id; - let url = `${this.get('namespace')}/${backendId}/config`; + let url = `${this.namespace}/${backendId}/config`; // aws has a lot more config endpoints if (modelName.includes('aws')) { url = `${url}/${this.pathForType(modelName)}`; diff --git a/ui/app/adapters/auth-method.js b/ui/app/adapters/auth-method.js index 38f79aa11..b8a43fa9f 100644 --- a/ui/app/adapters/auth-method.js +++ b/ui/app/adapters/auth-method.js @@ -1,7 +1,7 @@ +import AdapterError from '@ember-data/adapter/error'; import { assign } from '@ember/polyfills'; import { get, set } from '@ember/object'; import ApplicationAdapter from './application'; -import DS from 'ember-data'; import { encodePath } from 'vault/utils/path-encoding-helpers'; export default ApplicationAdapter.extend({ @@ -34,7 +34,7 @@ export default ApplicationAdapter.extend({ }); } return this.ajax(this.url(), 'GET').catch(e => { - if (e instanceof DS.AdapterError) { + if (e instanceof AdapterError) { set(e, 'policyPath', 'sys/auth'); } throw e; diff --git a/ui/app/adapters/capabilities.js b/ui/app/adapters/capabilities.js index ad04c1036..3bb3b63bf 100644 --- a/ui/app/adapters/capabilities.js +++ b/ui/app/adapters/capabilities.js @@ -1,6 +1,6 @@ +import AdapterError from '@ember-data/adapter/error'; import { set } from '@ember/object'; import ApplicationAdapter from './application'; -import DS from 'ember-data'; export default ApplicationAdapter.extend({ pathForType() { @@ -9,7 +9,7 @@ export default ApplicationAdapter.extend({ findRecord(store, type, id) { return this.ajax(this.buildURL(type), 'POST', { data: { paths: [id] } }).catch(e => { - if (e instanceof DS.AdapterError) { + if (e instanceof AdapterError) { set(e, 'policyPath', 'sys/capabilities-self'); } throw e; diff --git a/ui/app/adapters/cluster.js b/ui/app/adapters/cluster.js index dd7d17220..032b77c75 100644 --- a/ui/app/adapters/cluster.js +++ b/ui/app/adapters/cluster.js @@ -1,3 +1,4 @@ +import AdapterError from '@ember-data/adapter/error'; import { inject as service } from '@ember/service'; import { assign } from '@ember/polyfills'; import { hash, resolve } from 'rsvp'; @@ -5,9 +6,6 @@ import { assert } from '@ember/debug'; import { pluralize } from 'ember-inflector'; import ApplicationAdapter from './application'; -import DS from 'ember-data'; - -const { AdapterError } = DS; const ENDPOINTS = [ 'health', @@ -44,7 +42,7 @@ export default ApplicationAdapter.extend({ health: this.health(), sealStatus: this.sealStatus().catch(e => e), }; - if (this.get('version.isEnterprise') && this.get('namespaceService.inRootNamespace')) { + if (this.version.isEnterprise && this.namespaceService.inRootNamespace) { fetches.replicationStatus = this.replicationStatus().catch(e => e); } return hash(fetches).then(({ health, sealStatus, replicationStatus }) => { diff --git a/ui/app/adapters/kmip/base.js b/ui/app/adapters/kmip/base.js index 5815933da..3a25ff9dc 100644 --- a/ui/app/adapters/kmip/base.js +++ b/ui/app/adapters/kmip/base.js @@ -40,7 +40,7 @@ export default ApplicationAdapter.extend({ query(store, type, query) { return this.ajax(this.urlForQuery(query, type.modelName), 'GET').then(resp => { // remove pagination query items here - const { size, page, responsePath, pageFilter, ...modelAttrs } = query; + const { ...modelAttrs } = query; resp._requestQuery = modelAttrs; return resp; }); diff --git a/ui/app/adapters/pki-config.js b/ui/app/adapters/pki-config.js index c6bc8abf4..42e8e9e06 100644 --- a/ui/app/adapters/pki-config.js +++ b/ui/app/adapters/pki-config.js @@ -1,8 +1,8 @@ +import AdapterError from '@ember-data/adapter/error'; import { hash, resolve } from 'rsvp'; import { capitalize } from '@ember/string'; import { set } from '@ember/object'; import ApplicationAdapter from './application'; -import DS from 'ember-data'; export default ApplicationAdapter.extend({ namespace: 'v1', @@ -49,7 +49,7 @@ export default ApplicationAdapter.extend({ fetchSection(backendPath, section) { const sections = ['cert', 'urls', 'crl', 'tidy']; if (!section || !sections.includes(section)) { - const error = new DS.AdapterError(); + const error = new AdapterError(); set(error, 'httpStatus', 404); throw error; } diff --git a/ui/app/adapters/secret-v2-version.js b/ui/app/adapters/secret-v2-version.js index a6e132091..5aac49d73 100644 --- a/ui/app/adapters/secret-v2-version.js +++ b/ui/app/adapters/secret-v2-version.js @@ -1,8 +1,8 @@ /* eslint-disable */ +import AdapterError from '@ember-data/adapter/error'; import { isEmpty } from '@ember/utils'; import { get } from '@ember/object'; import ApplicationAdapter from './application'; -import DS from 'ember-data'; import { encodePath } from 'vault/utils/path-encoding-helpers'; import ControlGroupError from 'vault/lib/control-group-error'; @@ -30,7 +30,7 @@ export default ApplicationAdapter.extend({ return this._super(...arguments).catch(errorOrModel => { // if the response is a real 404 or if the secret is gated by a control group this will be an error, // otherwise the response will be the body of a deleted / destroyed version - if (errorOrModel instanceof DS.AdapterError) { + if (errorOrModel instanceof AdapterError) { throw errorOrModel; } return errorOrModel; diff --git a/ui/app/adapters/transit-key.js b/ui/app/adapters/transit-key.js index 384efee2c..c664f60e2 100644 --- a/ui/app/adapters/transit-key.js +++ b/ui/app/adapters/transit-key.js @@ -8,14 +8,17 @@ export default ApplicationAdapter.extend({ createOrUpdate(store, type, snapshot, requestType) { const serializer = store.serializerFor(type.modelName); const data = serializer.serialize(snapshot, requestType); - const { id } = snapshot; - let url = this.urlForSecret(snapshot.record.get('backend'), id); - + let name = snapshot.attr('name'); + let url = this.urlForSecret(snapshot.record.get('backend'), name); if (requestType === 'update') { url = url + '/config'; } - return this.ajax(url, 'POST', { data }); + return this.ajax(url, 'POST', { data }).then(resp => { + let response = resp || {}; + response.id = name; + return response; + }); }, createRecord() { diff --git a/ui/app/app.js b/ui/app/app.js index 509014ac6..f84033f0d 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -1,19 +1,15 @@ import Application from '@ember/application'; -import Resolver from './resolver'; +import Resolver from 'ember-resolver'; import loadInitializers from 'ember-load-initializers'; -import config from './config/environment'; +import config from 'vault/config/environment'; import defineModifier from 'ember-concurrency-test-waiter/define-modifier'; defineModifier(); - -let App; - -/* eslint-disable ember/avoid-leaking-state-in-ember-objects */ -App = Application.extend({ - modulePrefix: config.modulePrefix, - podModulePrefix: config.podModulePrefix, - Resolver, - engines: { +export default class App extends Application { + modulePrefix = config.modulePrefix; + podModulePrefix = config.podModulePrefix; + Resolver = Resolver; + engines = { openApiExplorer: { dependencies: { services: ['auth', 'flash-messages', 'namespace', 'router', 'version'], @@ -54,9 +50,7 @@ App = Application.extend({ }, }, }, - }, -}); + }; +} loadInitializers(App, config.modulePrefix); - -export default App; diff --git a/ui/app/components/auth-config-form/config.js b/ui/app/components/auth-config-form/config.js index e0bd2631e..49f692a7a 100644 --- a/ui/app/components/auth-config-form/config.js +++ b/ui/app/components/auth-config-form/config.js @@ -1,7 +1,7 @@ +import AdapterError from '@ember-data/adapter/error'; import { inject as service } from '@ember/service'; import Component from '@ember/component'; import { task } from 'ember-concurrency'; -import DS from 'ember-data'; /** * @module AuthConfigForm/Config @@ -29,7 +29,7 @@ const AuthConfigBase = Component.extend({ } catch (err) { // AdapterErrors are handled by the error-message component // in the form - if (err instanceof DS.AdapterError === false) { + if (err instanceof AdapterError === false) { throw err; } return; diff --git a/ui/app/components/auth-config-form/options.js b/ui/app/components/auth-config-form/options.js index 952f7d5dc..254d03ee0 100644 --- a/ui/app/components/auth-config-form/options.js +++ b/ui/app/components/auth-config-form/options.js @@ -1,7 +1,7 @@ +import AdapterError from '@ember-data/adapter/error'; import AuthConfigComponent from './config'; import { inject as service } from '@ember/service'; import { task } from 'ember-concurrency'; -import DS from 'ember-data'; /** * @module AuthConfigForm/Options @@ -27,7 +27,7 @@ export default AuthConfigComponent.extend({ } catch (err) { // AdapterErrors are handled by the error-message component // in the form - if (err instanceof DS.AdapterError === false) { + if (err instanceof AdapterError === false) { throw err; } // because we're not calling model.save the model never updates with diff --git a/ui/app/components/auth-form-options.js b/ui/app/components/auth-form-options.js new file mode 100644 index 000000000..557064773 --- /dev/null +++ b/ui/app/components/auth-form-options.js @@ -0,0 +1,3 @@ +import Component from '@ember/component'; + +export default Component.extend({}); diff --git a/ui/app/components/auth-form.js b/ui/app/components/auth-form.js index 42baadfff..6704d0c3a 100644 --- a/ui/app/components/auth-form.js +++ b/ui/app/components/auth-form.js @@ -89,8 +89,8 @@ export default Component.extend(DEFAULTS, { // set `with` to the first method if ( !this.wrappedToken && - ((this.get('fetchMethods.isIdle') && firstMethod && !this.get('selectedAuth')) || - (this.get('selectedAuth') && !this.get('selectedAuthBackend'))) + ((this.fetchMethods.isIdle && firstMethod && !this.selectedAuth) || + (this.selectedAuth && !this.selectedAuthBackend)) ) { this.set('selectedAuth', firstMethod); } @@ -98,7 +98,7 @@ export default Component.extend(DEFAULTS, { }, firstMethod() { - let firstMethod = this.get('methodsToShow.firstObject'); + let firstMethod = this.methodsToShow.firstObject; if (!firstMethod) return; // prefer backends with a path over those with a type return get(firstMethod, 'path') || get(firstMethod, 'type'); @@ -127,8 +127,11 @@ export default Component.extend(DEFAULTS, { } ), - providerPartialName: computed('selectedAuthBackend', function() { - let type = this.get('selectedAuthBackend.type') || 'token'; + providerPartialName: computed('selectedAuthBackend.type', function() { + if (!this.selectedAuthBackend) { + return; + } + let type = this.selectedAuthBackend.type || 'token'; type = type.toLowerCase(); let templateName = dasherize(type); return `partials/auth-form/${templateName}`; @@ -139,16 +142,16 @@ export default Component.extend(DEFAULTS, { cspErrorText: `This is a standby Vault node but can't communicate with the active node via request forwarding. Sign in at the active node to use the Vault UI.`, allSupportedMethods: computed('methodsToShow', 'hasMethodsWithPath', function() { - let hasMethodsWithPath = this.get('hasMethodsWithPath'); - let methodsToShow = this.get('methodsToShow'); + let hasMethodsWithPath = this.hasMethodsWithPath; + let methodsToShow = this.methodsToShow; return hasMethodsWithPath ? methodsToShow.concat(BACKENDS) : methodsToShow; }), hasMethodsWithPath: computed('methodsToShow', function() { - return this.get('methodsToShow').isAny('path'); + return this.methodsToShow.isAny('path'); }), methodsToShow: computed('methods', function() { - let methods = this.get('methods') || []; + let methods = this.methods || []; let shownMethods = methods.filter(m => BACKENDS.find(b => get(b, 'type').toLowerCase() === get(m, 'type').toLowerCase()) ); @@ -158,7 +161,7 @@ export default Component.extend(DEFAULTS, { unwrapToken: task(function*(token) { // will be using the Token Auth Method, so set it here this.set('selectedAuth', 'token'); - let adapter = this.get('store').adapterFor('tools'); + let adapter = this.store.adapterFor('tools'); try { let response = yield adapter.toolAction('unwrap', null, { clientToken: token }); this.set('token', response.auth.client_token); @@ -169,7 +172,7 @@ export default Component.extend(DEFAULTS, { }).withTestWaiter(), fetchMethods: task(function*() { - let store = this.get('store'); + let store = this.store; try { let methods = yield store.findAll('auth-method', { adapterOptions: { @@ -249,7 +252,7 @@ export default Component.extend(DEFAULTS, { this.setProperties({ error: null, }); - let backend = this.get('selectedAuthBackend') || {}; + let backend = this.selectedAuthBackend || {}; let backendMeta = BACKENDS.find( b => (get(b, 'type') || '').toLowerCase() === (get(backend, 'type') || '').toLowerCase() ); @@ -259,8 +262,8 @@ export default Component.extend(DEFAULTS, { if (passedData) { data = assign(data, passedData); } - if (this.get('customPath') || get(backend, 'id')) { - data.path = this.get('customPath') || get(backend, 'id'); + if (this.customPath || get(backend, 'id')) { + data.path = this.customPath || get(backend, 'id'); } return this.authenticate.unlinked().perform(backend.type, data); }, diff --git a/ui/app/components/auth-info.js b/ui/app/components/auth-info.js index 073f725da..76a2c0e5e 100644 --- a/ui/app/components/auth-info.js +++ b/ui/app/components/auth-info.js @@ -1,8 +1,7 @@ import { inject as service } from '@ember/service'; -import { or } from '@ember/object/computed'; +import { or, alias } from '@ember/object/computed'; import Component from '@ember/component'; import { run } from '@ember/runloop'; -import { computed } from '@ember/object'; export default Component.extend({ auth: service(), @@ -11,35 +10,33 @@ export default Component.extend({ version: service(), transitionToRoute: function() { - this.get('router').transitionTo(...arguments); + this.router.transitionTo(...arguments); }, classNames: 'user-menu auth-info', isRenewing: or('fakeRenew', 'auth.isRenewing'), - canExpire: computed.alias('auth.allowExpiration'), + canExpire: alias('auth.allowExpiration'), - isOSS: computed.alias('version.isOSS'), + isOSS: alias('version.isOSS'), actions: { restartGuide() { - this.get('wizard').restartGuide(); + this.wizard.restartGuide(); }, renewToken() { this.set('fakeRenew', true); run.later(() => { this.set('fakeRenew', false); - this.get('auth').renew(); + this.auth.renew(); }, 200); }, revokeToken() { - this.get('auth') - .revokeCurrentToken() - .then(() => { - this.transitionToRoute('vault.cluster.logout'); - }); + this.auth.revokeCurrentToken().then(() => { + this.transitionToRoute('vault.cluster.logout'); + }); }, }, }); diff --git a/ui/app/components/b64-toggle.js b/ui/app/components/b64-toggle.js index 6013f266d..a556b7aa6 100644 --- a/ui/app/components/b64-toggle.js +++ b/ui/app/components/b64-toggle.js @@ -1,7 +1,7 @@ import { equal } from '@ember/object/computed'; import { isBlank } from '@ember/utils'; import Component from '@ember/component'; -import { set, get, computed } from '@ember/object'; +import { set, computed } from '@ember/object'; import { encodeString, decodeString } from 'vault/utils/b64'; const B64 = 'base64'; @@ -83,40 +83,40 @@ export default Component.extend({ * @type boolean */ valuesMatch: computed('value', '_value', function() { - const { value, _value } = this.getProperties('value', '_value'); + const { value, _value } = this; const anyBlank = isBlank(value) || isBlank(_value); return !anyBlank && value === _value; }), init() { this._super(...arguments); - const initial = get(this, 'initialEncoding'); + const initial = this.initialEncoding; set(this, 'currentEncoding', initial); if (initial === B64) { - set(this, '_value', get(this, 'value')); + set(this, '_value', this.value); set(this, 'lastEncoding', B64); } }, didReceiveAttrs() { // if there's no value, reset encoding - if (get(this, 'value') === '') { + if (this.value === '') { set(this, 'currentEncoding', UTF8); return; } // the value has changed after we transformed it so we reset currentEncoding - if (get(this, 'isBase64') && !get(this, 'valuesMatch')) { + if (this.isBase64 && !this.valuesMatch) { set(this, 'currentEncoding', UTF8); } // the value changed back to one we previously had transformed - if (get(this, 'lastEncoding') === B64 && get(this, 'valuesMatch')) { + if (this.lastEncoding === B64 && this.valuesMatch) { set(this, 'currentEncoding', B64); } }, click() { - let val = get(this, 'value'); - const isUTF8 = get(this, 'currentEncoding') === UTF8; + let val = this.value; + const isUTF8 = this.currentEncoding === UTF8; if (!val) { return; } diff --git a/ui/app/components/config-pki-ca.js b/ui/app/components/config-pki-ca.js index a5669a5e6..2ab8792d6 100644 --- a/ui/app/components/config-pki-ca.js +++ b/ui/app/components/config-pki-ca.js @@ -68,7 +68,7 @@ export default Component.extend({ loading: false, willDestroy() { - const ca = this.get('model'); + const ca = this.model; if (ca) { ca.unloadRecord(); } @@ -76,9 +76,9 @@ export default Component.extend({ }, createOrReplaceModel(modelType) { - const ca = this.get('model'); - const config = this.get('config'); - const store = this.get('store'); + const ca = this.model; + const config = this.config; + const store = this.store; const backend = config.get('backend'); if (ca) { ca.unloadRecord(); @@ -101,8 +101,8 @@ export default Component.extend({ * */ downloadHrefs: computed('config', 'config.{backend,pem,caChain,der}', function() { - const config = this.get('config'); - const { backend, pem, caChain, der } = config.getProperties('backend', 'pem', 'caChain', 'der'); + const config = this.config; + const { backend, pem, caChain, der } = config; if (!pem) { return []; @@ -135,17 +135,17 @@ export default Component.extend({ actions: { saveCA(method) { this.set('loading', true); - const model = this.get('model'); - const isUpload = this.get('model.uploadPemBundle'); + const model = this.model; + const isUpload = this.model.uploadPemBundle; model .save({ adapterOptions: { method } }) .then(m => { if (method === 'setSignedIntermediate' || isUpload) { this.send('refresh'); - this.get('flashMessages').success('The certificate for this backend has been updated.'); + this.flashMessages.success('The certificate for this backend has been updated.'); } else if (!m.get('certificate') && !m.get('csr')) { // if there's no certificate, it wasn't generated and the generation was a noop - this.get('flashMessages').warning( + this.flashMessages.warning( 'You tried to generate a new root CA, but one currently exists. To replace the existing one, delete it first and then generate again.' ); } @@ -159,14 +159,14 @@ export default Component.extend({ }, deleteCA() { this.set('loading', true); - const model = this.get('model'); + const model = this.model; const backend = model.get('backend'); //TODO Is there better way to do this? This forces the saved state so Ember Data will make a server call. model.send('pushedData'); model .destroyRecord() .then(() => { - this.get('flashMessages').success( + this.flashMessages.success( `The CA key for ${backend} has been deleted. The old CA certificate will still be accessible for reading until a new certificate/key are generated or uploaded.` ); }) @@ -182,10 +182,10 @@ export default Component.extend({ signIntermediate: false, replaceCA: false, }); - this.get('onRefresh')(); + this.onRefresh(); }, toggleReplaceCA() { - if (!this.get('replaceCA')) { + if (!this.replaceCA) { this.createOrReplaceModel(); } this.toggleProperty('replaceCA'); diff --git a/ui/app/components/config-pki.js b/ui/app/components/config-pki.js index e0893994f..a91cead04 100644 --- a/ui/app/components/config-pki.js +++ b/ui/app/components/config-pki.js @@ -39,7 +39,7 @@ export default Component.extend({ actions: { save(section) { this.set('loading', true); - const config = this.get('config'); + const config = this.config; config .save({ adapterOptions: { @@ -48,7 +48,7 @@ export default Component.extend({ }, }) .then(() => { - this.get('flashMessages').success(`The ${section} config for this backend has been updated.`); + this.flashMessages.success(`The ${section} config for this backend has been updated.`); // attrs aren't persistent for Tidy if (section === 'tidy') { config.rollbackAttributes(); @@ -63,7 +63,7 @@ export default Component.extend({ }); }, refresh() { - this.get('onRefresh')(); + this.onRefresh(); }, }, }); diff --git a/ui/app/components/console/command-input.js b/ui/app/components/console/command-input.js index 228122fe6..10aa19ef8 100644 --- a/ui/app/components/console/command-input.js +++ b/ui/app/components/console/command-input.js @@ -14,18 +14,18 @@ export default Component.extend({ const keyCode = event.keyCode; switch (keyCode) { case keys.ENTER: - this.get('onExecuteCommand')(event.target.value); + this.onExecuteCommand(event.target.value); break; case keys.UP: case keys.DOWN: - this.get('onShiftCommand')(keyCode); + this.onShiftCommand(keyCode); break; default: - this.get('onValueUpdate')(event.target.value); + this.onValueUpdate(event.target.value); } }, fullscreen() { - this.get('onFullscreen')(); + this.onFullscreen(); }, }, }); diff --git a/ui/app/components/console/log-error-with-html.js b/ui/app/components/console/log-error-with-html.js new file mode 100644 index 000000000..557064773 --- /dev/null +++ b/ui/app/components/console/log-error-with-html.js @@ -0,0 +1,3 @@ +import Component from '@ember/component'; + +export default Component.extend({}); diff --git a/ui/app/components/console/log-list.js b/ui/app/components/console/log-list.js index 8da580793..28e226b39 100644 --- a/ui/app/components/console/log-list.js +++ b/ui/app/components/console/log-list.js @@ -1,9 +1,7 @@ +import { reads } from '@ember/object/computed'; import Component from '@ember/component'; -import { computed } from '@ember/object'; export default Component.extend({ content: null, - list: computed('content', function() { - return this.get('content').keys; - }), + list: reads('content.keys'), }); diff --git a/ui/app/components/console/log-object.js b/ui/app/components/console/log-object.js index d59ed8e9b..654fbbdf9 100644 --- a/ui/app/components/console/log-object.js +++ b/ui/app/components/console/log-object.js @@ -16,7 +16,7 @@ export function stringifyObjectValues(data) { export default Component.extend({ content: null, columns: computed('content', function() { - let data = this.get('content'); + let data = this.content; stringifyObjectValues(data); return columnify(data, { diff --git a/ui/app/components/console/ui-panel.js b/ui/app/components/console/ui-panel.js index 788db5ed1..81999491d 100644 --- a/ui/app/components/console/ui-panel.js +++ b/ui/app/components/console/ui-panel.js @@ -25,7 +25,7 @@ export default Component.extend({ classNameBindings: ['isFullscreen:fullscreen'], isFullscreen: false, inputValue: null, - log: alias('console.log'), + cliLog: alias('console.log'), didRender() { this._super(...arguments); @@ -33,7 +33,7 @@ export default Component.extend({ }, logAndOutput(command, logContent) { - this.get('console').logAndOutput(command, logContent); + this.console.logAndOutput(command, logContent); run.schedule('afterRender', () => this.scrollToBottom()); }, @@ -41,7 +41,7 @@ export default Component.extend({ executeCommand: task(function*(command, shouldThrow = false) { this.set('inputValue', ''); - let service = this.get('console'); + let service = this.console; let serviceArgs; if ( @@ -84,7 +84,7 @@ export default Component.extend({ this.logAndOutput(command, logFromResponse(resp, path, method, flags)); } catch (error) { if (error instanceof ControlGroupError) { - return this.logAndOutput(command, this.get('controlGroup').logFromError(error)); + return this.logAndOutput(command, this.controlGroup.logFromError(error)); } this.logAndOutput(command, logFromError(error, path, method)); } @@ -92,11 +92,11 @@ export default Component.extend({ refreshRoute: task(function*() { let owner = getOwner(this); - let routeName = this.get('router.currentRouteName'); + let routeName = this.router.currentRouteName; let route = owner.lookup(`route:${routeName}`); try { - this.get('store').clearAllDatasets(); + this.store.clearAllDatasets(); yield route.refresh(); this.logAndOutput(null, { type: 'success', content: 'The current screen has been refreshed!' }); } catch (error) { @@ -128,7 +128,7 @@ export default Component.extend({ }), shiftCommandIndex(keyCode) { - this.get('console').shiftCommandIndex(keyCode, val => { + this.console.shiftCommandIndex(keyCode, val => { this.set('inputValue', val); }); }, @@ -145,7 +145,7 @@ export default Component.extend({ this.toggleProperty('isFullscreen'); }, executeCommand(val) { - this.get('executeCommand').perform(val, true); + this.executeCommand.perform(val, true); }, shiftCommandIndex(direction) { this.shiftCommandIndex(direction); diff --git a/ui/app/components/control-group-success.js b/ui/app/components/control-group-success.js index d5659e619..1278f277b 100644 --- a/ui/app/components/control-group-success.js +++ b/ui/app/components/control-group-success.js @@ -16,20 +16,20 @@ export default Component.extend({ unwrapData: null, unwrap: task(function*(token) { - let adapter = this.get('store').adapterFor('tools'); + let adapter = this.store.adapterFor('tools'); this.set('error', null); try { let response = yield adapter.toolAction('unwrap', null, { clientToken: token }); this.set('unwrapData', response.auth || response.data); - this.get('controlGroup').deleteControlGroupToken(this.get('model.id')); + this.controlGroup.deleteControlGroupToken(this.model.id); } catch (e) { this.set('error', `Token unwrap failed: ${e.errors[0]}`); } }).drop(), markAndNavigate: task(function*() { - this.get('controlGroup').markTokenForUnwrap(this.get('model.id')); - let { url } = this.get('controlGroupResponse.uiParams'); - yield this.get('router').transitionTo(url); + this.controlGroup.markTokenForUnwrap(this.model.id); + let { url } = this.controlGroupResponse.uiParams; + yield this.router.transitionTo(url); }).drop(), }); diff --git a/ui/app/components/control-group.js b/ui/app/components/control-group.js index 704c359ad..ad89913c4 100644 --- a/ui/app/components/control-group.js +++ b/ui/app/components/control-group.js @@ -14,27 +14,28 @@ export default Component.extend({ didReceiveAttrs() { this._super(...arguments); - let accessor = this.get('model.id'); - let data = this.get('controlGroup').wrapInfoForAccessor(accessor); + let accessor = this.model.id; + let data = this.controlGroup.wrapInfoForAccessor(accessor); this.set('controlGroupResponse', data); }, currentUserEntityId: alias('auth.authData.entity_id'), currentUserIsRequesting: computed('currentUserEntityId', 'model.requestEntity.id', function() { - return this.get('currentUserEntityId') === this.get('model.requestEntity.id'); + if (!this.model.requestEntity) return false; + return this.currentUserEntityId === this.model.requestEntity.id; }), currentUserHasAuthorized: computed('currentUserEntityId', 'model.authorizations.@each.id', function() { - let authorizations = this.get('model.authorizations') || []; - return Boolean(authorizations.findBy('id', this.get('currentUserEntityId'))); + let authorizations = this.model.authorizations || []; + return Boolean(authorizations.findBy('id', this.currentUserEntityId)); }), isSuccess: or('currentUserHasAuthorized', 'model.approved'), requestorName: computed('currentUserIsRequesting', 'model.requestEntity', function() { - let entity = this.get('model.requestEntity'); + let entity = this.model.requestEntity; - if (this.get('currentUserIsRequesting')) { + if (this.currentUserIsRequesting) { return 'You'; } if (entity && get(entity, 'name')) { @@ -44,21 +45,18 @@ export default Component.extend({ }), bannerPrefix: computed('model.approved', 'currentUserHasAuthorized', function() { - if (this.get('currentUserHasAuthorized')) { + if (this.currentUserHasAuthorized) { return 'Thanks!'; } - if (this.get('model.approved')) { + if (this.model.approved) { return 'Success!'; } return 'Locked'; }), bannerText: computed('model.approved', 'currentUserIsRequesting', 'currentUserHasAuthorized', function() { - let isApproved = this.get('model.approved'); - let { currentUserHasAuthorized, currentUserIsRequesting } = this.getProperties( - 'currentUserIsRequesting', - 'currentUserHasAuthorized' - ); + let isApproved = this.model.approved; + let { currentUserHasAuthorized, currentUserIsRequesting } = this; if (currentUserHasAuthorized) { return 'You have given authorization'; } @@ -76,7 +74,7 @@ export default Component.extend({ refresh: task(function*() { try { - yield this.get('model').reload(); + yield this.model.reload(); } catch (e) { this.set('errors', e); } @@ -84,8 +82,8 @@ export default Component.extend({ authorize: task(function*() { try { - yield this.get('model').save(); - yield this.get('refresh').perform(); + yield this.model.save(); + yield this.refresh.perform(); } catch (e) { this.set('errors', e); } diff --git a/ui/app/components/flash-message.js b/ui/app/components/flash-message.js index 814fd3e15..788e0a34c 100644 --- a/ui/app/components/flash-message.js +++ b/ui/app/components/flash-message.js @@ -1,4 +1,4 @@ -import { getWithDefault, computed } from '@ember/object'; +import { computed } from '@ember/object'; import FlashMessage from 'ember-cli-flash/components/flash-message'; export default FlashMessage.extend({ @@ -6,7 +6,7 @@ export default FlashMessage.extend({ //https://github.com/poteto/ember-cli-flash/blob/master/addon/components/flash-message.js#L35 alertType: computed('flash.type', { get() { - const flashType = getWithDefault(this, 'flash.type', ''); + const flashType = this.flash.type || ''; let prefix = 'is-'; return `${prefix}${flashType}`; diff --git a/ui/app/components/generate-credentials.js b/ui/app/components/generate-credentials.js index 159d7350b..353849540 100644 --- a/ui/app/components/generate-credentials.js +++ b/ui/app/components/generate-credentials.js @@ -40,17 +40,17 @@ export default Component.extend({ emptyData: '{\n}', modelForType() { - const type = this.get('options'); + const type = this.options; if (type) { return type.model; } // if we don't have a mode for that type then redirect them back to the backend list - this.get('router').transitionTo('vault.cluster.secrets.backend.list-root', this.get('backendPath')); + this.router.transitionTo('vault.cluster.secrets.backend.list-root', this.backendPath); }, options: computed('action', 'backendType', function() { - const action = this.get('action') || 'creds'; - return MODEL_TYPES[`${this.get('backendType')}-${action}`]; + const action = this.action || 'creds'; + return MODEL_TYPES[`${this.backendType}-${action}`]; }), init() { @@ -59,25 +59,21 @@ export default Component.extend({ }, didReceiveAttrs() { - if (this.get('wizard.featureState') === 'displayRole') { - this.get('wizard').transitionFeatureMachine( - this.get('wizard.featureState'), - 'CONTINUE', - this.get('backendType') - ); + if (this.wizard.featureState === 'displayRole') { + this.wizard.transitionFeatureMachine(this.wizard.featureState, 'CONTINUE', this.backendType); } }, willDestroy() { - this.get('model').unloadRecord(); + this.model.unloadRecord(); this._super(...arguments); }, createOrReplaceModel() { const modelType = this.modelForType(); - const model = this.get('model'); - const roleName = this.get('roleName'); - const backendPath = this.get('backendPath'); + const model = this.model; + const roleName = this.roleName; + const backendPath = this.backendPath; if (!modelType) { return; } @@ -91,23 +87,19 @@ export default Component.extend({ }, id: `${backendPath}-${roleName}`, }; - const newModel = this.get('store').createRecord(modelType, attrs); + const newModel = this.store.createRecord(modelType, attrs); this.set('model', newModel); }, actions: { create() { - let model = this.get('model'); + let model = this.model; this.set('loading', true); this.model .save() .catch(() => { - if (this.get('wizard.featureState') === 'credentials') { - this.get('wizard').transitionFeatureMachine( - this.get('wizard.featureState'), - 'ERROR', - this.get('backendType') - ); + if (this.wizard.featureState === 'credentials') { + this.wizard.transitionFeatureMachine(this.wizard.featureState, 'ERROR', this.backendType); } }) .finally(() => { @@ -121,7 +113,7 @@ export default Component.extend({ const hasErrors = codemirror.state.lint.marked.length > 0; if (!hasErrors) { - set(this.get('model'), attr, JSON.parse(val)); + set(this.model, attr, JSON.parse(val)); } }, diff --git a/ui/app/components/generated-item.js b/ui/app/components/generated-item.js index e8ea6c034..c55dc7d7c 100644 --- a/ui/app/components/generated-item.js +++ b/ui/app/components/generated-item.js @@ -1,8 +1,8 @@ +import AdapterError from '@ember-data/adapter/error'; import { inject as service } from '@ember/service'; import Component from '@ember/component'; import { computed } from '@ember/object'; import { task } from 'ember-concurrency'; -import DS from 'ember-data'; /** * @module GeneratedItem @@ -24,7 +24,7 @@ export default Component.extend({ itemType: null, flashMessages: service(), router: service(), - props: computed(function() { + props: computed('model', function() { return this.model.serialize(); }), saveModel: task(function*() { @@ -33,7 +33,7 @@ export default Component.extend({ } catch (err) { // AdapterErrors are handled by the error-message component // in the form - if (err instanceof DS.AdapterError === false) { + if (err instanceof AdapterError === false) { throw err; } return; diff --git a/ui/app/components/home-link.js b/ui/app/components/home-link.js index 34457580c..7b70bf5e9 100644 --- a/ui/app/components/home-link.js +++ b/ui/app/components/home-link.js @@ -24,6 +24,6 @@ export default Component.extend({ }), computedClasses: computed('classNames', function() { - return this.get('classNames').join(' '); + return this.classNames.join(' '); }), }); diff --git a/ui/app/components/identity/_popup-base.js b/ui/app/components/identity/_popup-base.js index eaf8f0be9..febe721e7 100644 --- a/ui/app/components/identity/_popup-base.js +++ b/ui/app/components/identity/_popup-base.js @@ -29,12 +29,12 @@ export default Component.extend({ let messageArgs = this.messageArgs(...args); return this.transaction(...args) .then(() => { - this.get('onSuccess')(); - this.get('flashMessages').success(this.successMessage(...messageArgs)); + this.onSuccess(); + this.flashMessages.success(this.successMessage(...messageArgs)); }) .catch(e => { this.onError(...messageArgs); - this.get('flashMessages').success(this.errorMessage(e, ...messageArgs)); + this.flashMessages.success(this.errorMessage(e, ...messageArgs)); }); }, }, diff --git a/ui/app/components/identity/edit-form.js b/ui/app/components/identity/edit-form.js index 9aa972b45..673f66934 100644 --- a/ui/app/components/identity/edit-form.js +++ b/ui/app/components/identity/edit-form.js @@ -59,8 +59,8 @@ export default Component.extend({ // err will display via model state return; } - this.get('flashMessages').success(message); - yield this.get('onSave')({ saveType: 'save', model }); + this.flashMessages.success(message); + yield this.onSave({ saveType: 'save', model }); }) .drop() .withTestWaiter(), @@ -76,10 +76,10 @@ export default Component.extend({ actions: { deleteItem(model) { let message = this.getMessage(model, true); - let flash = this.get('flashMessages'); + let flash = this.flashMessages; model.destroyRecord().then(() => { flash.success(message); - return this.get('onSave')({ saveType: 'delete', model }); + return this.onSave({ saveType: 'delete', model }); }); }, }, diff --git a/ui/app/components/identity/entity-nav.js b/ui/app/components/identity/entity-nav.js new file mode 100644 index 000000000..557064773 --- /dev/null +++ b/ui/app/components/identity/entity-nav.js @@ -0,0 +1,3 @@ +import Component from '@ember/component'; + +export default Component.extend({}); diff --git a/ui/app/components/identity/item-details.js b/ui/app/components/identity/item-details.js index 929668288..cfa2dd928 100644 --- a/ui/app/components/identity/item-details.js +++ b/ui/app/components/identity/item-details.js @@ -11,10 +11,10 @@ export default Component.extend({ model .save() .then(() => { - this.get('flashMessages').success(`Successfully enabled entity: ${model.id}`); + this.flashMessages.success(`Successfully enabled entity: ${model.id}`); }) .catch(e => { - this.get('flashMessages').success( + this.flashMessages.success( `There was a problem enabling the entity: ${model.id} - ${e.errors.join(' ') || e.message}` ); }); diff --git a/ui/app/components/identity/lookup-input.js b/ui/app/components/identity/lookup-input.js index 2e83204a6..475fdbf76 100644 --- a/ui/app/components/identity/lookup-input.js +++ b/ui/app/components/identity/lookup-input.js @@ -20,26 +20,20 @@ export default Component.extend({ init() { this._super(...arguments); - this.get('store') - .findAll('auth-method') - .then(methods => { - this.set('authMethods', methods); - this.set('aliasMountAccessor', methods.get('firstObject.accessor')); - }); + this.store.findAll('auth-method').then(methods => { + this.set('authMethods', methods); + this.set('aliasMountAccessor', methods.get('firstObject.accessor')); + }); }, adapter() { - let type = this.get('type'); - let store = this.get('store'); + let type = this.type; + let store = this.store; return store.adapterFor(`identity/${type}`); }, data() { - let { param, paramValue, aliasMountAccessor } = this.getProperties( - 'param', - 'paramValue', - 'aliasMountAccessor' - ); + let { param, paramValue, aliasMountAccessor } = this; let data = {}; data[underscore([param])] = paramValue; @@ -50,10 +44,10 @@ export default Component.extend({ }, lookup: task(function*() { - let flash = this.get('flashMessages'); - let type = this.get('type'); - let store = this.get('store'); - let { param, paramValue } = this.getProperties('param', 'paramValue'); + let flash = this.flashMessages; + let type = this.type; + let store = this.store; + let { param, paramValue } = this; let response; try { response = yield this.adapter().lookup(store, this.data()); @@ -64,7 +58,7 @@ export default Component.extend({ return; } if (response) { - return this.get('router').transitionTo('vault.cluster.access.identity.show', response.id, 'details'); + return this.router.transitionTo('vault.cluster.access.identity.show', response.id, 'details'); } else { flash.danger(`We were unable to find an identity ${type} with a "${param}" of "${paramValue}".`); } diff --git a/ui/app/components/identity/popup-members.js b/ui/app/components/identity/popup-members.js index 560a4b1ce..36fe4f86b 100644 --- a/ui/app/components/identity/popup-members.js +++ b/ui/app/components/identity/popup-members.js @@ -6,11 +6,11 @@ export default Base.extend({ model: alias('params.firstObject'), groupArray: computed('params', function() { - return this.get('params').objectAt(1); + return this.params.objectAt(1); }), memberId: computed('params', function() { - return this.get('params').objectAt(2); + return this.params.objectAt(2); }), messageArgs(/*model, groupArray, memberId*/) { diff --git a/ui/app/components/identity/popup-policy.js b/ui/app/components/identity/popup-policy.js index 303081850..b77429363 100644 --- a/ui/app/components/identity/popup-policy.js +++ b/ui/app/components/identity/popup-policy.js @@ -5,7 +5,7 @@ import Base from './_popup-base'; export default Base.extend({ model: alias('params.firstObject'), policyName: computed('params', function() { - return this.get('params').objectAt(1); + return this.params.objectAt(1); }), messageArgs(model, policyName) { diff --git a/ui/app/components/json-editor.js b/ui/app/components/json-editor.js index 62de07dc6..48cea1bc6 100644 --- a/ui/app/components/json-editor.js +++ b/ui/app/components/json-editor.js @@ -16,7 +16,7 @@ const JSON_EDITOR_DEFAULTS = { export default IvyCodemirrorComponent.extend({ 'data-test-component': 'json-editor', updateCodeMirrorOptions() { - const options = assign({}, JSON_EDITOR_DEFAULTS, this.get('options')); + const options = assign({}, JSON_EDITOR_DEFAULTS, this.options); if (options.autoHeight) { options.viewportMargin = Infinity; delete options.autoHeight; diff --git a/ui/app/components/kv-object-editor.js b/ui/app/components/kv-object-editor.js index 07333cca3..a8da4b35c 100644 --- a/ui/app/components/kv-object-editor.js +++ b/ui/app/components/kv-object-editor.js @@ -18,7 +18,7 @@ export default Component.extend({ init() { this._super(...arguments); - const data = KVObject.create({ content: [] }).fromJSON(this.get('value')); + const data = KVObject.create({ content: [] }).fromJSON(this.value); this.set('kvData', data); this.addRow(); }, @@ -26,20 +26,20 @@ export default Component.extend({ kvData: null, kvDataAsJSON: computed('kvData', 'kvData.[]', function() { - return this.get('kvData').toJSON(); + return this.kvData.toJSON(); }), kvDataIsAdvanced: computed('kvData', 'kvData.[]', function() { - return this.get('kvData').isAdvanced(); + return this.kvData.isAdvanced(); }), kvHasDuplicateKeys: computed('kvData', 'kvData.@each.name', function() { - let data = this.get('kvData'); + let data = this.kvData; return data.uniqBy('name').length !== data.get('length'); }), addRow() { - let data = this.get('kvData'); + let data = this.kvData; let newObj = { name: '', value: '' }; if (!isNone(data.findBy('name', ''))) { return; @@ -53,17 +53,17 @@ export default Component.extend({ }, updateRow() { - let data = this.get('kvData'); - this.get('onChange')(data.toJSON()); + let data = this.kvData; + this.onChange(data.toJSON()); }, deleteRow(object, index) { - let data = this.get('kvData'); + let data = this.kvData; let oldObj = data.objectAt(index); assert('object guids match', guidFor(oldObj) === guidFor(object)); data.removeAt(index); - this.get('onChange')(data.toJSON()); + this.onChange(data.toJSON()); }, }, }); diff --git a/ui/app/components/license-info.js b/ui/app/components/license-info.js index b48d1b787..c772a9b3d 100644 --- a/ui/app/components/license-info.js +++ b/ui/app/components/license-info.js @@ -1,3 +1,4 @@ +import { equal } from '@ember/object/computed'; import Component from '@ember/component'; import { allFeatures } from 'vault/helpers/all-features'; import { computed } from '@ember/object'; @@ -10,10 +11,8 @@ export default Component.extend({ model: null, text: '', showForm: false, - isTemporary: computed('licenseId', function() { - return this.licenseId === 'temporary'; - }), - featuresInfo: computed('model', 'features', function() { + isTemporary: equal('licenseId', 'temporary'), + featuresInfo: computed('features', 'model.performanceStandbyCount', function() { return allFeatures().map(feature => { let active = this.features.includes(feature); if (active && feature === 'Performance Standby') { diff --git a/ui/app/components/mount-accessor-select.js b/ui/app/components/mount-accessor-select.js index ea4c9a704..73e775f47 100644 --- a/ui/app/components/mount-accessor-select.js +++ b/ui/app/components/mount-accessor-select.js @@ -12,12 +12,12 @@ export default Component.extend({ init() { this._super(...arguments); - this.get('authMethods').perform(); + this.authMethods.perform(); }, authMethods: task(function*() { - let methods = yield this.get('store').findAll('auth-method'); - if (!this.get('value')) { + let methods = yield this.store.findAll('auth-method'); + if (!this.value) { this.set('value', methods.get('firstObject.accessor')); } return methods; @@ -25,7 +25,7 @@ export default Component.extend({ actions: { change(value) { - this.get('onChange')(value); + this.onChange(value); }, }, }); diff --git a/ui/app/components/mount-backend-form.js b/ui/app/components/mount-backend-form.js index 6328e38ed..6e0237cef 100644 --- a/ui/app/components/mount-backend-form.js +++ b/ui/app/components/mount-backend-form.js @@ -51,12 +51,12 @@ export default Component.extend({ this.set('mountModel', model); }, - mountTypes: computed('mountType', function() { + mountTypes: computed('engines', 'mountType', function() { return this.mountType === 'secret' ? this.engines : METHODS; }), - engines: computed('version.features[]', function() { - if (this.get('version.isEnterprise')) { + engines: computed('version.{features[],isEnterprise}', function() { + if (this.version.isEnterprise) { return ENGINES.concat([KMIP, TRANSFORM]); } return ENGINES; @@ -64,7 +64,7 @@ export default Component.extend({ willDestroy() { // if unsaved, we want to unload so it doesn't show up in the auth mount list - this.get('mountModel').rollbackAttributes(); + this.mountModel.rollbackAttributes(); }, checkPathChange(type) { @@ -81,7 +81,7 @@ export default Component.extend({ mountBackend: task(function*() { const mountModel = this.mountModel; - const { type, path } = mountModel.getProperties('type', 'path'); + const { type, path } = mountModel; try { yield mountModel.save(); } catch (err) { diff --git a/ui/app/components/namespace-link.js b/ui/app/components/namespace-link.js index 0d966e845..7b5993556 100644 --- a/ui/app/components/namespace-link.js +++ b/ui/app/components/namespace-link.js @@ -13,13 +13,13 @@ export default Component.extend({ showLastSegment: false, normalizedNamespace: computed('targetNamespace', function() { - let ns = this.get('targetNamespace'); + let ns = this.targetNamespace; return (ns || '').replace(/\.+/g, '/').replace(/☃/g, '.'); }), namespaceDisplay: computed('normalizedNamespace', 'showLastSegment', function() { - let ns = this.get('normalizedNamespace'); - let showLastSegment = this.get('showLastSegment'); + let ns = this.normalizedNamespace; + let showLastSegment = this.showLastSegment; let parts = ns.split('/'); if (ns === '') { return 'root'; @@ -28,6 +28,6 @@ export default Component.extend({ }), isCurrentNamespace: computed('targetNamespace', 'currentNamespace', function() { - return this.get('currentNamespace') === this.get('targetNamespace'); + return this.currentNamespace === this.targetNamespace; }), }); diff --git a/ui/app/components/namespace-picker.js b/ui/app/components/namespace-picker.js index 60e0e4829..44146c153 100644 --- a/ui/app/components/namespace-picker.js +++ b/ui/app/components/namespace-picker.js @@ -21,17 +21,17 @@ export default Component.extend({ init() { this._super(...arguments); - this.get('namespaceService.findNamespacesForUser').perform(); + this.namespaceService?.findNamespacesForUser.perform(); }, didReceiveAttrs() { this._super(...arguments); - let ns = this.get('namespace'); - let oldNS = this.get('oldNamespace'); + let ns = this.namespace; + let oldNS = this.oldNamespace; if (!oldNS || ns !== oldNS) { - this.get('setForAnimation').perform(); - this.get('fetchListCapability').perform(); + this.setForAnimation.perform(); + this.fetchListCapability.perform(); } this.set('oldNamespace', ns); }, @@ -48,8 +48,8 @@ export default Component.extend({ } }), setForAnimation: task(function*() { - let leaves = this.get('menuLeaves'); - let lastLeaves = this.get('lastMenuLeaves'); + let leaves = this.menuLeaves; + let lastLeaves = this.lastMenuLeaves; if (!lastLeaves) { this.set('lastMenuLeaves', leaves); yield timeout(0); @@ -82,7 +82,7 @@ export default Component.extend({ inRootNamespace: alias('namespaceService.inRootNamespace'), namespaceTree: computed('accessibleNamespaces', function() { - let nsList = this.get('accessibleNamespaces'); + let nsList = this.accessibleNamespaces; if (!nsList) { return []; @@ -91,7 +91,7 @@ export default Component.extend({ }), maybeAddRoot(leaves) { - let userRoot = this.get('auth.authData.userRootNamespace'); + let userRoot = this.auth.authData.userRootNamespace; if (userRoot === '') { leaves.unshift(''); } @@ -123,8 +123,8 @@ export default Component.extend({ // to render the nodes of each leaf // gets set as 'lastMenuLeaves' in the ember concurrency task above - menuLeaves: computed('namespacePath', 'namespaceTree', function() { - let ns = this.get('namespacePath'); + menuLeaves: computed('namespacePath', 'namespaceTree', 'pathToLeaf', function() { + let ns = this.namespacePath; ns = ns.replace(/^\//, ''); let leaves = ancestorKeysForKey(ns); leaves.push(ns); @@ -137,7 +137,7 @@ export default Component.extend({ // the nodes at the root of the namespace tree // these will get rendered as the bottom layer rootLeaves: computed('namespaceTree', function() { - let tree = this.get('namespaceTree'); + let tree = this.namespaceTree; let leaves = Object.keys(tree); return leaves; }), @@ -145,11 +145,11 @@ export default Component.extend({ currentLeaf: alias('lastMenuLeaves.lastObject'), canAccessMultipleNamespaces: gt('accessibleNamespaces.length', 1), isUserRootNamespace: computed('auth.authData.userRootNamespace', 'namespacePath', function() { - return this.get('auth.authData.userRootNamespace') === this.get('namespacePath'); + return this.auth.authData.userRootNamespace === this.namespacePath; }), namespaceDisplay: computed('namespacePath', 'accessibleNamespaces', 'accessibleNamespaces.[]', function() { - let namespace = this.get('namespacePath'); + let namespace = this.namespacePath; if (namespace === '') { return ''; } @@ -159,7 +159,7 @@ export default Component.extend({ actions: { refreshNamespaceList() { - this.get('namespaceService.findNamespacesForUser').perform(); + this.namespaceService.findNamespacesForUser.perform(); }, }, }); diff --git a/ui/app/components/pgp-file.js b/ui/app/components/pgp-file.js index 1a0720299..920846360 100644 --- a/ui/app/components/pgp-file.js +++ b/ui/app/components/pgp-file.js @@ -50,7 +50,7 @@ export default Component.extend({ // If after decoding it's not b64, we want // the original as it was only encoded when we used `readAsDataURL`. const fileData = decoded.match(BASE_64_REGEX) ? decoded : b64File; - yield this.get('onChange')(this.get('index'), { value: fileData, fileName: filename }); + yield this.onChange(this.index, { value: fileData, fileName: filename }); }).withTestWaiter(), actions: { @@ -64,12 +64,12 @@ export default Component.extend({ } }, updateData(e) { - const key = this.get('key'); + const key = this.key; set(key, 'value', e.target.value); - this.get('onChange')(this.get('index'), this.get('key')); + this.onChange(this.index, this.key); }, clearKey() { - this.get('onChange')(this.get('index'), { value: '' }); + this.onChange(this.index, { value: '' }); }, }, }); diff --git a/ui/app/components/pki-cert-show.js b/ui/app/components/pki-cert-show.js index 4a2e09c45..bd1dad467 100644 --- a/ui/app/components/pki-cert-show.js +++ b/ui/app/components/pki-cert-show.js @@ -3,7 +3,7 @@ import RoleEdit from './role-edit'; export default RoleEdit.extend({ actions: { delete() { - this.get('model').save({ adapterOptions: { method: 'revoke' } }); + this.model.save({ adapterOptions: { method: 'revoke' } }); }, }, }); diff --git a/ui/app/components/pricing-metrics-dates.js b/ui/app/components/pricing-metrics-dates.js index e14a875fc..88af4dd66 100644 --- a/ui/app/components/pricing-metrics-dates.js +++ b/ui/app/components/pricing-metrics-dates.js @@ -69,7 +69,9 @@ export default Component.extend({ } }), - showResultsWarning: computed('resultStart', 'resultEnd', function() { + // We don't want the warning to show when inputs are being updated before query is made + /* eslint-disable-next-line ember/require-computed-property-dependencies */ + showResultsWarning: computed('resultEnd', 'resultStart', function() { if (!this.queryStart || !this.queryEnd || !this.resultStart || !this.resultEnd) { return false; } @@ -96,7 +98,7 @@ export default Component.extend({ return false; }), - error: computed('end', 'start', function() { + error: computed('end', 'endDate', 'retentionMonths', 'start', 'startDate', function() { if (!this.startDate) { return 'Start date is invalid. Please use format MM/YYYY'; } diff --git a/ui/app/components/radial-progress.js b/ui/app/components/radial-progress.js index 4c70f641d..ea221a460 100644 --- a/ui/app/components/radial-progress.js +++ b/ui/app/components/radial-progress.js @@ -11,19 +11,19 @@ export default Component.extend({ strokeWidth: 1, viewBox: computed('size', function() { - let s = this.get('size'); + let s = this.size; return `0 0 ${s} ${s}`; }), centerValue: computed('size', function() { - return this.get('size') / 2; + return this.size / 2; }), r: computed('size', 'strokeWidth', function() { - return (this.get('size') - this.get('strokeWidth')) / 2; + return (this.size - this.strokeWidth) / 2; }), c: computed('r', function() { - return 2 * Math.PI * this.get('r'); + return 2 * Math.PI * this.r; }), dashArrayOffset: computed('c', 'progressDecimal', function() { - return this.get('c') * (1 - this.get('progressDecimal')); + return this.c * (1 - this.progressDecimal); }), }); diff --git a/ui/app/components/role-aws-edit.js b/ui/app/components/role-aws-edit.js index d7e570434..4d0ad5cf4 100644 --- a/ui/app/components/role-aws-edit.js +++ b/ui/app/components/role-aws-edit.js @@ -1,5 +1,5 @@ import { isBlank } from '@ember/utils'; -import { set, get } from '@ember/object'; +import { set } from '@ember/object'; import RoleEdit from './role-edit'; const SHOW_ROUTE = 'vault.cluster.secrets.backend.show'; @@ -8,14 +8,13 @@ export default RoleEdit.extend({ createOrUpdate(type, event) { event.preventDefault(); - const modelId = this.get('model.id'); + const modelId = this.model.id; // prevent from submitting if there's no key // maybe do something fancier later if (type === 'create' && isBlank(modelId)) { return; } - - var credential_type = get(this, 'model.credential_type'); + var credential_type = this.model.credential_type; if (credential_type == 'iam_user') { set(this, 'model.role_arns', []); } @@ -27,7 +26,7 @@ export default RoleEdit.extend({ set(this, 'model.policy_arns', []); } - var policy_document = get(this, 'model.policy_document'); + var policy_document = this.model.policy_document; if (policy_document == '{}') { set(this, 'model.policy_document', ''); } @@ -43,7 +42,7 @@ export default RoleEdit.extend({ const hasErrors = codemirror.state.lint.marked.length > 0; if (!hasErrors) { - set(this.get('model'), attr, val); + set(this.model, attr, val); } }, }, diff --git a/ui/app/components/role-edit.js b/ui/app/components/role-edit.js index fb9bc80b6..d2d759096 100644 --- a/ui/app/components/role-edit.js +++ b/ui/app/components/role-edit.js @@ -24,21 +24,13 @@ export default Component.extend(FocusOnInsertMixin, { didReceiveAttrs() { this._super(...arguments); if ( - (this.get('wizard.featureState') === 'details' && this.get('mode') === 'create') || - (this.get('wizard.featureState') === 'role' && this.get('mode') === 'show') + (this.wizard.featureState === 'details' && this.mode === 'create') || + (this.wizard.featureState === 'role' && this.mode === 'show') ) { - this.get('wizard').transitionFeatureMachine( - this.get('wizard.featureState'), - 'CONTINUE', - this.get('backendType') - ); + this.wizard.transitionFeatureMachine(this.wizard.featureState, 'CONTINUE', this.backendType); } - if (this.get('wizard.featureState') === 'displayRole') { - this.get('wizard').transitionFeatureMachine( - this.get('wizard.featureState'), - 'NOOP', - this.get('backendType') - ); + if (this.wizard.featureState === 'displayRole') { + this.wizard.transitionFeatureMachine(this.wizard.featureState, 'NOOP', this.backendType); } }, @@ -59,26 +51,26 @@ export default Component.extend(FocusOnInsertMixin, { .cancelOn('willDestroyElement'), transitionToRoute() { - this.get('router').transitionTo(...arguments); + this.router.transitionTo(...arguments); }, onEscape(e) { - if (e.keyCode !== keys.ESC || this.get('mode') !== 'show') { + if (e.keyCode !== keys.ESC || this.mode !== 'show') { return; } this.transitionToRoute(LIST_ROOT_ROUTE); }, hasDataChanges() { - get(this, 'onDataChange')(get(this, 'model.hasDirtyAttributes')); + this.onDataChange(this.model.hasDirtyAttributes); }, persist(method, successCallback) { - const model = get(this, 'model'); + const model = this.model; return model[method]().then(() => { if (!get(model, 'isError')) { - if (this.get('wizard.featureState') === 'role') { - this.get('wizard').transitionFeatureMachine('role', 'CONTINUE', this.get('backendType')); + if (this.wizard.featureState === 'role') { + this.wizard.transitionFeatureMachine('role', 'CONTINUE', this.backendType); } successCallback(model); } @@ -89,7 +81,7 @@ export default Component.extend(FocusOnInsertMixin, { createOrUpdate(type, event) { event.preventDefault(); - const modelId = this.get('model.id'); + const modelId = this.model.id; // prevent from submitting if there's no key // maybe do something fancier later if (type === 'create' && isBlank(modelId)) { @@ -103,11 +95,11 @@ export default Component.extend(FocusOnInsertMixin, { }, setValue(key, event) { - set(get(this, 'model'), key, event.target.checked); + set(this.model, key, event.target.checked); }, refresh() { - this.get('onRefresh')(); + this.onRefresh(); }, delete() { @@ -122,7 +114,7 @@ export default Component.extend(FocusOnInsertMixin, { const hasErrors = codemirror.state.lint.marked.length > 0; if (!hasErrors) { - set(this.get('model'), attr, JSON.parse(val)); + set(this.model, attr, JSON.parse(val)); } }, }, diff --git a/ui/app/components/role-ssh-edit.js b/ui/app/components/role-ssh-edit.js index 5ee426674..05da151c9 100644 --- a/ui/app/components/role-ssh-edit.js +++ b/ui/app/components/role-ssh-edit.js @@ -8,7 +8,7 @@ export default RoleEdit.extend({ actions: { updateTtl(path, val) { - const model = this.get('model'); + const model = this.model; let valueToSet = val.enabled === true ? `${val.seconds}s` : undefined; model.set(path, valueToSet); }, diff --git a/ui/app/components/secret-edit.js b/ui/app/components/secret-edit.js index 2af4d5784..49eb853f6 100644 --- a/ui/app/components/secret-edit.js +++ b/ui/app/components/secret-edit.js @@ -2,7 +2,7 @@ import { isBlank, isNone } from '@ember/utils'; import { inject as service } from '@ember/service'; import Component from '@ember/component'; import { computed, set } from '@ember/object'; -import { alias, or } from '@ember/object/computed'; +import { alias, or, not } from '@ember/object/computed'; import { task, waitForEvent } from 'ember-concurrency'; import FocusOnInsertMixin from 'vault/mixins/focus-on-insert'; import WithNavToNearestAncestor from 'vault/mixins/with-nav-to-nearest-ancestor'; @@ -35,7 +35,7 @@ export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, { wrappedData: null, isWrapping: false, - showWrapButton: computed.not('wrappedData'), + showWrapButton: not('wrappedData'), // called with a bool indicating if there's been a change in the secretData onDataChange() {}, @@ -154,9 +154,7 @@ export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, { return this.secretData.isAdvanced(); }), - showAdvancedMode: computed('preferAdvancedEdit', 'secretDataIsAdvanced', 'lastChange', function() { - return this.secretDataIsAdvanced || this.preferAdvancedEdit; - }), + showAdvancedMode: or('secretDataIsAdvanced', 'preferAdvancedEdit'), isWriteWithoutRead: computed('model.failedServerRead', 'modelForData.failedServerRead', 'isV2', function() { if (!this.model) return; diff --git a/ui/app/components/secret-link.js b/ui/app/components/secret-link.js index 2242c215d..fd400d293 100644 --- a/ui/app/components/secret-link.js +++ b/ui/app/components/secret-link.js @@ -31,7 +31,7 @@ export default Component.extend({ ariaLabel: null, linkParams: computed('mode', 'secret', 'queryParams', function() { - let data = this.getProperties('mode', 'secret', 'queryParams'); + let data = { mode: this.mode, secret: this.secret, queryParams: this.queryParams }; return linkParams(data); }), }); diff --git a/ui/app/components/shamir-progress.js b/ui/app/components/shamir-progress.js index 477d738d9..817ada1ba 100644 --- a/ui/app/components/shamir-progress.js +++ b/ui/app/components/shamir-progress.js @@ -6,7 +6,7 @@ export default Component.extend({ progress: null, classNames: ['shamir-progress'], progressDecimal: computed('threshold', 'progress', function() { - const { threshold, progress } = this.getProperties('threshold', 'progress'); + const { threshold, progress } = this; if (threshold && progress) { return progress / threshold; } diff --git a/ui/app/components/splash-page.js b/ui/app/components/splash-page.js index b69b76ffb..578f8894c 100644 --- a/ui/app/components/splash-page.js +++ b/ui/app/components/splash-page.js @@ -9,6 +9,6 @@ export default Component.extend({ tagName: '', activeCluster: computed('auth.activeCluster', function() { - return this.get('store').peekRecord('cluster', this.get('auth.activeCluster')); + return this.store.peekRecord('cluster', this.auth.activeCluster); }), }); diff --git a/ui/app/components/status-menu.js b/ui/app/components/status-menu.js index 406749a0c..8ec26c7c1 100644 --- a/ui/app/components/status-menu.js +++ b/ui/app/components/status-menu.js @@ -1,5 +1,5 @@ import { inject as service } from '@ember/service'; -import { alias } from '@ember/object/computed'; +import { alias, reads } from '@ember/object/computed'; import Component from '@ember/component'; import { computed } from '@ember/object'; @@ -23,9 +23,7 @@ export default Component.extend({ return glyphs[this.type]; }), activeCluster: computed('auth.activeCluster', function() { - return this.get('store').peekRecord('cluster', this.get('auth.activeCluster')); - }), - currentToken: computed('auth.currentToken', function() { - return this.get('auth.currentToken'); + return this.store.peekRecord('cluster', this.auth.activeCluster); }), + currentToken: reads('auth.currentToken'), }); diff --git a/ui/app/components/text-file.js b/ui/app/components/text-file.js index 42a4b885b..e1d72a078 100644 --- a/ui/app/components/text-file.js +++ b/ui/app/components/text-file.js @@ -59,7 +59,7 @@ export default Component.extend({ }, setFile(contents, filename) { - this.get('onChange')(this.get('index'), { value: contents, fileName: filename }); + this.onChange(this.index, { value: contents, fileName: filename }); }, actions: { @@ -73,12 +73,12 @@ export default Component.extend({ } }, updateData(e) { - const file = this.get('file'); + const file = this.file; set(file, 'value', e.target.value); - this.get('onChange')(this.get('index'), this.get('file')); + this.onChange(this.index, this.file); }, clearFile() { - this.get('onChange')(this.get('index'), { value: '' }); + this.onChange(this.index, { value: '' }); }, }, }); diff --git a/ui/app/components/tool-actions-form.js b/ui/app/components/tool-actions-form.js index b9a96e60b..606fca66e 100644 --- a/ui/app/components/tool-actions-form.js +++ b/ui/app/components/tool-actions-form.js @@ -2,7 +2,7 @@ import { match } from '@ember/object/computed'; import { assign } from '@ember/polyfills'; import { inject as service } from '@ember/service'; import Component from '@ember/component'; -import { setProperties, computed, set, get } from '@ember/object'; +import { setProperties, computed, set } from '@ember/object'; import { addSeconds } from 'date-fns'; const DEFAULTS = { @@ -51,8 +51,8 @@ export default Component.extend(DEFAULTS, { }, checkAction() { - const currentAction = get(this, 'selectedAction'); - const oldAction = get(this, 'oldSelectedAction'); + const currentAction = this.selectedAction; + const oldAction = this.oldSelectedAction; if (currentAction !== oldAction) { this.reset(); @@ -63,7 +63,7 @@ export default Component.extend(DEFAULTS, { dataIsEmpty: match('data', new RegExp(DEFAULTS.data)), expirationDate: computed('creation_time', 'creation_ttl', function() { - const { creation_time, creation_ttl } = this.getProperties('creation_time', 'creation_ttl'); + const { creation_time, creation_ttl } = this; if (!(creation_time && creation_ttl)) { return null; } @@ -93,32 +93,30 @@ export default Component.extend(DEFAULTS, { props = assign({}, props, { [keyName]: resp.wrap_info.token }); } if (props.token || props.rewrap_token || props.unwrap_data || action === 'lookup') { - this.get('wizard').transitionFeatureMachine(this.get('wizard.featureState'), 'CONTINUE'); + this.wizard.transitionFeatureMachine(this.wizard.featureState, 'CONTINUE'); } setProperties(this, props); }, getData() { - const action = get(this, 'selectedAction'); + const action = this.selectedAction; if (WRAPPING_ENDPOINTS.includes(action)) { - return get(this, 'dataIsEmpty') - ? { token: (get(this, 'token') || '').trim() } - : JSON.parse(get(this, 'data')); + return this.dataIsEmpty ? { token: (this.token || '').trim() } : JSON.parse(this.data); } if (action === 'random') { - return this.getProperties('bytes', 'format'); + return { bytes: this.bytes, format: this.format }; } if (action === 'hash') { - return this.getProperties('input', 'format', 'algorithm'); + return { input: this.input, format: this.format, algorithm: this.algorithm }; } }, actions: { doSubmit(evt) { evt.preventDefault(); - const action = get(this, 'selectedAction'); - const wrapTTL = action === 'wrap' ? get(this, 'wrapTTL') : null; + const action = this.selectedAction; + const wrapTTL = action === 'wrap' ? this.wrapTTL : null; const data = this.getData(); setProperties(this, { errors: null, @@ -127,7 +125,7 @@ export default Component.extend(DEFAULTS, { creation_ttl: null, }); - get(this, 'store') + this.store .adapterFor('tools') .toolAction(action, data, { wrapTTL }) .then(resp => this.handleSuccess(resp, action), (...errArgs) => this.handleError(...errArgs)); diff --git a/ui/app/components/transform-edit-base.js b/ui/app/components/transform-edit-base.js index 76f180d34..694925c66 100644 --- a/ui/app/components/transform-edit-base.js +++ b/ui/app/components/transform-edit-base.js @@ -2,7 +2,7 @@ import { inject as service } from '@ember/service'; import { or } from '@ember/object/computed'; import { isBlank } from '@ember/utils'; import Component from '@ember/component'; -import { set, get } from '@ember/object'; +import { set } from '@ember/object'; import FocusOnInsertMixin from 'vault/mixins/focus-on-insert'; const LIST_ROOT_ROUTE = 'vault.cluster.secrets.backend.list-root'; @@ -66,7 +66,7 @@ export default Component.extend(FocusOnInsertMixin, { }, persist(method, successCallback) { - const model = get(this, 'model'); + const model = this.model; return model[method]() .then(() => { successCallback(model); @@ -78,18 +78,17 @@ export default Component.extend(FocusOnInsertMixin, { }, applyDelete(callback = () => {}) { - const tab = this.listTabFromType(this.get('model.constructor.modelName')); + const tab = this.listTabFromType(this.model.constructor.modelName); this.persist('destroyRecord', () => { this.hasDataChanges(); callback(); - // TODO: Investigate what is causing a console error after this point this.transitionToRoute(LIST_ROOT_ROUTE, { queryParams: { tab } }); }); }, applyChanges(type, callback = () => {}) { - const modelId = this.get('model.id') || this.get('model.name'); // transform comes in as model.name - const modelPrefix = this.modelPrefixFromType(this.get('model.constructor.modelName')); + const modelId = this.model.id || this.model.name; // transform comes in as model.name + const modelPrefix = this.modelPrefixFromType(this.model.constructor.modelName); // prevent from submitting if there's no key // maybe do something fancier later if (type === 'create' && isBlank(modelId)) { @@ -115,11 +114,11 @@ export default Component.extend(FocusOnInsertMixin, { }, setValue(key, event) { - set(get(this, 'model'), key, event.target.checked); + set(this.model, key, event.target.checked); }, refresh() { - this.get('onRefresh')(); + this.onRefresh(); }, delete() { diff --git a/ui/app/components/transform-list-item.js b/ui/app/components/transform-list-item.js index e45bf3c1a..9df9fddd1 100644 --- a/ui/app/components/transform-list-item.js +++ b/ui/app/components/transform-list-item.js @@ -21,7 +21,7 @@ export default Component.extend({ itemType: '', isBuiltin: computed('item', 'itemType', function() { - const item = this.get('item'); + const item = this.item; if (this.itemType === 'alphabet' || this.itemType === 'template') { return item.get('id').startsWith('builtin/'); } diff --git a/ui/app/components/transform-role-edit.js b/ui/app/components/transform-role-edit.js index ba4fdf648..45d70e80d 100644 --- a/ui/app/components/transform-role-edit.js +++ b/ui/app/components/transform-role-edit.js @@ -5,12 +5,12 @@ export default TransformBase.extend({ init() { this._super(...arguments); - this.set('initialTransformations', this.get('model.transformations')); + this.set('initialTransformations', this.model.transformations); }, handleUpdateTransformations(updateTransformations, roleId, type = 'update') { if (!updateTransformations) return; - const backend = this.get('model.backend'); + const backend = this.model.backend; const promises = updateTransformations.map(transform => { return this.store .queryRecord('transform', { @@ -57,7 +57,7 @@ export default TransformBase.extend({ message = 'This role was edited to remove transformations, but this role was not removed from those transformations’ allowed_roles due to a lack of permissions.'; } - this.get('flashMessages').stickyInfo(message); + this.flashMessages.stickyInfo(message); } }); }, @@ -67,8 +67,8 @@ export default TransformBase.extend({ event.preventDefault(); this.applyChanges('save', () => { - const roleId = this.get('model.id'); - const newModelTransformations = this.get('model.transformations'); + const roleId = this.model.id; + const newModelTransformations = this.model.transformations; if (!this.initialTransformations) { this.handleUpdateTransformations( diff --git a/ui/app/components/transformation-edit.js b/ui/app/components/transformation-edit.js index 9db2c5d92..269c251cb 100644 --- a/ui/app/components/transformation-edit.js +++ b/ui/app/components/transformation-edit.js @@ -5,7 +5,8 @@ export default TransformBase.extend({ init() { this._super(...arguments); - this.set('initialRoles', this.get('model.allowed_roles')); + if (!this.model) return; + this.set('initialRoles', this.model.allowed_roles); }, updateOrCreateRole(role, transformationId, backend) { @@ -59,7 +60,7 @@ export default TransformBase.extend({ handleUpdateRoles(updateRoles, transformationId) { if (!updateRoles) return; - const backend = this.get('model.backend'); + const backend = this.model.backend; const promises = updateRoles.map(r => this.updateOrCreateRole(r, transformationId, backend)); Promise.all(promises).then(results => { @@ -73,7 +74,7 @@ export default TransformBase.extend({ // eg. trying to update a role with empty array as transformations message = `You've edited the allowed_roles for this transformation. However, the corresponding edits to some roles' transformations were not made`; } - this.get('flashMessages').stickyInfo(message); + this.flashMessages.stickyInfo(message); } }); }, @@ -93,12 +94,12 @@ export default TransformBase.extend({ event.preventDefault(); this.applyChanges('save', () => { - const transformationId = this.get('model.id'); - const newModelRoles = this.get('model.allowed_roles') || []; - const initialRoles = this.get('initialRoles') || []; + const transformationId = this.model.id; + const newModelRoles = this.model.allowed_roles || []; + const initialRoles = this.initialRoles || []; const updateRoles = [...newModelRoles, ...initialRoles] - .filter(r => !this.isWildcard(r)) // TODO: expand wildcards into included roles instead + .filter(r => !this.isWildcard(r)) // CBS TODO: expand wildcards into included roles instead .map(role => { if (initialRoles.indexOf(role) < 0) { return { diff --git a/ui/app/components/transit-edit.js b/ui/app/components/transit-edit.js index d5258086e..c596777bc 100644 --- a/ui/app/components/transit-edit.js +++ b/ui/app/components/transit-edit.js @@ -37,29 +37,29 @@ export default Component.extend(FocusOnInsertMixin, { .cancelOn('willDestroyElement'), transitionToRoute() { - this.get('router').transitionTo(...arguments); + this.router.transitionTo(...arguments); }, onEscape(e) { - if (e.keyCode !== keys.ESC || this.get('mode') !== 'show') { + if (e.keyCode !== keys.ESC || this.mode !== 'show') { return; } this.transitionToRoute(LIST_ROOT_ROUTE); }, hasDataChanges() { - get(this, 'onDataChange')(get(this, 'key.hasDirtyAttributes')); + this.onDataChange(this.key.hasDirtyAttributes); }, persistKey(method, successCallback) { - const key = get(this, 'key'); + const key = this.key; return key[method]().then(() => { if (!get(key, 'isError')) { - if (this.get('wizard.featureState') === 'secret') { - this.get('wizard').transitionFeatureMachine('secret', 'CONTINUE'); + if (this.wizard.featureState === 'secret') { + this.wizard.transitionFeatureMachine('secret', 'CONTINUE'); } else { - if (this.get('wizard.featureState') === 'encryption') { - this.get('wizard').transitionFeatureMachine('encryption', 'CONTINUE', 'transit'); + if (this.wizard.featureState === 'encryption') { + this.wizard.transitionFeatureMachine('encryption', 'CONTINUE', 'transit'); } } successCallback(key); @@ -71,7 +71,7 @@ export default Component.extend(FocusOnInsertMixin, { createOrUpdateKey(type, event) { event.preventDefault(); - const keyId = this.get('key.id'); + const keyId = this.key.id || this.key.name; // prevent from submitting if there's no key // maybe do something fancier later if (type === 'create' && isBlank(keyId)) { @@ -89,19 +89,19 @@ export default Component.extend(FocusOnInsertMixin, { }, setValueOnKey(key, event) { - set(get(this, 'key'), key, event.target.checked); + set(this.key, key, event.target.checked); }, derivedChange(val) { - get(this, 'key').setDerived(val); + this.key.setDerived(val); }, convergentEncryptionChange(val) { - get(this, 'key').setConvergentEncryption(val); + this.key.setConvergentEncryption(val); }, refresh() { - this.get('onRefresh')(); + this.onRefresh(); }, deleteKey() { diff --git a/ui/app/components/transit-key-actions.js b/ui/app/components/transit-key-actions.js index 3a4294f8d..4ccfc3445 100644 --- a/ui/app/components/transit-key-actions.js +++ b/ui/app/components/transit-key-actions.js @@ -65,9 +65,12 @@ export default Component.extend(TRANSIT_PARAMS, { onRefresh() {}, init() { this._super(...arguments); + // TODO figure out why get is needed here Ember Upgrade + // eslint-disable-next-line ember/no-get if (get(this, 'selectedAction')) { return; } + // eslint-disable-next-line ember/no-get set(this, 'selectedAction', get(this, 'key.supportedActions.firstObject')); assert('`key` is required for `' + this.toString() + '`.', this.getModelInfo()); }, @@ -75,14 +78,14 @@ export default Component.extend(TRANSIT_PARAMS, { didReceiveAttrs() { this._super(...arguments); this.checkAction(); - if (get(this, 'selectedAction') === 'export') { + if (this.selectedAction === 'export') { this.setExportKeyDefaults(); } }, setExportKeyDefaults() { - const exportKeyType = get(this, 'key.exportKeyTypes.firstObject'); - const exportKeyVersion = get(this, 'key.validKeyVersions.lastObject'); + const exportKeyType = this.key.exportKeyTypes.firstObject; + const exportKeyVersion = this.key.validKeyVersions.lastObject; this.setProperties({ exportKeyType, exportKeyVersion, @@ -90,12 +93,12 @@ export default Component.extend(TRANSIT_PARAMS, { }, keyIsRSA: computed('key.type', function() { - let type = get(this, 'key.type'); + let type = this.key.type; return type === 'rsa-2048' || type === 'rsa-3072' || type === 'rsa-4096'; }), getModelInfo() { - const model = get(this, 'key') || get(this, 'backend'); + const model = this.key || this.backend; if (!model) { return null; } @@ -109,8 +112,8 @@ export default Component.extend(TRANSIT_PARAMS, { }, checkAction() { - const currentAction = get(this, 'selectedAction'); - const oldAction = get(this, 'oldSelectedAction'); + const currentAction = this.selectedAction; + const oldAction = this.oldSelectedAction; this.resetParams(oldAction, currentAction); set(this, 'oldSelectedAction', currentAction); @@ -124,7 +127,7 @@ export default Component.extend(TRANSIT_PARAMS, { // don't save values from datakey oldAction === 'datakey' || // can rewrap signatures — using that as a ciphertext later would be problematic - (oldAction === 'rewrap' && !get(this, 'key.supportsEncryption')); + (oldAction === 'rewrap' && !this.key.supportsEncryption); if (!clearWithoutCheck && action) { paramsToKeep = PARAMS_FOR_ACTION[action]; @@ -152,7 +155,7 @@ export default Component.extend(TRANSIT_PARAMS, { triggerSuccessMessage(action) { const message = SUCCESS_MESSAGE_FOR_ACTION[action]; if (!message) return; - this.get('flashMessages').success(message); + this.flashMessages.success(message); }, handleSuccess(resp, options, action) { @@ -170,13 +173,13 @@ export default Component.extend(TRANSIT_PARAMS, { this.toggleProperty('isModalActive'); this.setProperties(props); if (action === 'rotate') { - this.get('onRefresh')(); + this.onRefresh(); } this.triggerSuccessMessage(action); }, compactData(data) { - let type = get(this, 'key.type'); + let type = this.key.type; let isRSA = type === 'rsa-2048' || type === 'rsa-3072' || type === 'rsa-4096'; return Object.keys(data).reduce((result, key) => { if (key === 'signature_algorithm' && !isRSA) { @@ -196,7 +199,7 @@ export default Component.extend(TRANSIT_PARAMS, { }, onClear() { - this.resetParams(null, get(this, 'selectedAction')); + this.resetParams(null, this.selectedAction); }, clearParams(params) { @@ -206,14 +209,14 @@ export default Component.extend(TRANSIT_PARAMS, { toggleModal(successMessage) { if (!!successMessage && typeof successMessage === 'string') { - this.get('flashMessages').success(successMessage); + this.flashMessages.success(successMessage); } this.toggleProperty('isModalActive'); }, doSubmit(data, options = {}) { const { backend, id } = this.getModelInfo(); - const action = this.get('selectedAction'); + const action = this.selectedAction; const { encodedBase64, ...formData } = data || {}; if (!encodedBase64) { if (action === 'encrypt' && !!formData.plaintext) { @@ -228,7 +231,7 @@ export default Component.extend(TRANSIT_PARAMS, { errors: null, result: null, }); - this.get('store') + this.store .adapterFor('transit-key') .keyAction(action, { backend, id, payload }, options) .then( diff --git a/ui/app/components/ui-wizard.js b/ui/app/components/ui-wizard.js index 3ed52b8cf..0793a2a6b 100644 --- a/ui/app/components/ui-wizard.js +++ b/ui/app/components/ui-wizard.js @@ -1,7 +1,6 @@ import { inject as service } from '@ember/service'; -import { alias } from '@ember/object/computed'; +import { alias, or } from '@ember/object/computed'; import Component from '@ember/component'; -import { computed } from '@ember/object'; import { matchesState } from 'xstate'; export default Component.extend({ @@ -9,9 +8,7 @@ export default Component.extend({ wizard: service(), auth: service(), - shouldRender: computed('wizard.showWhenUnauthenticated', 'auth.currentToken', function() { - return this.get('auth.currentToken') || this.get('wizard.showWhenUnauthenticated'); - }), + shouldRender: or('auth.currentToken', 'wizard.showWhenUnauthenticated'), currentState: alias('wizard.currentState'), featureState: alias('wizard.featureState'), featureComponent: alias('wizard.featureComponent'), @@ -22,41 +19,33 @@ export default Component.extend({ actions: { dismissWizard() { - this.get('wizard').transitionTutorialMachine(this.get('currentState'), 'DISMISS'); + this.wizard.transitionTutorialMachine(this.currentState, 'DISMISS'); }, advanceWizard() { - let inInit = matchesState('init', this.get('wizard.currentState')); - let event = inInit ? this.get('wizard.initEvent') || 'CONTINUE' : 'CONTINUE'; - this.get('wizard').transitionTutorialMachine(this.get('currentState'), event); + let inInit = matchesState('init', this.wizard.currentState); + let event = inInit ? this.wizard.initEvent || 'CONTINUE' : 'CONTINUE'; + this.wizard.transitionTutorialMachine(this.currentState, event); }, advanceFeature() { - this.get('wizard').transitionFeatureMachine(this.get('featureState'), 'CONTINUE'); + this.wizard.transitionFeatureMachine(this.featureState, 'CONTINUE'); }, finishFeature() { - this.get('wizard').transitionFeatureMachine(this.get('featureState'), 'DONE'); + this.wizard.transitionFeatureMachine(this.featureState, 'DONE'); }, repeatStep() { - this.get('wizard').transitionFeatureMachine( - this.get('featureState'), - 'REPEAT', - this.get('componentState') - ); + this.wizard.transitionFeatureMachine(this.featureState, 'REPEAT', this.componentState); }, resetFeature() { - this.get('wizard').transitionFeatureMachine( - this.get('featureState'), - 'RESET', - this.get('componentState') - ); + this.wizard.transitionFeatureMachine(this.featureState, 'RESET', this.componentState); }, pauseWizard() { - this.get('wizard').transitionTutorialMachine(this.get('currentState'), 'PAUSE'); + this.wizard.transitionTutorialMachine(this.currentState, 'PAUSE'); }, }, }); diff --git a/ui/app/components/wizard-content.js b/ui/app/components/wizard-content.js index 6a929b5db..a257e4dd3 100644 --- a/ui/app/components/wizard-content.js +++ b/ui/app/components/wizard-content.js @@ -1,3 +1,4 @@ +import { alias, reads } from '@ember/object/computed'; import { inject as service } from '@ember/service'; import Component from '@ember/component'; import { computed } from '@ember/object'; @@ -10,24 +11,28 @@ export default Component.extend({ glyph: null, headerText: null, selectProgress: null, - currentMachine: computed.alias('wizard.currentMachine'), - tutorialState: computed.alias('wizard.currentState'), - tutorialComponent: computed.alias('wizard.tutorialComponent'), - showProgress: computed('wizard.featureComponent', 'tutorialState', function() { - return ( - this.tutorialComponent.includes('active') && - (this.tutorialState.includes('init.active') || - (this.wizard.featureComponent && this.wizard.featureMachineHistory)) - ); - }), - featureMachineHistory: computed.alias('wizard.featureMachineHistory'), - totalFeatures: computed('wizard.featureList', function() { - return this.wizard.featureList.length; - }), + currentMachine: alias('wizard.currentMachine'), + tutorialState: alias('wizard.currentState'), + tutorialComponent: alias('wizard.tutorialComponent'), + showProgress: computed( + 'tutorialComponent', + 'tutorialState', + 'wizard.{featureComponent,featureMachineHistory}', + function() { + if (!this.tutorialComponent) return; + return ( + this.tutorialComponent.includes('active') && + (this.tutorialState.includes('init.active') || + (this.wizard.featureComponent && this.wizard.featureMachineHistory)) + ); + } + ), + featureMachineHistory: alias('wizard.featureMachineHistory'), + totalFeatures: reads('wizard.featureList.length'), completedFeatures: computed('wizard.currentMachine', function() { return this.wizard.getCompletedFeatures(); }), - currentFeatureProgress: computed('featureMachineHistory.[]', function() { + currentFeatureProgress: computed('currentMachine', 'featureMachineHistory.[]', 'tutorialState', function() { if (this.tutorialState.includes('active.feature')) { let totalSteps = FEATURE_MACHINE_STEPS[this.currentMachine]; if (this.currentMachine === 'secrets') { @@ -63,35 +68,43 @@ export default Component.extend({ } return null; }), - progressBar: computed('currentFeatureProgress', 'currentFeature', 'currentTutorialProgress', function() { - let bar = []; - if (this.currentTutorialProgress) { - bar.push({ - style: htmlSafe(`width:${this.currentTutorialProgress.percentage}%;`), - completed: false, - showIcon: true, - }); - } else { - if (this.currentFeatureProgress) { - this.completedFeatures.forEach(feature => { - bar.push({ style: htmlSafe('width:100%;'), completed: true, feature: feature, showIcon: true }); - }); - this.wizard.featureList.forEach(feature => { - if (feature === this.currentMachine) { - bar.push({ - style: htmlSafe(`width:${this.currentFeatureProgress.percentage}%;`), - completed: this.currentFeatureProgress.percentage == 100 ? true : false, - feature: feature, - showIcon: true, - }); - } else { - bar.push({ style: htmlSafe('width:0%;'), completed: false, feature: feature, showIcon: true }); - } + progressBar: computed( + 'completedFeatures', + 'currentFeature', + 'currentFeatureProgress.percentage', + 'currentMachine', + 'currentTutorialProgress.percentage', + 'wizard.featureList', + function() { + let bar = []; + if (this.currentTutorialProgress) { + bar.push({ + style: htmlSafe(`width:${this.currentTutorialProgress.percentage}%;`), + completed: false, + showIcon: true, }); + } else { + if (this.currentFeatureProgress) { + this.completedFeatures.forEach(feature => { + bar.push({ style: htmlSafe('width:100%;'), completed: true, feature: feature, showIcon: true }); + }); + this.wizard.featureList.forEach(feature => { + if (feature === this.currentMachine) { + bar.push({ + style: htmlSafe(`width:${this.currentFeatureProgress.percentage}%;`), + completed: this.currentFeatureProgress.percentage == 100 ? true : false, + feature: feature, + showIcon: true, + }); + } else { + bar.push({ style: htmlSafe('width:0%;'), completed: false, feature: feature, showIcon: true }); + } + }); + } } + return bar; } - return bar; - }), + ), actions: { dismissWizard() { diff --git a/ui/app/components/wizard/features-selection.js b/ui/app/components/wizard/features-selection.js index f57d7f751..acd16cd0f 100644 --- a/ui/app/components/wizard/features-selection.js +++ b/ui/app/components/wizard/features-selection.js @@ -1,3 +1,4 @@ +import { or, not } from '@ember/object/computed'; import { inject as service } from '@ember/service'; import Component from '@ember/component'; import { computed } from '@ember/object'; @@ -15,13 +16,13 @@ export default Component.extend({ }, maybeHideFeatures() { - let features = this.get('allFeatures'); + let features = this.allFeatures; features.forEach(feat => { feat.disabled = this.doesNotHavePermission(feat.requiredPermissions); }); - if (this.get('showReplication') === false) { - let feature = this.get('allFeatures').findBy('key', 'replication'); + if (this.showReplication === false) { + let feature = this.allFeatures.findBy('key', 'replication'); feature.show = false; } }, @@ -126,24 +127,18 @@ export default Component.extend({ ]; }), - showReplication: computed('version.{hasPerfReplication,hasDRReplication}', function() { - return this.get('version.hasPerfReplication') || this.get('version.hasDRReplication'); - }), + showReplication: or('version.hasPerfReplication', 'version.hasDRReplication'), selectedFeatures: computed('allFeatures.@each.selected', function() { - return this.get('allFeatures') - .filterBy('selected') - .mapBy('key'); + return this.allFeatures.filterBy('selected').mapBy('key'); }), - cannotStartWizard: computed('selectedFeatures', function() { - return !this.get('selectedFeatures').length; - }), + cannotStartWizard: not('selectedFeatures.length'), actions: { saveFeatures() { - let wizard = this.get('wizard'); - wizard.saveFeatures(this.get('selectedFeatures')); + let wizard = this.wizard; + wizard.saveFeatures(this.selectedFeatures); wizard.transitionTutorialMachine('active.select', 'CONTINUE'); }, }, diff --git a/ui/app/components/wizard/mounts-wizard.js b/ui/app/components/wizard/mounts-wizard.js index f725270ba..1a2fa74af 100644 --- a/ui/app/components/wizard/mounts-wizard.js +++ b/ui/app/components/wizard/mounts-wizard.js @@ -1,5 +1,5 @@ import { inject as service } from '@ember/service'; -import { alias } from '@ember/object/computed'; +import { alias, equal } from '@ember/object/computed'; import Component from '@ember/component'; import { computed } from '@ember/object'; import { engines } from 'vault/helpers/mountable-secret-engines'; @@ -18,34 +18,32 @@ export default Component.extend({ fullNextStep: alias('wizard.nextStep'), nextFeature: alias('wizard.nextFeature'), nextStep: computed('fullNextStep', function() { - return this.get('fullNextStep').split('.').lastObject; - }), - needsEncryption: computed('mountSubtype', function() { - return this.get('mountSubtype') === 'transit'; + return this.fullNextStep.split('.').lastObject; }), + needsEncryption: equal('mountSubtype', 'transit'), stepComponent: alias('wizard.stepComponent'), - detailsComponent: computed('mountSubtype', function() { - let suffix = this.get('currentMachine') === 'secrets' ? 'engine' : 'method'; - return this.get('mountSubtype') ? `wizard/${this.get('mountSubtype')}-${suffix}` : null; + detailsComponent: computed('currentMachine', 'mountSubtype', function() { + let suffix = this.currentMachine === 'secrets' ? 'engine' : 'method'; + return this.mountSubtype ? `wizard/${this.mountSubtype}-${suffix}` : null; }), - isSupported: computed('mountSubtype', function() { - if (this.get('currentMachine') === 'secrets') { - return supportedSecrets.includes(this.get('mountSubtype')); + isSupported: computed('currentMachine', 'mountSubtype', function() { + if (this.currentMachine === 'secrets') { + return supportedSecrets.includes(this.mountSubtype); } else { - return supportedAuth.includes(this.get('mountSubtype')); + return supportedAuth.includes(this.mountSubtype); } }), - mountName: computed('mountSubtype', function() { - if (this.get('currentMachine') === 'secrets') { + mountName: computed('currentMachine', 'mountSubtype', function() { + if (this.currentMachine === 'secrets') { var secret = engines().find(engine => { - return engine.type === this.get('mountSubtype'); + return engine.type === this.mountSubtype; }); if (secret) { return secret.displayName; } } else { var auth = methods().find(method => { - return method.type === this.get('mountSubtype'); + return method.type === this.mountSubtype; }); if (auth) { return auth.displayName; @@ -54,7 +52,7 @@ export default Component.extend({ return null; }), actionText: computed('mountSubtype', function() { - switch (this.get('mountSubtype')) { + switch (this.mountSubtype) { case 'aws': return 'Generate credential'; case 'ssh': diff --git a/ui/app/components/wrap-ttl.js b/ui/app/components/wrap-ttl.js index a1ebde474..1b6a625c1 100644 --- a/ui/app/components/wrap-ttl.js +++ b/ui/app/components/wrap-ttl.js @@ -1,6 +1,6 @@ import { assert } from '@ember/debug'; import Component from '@ember/component'; -import { set, get, computed } from '@ember/object'; +import { set, computed } from '@ember/object'; import hbs from 'htmlbars-inline-precompile'; export default Component.extend({ @@ -11,18 +11,18 @@ export default Component.extend({ ttl: '30m', wrapTTL: computed('wrapResponse', 'ttl', function() { - const { wrapResponse, ttl } = this.getProperties('wrapResponse', 'ttl'); + const { wrapResponse, ttl } = this; return wrapResponse ? ttl : null; }), didRender() { this._super(...arguments); - get(this, 'onChange')(get(this, 'wrapTTL')); + this.onChange(this.wrapTTL); }, init() { this._super(...arguments); - assert('`onChange` handler is a required attr in `' + this.toString() + '`.', get(this, 'onChange')); + assert('`onChange` handler is a required attr in `' + this.toString() + '`.', this.onChange); }, layout: hbs` @@ -43,7 +43,7 @@ export default Component.extend({ changedValue(ttlObj) { set(this, 'wrapResponse', ttlObj.enabled); set(this, 'ttl', `${ttlObj.seconds}s`); - get(this, 'onChange')(get(this, 'wrapTTL')); + this.onChange(this.wrapTTL); }, }, }); diff --git a/ui/app/controllers/application.js b/ui/app/controllers/application.js index 85336b43b..c800ccf48 100644 --- a/ui/app/controllers/application.js +++ b/ui/app/controllers/application.js @@ -8,11 +8,11 @@ export default Controller.extend({ auth: service(), store: service(), activeCluster: computed('auth.activeCluster', function() { - let id = this.get('auth.activeCluster'); - return id ? this.get('store').peekRecord('cluster', id) : null; + let id = this.auth.activeCluster; + return id ? this.store.peekRecord('cluster', id) : null; }), activeClusterName: computed('activeCluster', function() { - const activeCluster = this.get('activeCluster'); + const activeCluster = this.activeCluster; return activeCluster ? activeCluster.get('name') : null; }), }); diff --git a/ui/app/controllers/vault.js b/ui/app/controllers/vault.js index 562a3c39c..4189d0b20 100644 --- a/ui/app/controllers/vault.js +++ b/ui/app/controllers/vault.js @@ -16,11 +16,11 @@ export default Controller.extend({ auth: service(), store: service(), activeCluster: computed('auth.activeCluster', function() { - let id = this.get('auth.activeCluster'); - return id ? this.get('store').peekRecord('cluster', id) : null; + let id = this.auth.activeCluster; + return id ? this.store.peekRecord('cluster', id) : null; }), activeClusterName: computed('activeCluster', function() { - const activeCluster = this.get('activeCluster'); + const activeCluster = this.activeCluster; return activeCluster ? activeCluster.get('name') : null; }), }); diff --git a/ui/app/controllers/vault/cluster.js b/ui/app/controllers/vault/cluster.js index ddfb2e391..fd3d32463 100644 --- a/ui/app/controllers/vault/cluster.js +++ b/ui/app/controllers/vault/cluster.js @@ -1,3 +1,4 @@ +/* eslint-disable ember/no-observers */ import { inject as service } from '@ember/service'; import { alias } from '@ember/object/computed'; import Controller from '@ember/controller'; @@ -24,19 +25,18 @@ export default Controller.extend({ namespaceQueryParam: '', - /* eslint-disable-next-line ember/no-observers */ onQPChange: observer('namespaceQueryParam', function() { - this.get('namespaceService').setNamespace(this.get('namespaceQueryParam')); + this.namespaceService.setNamespace(this.namespaceQueryParam); }), consoleOpen: alias('console.isOpen'), activeCluster: computed('auth.activeCluster', function() { - return this.get('store').peekRecord('cluster', this.get('auth.activeCluster')); + return this.store.peekRecord('cluster', this.auth.activeCluster); }), activeClusterName: computed('activeCluster', function() { - const activeCluster = this.get('activeCluster'); + const activeCluster = this.activeCluster; return activeCluster ? activeCluster.get('name') : null; }), @@ -46,11 +46,7 @@ export default Controller.extend({ 'auth.currentToken', 'activeCluster.{dr.isSecondary,needsInit,sealed}', function() { - if ( - this.get('activeCluster.dr.isSecondary') || - this.get('activeCluster.needsInit') || - this.get('activeCluster.sealed') - ) { + if (this.activeCluster.dr?.isSecondary || this.activeCluster.needsInit || this.activeCluster.sealed) { return false; } if ( @@ -60,6 +56,7 @@ export default Controller.extend({ ) { return true; } + return; } ), diff --git a/ui/app/controllers/vault/cluster/access/identity/create.js b/ui/app/controllers/vault/cluster/access/identity/create.js index 89940cb4a..0c6a1a89c 100644 --- a/ui/app/controllers/vault/cluster/access/identity/create.js +++ b/ui/app/controllers/vault/cluster/access/identity/create.js @@ -15,7 +15,7 @@ export default Controller.extend({ }; let routeName = listRoutes[type]; if (!isDelete) { - yield this.transitionToRoute(this.get('showRoute'), model.id, this.get('showTab')); + yield this.transitionToRoute(this.showRoute, model.id, this.showTab); return; } yield this.transitionToRoute(routeName); diff --git a/ui/app/controllers/vault/cluster/access/identity/index.js b/ui/app/controllers/vault/cluster/access/identity/index.js index 0ab1d2827..155d3b162 100644 --- a/ui/app/controllers/vault/cluster/access/identity/index.js +++ b/ui/app/controllers/vault/cluster/access/identity/index.js @@ -13,10 +13,10 @@ export default Controller.extend(ListController, { .destroyRecord() .then(() => { this.send('reload'); - this.get('flashMessages').success(`Successfully deleted ${type}: ${id}`); + this.flashMessages.success(`Successfully deleted ${type}: ${id}`); }) .catch(e => { - this.get('flashMessages').success( + this.flashMessages.success( `There was a problem deleting ${type}: ${id} - ${e.errors.join(' ') || e.message}` ); }); @@ -31,10 +31,10 @@ export default Controller.extend(ListController, { model .save() .then(() => { - this.get('flashMessages').success(`Successfully ${action[0]} ${type}: ${id}`); + this.flashMessages.success(`Successfully ${action[0]} ${type}: ${id}`); }) .catch(e => { - this.get('flashMessages').success( + this.flashMessages.success( `There was a problem ${action[1]} ${type}: ${id} - ${e.errors.join(' ') || e.message}` ); }); diff --git a/ui/app/controllers/vault/cluster/access/leases/list.js b/ui/app/controllers/vault/cluster/access/leases/list.js index 7c9ae9b06..80232bb52 100644 --- a/ui/app/controllers/vault/cluster/access/leases/list.js +++ b/ui/app/controllers/vault/cluster/access/leases/list.js @@ -9,23 +9,23 @@ export default Controller.extend(ListController, { store: service(), clusterController: controller('vault.cluster'), - backendCrumb: computed(function() { + backendCrumb: computed('clusterController.model.name', function() { return { label: 'leases', text: 'leases', path: 'vault.cluster.access.leases.list-root', - model: this.get('clusterController.model.name'), + model: this.clusterController.model.name, }; }), isLoading: false, filterIsFolder: computed('filter', function() { - return !!utils.keyIsFolder(this.get('filter')); + return !!utils.keyIsFolder(this.filter); }), emptyTitle: computed('baseKey.id', 'filter', 'filterIsFolder', function() { - let id = this.get('baseKey.id'); + let id = this.baseKey.id; let filter = this.filter; if (id === '') { return 'There are currently no leases.'; @@ -37,22 +37,23 @@ export default Controller.extend(ListController, { return `We couldn't find a prefix matching "${filter}".`; } } + return ''; }), actions: { revokePrefix(prefix, isForce) { - const adapter = this.get('store').adapterFor('lease'); + const adapter = this.store.adapterFor('lease'); const method = isForce ? 'forceRevokePrefix' : 'revokePrefix'; const fn = adapter[method]; fn.call(adapter, prefix) .then(() => { return this.transitionToRoute('vault.cluster.access.leases.list-root').then(() => { - this.get('flashMessages').success(`All of the leases under ${prefix} will be revoked.`); + this.flashMessages.success(`All of the leases under ${prefix} will be revoked.`); }); }) .catch(e => { const errString = e.errors.join('.'); - this.get('flashMessages').danger( + this.flashMessages.danger( `There was an error attempting to revoke the prefix: ${prefix}. ${errString}.` ); }); diff --git a/ui/app/controllers/vault/cluster/access/leases/show.js b/ui/app/controllers/vault/cluster/access/leases/show.js index a0112b7cc..343bc0b23 100644 --- a/ui/app/controllers/vault/cluster/access/leases/show.js +++ b/ui/app/controllers/vault/cluster/access/leases/show.js @@ -6,12 +6,12 @@ import Controller, { inject as controller } from '@ember/controller'; export default Controller.extend({ clusterController: controller('vault.cluster'), - backendCrumb: computed(function() { + backendCrumb: computed('clusterController.model.name', function() { return { label: 'leases', text: 'leases', path: 'vault.cluster.access.leases.list-root', - model: this.get('clusterController.model.name'), + model: this.clusterController.model.name, }; }), @@ -26,7 +26,7 @@ export default Controller.extend({ renewLease(model, interval) { const adapter = model.store.adapterFor('lease'); - const flash = this.get('flashMessages'); + const flash = this.flashMessages; adapter .renew(model.id, interval) .then(() => { diff --git a/ui/app/controllers/vault/cluster/access/methods.js b/ui/app/controllers/vault/cluster/access/methods.js index 13fe9b57a..15d47023f 100644 --- a/ui/app/controllers/vault/cluster/access/methods.js +++ b/ui/app/controllers/vault/cluster/access/methods.js @@ -12,12 +12,12 @@ export default Controller.extend({ filter: null, disableMethod: task(function*(method) { - const { type, path } = method.getProperties('type', 'path'); + const { type, path } = method; try { yield method.destroyRecord(); - this.get('flashMessages').success(`The ${type} Auth Method at ${path} has been disabled.`); + this.flashMessages.success(`The ${type} Auth Method at ${path} has been disabled.`); } catch (err) { - this.get('flashMessages').danger( + this.flashMessages.danger( `There was an error disabling Auth Method at ${path}: ${err.errors.join(' ')}.` ); } diff --git a/ui/app/controllers/vault/cluster/access/namespaces/create.js b/ui/app/controllers/vault/cluster/access/namespaces/create.js index a0d3ab9b6..1f410dd2d 100644 --- a/ui/app/controllers/vault/cluster/access/namespaces/create.js +++ b/ui/app/controllers/vault/cluster/access/namespaces/create.js @@ -6,7 +6,7 @@ export default Controller.extend({ onSave({ saveType }) { if (saveType === 'save') { // fetch new namespaces for the namespace picker - this.get('namespaceService.findNamespacesForUser').perform(); + this.namespaceService.findNamespacesForUser.perform(); return this.transitionToRoute('vault.cluster.access.namespaces.index'); } }, diff --git a/ui/app/controllers/vault/cluster/access/namespaces/index.js b/ui/app/controllers/vault/cluster/access/namespaces/index.js index 6044aba2d..87487c1ff 100644 --- a/ui/app/controllers/vault/cluster/access/namespaces/index.js +++ b/ui/app/controllers/vault/cluster/access/namespaces/index.js @@ -8,7 +8,7 @@ export default Controller.extend({ actions: { refreshNamespaceList() { // fetch new namespaces for the namespace picker - this.get('namespaceService.findNamespacesForUser').perform(); + this.namespaceService.findNamespacesForUser.perform(); }, }, }); diff --git a/ui/app/controllers/vault/cluster/auth.js b/ui/app/controllers/vault/cluster/auth.js index 873376139..03907ac29 100644 --- a/ui/app/controllers/vault/cluster/auth.js +++ b/ui/app/controllers/vault/cluster/auth.js @@ -16,7 +16,7 @@ export default Controller.extend({ updateNamespace: task(function*(value) { // debounce yield timeout(500); - this.get('namespaceService').setNamespace(value, true); + this.namespaceService.setNamespace(value, true); this.set('namespaceQueryParam', value); }).restartable(), }); diff --git a/ui/app/controllers/vault/cluster/init.js b/ui/app/controllers/vault/cluster/init.js index fd40ba951..41f2dee36 100644 --- a/ui/app/controllers/vault/cluster/init.js +++ b/ui/app/controllers/vault/cluster/init.js @@ -22,8 +22,8 @@ export default Controller.extend(DEFAULTS, { this.set('loading', false); this.set('keyData', resp); this.model.reload(); - this.get('wizard').set('initEvent', 'SAVE'); - this.get('wizard').transitionTutorialMachine(this.get('wizard.currentState'), 'TOSAVE'); + this.wizard.set('initEvent', 'SAVE'); + this.wizard.transitionTutorialMachine(this.wizard.currentState, 'TOSAVE'); }, initError(e) { @@ -36,7 +36,7 @@ export default Controller.extend(DEFAULTS, { }, keyFilename: computed('model.name', function() { - return `vault-cluster-${this.get('model.name')}`; + return `vault-cluster-${this.model.name}`; }), actions: { diff --git a/ui/app/controllers/vault/cluster/policies/create.js b/ui/app/controllers/vault/cluster/policies/create.js index 7965ae2d5..405f65327 100644 --- a/ui/app/controllers/vault/cluster/policies/create.js +++ b/ui/app/controllers/vault/cluster/policies/create.js @@ -8,7 +8,7 @@ export default Controller.extend(PolicyEditController, { actions: { setPolicyFromFile(index, fileInfo) { let { value, fileName } = fileInfo; - let model = this.get('model'); + let model = this.model; model.set('policy', value); if (!model.get('name')) { let trimmedFileName = trimRight(fileName, ['.json', '.txt', '.hcl', '.policy']); diff --git a/ui/app/controllers/vault/cluster/policies/index.js b/ui/app/controllers/vault/cluster/policies/index.js index 925bb518f..f7060a76b 100644 --- a/ui/app/controllers/vault/cluster/policies/index.js +++ b/ui/app/controllers/vault/cluster/policies/index.js @@ -21,18 +21,18 @@ export default Controller.extend({ isLoading: false, filterMatchesKey: computed('filter', 'model', 'model.[]', function() { - var filter = this.get('filter'); - var content = this.get('model'); + var filter = this.filter; + var content = this.model; return !!(content && content.length && content.findBy('id', filter)); }), firstPartialMatch: computed('filter', 'model', 'model.[]', 'filterMatchesKey', function() { - var filter = this.get('filter'); - var content = this.get('model'); + var filter = this.filter; + var content = this.model; if (!content) { return; } - var filterMatchesKey = this.get('filterMatchesKey'); + var filterMatchesKey = this.filterMatchesKey; var re = new RegExp('^' + filter); return filterMatchesKey ? null @@ -51,15 +51,15 @@ export default Controller.extend({ deletePolicy(model) { let policyType = model.get('policyType'); let name = model.id; - let flash = this.get('flashMessages'); + let flash = this.flashMessages; model .destroyRecord() .then(() => { // this will clear the dataset cache on the store this.send('reload'); flash.success(`${policyType.toUpperCase()} policy "${name}" was successfully deleted.`); - if (this.get('wizard.featureState') === 'delete') { - this.get('wizard').transitionFeatureMachine('delete', 'CONTINUE', policyType); + if (this.wizard.featureState === 'delete') { + this.wizard.transitionFeatureMachine('delete', 'CONTINUE', policyType); } }) .catch(e => { diff --git a/ui/app/controllers/vault/cluster/secrets/backend/configuration.js b/ui/app/controllers/vault/cluster/secrets/backend/configuration.js index 93aabec1d..2f27f26bc 100644 --- a/ui/app/controllers/vault/cluster/secrets/backend/configuration.js +++ b/ui/app/controllers/vault/cluster/secrets/backend/configuration.js @@ -4,6 +4,6 @@ import Controller from '@ember/controller'; export default Controller.extend({ isConfigurable: computed('model.type', function() { const configurableEngines = ['aws', 'ssh', 'pki']; - return configurableEngines.includes(this.get('model.type')); + return configurableEngines.includes(this.model.type); }), }); diff --git a/ui/app/controllers/vault/cluster/secrets/backend/create.js b/ui/app/controllers/vault/cluster/secrets/backend/create.js index b73dd7e59..0cb8fd2ab 100644 --- a/ui/app/controllers/vault/cluster/secrets/backend/create.js +++ b/ui/app/controllers/vault/cluster/secrets/backend/create.js @@ -14,7 +14,7 @@ export default Controller.extend(BackendCrumbMixin, { }, toggleAdvancedEdit(bool) { this.set('preferAdvancedEdit', bool); - this.get('backendController').set('preferAdvancedEdit', bool); + this.backendController.set('preferAdvancedEdit', bool); }, }, }); diff --git a/ui/app/controllers/vault/cluster/secrets/backend/edit.js b/ui/app/controllers/vault/cluster/secrets/backend/edit.js index b3acca861..cd99bfbe7 100644 --- a/ui/app/controllers/vault/cluster/secrets/backend/edit.js +++ b/ui/app/controllers/vault/cluster/secrets/backend/edit.js @@ -17,7 +17,7 @@ export default Controller.extend(BackendCrumbMixin, { toggleAdvancedEdit(bool) { this.set('preferAdvancedEdit', bool); - this.get('backendController').set('preferAdvancedEdit', bool); + this.backendController.set('preferAdvancedEdit', bool); }, }, }); diff --git a/ui/app/controllers/vault/cluster/secrets/backend/list.js b/ui/app/controllers/vault/cluster/secrets/backend/list.js index 6aa11e225..77261d496 100644 --- a/ui/app/controllers/vault/cluster/secrets/backend/list.js +++ b/ui/app/controllers/vault/cluster/secrets/backend/list.js @@ -1,3 +1,4 @@ +import { or } from '@ember/object/computed'; import { computed } from '@ember/object'; import { inject as service } from '@ember/service'; import Controller from '@ember/controller'; @@ -13,12 +14,10 @@ export default Controller.extend(ListController, BackendCrumbMixin, WithNavToNea tab: '', filterIsFolder: computed('filter', function() { - return !!utils.keyIsFolder(this.get('filter')); + return !!utils.keyIsFolder(this.filter); }), - isConfigurableTab: computed('isCertTab', 'isConfigure', function() { - return this.get('isCertTab') || this.get('isConfigure'); - }), + isConfigurableTab: or('isCertTab', 'isConfigure'), actions: { chooseAction(action) { @@ -32,7 +31,7 @@ export default Controller.extend(ListController, BackendCrumbMixin, WithNavToNea .saveZeroAddressConfig() .catch(e => { item.set('zeroAddress', false); - this.get('flashMessages').danger(e.message); + this.flashMessages.danger(e.message); }) .finally(() => { this.set('loading-' + item.id, false); @@ -42,7 +41,7 @@ export default Controller.extend(ListController, BackendCrumbMixin, WithNavToNea delete(item, type) { const name = item.id; item.destroyRecord().then(() => { - this.get('flashMessages').success(`${name} was successfully deleted.`); + this.flashMessages.success(`${name} was successfully deleted.`); this.send('reload'); if (type === 'secret') { this.navToNearestAncestor.perform(name); diff --git a/ui/app/controllers/vault/cluster/secrets/backend/show.js b/ui/app/controllers/vault/cluster/secrets/backend/show.js index 26c00b359..ca73190cc 100644 --- a/ui/app/controllers/vault/cluster/secrets/backend/show.js +++ b/ui/app/controllers/vault/cluster/secrets/backend/show.js @@ -19,7 +19,7 @@ export default Controller.extend(BackendCrumbMixin, { toggleAdvancedEdit(bool) { this.set('preferAdvancedEdit', bool); - this.get('backendController').set('preferAdvancedEdit', bool); + this.backendController.set('preferAdvancedEdit', bool); }, }, }); diff --git a/ui/app/controllers/vault/cluster/secrets/backend/sign.js b/ui/app/controllers/vault/cluster/secrets/backend/sign.js index 73ef095f2..c9eca9046 100644 --- a/ui/app/controllers/vault/cluster/secrets/backend/sign.js +++ b/ui/app/controllers/vault/cluster/secrets/backend/sign.js @@ -19,21 +19,21 @@ export default Controller.extend({ const hasErrors = codemirror.state.lint.marked.length > 0; if (!hasErrors) { - set(this.get('model'), attr, JSON.parse(val)); + set(this.model, attr, JSON.parse(val)); } }, updateTtl(path, val) { - const model = this.get('model'); + const model = this.model; let valueToSet = val.enabled === true ? `${val.seconds}s` : undefined; set(model, path, valueToSet); }, newModel() { - const model = this.get('model'); + const model = this.model; const roleModel = model.get('role'); model.unloadRecord(); - const newModel = this.get('store').createRecord('ssh-sign', { + const newModel = this.store.createRecord('ssh-sign', { role: roleModel, id: `${get(roleModel, 'backend')}-${get(roleModel, 'name')}`, }); diff --git a/ui/app/controllers/vault/cluster/secrets/backends.js b/ui/app/controllers/vault/cluster/secrets/backends.js index 088bd461a..474cabdba 100644 --- a/ui/app/controllers/vault/cluster/secrets/backends.js +++ b/ui/app/controllers/vault/cluster/secrets/backends.js @@ -9,7 +9,7 @@ export default Controller.extend({ displayableBackends: filterBy('model', 'shouldIncludeInList'), supportedBackends: computed('displayableBackends', 'displayableBackends.[]', function() { - return (this.get('displayableBackends') || []) + return (this.displayableBackends || []) .filter(backend => LINKED_BACKENDS.includes(backend.get('engineType'))) .sortBy('id'); }), @@ -20,9 +20,9 @@ export default Controller.extend({ 'supportedBackends', 'supportedBackends.[]', function() { - return (this.get('displayableBackends') || []) + return (this.displayableBackends || []) .slice() - .removeObjects(this.get('supportedBackends')) + .removeObjects(this.supportedBackends) .sortBy('id'); } ), @@ -31,9 +31,9 @@ export default Controller.extend({ const { engineType, path } = engine; try { yield engine.destroyRecord(); - this.get('flashMessages').success(`The ${engineType} Secrets Engine at ${path} has been disabled.`); + this.flashMessages.success(`The ${engineType} Secrets Engine at ${path} has been disabled.`); } catch (err) { - this.get('flashMessages').danger( + this.flashMessages.danger( `There was an error disabling the ${engineType} Secrets Engine at ${path}: ${err.errors.join(' ')}.` ); } diff --git a/ui/app/controllers/vault/cluster/settings/configure-secret-backend.js b/ui/app/controllers/vault/cluster/settings/configure-secret-backend.js index bbef44ced..2e488fc6d 100644 --- a/ui/app/controllers/vault/cluster/settings/configure-secret-backend.js +++ b/ui/app/controllers/vault/cluster/settings/configure-secret-backend.js @@ -20,26 +20,24 @@ export default Controller.extend(CONFIG_ATTRS, { flashMessages: service(), loading: false, reset() { - this.get('model').rollbackAttributes(); + this.model.rollbackAttributes(); this.setProperties(CONFIG_ATTRS); }, actions: { saveConfig(options = { delete: false }) { const isDelete = options.delete; - if (this.get('model.type') === 'ssh') { + if (this.model.type === 'ssh') { this.set('loading', true); - this.get('model') - .saveCA({ isDelete }) - .then(() => { - this.set('loading', false); - this.send('refreshRoute'); - this.set('configured', !isDelete); - if (isDelete) { - this.get('flashMessages').success('SSH Certificate Authority Configuration deleted!'); - } else { - this.get('flashMessages').success('SSH Certificate Authority Configuration saved!'); - } - }); + this.model.saveCA({ isDelete }).then(() => { + this.set('loading', false); + this.send('refreshRoute'); + this.set('configured', !isDelete); + if (isDelete) { + this.flashMessages.success('SSH Certificate Authority Configuration deleted!'); + } else { + this.flashMessages.success('SSH Certificate Authority Configuration saved!'); + } + }); } }, @@ -51,7 +49,7 @@ export default Controller.extend(CONFIG_ATTRS, { if (!hasData) { return; } - this.get('model') + this.model .save({ adapterOptions: { adapterMethod: method, @@ -59,9 +57,9 @@ export default Controller.extend(CONFIG_ATTRS, { }, }) .then(() => { - this.get('model').send('pushedData'); + this.model.send('pushedData'); this.reset(); - this.get('flashMessages').success('The backend configuration saved successfully!'); + this.flashMessages.success('The backend configuration saved successfully!'); }) .finally(() => { this.set('loading', false); diff --git a/ui/app/controllers/vault/cluster/settings/mount-secret-backend.js b/ui/app/controllers/vault/cluster/settings/mount-secret-backend.js index c9358cec8..c3371a6bf 100644 --- a/ui/app/controllers/vault/cluster/settings/mount-secret-backend.js +++ b/ui/app/controllers/vault/cluster/settings/mount-secret-backend.js @@ -19,7 +19,7 @@ export default Controller.extend({ transition = this.transitionToRoute('vault.cluster.secrets.backends'); } return transition.followRedirects().then(() => { - this.get('wizard').transitionFeatureMachine(this.get('wizard.featureState'), 'CONTINUE', type); + this.wizard.transitionFeatureMachine(this.wizard.featureState, 'CONTINUE', type); }); }, onConfigError: function(modelId) { diff --git a/ui/app/controllers/vault/cluster/settings/seal.js b/ui/app/controllers/vault/cluster/settings/seal.js index 721a2fee6..c7fc3dc1d 100644 --- a/ui/app/controllers/vault/cluster/settings/seal.js +++ b/ui/app/controllers/vault/cluster/settings/seal.js @@ -11,7 +11,7 @@ export default Controller.extend({ .seal() .then(() => { this.model.cluster.get('leaderNode').set('sealed', true); - this.get('auth').deleteCurrentToken(); + this.auth.deleteCurrentToken(); return this.transitionToRoute('vault.cluster.unseal'); }); }, diff --git a/ui/app/controllers/vault/cluster/unseal.js b/ui/app/controllers/vault/cluster/unseal.js index 72539a669..7f975cd90 100644 --- a/ui/app/controllers/vault/cluster/unseal.js +++ b/ui/app/controllers/vault/cluster/unseal.js @@ -6,16 +6,14 @@ export default Controller.extend({ actions: { transitionToCluster(resp) { - return this.get('model') - .reload() - .then(() => { - this.get('wizard').transitionTutorialMachine(this.get('wizard.currentState'), 'CONTINUE', resp); - return this.transitionToRoute('vault.cluster', this.get('model.name')); - }); + return this.model.reload().then(() => { + this.wizard.transitionTutorialMachine(this.wizard.currentState, 'CONTINUE', resp); + return this.transitionToRoute('vault.cluster', this.model.name); + }); }, setUnsealState(resp) { - this.get('wizard').set('componentState', resp); + this.wizard.set('componentState', resp); }, isUnsealed(data) { diff --git a/ui/app/helpers/-date-base.js b/ui/app/helpers/-date-base.js index ab4c2b025..384cf7909 100644 --- a/ui/app/helpers/-date-base.js +++ b/ui/app/helpers/-date-base.js @@ -1,12 +1,11 @@ import { run } from '@ember/runloop'; import Helper from '@ember/component/helper'; -import { get } from '@ember/object'; export default Helper.extend({ disableInterval: false, compute(value, { interval }) { - if (get(this, 'disableInterval')) { + if (this.disableInterval) { return; } diff --git a/ui/app/helpers/has-permission.js b/ui/app/helpers/has-permission.js index 0e5ae43c6..091285dcd 100644 --- a/ui/app/helpers/has-permission.js +++ b/ui/app/helpers/has-permission.js @@ -1,10 +1,10 @@ +/* eslint-disable ember/no-observers */ import Helper from '@ember/component/helper'; import { inject as service } from '@ember/service'; import { observer } from '@ember/object'; export default Helper.extend({ permissions: service(), - /* eslint-disable-next-line ember/no-observers */ onPermissionsChange: observer( 'permissions.exactPaths', 'permissions.globPaths', diff --git a/ui/app/helpers/nav-to-route.js b/ui/app/helpers/nav-to-route.js index e314456d9..9eb816c8c 100644 --- a/ui/app/helpers/nav-to-route.js +++ b/ui/app/helpers/nav-to-route.js @@ -6,7 +6,7 @@ export default Helper.extend({ compute([routeName, ...models], { replace = false }) { return () => { - const router = this.get('router'); + const router = this.router; const method = replace ? router.replaceWith : router.transitionTo; return method.call(router, routeName, ...models); }; diff --git a/ui/app/lib/attach-capabilities.js b/ui/app/lib/attach-capabilities.js index b85832a27..4ca42e28b 100644 --- a/ui/app/lib/attach-capabilities.js +++ b/ui/app/lib/attach-capabilities.js @@ -1,8 +1,7 @@ -import DS from 'ember-data'; +import { belongsTo } from '@ember-data/model'; import { assert, debug } from '@ember/debug'; import { typeOf } from '@ember/utils'; import { isArray } from '@ember/array'; -const { belongsTo } = DS; /* * diff --git a/ui/app/lib/control-group-error.js b/ui/app/lib/control-group-error.js index 214ff5286..52094f1ae 100644 --- a/ui/app/lib/control-group-error.js +++ b/ui/app/lib/control-group-error.js @@ -1,6 +1,6 @@ -import DS from 'ember-data'; +import AdapterError from '@ember-data/adapter/error'; -export default class ControlGroupError extends DS.AdapterError { +export default class ControlGroupError extends AdapterError { constructor(wrapInfo) { let { accessor, creation_path, creation_time, token, ttl } = wrapInfo; super(); diff --git a/ui/app/macros/maybe-query-record.js b/ui/app/macros/maybe-query-record.js index d27a2323c..8e1a7fdac 100644 --- a/ui/app/macros/maybe-query-record.js +++ b/ui/app/macros/maybe-query-record.js @@ -4,13 +4,13 @@ import PromiseProxyMixin from '@ember/object/promise-proxy-mixin'; import { resolve } from 'rsvp'; export function maybeQueryRecord(modelName, options = {}, ...keys) { - return computed(...keys, { + return computed(...keys, 'store', { get() { const query = typeof options === 'function' ? options(this) : options; const PromiseObject = ObjectProxy.extend(PromiseProxyMixin); return PromiseObject.create({ - promise: query ? this.get('store').queryRecord(modelName, query) : resolve({}), + promise: query ? this.store.queryRecord(modelName, query) : resolve({}), }); }, }); diff --git a/ui/app/mixins/backend-crumb.js b/ui/app/mixins/backend-crumb.js index 2a780a630..f1dfc42ea 100644 --- a/ui/app/mixins/backend-crumb.js +++ b/ui/app/mixins/backend-crumb.js @@ -3,7 +3,7 @@ import Mixin from '@ember/object/mixin'; export default Mixin.create({ backendCrumb: computed('backend', function() { - const backend = this.get('backend'); + const backend = this.backend; if (backend === undefined) { throw new Error('backend-crumb mixin requires backend to be set'); diff --git a/ui/app/mixins/cluster-route.js b/ui/app/mixins/cluster-route.js index b16695627..e4c6f938c 100644 --- a/ui/app/mixins/cluster-route.js +++ b/ui/app/mixins/cluster-route.js @@ -51,7 +51,7 @@ export default Mixin.create({ }, authToken() { - return get(this, 'auth.currentToken'); + return this.auth.currentToken; }, hasKeyData() { diff --git a/ui/app/mixins/focus-on-insert.js b/ui/app/mixins/focus-on-insert.js index 6ce409d68..0743de576 100644 --- a/ui/app/mixins/focus-on-insert.js +++ b/ui/app/mixins/focus-on-insert.js @@ -15,14 +15,14 @@ export default Mixin.create({ }), focusOnInsertFocus() { - if (this.get('shouldFocus') === false) { + if (this.shouldFocus === false) { return; } this.forceFocus(); }, forceFocus() { - var $targ = this.element.querySelectorAll(this.get('focusOnInsertSelector') || 'input[type="text"]')[0]; + var $targ = this.element.querySelectorAll(this.focusOnInsertSelector || 'input[type="text"]')[0]; if ($targ && $targ !== document.activeElement) { $targ.focus(); } diff --git a/ui/app/mixins/model-boundary-route.js b/ui/app/mixins/model-boundary-route.js index 50bf10dde..9166d1bf1 100644 --- a/ui/app/mixins/model-boundary-route.js +++ b/ui/app/mixins/model-boundary-route.js @@ -20,8 +20,8 @@ export default Mixin.create({ modelTypes: null, verifyProps: on('init', function() { - var modelType = this.get('modelType'); - var modelTypes = this.get('modelTypes'); + var modelType = this.modelType; + var modelTypes = this.modelTypes; warn( 'No `modelType` or `modelTypes` specified for `' + this.toString() + @@ -38,8 +38,8 @@ export default Mixin.create({ }), clearModelCache: on('deactivate', function() { - var modelType = this.get('modelType'); - var modelTypes = this.get('modelTypes'); + var modelType = this.modelType; + var modelTypes = this.modelTypes; if (!modelType && !modelTypes) { warn( diff --git a/ui/app/mixins/policy-edit-controller.js b/ui/app/mixins/policy-edit-controller.js index 36ba97e49..1bc31e573 100644 --- a/ui/app/mixins/policy-edit-controller.js +++ b/ui/app/mixins/policy-edit-controller.js @@ -8,7 +8,7 @@ export default Mixin.create({ deletePolicy(model) { let policyType = model.get('policyType'); let name = model.get('name'); - let flash = this.get('flashMessages'); + let flash = this.flashMessages; model .destroyRecord() .then(() => { @@ -24,15 +24,15 @@ export default Mixin.create({ }, savePolicy(model) { - let flash = this.get('flashMessages'); + let flash = this.flashMessages; let policyType = model.get('policyType'); let name = model.get('name'); model .save() .then(m => { flash.success(`${policyType.toUpperCase()} policy "${name}" was successfully saved.`); - if (this.get('wizard.featureState') === 'create') { - this.get('wizard').transitionFeatureMachine('create', 'CONTINUE', policyType); + if (this.wizard.featureState === 'create') { + this.wizard.transitionFeatureMachine('create', 'CONTINUE', policyType); } return this.transitionToRoute('vault.cluster.policy.show', m.get('policyType'), m.get('name')); }) diff --git a/ui/app/models/auth-config.js b/ui/app/models/auth-config.js index 3c70bb14e..90819e70f 100644 --- a/ui/app/models/auth-config.js +++ b/ui/app/models/auth-config.js @@ -1,7 +1,6 @@ -import DS from 'ember-data'; -const { belongsTo } = DS; +import Model, { belongsTo } from '@ember-data/model'; -export default DS.Model.extend({ +export default Model.extend({ backend: belongsTo('auth-method', { inverse: 'authConfigs', readOnly: true, async: false }), getHelpUrl: function(backend) { return `/v1/auth/${backend}/config?help=1`; diff --git a/ui/app/models/auth-config/aws/client.js b/ui/app/models/auth-config/aws/client.js index 7568371f5..ebcc4e507 100644 --- a/ui/app/models/auth-config/aws/client.js +++ b/ui/app/models/auth-config/aws/client.js @@ -1,10 +1,8 @@ +import { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import AuthConfig from '../../auth-config'; import fieldToAttrs from 'vault/utils/field-to-attrs'; -const { attr } = DS; - export default AuthConfig.extend({ secretKey: attr('string'), accessKey: attr('string'), diff --git a/ui/app/models/auth-config/aws/tidy.js b/ui/app/models/auth-config/aws/tidy.js index fc4e1a0e0..5643ec7f3 100644 --- a/ui/app/models/auth-config/aws/tidy.js +++ b/ui/app/models/auth-config/aws/tidy.js @@ -1,10 +1,8 @@ +import { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; import AuthConfig from '../../auth-config'; -const { attr } = DS; - export default AuthConfig.extend({ safetyBuffer: attr({ defaultValue: '72h', diff --git a/ui/app/models/auth-config/azure.js b/ui/app/models/auth-config/azure.js index 6ef8a3f50..cfab61013 100644 --- a/ui/app/models/auth-config/azure.js +++ b/ui/app/models/auth-config/azure.js @@ -1,11 +1,9 @@ +import { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import AuthConfig from '../auth-config'; import { combineFieldGroups } from 'vault/utils/openapi-to-attrs'; import fieldToAttrs from 'vault/utils/field-to-attrs'; -const { attr } = DS; - export default AuthConfig.extend({ useOpenAPI: true, tenantId: attr('string', { @@ -26,7 +24,7 @@ export default AuthConfig.extend({ googleCertsEndpoint: attr('string'), - fieldGroups: computed(function() { + fieldGroups: computed('newFields', function() { let groups = [ { default: ['tenantId', 'resource'] }, { diff --git a/ui/app/models/auth-config/gcp.js b/ui/app/models/auth-config/gcp.js index 25d91d284..d931ac4de 100644 --- a/ui/app/models/auth-config/gcp.js +++ b/ui/app/models/auth-config/gcp.js @@ -1,11 +1,9 @@ +import { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import AuthConfig from '../auth-config'; import { combineFieldGroups } from 'vault/utils/openapi-to-attrs'; import fieldToAttrs from 'vault/utils/field-to-attrs'; -const { attr } = DS; - export default AuthConfig.extend({ useOpenAPI: true, // We have to leave this here because the backend doesn't support the file type yet. @@ -15,7 +13,7 @@ export default AuthConfig.extend({ googleCertsEndpoint: attr('string'), - fieldGroups: computed(function() { + fieldGroups: computed('newFields', function() { let groups = [ { default: ['credentials'] }, { diff --git a/ui/app/models/auth-config/github.js b/ui/app/models/auth-config/github.js index df745af14..436c050c5 100644 --- a/ui/app/models/auth-config/github.js +++ b/ui/app/models/auth-config/github.js @@ -1,11 +1,9 @@ +import { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import AuthConfig from '../auth-config'; import fieldToAttrs from 'vault/utils/field-to-attrs'; import { combineFieldGroups } from 'vault/utils/openapi-to-attrs'; -const { attr } = DS; - export default AuthConfig.extend({ useOpenAPI: true, organization: attr('string'), @@ -13,7 +11,7 @@ export default AuthConfig.extend({ label: 'Base URL', }), - fieldGroups: computed(function() { + fieldGroups: computed('newFields', function() { let groups = [ { default: ['organization'] }, { diff --git a/ui/app/models/auth-config/jwt.js b/ui/app/models/auth-config/jwt.js index 91b68b54f..7eecbb26e 100644 --- a/ui/app/models/auth-config/jwt.js +++ b/ui/app/models/auth-config/jwt.js @@ -1,11 +1,9 @@ +import { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import AuthConfig from '../auth-config'; import fieldToAttrs from 'vault/utils/field-to-attrs'; import { combineFieldGroups } from 'vault/utils/openapi-to-attrs'; -const { attr } = DS; - export default AuthConfig.extend({ useOpenAPI: true, oidcDiscoveryUrl: attr('string', { @@ -38,7 +36,7 @@ export default AuthConfig.extend({ boundIssuer: attr('string', { helpText: 'The value against which to match the iss claim in a JWT', }), - fieldGroups: computed(function() { + fieldGroups: computed('constructor.modelName', 'newFields', function() { let type = this.constructor.modelName.split('/')[1].toUpperCase(); let groups = [ { diff --git a/ui/app/models/auth-config/kubernetes.js b/ui/app/models/auth-config/kubernetes.js index 8eb0b0913..8afaa6c11 100644 --- a/ui/app/models/auth-config/kubernetes.js +++ b/ui/app/models/auth-config/kubernetes.js @@ -1,12 +1,10 @@ +import { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import AuthConfig from '../auth-config'; import { combineFieldGroups } from 'vault/utils/openapi-to-attrs'; import fieldToAttrs from 'vault/utils/field-to-attrs'; -const { attr } = DS; - export default AuthConfig.extend({ useOpenAPI: true, kubernetesHost: attr('string', { @@ -28,7 +26,7 @@ export default AuthConfig.extend({ editType: 'stringArray', }), - fieldGroups: computed(function() { + fieldGroups: computed('newFields', function() { let groups = [ { default: ['kubernetesHost', 'kubernetesCaCert'], diff --git a/ui/app/models/auth-config/ldap.js b/ui/app/models/auth-config/ldap.js index f47025f45..d28130f22 100644 --- a/ui/app/models/auth-config/ldap.js +++ b/ui/app/models/auth-config/ldap.js @@ -1,19 +1,17 @@ +import { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import AuthConfig from '../auth-config'; import fieldToAttrs from 'vault/utils/field-to-attrs'; import { combineFieldGroups } from 'vault/utils/openapi-to-attrs'; -const { attr } = DS; - export default AuthConfig.extend({ useOpenAPI: true, certificate: attr({ label: 'Certificate', editType: 'textarea', }), - fieldGroups: computed(function() { + fieldGroups: computed('newFields', function() { let groups = [ { default: ['url'], diff --git a/ui/app/models/auth-config/okta.js b/ui/app/models/auth-config/okta.js index 2d0d01d29..d87073d8a 100644 --- a/ui/app/models/auth-config/okta.js +++ b/ui/app/models/auth-config/okta.js @@ -1,11 +1,9 @@ +import { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import AuthConfig from '../auth-config'; import fieldToAttrs from 'vault/utils/field-to-attrs'; import { combineFieldGroups } from 'vault/utils/openapi-to-attrs'; -const { attr } = DS; - export default AuthConfig.extend({ useOpenAPI: true, orgName: attr('string', { @@ -25,7 +23,7 @@ export default AuthConfig.extend({ "Useful if using Vault's built-in MFA mechanisms. Will also cause certain other statuses to be ignored, such as PASSWORD_EXPIRED", }), - fieldGroups: computed(function() { + fieldGroups: computed('newFields', function() { let groups = [ { default: ['orgName'], diff --git a/ui/app/models/auth-config/radius.js b/ui/app/models/auth-config/radius.js index 7479c5a8b..d4c2b9337 100644 --- a/ui/app/models/auth-config/radius.js +++ b/ui/app/models/auth-config/radius.js @@ -1,17 +1,15 @@ +import { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import AuthConfig from '../auth-config'; import { combineFieldGroups } from 'vault/utils/openapi-to-attrs'; import fieldToAttrs from 'vault/utils/field-to-attrs'; -const { attr } = DS; - export default AuthConfig.extend({ useOpenAPI: true, host: attr('string'), secret: attr('string'), - fieldGroups: computed(function() { + fieldGroups: computed('newFields', function() { let groups = [ { default: ['host', 'secret'], diff --git a/ui/app/models/auth-method.js b/ui/app/models/auth-method.js index eb4646728..ffe2dfdb4 100644 --- a/ui/app/models/auth-method.js +++ b/ui/app/models/auth-method.js @@ -1,6 +1,6 @@ +import Model, { hasMany, attr } from '@ember-data/model'; import { alias } from '@ember/object/computed'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import { fragment } from 'ember-data-model-fragments/attributes'; import fieldToAttrs, { expandAttributeMeta } from 'vault/utils/field-to-attrs'; import { memberAction } from 'ember-api-actions'; @@ -8,9 +8,7 @@ import { memberAction } from 'ember-api-actions'; import apiPath from 'vault/utils/api-path'; import attachCapabilities from 'vault/lib/attach-capabilities'; -const { attr, hasMany } = DS; - -let Model = DS.Model.extend({ +let ModelExport = Model.extend({ authConfigs: hasMany('auth-config', { polymorphic: true, inverse: 'backend', async: false }), path: attr('string'), accessor: attr('string'), @@ -19,7 +17,7 @@ let Model = DS.Model.extend({ // namespaces introduced types with a `ns_` prefix for built-in engines // so we need to strip that to normalize the type methodType: computed('type', function() { - return this.get('type').replace(/^ns_/, ''); + return this.type.replace(/^ns_/, ''); }), description: attr('string', { editType: 'textarea', @@ -37,10 +35,10 @@ let Model = DS.Model.extend({ // used when the `auth` prefix is important, // currently only when setting perf mount filtering apiPath: computed('path', function() { - return `auth/${this.get('path')}`; + return `auth/${this.path}`; }), localDisplay: computed('local', function() { - return this.get('local') ? 'local' : 'replicated'; + return this.local ? 'local' : 'replicated'; }), tuneAttrs: computed(function() { @@ -85,17 +83,17 @@ let Model = DS.Model.extend({ }), attrs: computed('formFields', function() { - return expandAttributeMeta(this, this.get('formFields')); + return expandAttributeMeta(this, this.formFields); }), fieldGroups: computed('formFieldGroups', function() { - return fieldToAttrs(this, this.get('formFieldGroups')); + return fieldToAttrs(this, this.formFieldGroups); }), canDisable: alias('deletePath.canDelete'), canEdit: alias('configPath.canUpdate'), }); -export default attachCapabilities(Model, { +export default attachCapabilities(ModelExport, { deletePath: apiPath`sys/auth/${'id'}`, configPath: function(context) { if (context.type === 'aws') { diff --git a/ui/app/models/aws-credential.js b/ui/app/models/aws-credential.js index ec778e3a4..8ce389aa4 100644 --- a/ui/app/models/aws-credential.js +++ b/ui/app/models/aws-credential.js @@ -1,7 +1,6 @@ +import Model, { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -const { attr } = DS; const CREDENTIAL_TYPES = [ { value: 'iam_user', @@ -18,7 +17,7 @@ const CREDENTIAL_TYPES = [ ]; const DISPLAY_FIELDS = ['accessKey', 'secretKey', 'securityToken', 'leaseId', 'renewable', 'leaseDuration']; -export default DS.Model.extend({ +export default Model.extend({ helpText: 'For Vault roles of credential type iam_user, there are no inputs, just submit the form. Choose a type to change the input options.', role: attr('object', { @@ -53,20 +52,25 @@ export default DS.Model.extend({ securityToken: attr('string'), attrs: computed('credentialType', 'accessKey', 'securityToken', function() { - let type = this.get('credentialType'); + let type = this.credentialType; let fieldsForType = { iam_user: ['credentialType'], assumed_role: ['credentialType', 'ttl', 'roleArn'], federation_token: ['credentialType', 'ttl'], }; - if (this.get('accessKey') || this.get('securityToken')) { + if (this.accessKey || this.securityToken) { return expandAttributeMeta(this, DISPLAY_FIELDS.slice(0)); } return expandAttributeMeta(this, fieldsForType[type].slice(0)); }), toCreds: computed('accessKey', 'secretKey', 'securityToken', 'leaseId', function() { - const props = this.getProperties('accessKey', 'secretKey', 'securityToken', 'leaseId'); + const props = { + accessKey: this.accessKey, + secretKey: this.secretKey, + securityToken: this.securityToken, + leasId: this.leaseId, + }; const propsWithVals = Object.keys(props).reduce((ret, prop) => { if (props[prop]) { ret[prop] = props[prop]; diff --git a/ui/app/models/capabilities.js b/ui/app/models/capabilities.js index 04b91b146..0a755febc 100644 --- a/ui/app/models/capabilities.js +++ b/ui/app/models/capabilities.js @@ -2,10 +2,9 @@ // `path` is also the primaryId // https://www.vaultproject.io/docs/concepts/policies.html#capabilities -import { computed } from '@ember/object'; -import DS from 'ember-data'; +import Model, { attr } from '@ember-data/model'; -const { attr } = DS; +import { computed } from '@ember/object'; const SUDO_PATHS = [ 'sys/seal', @@ -21,8 +20,8 @@ export { SUDO_PATHS, SUDO_PATH_PREFIXES }; const computedCapability = function(capability) { return computed('path', 'capabilities', 'capabilities.[]', function() { - const capabilities = this.get('capabilities'); - const path = this.get('path'); + const capabilities = this.capabilities; + const path = this.path; if (!capabilities) { return false; } @@ -40,7 +39,7 @@ const computedCapability = function(capability) { }); }; -export default DS.Model.extend({ +export default Model.extend({ path: attr('string'), capabilities: attr('array'), canSudo: computedCapability('sudo'), diff --git a/ui/app/models/cluster.js b/ui/app/models/cluster.js index 6090d149f..39b692a81 100644 --- a/ui/app/models/cluster.js +++ b/ui/app/models/cluster.js @@ -1,11 +1,10 @@ +import Model, { attr, hasMany } from '@ember-data/model'; import { inject as service } from '@ember/service'; import { alias, and, equal, gte, not, or } from '@ember/object/computed'; import { get, computed } from '@ember/object'; -import DS from 'ember-data'; import { fragment } from 'ember-data-model-fragments/attributes'; -const { hasMany, attr } = DS; -export default DS.Model.extend({ +export default Model.extend({ version: service(), nodes: hasMany('nodes', { async: false }), @@ -16,18 +15,18 @@ export default DS.Model.extend({ needsInit: computed('nodes', 'nodes.@each.initialized', function() { // needs init if no nodes are initialized - return this.get('nodes').isEvery('initialized', false); + return this.nodes.isEvery('initialized', false); }), unsealed: computed('nodes', 'nodes.{[],@each.sealed}', function() { // unsealed if there's at least one unsealed node - return !!this.get('nodes').findBy('sealed', false); + return !!this.nodes.findBy('sealed', false); }), sealed: not('unsealed'), leaderNode: computed('nodes', 'nodes.[]', function() { - const nodes = this.get('nodes'); + const nodes = this.nodes; if (nodes.get('length') === 1) { return nodes.get('firstObject'); } else { @@ -64,7 +63,7 @@ export default DS.Model.extend({ return !this.dr.mode || !this.performance.mode; }), replicationAttrs: computed('dr.mode', 'performance.mode', 'replicationMode', function() { - const replicationMode = this.get('replicationMode'); + const replicationMode = this.replicationMode; return replicationMode ? get(this, replicationMode) : null; }), }); diff --git a/ui/app/models/control-group-config.js b/ui/app/models/control-group-config.js index b0cabac73..c598f1688 100644 --- a/ui/app/models/control-group-config.js +++ b/ui/app/models/control-group-config.js @@ -1,12 +1,11 @@ +import Model, { attr } from '@ember-data/model'; import { alias } from '@ember/object/computed'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; -const { attr } = DS; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -export default DS.Model.extend({ +export default Model.extend({ fields: computed(function() { return expandAttributeMeta(this, ['maxTtl']); }), diff --git a/ui/app/models/control-group.js b/ui/app/models/control-group.js index a5e05a022..054f6e331 100644 --- a/ui/app/models/control-group.js +++ b/ui/app/models/control-group.js @@ -1,10 +1,8 @@ +import Model, { hasMany, belongsTo, attr } from '@ember-data/model'; import { alias } from '@ember/object/computed'; -import DS from 'ember-data'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; -const { attr, belongsTo, hasMany } = DS; - -export default DS.Model.extend({ +export default Model.extend({ approved: attr('boolean'), requestPath: attr('string'), requestEntity: belongsTo('identity/entity', { async: false }), diff --git a/ui/app/models/identity/_base.js b/ui/app/models/identity/_base.js index 9c0c6d51b..5ca18495e 100644 --- a/ui/app/models/identity/_base.js +++ b/ui/app/models/identity/_base.js @@ -1,18 +1,18 @@ +import Model from '@ember-data/model'; import { assert } from '@ember/debug'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -export default DS.Model.extend({ +export default Model.extend({ formFields: computed(function() { return assert('formFields should be overridden', false); }), fields: computed('formFields', 'formFields.[]', function() { - return expandAttributeMeta(this, this.get('formFields')); + return expandAttributeMeta(this, this.formFields); }), - identityType: computed(function() { + identityType: computed('constructor.modelName', function() { let modelType = this.constructor.modelName.split('/')[1]; return modelType; }), diff --git a/ui/app/models/identity/entity-alias.js b/ui/app/models/identity/entity-alias.js index 8210a7565..efb8bc5d1 100644 --- a/ui/app/models/identity/entity-alias.js +++ b/ui/app/models/identity/entity-alias.js @@ -1,9 +1,8 @@ +import { belongsTo, attr } from '@ember-data/model'; import { computed } from '@ember/object'; import { alias } from '@ember/object/computed'; import IdentityModel from './_base'; -import DS from 'ember-data'; import identityCapabilities from 'vault/macros/identity-capabilities'; -const { attr, belongsTo } = DS; export default IdentityModel.extend({ parentType: 'entity', diff --git a/ui/app/models/identity/entity-merge.js b/ui/app/models/identity/entity-merge.js index a5df0b9e0..0a0e986af 100644 --- a/ui/app/models/identity/entity-merge.js +++ b/ui/app/models/identity/entity-merge.js @@ -1,7 +1,6 @@ +import { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import IdentityModel from './_base'; -const { attr } = DS; export default IdentityModel.extend({ formFields: computed(function() { diff --git a/ui/app/models/identity/entity.js b/ui/app/models/identity/entity.js index 562681a06..c3b325603 100644 --- a/ui/app/models/identity/entity.js +++ b/ui/app/models/identity/entity.js @@ -1,12 +1,10 @@ +import { hasMany, attr } from '@ember-data/model'; import { computed } from '@ember/object'; import { alias } from '@ember/object/computed'; import IdentityModel from './_base'; -import DS from 'ember-data'; import apiPath from 'vault/utils/api-path'; import attachCapabilities from 'vault/lib/attach-capabilities'; -const { attr, hasMany } = DS; - let Model = IdentityModel.extend({ formFields: computed(function() { return ['name', 'disabled', 'policies', 'metadata']; diff --git a/ui/app/models/identity/group-alias.js b/ui/app/models/identity/group-alias.js index c132d40d1..f73a97716 100644 --- a/ui/app/models/identity/group-alias.js +++ b/ui/app/models/identity/group-alias.js @@ -1,11 +1,9 @@ +import { belongsTo, attr } from '@ember-data/model'; import { computed } from '@ember/object'; import { alias } from '@ember/object/computed'; import IdentityModel from './_base'; -import DS from 'ember-data'; import identityCapabilities from 'vault/macros/identity-capabilities'; -const { attr, belongsTo } = DS; - export default IdentityModel.extend({ parentType: 'group', formFields: computed(function() { diff --git a/ui/app/models/identity/group.js b/ui/app/models/identity/group.js index 4d1aac831..d51a96ef6 100644 --- a/ui/app/models/identity/group.js +++ b/ui/app/models/identity/group.js @@ -1,16 +1,14 @@ +import { belongsTo, attr } from '@ember-data/model'; import { alias } from '@ember/object/computed'; import { computed } from '@ember/object'; import IdentityModel from './_base'; -import DS from 'ember-data'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; import identityCapabilities from 'vault/macros/identity-capabilities'; -const { attr, belongsTo } = DS; - export default IdentityModel.extend({ formFields: computed('type', function() { let fields = ['name', 'type', 'policies', 'metadata']; - if (this.get('type') === 'internal') { + if (this.type === 'internal') { return fields.concat(['memberGroupIds', 'memberEntityIds']); } return fields; @@ -65,7 +63,7 @@ export default IdentityModel.extend({ 'memberGroupIds', 'memberGroupIds.[]', function() { - let { memberEntityIds, memberGroupIds } = this.getProperties('memberEntityIds', 'memberGroupIds'); + let { memberEntityIds, memberGroupIds } = this; let numEntities = (memberEntityIds && memberEntityIds.get('length')) || 0; let numGroups = (memberGroupIds && memberGroupIds.get('length')) || 0; return numEntities + numGroups > 0; @@ -79,12 +77,12 @@ export default IdentityModel.extend({ aliasPath: lazyCapabilities(apiPath`identity/group-alias`), canAddAlias: computed('aliasPath.canCreate', 'type', 'alias', function() { - let type = this.get('type'); - let alias = this.get('alias'); + let type = this.type; + let alias = this.alias; // internal groups can't have aliases, and external groups can only have one if (type === 'internal' || alias) { return false; } - return this.get('aliasPath.canCreate'); + return this.aliasPath.canCreate; }), }); diff --git a/ui/app/models/kmip/ca.js b/ui/app/models/kmip/ca.js index 08a2989db..7ef8847e9 100644 --- a/ui/app/models/kmip/ca.js +++ b/ui/app/models/kmip/ca.js @@ -1,7 +1,6 @@ -import DS from 'ember-data'; -const { attr, belongsTo } = DS; +import Model, { belongsTo, attr } from '@ember-data/model'; -export default DS.Model.extend({ +export default Model.extend({ config: belongsTo('kmip/config', { async: false }), caPem: attr('string', { label: 'CA PEM', diff --git a/ui/app/models/kmip/config.js b/ui/app/models/kmip/config.js index 6726aeee8..0ccb77153 100644 --- a/ui/app/models/kmip/config.js +++ b/ui/app/models/kmip/config.js @@ -1,18 +1,16 @@ -import DS from 'ember-data'; +import Model, { belongsTo } from '@ember-data/model'; import { computed } from '@ember/object'; import { combineFieldGroups } from 'vault/utils/openapi-to-attrs'; import fieldToAttrs from 'vault/utils/field-to-attrs'; -const { belongsTo } = DS; - -export default DS.Model.extend({ +export default Model.extend({ useOpenAPI: true, ca: belongsTo('kmip/ca', { async: false }), getHelpUrl(path) { return `/v1/${path}/config?help=1`; }, - fieldGroups: computed(function() { + fieldGroups: computed('newFields', function() { let groups = [{ default: ['listenAddrs', 'connectionTimeout'] }]; groups = combineFieldGroups(groups, this.newFields, []); diff --git a/ui/app/models/kmip/credential.js b/ui/app/models/kmip/credential.js index a8f9f0320..e5923aa37 100644 --- a/ui/app/models/kmip/credential.js +++ b/ui/app/models/kmip/credential.js @@ -1,11 +1,10 @@ -import DS from 'ember-data'; +import Model, { attr } from '@ember-data/model'; import fieldToAttrs from 'vault/utils/field-to-attrs'; import { computed } from '@ember/object'; -const { attr } = DS; import apiPath from 'vault/utils/api-path'; import attachCapabilities from 'vault/lib/attach-capabilities'; -const Model = DS.Model.extend({ +const ModelExport = Model.extend({ backend: attr({ readOnly: true }), scope: attr({ readOnly: true }), role: attr({ readOnly: true }), @@ -31,6 +30,6 @@ const Model = DS.Model.extend({ }), }); -export default attachCapabilities(Model, { +export default attachCapabilities(ModelExport, { deletePath: apiPath`${'backend'}/scope/${'scope'}/role/${'role'}/credentials/revoke`, }); diff --git a/ui/app/models/kmip/role.js b/ui/app/models/kmip/role.js index cb3cce35b..c1317c5dd 100644 --- a/ui/app/models/kmip/role.js +++ b/ui/app/models/kmip/role.js @@ -1,11 +1,9 @@ -import DS from 'ember-data'; +import Model, { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -import fieldToAttrs from 'vault/utils/field-to-attrs'; +import fieldToAttrs, { expandAttributeMeta } from 'vault/utils/field-to-attrs'; import apiPath from 'vault/utils/api-path'; import attachCapabilities from 'vault/lib/attach-capabilities'; -const { attr } = DS; export const COMPUTEDS = { operationFields: computed('newFields', function() { return this.newFields.filter(key => key.startsWith('operation')); @@ -19,13 +17,13 @@ export const COMPUTEDS = { return ['tlsClientKeyBits', 'tlsClientKeyType', 'tlsClientTtl']; }), - nonOperationFields: computed('tlsFields', 'operationFields', function() { + nonOperationFields: computed('newFields', 'operationFields', 'tlsFields', function() { let excludeFields = ['role'].concat(this.operationFields, this.tlsFields); return this.newFields.slice().removeObjects(excludeFields); }), }; -const Model = DS.Model.extend(COMPUTEDS, { +const ModelExport = Model.extend(COMPUTEDS, { useOpenAPI: true, backend: attr({ readOnly: true }), scope: attr({ readOnly: true }), @@ -33,7 +31,7 @@ const Model = DS.Model.extend(COMPUTEDS, { getHelpUrl(path) { return `/v1/${path}/scope/example/role/example?help=1`; }, - fieldGroups: computed('fields', 'tlsFields', 'nonOperationFields', function() { + fieldGroups: computed('fields', 'nonOperationFields.length', 'tlsFields', function() { const groups = [{ TLS: this.tlsFields }]; if (this.nonOperationFields.length) { groups.unshift({ default: this.nonOperationFields }); @@ -76,6 +74,6 @@ const Model = DS.Model.extend(COMPUTEDS, { }), }); -export default attachCapabilities(Model, { +export default attachCapabilities(ModelExport, { updatePath: apiPath`${'backend'}/scope/${'scope'}/role/${'id'}`, }); diff --git a/ui/app/models/kmip/scope.js b/ui/app/models/kmip/scope.js index 24171565b..cccf0f5f9 100644 --- a/ui/app/models/kmip/scope.js +++ b/ui/app/models/kmip/scope.js @@ -1,12 +1,11 @@ +import Model, { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import apiPath from 'vault/utils/api-path'; import attachCapabilities from 'vault/lib/attach-capabilities'; -const { attr } = DS; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -let Model = DS.Model.extend({ +let ModelExport = Model.extend({ name: attr('string'), backend: attr({ readOnly: true }), attrs: computed(function() { @@ -14,6 +13,6 @@ let Model = DS.Model.extend({ }), }); -export default attachCapabilities(Model, { +export default attachCapabilities(ModelExport, { updatePath: apiPath`${'backend'}/scope/${'id'}`, }); diff --git a/ui/app/models/lease.js b/ui/app/models/lease.js index 73d299065..f288d6fde 100644 --- a/ui/app/models/lease.js +++ b/ui/app/models/lease.js @@ -1,7 +1,6 @@ +import Model, { attr } from '@ember-data/model'; import { match } from '@ember/object/computed'; -import DS from 'ember-data'; import KeyMixin from 'vault/mixins/key-mixin'; -const { attr } = DS; /* sample response { @@ -15,7 +14,7 @@ const { attr } = DS; */ -export default DS.Model.extend(KeyMixin, { +export default Model.extend(KeyMixin, { issueTime: attr('string'), expireTime: attr('string'), lastRenewal: attr('string'), diff --git a/ui/app/models/license.js b/ui/app/models/license.js index 369678ab0..8b8db3307 100644 --- a/ui/app/models/license.js +++ b/ui/app/models/license.js @@ -1,5 +1,4 @@ -import DS from 'ember-data'; -const { attr } = DS; +import Model, { attr } from '@ember-data/model'; /* sample response { @@ -20,7 +19,7 @@ const { attr } = DS; } */ -export default DS.Model.extend({ +export default Model.extend({ expirationTime: attr('string'), features: attr('array'), licenseId: attr('string'), diff --git a/ui/app/models/metrics/activity.js b/ui/app/models/metrics/activity.js index 68945a755..d220bf184 100644 --- a/ui/app/models/metrics/activity.js +++ b/ui/app/models/metrics/activity.js @@ -1,7 +1,7 @@ -import DS from 'ember-data'; +import Model, { attr } from '@ember-data/model'; -export default DS.Model.extend({ - total: DS.attr('object'), - endTime: DS.attr('string'), - startTime: DS.attr('string'), +export default Model.extend({ + total: attr('object'), + endTime: attr('string'), + startTime: attr('string'), }); diff --git a/ui/app/models/metrics/config.js b/ui/app/models/metrics/config.js index bf904563a..58de31293 100644 --- a/ui/app/models/metrics/config.js +++ b/ui/app/models/metrics/config.js @@ -1,12 +1,10 @@ -import DS from 'ember-data'; +import Model, { attr } from '@ember-data/model'; import { computed } from '@ember/object'; import attachCapabilities from 'vault/lib/attach-capabilities'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; import { apiPath } from 'vault/macros/lazy-capabilities'; -const { attr } = DS; - -const M = DS.Model.extend({ +const M = Model.extend({ queriesAvailable: attr('boolean'), defaultReportMonths: attr('number', { label: 'Default display', diff --git a/ui/app/models/mount-config.js b/ui/app/models/mount-config.js index 65f11c2d4..f2f12b563 100644 --- a/ui/app/models/mount-config.js +++ b/ui/app/models/mount-config.js @@ -1,4 +1,4 @@ -import attr from 'ember-data/attr'; +import { attr } from '@ember-data/model'; import Fragment from 'ember-data-model-fragments/fragment'; export default Fragment.extend({ diff --git a/ui/app/models/mount-options.js b/ui/app/models/mount-options.js index a3f7c7601..17a89e10c 100644 --- a/ui/app/models/mount-options.js +++ b/ui/app/models/mount-options.js @@ -1,4 +1,4 @@ -import attr from 'ember-data/attr'; +import { attr } from '@ember-data/model'; import Fragment from 'ember-data-model-fragments/fragment'; export default Fragment.extend({ diff --git a/ui/app/models/namespace.js b/ui/app/models/namespace.js index 8fbdaa87b..894c9879b 100644 --- a/ui/app/models/namespace.js +++ b/ui/app/models/namespace.js @@ -1,16 +1,14 @@ +import Model, { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; - -const { attr } = DS; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -export default DS.Model.extend({ +export default Model.extend({ path: attr('string', { validationAttr: 'pathIsValid', invalidMessage: 'You have entered and invalid path please only include letters, numbers, -, ., and _.', }), pathIsValid: computed('path', function() { - return this.get('path') && this.get('path').match(/^[\w\d-.]+$/g); + return this.path && this.path.match(/^[\w\d-.]+$/g); }), description: attr('string', { editType: 'textarea', diff --git a/ui/app/models/node.js b/ui/app/models/node.js index 2f8595bec..2acd3a05e 100644 --- a/ui/app/models/node.js +++ b/ui/app/models/node.js @@ -1,8 +1,7 @@ +import Model, { attr } from '@ember-data/model'; import { alias, and, equal } from '@ember/object/computed'; -import DS from 'ember-data'; -const { attr } = DS; -export default DS.Model.extend({ +export default Model.extend({ name: attr('string'), //https://www.vaultproject.io/docs/http/sys-health.html initialized: attr('boolean'), diff --git a/ui/app/models/path-filter-config.js b/ui/app/models/path-filter-config.js index 893c6c678..569fa162c 100644 --- a/ui/app/models/path-filter-config.js +++ b/ui/app/models/path-filter-config.js @@ -1,7 +1,6 @@ -import DS from 'ember-data'; -const { attr } = DS; +import Model, { attr } from '@ember-data/model'; -export default DS.Model.extend({ +export default Model.extend({ mode: attr('string'), paths: attr('array', { defaultValue: function() { diff --git a/ui/app/models/pki-ca-certificate-sign.js b/ui/app/models/pki-ca-certificate-sign.js index ca88f787f..7bcc44b37 100644 --- a/ui/app/models/pki-ca-certificate-sign.js +++ b/ui/app/models/pki-ca-certificate-sign.js @@ -1,10 +1,8 @@ +import { attr } from '@ember-data/model'; import { copy } from 'ember-copy'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import Certificate from './pki-certificate-sign'; -const { attr } = DS; - export default Certificate.extend({ backend: attr('string', { readOnly: true, @@ -68,7 +66,7 @@ export default Certificate.extend({ default: ['csr', 'commonName', 'format', 'useCsrValues'], }, ]; - if (this.get('useCsrValues') === false) { + if (this.useCsrValues === false) { groups = groups.concat(options); } diff --git a/ui/app/models/pki-ca-certificate.js b/ui/app/models/pki-ca-certificate.js index 043c018a6..08ebd372b 100644 --- a/ui/app/models/pki-ca-certificate.js +++ b/ui/app/models/pki-ca-certificate.js @@ -1,11 +1,9 @@ +import { attr } from '@ember-data/model'; import { and } from '@ember/object/computed'; import { computed } from '@ember/object'; import Certificate from './pki-certificate'; -import DS from 'ember-data'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; -const { attr } = DS; - export default Certificate.extend({ DISPLAY_FIELDS: computed(function() { return [ @@ -44,8 +42,8 @@ export default Certificate.extend({ }), fieldDefinition: computed('caType', 'uploadPemBundle', function() { - const type = this.get('caType'); - const isUpload = this.get('uploadPemBundle'); + const type = this.caType; + const isUpload = this.uploadPemBundle; let groups = [{ default: ['caType', 'uploadPemBundle'] }]; if (isUpload) { groups[0].default.push('pemBundle'); diff --git a/ui/app/models/pki-certificate-sign.js b/ui/app/models/pki-certificate-sign.js index 8fa57d31e..9e64e4dde 100644 --- a/ui/app/models/pki-certificate-sign.js +++ b/ui/app/models/pki-certificate-sign.js @@ -1,9 +1,8 @@ +import { attr } from '@ember-data/model'; import { copy } from 'ember-copy'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import Certificate from './pki-certificate'; import { combineFieldGroups } from 'vault/utils/openapi-to-attrs'; -const { attr } = DS; export default Certificate.extend({ signVerbatim: attr('boolean', { @@ -16,7 +15,7 @@ export default Certificate.extend({ editType: 'textarea', }), - fieldGroups: computed('signVerbatim', function() { + fieldGroups: computed('newFields', 'signVerbatim', function() { const options = { Options: ['altNames', 'ipSans', 'ttl', 'excludeCnFromSans', 'otherSans'] }; let groups = [ { @@ -26,7 +25,7 @@ export default Certificate.extend({ if (this.newFields) { groups = combineFieldGroups(groups, this.newFields, []); } - if (this.get('signVerbatim') === false) { + if (this.signVerbatim === false) { groups.push(options); } diff --git a/ui/app/models/pki-certificate.js b/ui/app/models/pki-certificate.js index 5bcd2dc94..73bd6895e 100644 --- a/ui/app/models/pki-certificate.js +++ b/ui/app/models/pki-certificate.js @@ -1,12 +1,10 @@ +import Model, { attr } from '@ember-data/model'; import { alias } from '@ember/object/computed'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; import fieldToAttrs, { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -const { attr } = DS; - -export default DS.Model.extend({ +export default Model.extend({ idPrefix: 'cert/', backend: attr('string', { @@ -89,11 +87,11 @@ export default DS.Model.extend({ }), fieldGroups: computed('fieldDefinition', function() { - return this.fieldsToAttrs(this.get('fieldDefinition')); + return this.fieldsToAttrs(this.fieldDefinition); }), - attrs: computed('certificate', 'csr', function() { - let keys = this.get('certificate') || this.get('csr') ? this.get('DISPLAY_FIELDS').slice(0) : []; + attrs: computed('DISPLAY_FIELDS', 'certificate', 'csr', function() { + let keys = this.certificate || this.csr ? this.DISPLAY_FIELDS.slice(0) : []; return expandAttributeMeta(this, keys); }), @@ -106,15 +104,15 @@ export default DS.Model.extend({ 'revocationTime', 'serialNumber', function() { - const props = this.getProperties( - 'certificate', - 'issuingCa', - 'caChain', - 'privateKey', - 'privateKeyType', - 'revocationTime', - 'serialNumber' - ); + const props = { + certificate: this.certificate, + issuingCa: this.issuingCa, + caChain: this.caChain, + privateKey: this.privateKey, + privateKeyType: this.privateKeyType, + revocationTime: this.revocationTime, + serialNumber: this.serialNumber, + }; const propsWithVals = Object.keys(props).reduce((ret, prop) => { if (props[prop]) { ret[prop] = props[prop]; diff --git a/ui/app/models/pki-config.js b/ui/app/models/pki-config.js index bc1bfabd5..574c01076 100644 --- a/ui/app/models/pki-config.js +++ b/ui/app/models/pki-config.js @@ -1,10 +1,8 @@ +import Model, { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -const { attr } = DS; - -export default DS.Model.extend({ +export default Model.extend({ backend: attr('string'), der: attr(), pem: attr('string'), diff --git a/ui/app/models/policy.js b/ui/app/models/policy.js index 102ebf470..93e07ba0a 100644 --- a/ui/app/models/policy.js +++ b/ui/app/models/policy.js @@ -1,14 +1,12 @@ +import Model, { attr } from '@ember-data/model'; import { alias } from '@ember/object/computed'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; -let { attr } = DS; - -export default DS.Model.extend({ +export default Model.extend({ name: attr('string'), policy: attr('string'), - policyType: computed(function() { + policyType: computed('constructor.modelName', function() { return this.constructor.modelName.split('/')[1]; }), @@ -17,7 +15,7 @@ export default DS.Model.extend({ canEdit: alias('updatePath.canUpdate'), canRead: alias('updatePath.canRead'), format: computed('policy', function() { - let policy = this.get('policy'); + let policy = this.policy; let isJSON; try { let parsed = JSON.parse(policy); diff --git a/ui/app/models/policy/egp.js b/ui/app/models/policy/egp.js index 7a70778aa..d21afb931 100644 --- a/ui/app/models/policy/egp.js +++ b/ui/app/models/policy/egp.js @@ -1,11 +1,9 @@ +import { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import PolicyModel from './rgp'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -let { attr } = DS; - export default PolicyModel.extend({ paths: attr({ editType: 'stringArray', diff --git a/ui/app/models/policy/rgp.js b/ui/app/models/policy/rgp.js index 112e6e823..e4f3bc62a 100644 --- a/ui/app/models/policy/rgp.js +++ b/ui/app/models/policy/rgp.js @@ -1,11 +1,9 @@ +import { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import PolicyModel from '../policy'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -let { attr } = DS; - export default PolicyModel.extend({ enforcementLevel: attr('string', { possibleValues: ['advisory', 'soft-mandatory', 'hard-mandatory'], diff --git a/ui/app/models/raft-join.js b/ui/app/models/raft-join.js index df814b594..22e49a2e1 100644 --- a/ui/app/models/raft-join.js +++ b/ui/app/models/raft-join.js @@ -1,7 +1,6 @@ -import DS from 'ember-data'; +import Model, { attr } from '@ember-data/model'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; import { computed } from '@ember/object'; -const { attr } = DS; //leader_api_addr (string: ) – Address of the leader node in the Raft cluster to which this node is trying to join. @@ -13,7 +12,7 @@ const { attr } = DS; //leader_client_key (string: "") - Client key used to communicate with Raft's leader node. -export default DS.Model.extend({ +export default Model.extend({ leaderApiAddr: attr('string', { label: 'Leader API Address', }), diff --git a/ui/app/models/replication-attributes.js b/ui/app/models/replication-attributes.js index bb6915534..8e8e9de5c 100644 --- a/ui/app/models/replication-attributes.js +++ b/ui/app/models/replication-attributes.js @@ -1,12 +1,12 @@ import { match, not } from '@ember/object/computed'; import { computed } from '@ember/object'; -import attr from 'ember-data/attr'; +import { attr } from '@ember-data/model'; import Fragment from 'ember-data-model-fragments/fragment'; export default Fragment.extend({ clusterId: attr('string'), - clusterIdDisplay: computed('mode', function() { - const clusterId = this.get('clusterId'); + clusterIdDisplay: computed('clusterId', 'mode', function() { + const clusterId = this.clusterId; return clusterId ? clusterId.split('-')[0] : null; }), mode: attr('string'), @@ -23,11 +23,11 @@ export default Fragment.extend({ // secondary attrs isSecondary: match('mode', /secondary/), connection_state: attr('string'), - modeForUrl: computed('mode', function() { - const mode = this.get('mode'); + modeForUrl: computed('isPrimary', 'isSecondary', 'mode', function() { + const mode = this.mode; return mode === 'bootstrapping' ? 'bootstrapping' - : (this.get('isSecondary') && 'secondary') || (this.get('isPrimary') && 'primary'); + : (this.isSecondary && 'secondary') || (this.isPrimary && 'primary'); }), modeForHeader: computed('mode', function() { const mode = this.mode; @@ -48,8 +48,8 @@ export default Fragment.extend({ lastWAL: attr('number'), merkleRoot: attr('string'), merkleSyncProgress: attr('object'), - syncProgress: computed('state', 'merkleSyncProgress', function() { - const { state, merkleSyncProgress } = this.getProperties('state', 'merkleSyncProgress'); + get syncProgress() { + const { state, merkleSyncProgress } = this; if (state !== 'merkle-sync' || !merkleSyncProgress) { return null; } @@ -58,10 +58,10 @@ export default Fragment.extend({ progress: sync_progress, total: sync_total_keys, }; - }).volatile(), + }, syncProgressPercent: computed('syncProgress', function() { - const syncProgress = this.get('syncProgress'); + const syncProgress = this.syncProgress; if (!syncProgress) { return null; } @@ -80,6 +80,6 @@ export default Fragment.extend({ unsupported: 'Not supported', }; - return displays[this.get('mode')] || 'Disabled'; + return displays[this.mode] || 'Disabled'; }), }); diff --git a/ui/app/models/replication-mode.js b/ui/app/models/replication-mode.js index df79d46ac..b00a688b0 100644 --- a/ui/app/models/replication-mode.js +++ b/ui/app/models/replication-mode.js @@ -1,5 +1,4 @@ -import DS from 'ember-data'; -const { attr } = DS; +import Model, { attr } from '@ember-data/model'; /* sample response @@ -33,6 +32,6 @@ const { attr } = DS; */ -export default DS.Model.extend({ +export default Model.extend({ status: attr('object'), }); diff --git a/ui/app/models/role-aws.js b/ui/app/models/role-aws.js index 6f740dbc5..422499b5a 100644 --- a/ui/app/models/role-aws.js +++ b/ui/app/models/role-aws.js @@ -1,11 +1,9 @@ +import Model, { attr } from '@ember-data/model'; import { alias } from '@ember/object/computed'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -const { attr } = DS; - const CREDENTIAL_TYPES = [ { value: 'iam_user', @@ -20,7 +18,7 @@ const CREDENTIAL_TYPES = [ displayName: 'Federation Token', }, ]; -export default DS.Model.extend({ +export default Model.extend({ backend: attr('string', { readOnly: true, }), diff --git a/ui/app/models/role-jwt.js b/ui/app/models/role-jwt.js index fda75df70..6e0a6cfe4 100644 --- a/ui/app/models/role-jwt.js +++ b/ui/app/models/role-jwt.js @@ -1,7 +1,6 @@ -import DS from 'ember-data'; +import Model, { attr } from '@ember-data/model'; import { computed } from '@ember/object'; import parseURL from 'core/utils/parse-url'; -const { attr } = DS; const DOMAIN_STRINGS = { github: 'GitHub', @@ -16,7 +15,7 @@ const PROVIDER_WITH_LOGO = ['GitLab', 'Google', 'Auth0']; export { DOMAIN_STRINGS, PROVIDER_WITH_LOGO }; -export default DS.Model.extend({ +export default Model.extend({ authUrl: attr('string'), providerName: computed('authUrl', function() { diff --git a/ui/app/models/role-pki.js b/ui/app/models/role-pki.js index 3f4459f55..219e37a39 100644 --- a/ui/app/models/role-pki.js +++ b/ui/app/models/role-pki.js @@ -1,12 +1,11 @@ +import Model, { attr } from '@ember-data/model'; import { alias } from '@ember/object/computed'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; import fieldToAttrs from 'vault/utils/field-to-attrs'; import { combineFieldGroups } from 'vault/utils/openapi-to-attrs'; -const { attr } = DS; -export default DS.Model.extend({ +export default Model.extend({ backend: attr('string', { readOnly: true, }), @@ -33,7 +32,7 @@ export default DS.Model.extend({ signVerbatimPath: lazyCapabilities(apiPath`${'backend'}/sign-verbatim/${'id'}`, 'backend', 'id'), canSignVerbatim: alias('signVerbatimPath.canUpdate'), - fieldGroups: computed(function() { + fieldGroups: computed('newFields', function() { let groups = [ { default: ['name', 'keyType'] }, { diff --git a/ui/app/models/role-ssh.js b/ui/app/models/role-ssh.js index 5f1128d4a..44b201bae 100644 --- a/ui/app/models/role-ssh.js +++ b/ui/app/models/role-ssh.js @@ -1,11 +1,10 @@ +import Model, { attr } from '@ember-data/model'; import { alias } from '@ember/object/computed'; import { computed } from '@ember/object'; -import DS from 'ember-data'; +import fieldToAttrs from 'vault/utils/field-to-attrs'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -const { attr } = DS; - // these arrays define the order in which the fields will be displayed // see // https://github.com/hashicorp/vault/blob/master/builtin/logical/ssh/path_roles.go#L542 for list of fields for each key type @@ -40,7 +39,7 @@ const CA_FIELDS = [ 'keyIdFormat', ]; -export default DS.Model.extend({ +export default Model.extend({ useOpenAPI: true, getHelpUrl: function(backend) { return `/v1/${backend}/roles/example?help=1`; @@ -118,12 +117,25 @@ export default DS.Model.extend({ helpText: 'When supplied, this value specifies a custom format for the key id of a signed certificate', }), - attrsForKeyType: computed('keyType', function() { - const keyType = this.get('keyType'); + showFields: computed('keyType', function() { + const keyType = this.keyType; let keys = keyType === 'ca' ? CA_FIELDS.slice(0) : OTP_FIELDS.slice(0); return expandAttributeMeta(this, keys); }), + fieldGroups: computed('keyType', function() { + let numRequired = this.keyType === 'otp' ? 3 : 4; + let fields = this.keyType === 'otp' ? [...OTP_FIELDS] : [...CA_FIELDS]; + let defaultFields = fields.splice(0, numRequired); + const groups = [ + { default: defaultFields }, + { + Options: [...fields], + }, + ]; + return fieldToAttrs(this, groups); + }), + updatePath: lazyCapabilities(apiPath`${'backend'}/roles/${'id'}`, 'backend', 'id'), canDelete: alias('updatePath.canDelete'), canEdit: alias('updatePath.canUpdate'), diff --git a/ui/app/models/secret-engine.js b/ui/app/models/secret-engine.js index ddf70694b..e5e9cceb8 100644 --- a/ui/app/models/secret-engine.js +++ b/ui/app/models/secret-engine.js @@ -1,15 +1,13 @@ +import Model, { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import { fragment } from 'ember-data-model-fragments/attributes'; import fieldToAttrs, { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -const { attr } = DS; - //identity will be managed separately and the inclusion //of the system backend is an implementation detail const LIST_EXCLUDED_BACKENDS = ['system', 'identity']; -export default DS.Model.extend({ +export default Model.extend({ path: attr('string'), accessor: attr('string'), name: attr('string'), @@ -31,8 +29,8 @@ export default DS.Model.extend({ }), modelTypeForKV: computed('engineType', 'options.version', function() { - let type = this.get('engineType'); - let version = this.get('options.version'); + let type = this.engineType; + let version = this.options?.version; let modelType = 'secret'; if ((type === 'kv' || type === 'generic') && version === 2) { modelType = 'secret-v2'; @@ -40,12 +38,10 @@ export default DS.Model.extend({ return modelType; }), - isV2KV: computed('modelTypeForKV', function() { - return this.modelTypeForKV === 'secret-v2'; - }), + isV2KV: computed.equal('modelTypeForKV', 'secret-v2'), formFields: computed('engineType', function() { - let type = this.get('engineType'); + let type = this.engineType; let fields = [ 'type', 'path', @@ -62,7 +58,7 @@ export default DS.Model.extend({ }), formFieldGroups: computed('engineType', function() { - let type = this.get('engineType'); + let type = this.engineType; let defaultGroup = { default: ['path'] }; if (type === 'kv' || type === 'generic') { defaultGroup.default.push('options.{version}'); @@ -82,25 +78,25 @@ export default DS.Model.extend({ }), attrs: computed('formFields', function() { - return expandAttributeMeta(this, this.get('formFields')); + return expandAttributeMeta(this, this.formFields); }), fieldGroups: computed('formFieldGroups', function() { - return fieldToAttrs(this, this.get('formFieldGroups')); + return fieldToAttrs(this, this.formFieldGroups); }), // namespaces introduced types with a `ns_` prefix for built-in engines // so we need to strip that to normalize the type engineType: computed('type', function() { - return (this.get('type') || '').replace(/^ns_/, ''); + return (this.type || '').replace(/^ns_/, ''); }), shouldIncludeInList: computed('engineType', function() { - return !LIST_EXCLUDED_BACKENDS.includes(this.get('engineType')); + return !LIST_EXCLUDED_BACKENDS.includes(this.engineType); }), localDisplay: computed('local', function() { - return this.get('local') ? 'local' : 'replicated'; + return this.local ? 'local' : 'replicated'; }), // ssh specific ones @@ -111,7 +107,7 @@ export default DS.Model.extend({ }), saveCA(options) { - if (this.get('type') !== 'ssh') { + if (this.type !== 'ssh') { return; } if (options.isDelete) { diff --git a/ui/app/models/secret-v2-version.js b/ui/app/models/secret-v2-version.js index 4ad9c11dc..fc7ea739a 100644 --- a/ui/app/models/secret-v2-version.js +++ b/ui/app/models/secret-v2-version.js @@ -1,9 +1,7 @@ +import { belongsTo, attr } from '@ember-data/model'; import Secret from './secret'; -import DS from 'ember-data'; import { computed } from '@ember/object'; -const { attr, belongsTo } = DS; - export default Secret.extend({ failedServerRead: attr('boolean'), pathAttr: 'path', @@ -13,7 +11,7 @@ export default Secret.extend({ deletionTime: attr('string'), createdTime: attr('string'), deleted: computed('deletionTime', function() { - const deletionTime = new Date(this.get('deletionTime')); + const deletionTime = new Date(this.deletionTime); const now = new Date(); return deletionTime <= now; }), diff --git a/ui/app/models/secret-v2.js b/ui/app/models/secret-v2.js index 21c7ca719..5a1b00881 100644 --- a/ui/app/models/secret-v2.js +++ b/ui/app/models/secret-v2.js @@ -1,12 +1,10 @@ -import DS from 'ember-data'; +import Model, { belongsTo, hasMany, attr } from '@ember-data/model'; import { computed } from '@ember/object'; import { alias } from '@ember/object/computed'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; import KeyMixin from 'vault/mixins/key-mixin'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; -const { attr, hasMany, belongsTo, Model } = DS; - export default Model.extend(KeyMixin, { failedServerRead: attr('boolean'), engine: belongsTo('secret-engine', { async: false }), diff --git a/ui/app/models/secret.js b/ui/app/models/secret.js index 750f0e44f..fb37f1452 100644 --- a/ui/app/models/secret.js +++ b/ui/app/models/secret.js @@ -1,11 +1,10 @@ +import Model, { attr } from '@ember-data/model'; import { computed } from '@ember/object'; import { alias } from '@ember/object/computed'; -import DS from 'ember-data'; import KeyMixin from 'vault/mixins/key-mixin'; -const { attr } = DS; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; -export default DS.Model.extend(KeyMixin, { +export default Model.extend(KeyMixin, { failedServerRead: attr('boolean'), auth: attr('string'), lease_duration: attr('number'), @@ -14,18 +13,18 @@ export default DS.Model.extend(KeyMixin, { secretData: attr('object'), secretKeyAndValue: computed('secretData', function() { - const data = this.get('secretData'); + const data = this.secretData; return Object.keys(data).map(key => { return { key, value: data[key] }; }); }), dataAsJSONString: computed('secretData', function() { - return JSON.stringify(this.get('secretData'), null, 2); + return JSON.stringify(this.secretData, null, 2); }), isAdvancedFormat: computed('secretData', function() { - const data = this.get('secretData'); + const data = this.secretData; return data && Object.keys(data).some(key => typeof data[key] !== 'string'); }), diff --git a/ui/app/models/server.js b/ui/app/models/server.js index 26d7e98aa..62dc72727 100644 --- a/ui/app/models/server.js +++ b/ui/app/models/server.js @@ -1,8 +1,7 @@ -import DS from 'ember-data'; -const { attr } = DS; +import Model, { attr } from '@ember-data/model'; //{"node_id":"1249bfbc-b234-96f3-0c66-07078ac3e16e","address":"127.0.0.1:8201","leader":true,"protocol_version":"3","voter":true} -export default DS.Model.extend({ +export default Model.extend({ address: attr('string'), nodeId: attr('string'), protocolVersion: attr('string'), diff --git a/ui/app/models/ssh-otp-credential.js b/ui/app/models/ssh-otp-credential.js index 3664c0fb2..9af3716b0 100644 --- a/ui/app/models/ssh-otp-credential.js +++ b/ui/app/models/ssh-otp-credential.js @@ -1,11 +1,11 @@ +import { reads } from '@ember/object/computed'; +import Model, { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -const { attr } = DS; const CREATE_FIELDS = ['username', 'ip']; const DISPLAY_FIELDS = ['username', 'ip', 'key', 'keyType', 'port']; -export default DS.Model.extend({ +export default Model.extend({ role: attr('object', { readOnly: true, }), @@ -17,11 +17,8 @@ export default DS.Model.extend({ keyType: attr('string'), port: attr('number'), attrs: computed('key', function() { - let keys = this.get('key') ? DISPLAY_FIELDS.slice(0) : CREATE_FIELDS.slice(0); + let keys = this.key ? DISPLAY_FIELDS.slice(0) : CREATE_FIELDS.slice(0); return expandAttributeMeta(this, keys); }), - toCreds: computed('key', function() { - // todo: would this be better copied as an SSH command? - return this.get('key'); - }), + toCreds: reads('key'), }); diff --git a/ui/app/models/ssh-sign.js b/ui/app/models/ssh-sign.js index 8d8cb76a8..e61173c0c 100644 --- a/ui/app/models/ssh-sign.js +++ b/ui/app/models/ssh-sign.js @@ -1,7 +1,6 @@ +import Model, { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -const { attr } = DS; const CREATE_FIELDS = [ 'publicKey', 'keyId', @@ -14,7 +13,7 @@ const CREATE_FIELDS = [ const DISPLAY_FIELDS = ['signedKey', 'leaseId', 'renewable', 'leaseDuration', 'serialNumber']; -export default DS.Model.extend({ +export default Model.extend({ role: attr('object', { readOnly: true, }), @@ -47,7 +46,7 @@ export default DS.Model.extend({ signedKey: attr('string'), attrs: computed('signedKey', function() { - let keys = this.get('signedKey') ? DISPLAY_FIELDS.slice(0) : CREATE_FIELDS.slice(0); + let keys = this.signedKey ? DISPLAY_FIELDS.slice(0) : CREATE_FIELDS.slice(0); return expandAttributeMeta(this, keys); }), }); diff --git a/ui/app/models/transform.js b/ui/app/models/transform.js index ef2a16d93..2e77cbbd8 100644 --- a/ui/app/models/transform.js +++ b/ui/app/models/transform.js @@ -1,11 +1,9 @@ +import Model, { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import { apiPath } from 'vault/macros/lazy-capabilities'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; import attachCapabilities from 'vault/lib/attach-capabilities'; -const { attr } = DS; - // these arrays define the order in which the fields will be displayed // see //https://www.vaultproject.io/api-docs/secret/transform#create-update-transformation @@ -35,10 +33,10 @@ const TWEAK_SOURCE = [ }, ]; -const Model = DS.Model.extend({ +const ModelExport = Model.extend({ useOpenAPI: false, name: attr('string', { - // TODO: make this required for making a transformation + // CBS TODO: make this required for making a transformation label: 'Name', fieldValue: 'id', readOnly: true, @@ -55,7 +53,7 @@ const Model = DS.Model.extend({ defaultValue: 'supplied', label: 'Tweak source', possibleValues: TWEAK_SOURCE, - subText: `A tweak value is used when performing FPE transformations. This can be supplied, generated, or internal.`, // TODO: I do not include the link here. Need to figure out the best way to approach this. + subText: `A tweak value is used when performing FPE transformations. This can be supplied, generated, or internal.`, // CBS TODO: I do not include the link here. Need to figure out the best way to approach this. }), masking_character: attr('string', { characterLimit: 1, @@ -66,7 +64,7 @@ const Model = DS.Model.extend({ template: attr('array', { editType: 'searchSelect', fallbackComponent: 'string-list', - label: 'Template', // TODO: make this required for making a transformation + label: 'Template', // CBS TODO: make this required for making a transformation models: ['transform/template'], selectLimit: 1, onlyAllowExisting: true, @@ -89,7 +87,7 @@ const Model = DS.Model.extend({ return ['name', 'type', 'tweak_source', 'template', 'allowed_roles']; }), transformFieldAttrs: computed('transformAttrs', function() { - return expandAttributeMeta(this, this.get('transformAttrs')); + return expandAttributeMeta(this, this.transformAttrs); }), backend: attr('string', { @@ -97,6 +95,6 @@ const Model = DS.Model.extend({ }), }); -export default attachCapabilities(Model, { +export default attachCapabilities(ModelExport, { updatePath: apiPath`${'backend'}/transformation/${'id'}`, }); diff --git a/ui/app/models/transform/alphabet.js b/ui/app/models/transform/alphabet.js index f60deaad2..fbb9d74b7 100644 --- a/ui/app/models/transform/alphabet.js +++ b/ui/app/models/transform/alphabet.js @@ -1,12 +1,11 @@ -import DS from 'ember-data'; +import Model from '@ember-data/model'; +import { attr } from '@ember-data/model'; import { computed } from '@ember/object'; import { apiPath } from 'vault/macros/lazy-capabilities'; import attachCapabilities from 'vault/lib/attach-capabilities'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -const { attr } = DS; - -const Model = DS.Model.extend({ +const M = Model.extend({ idPrefix: 'alphabet/', idForNav: computed('id', 'idPrefix', function() { let modelId = this.id || ''; @@ -32,6 +31,6 @@ const Model = DS.Model.extend({ backend: attr('string', { readOnly: true }), }); -export default attachCapabilities(Model, { +export default attachCapabilities(M, { updatePath: apiPath`${'backend'}/alphabet/${'id'}`, }); diff --git a/ui/app/models/transform/role.js b/ui/app/models/transform/role.js index 57e5f4ab0..c650b6685 100644 --- a/ui/app/models/transform/role.js +++ b/ui/app/models/transform/role.js @@ -1,12 +1,10 @@ +import Model, { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import { apiPath } from 'vault/macros/lazy-capabilities'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; import attachCapabilities from 'vault/lib/attach-capabilities'; -const { attr } = DS; - -const Model = DS.Model.extend({ +const ModelExport = Model.extend({ // used for getting appropriate options for backend idPrefix: 'role/', // the id prefixed with `role/` so we can use it as the *secret param for the secret show route @@ -40,6 +38,6 @@ const Model = DS.Model.extend({ backend: attr('string', { readOnly: true }), }); -export default attachCapabilities(Model, { +export default attachCapabilities(ModelExport, { updatePath: apiPath`${'backend'}/role/${'id'}`, }); diff --git a/ui/app/models/transform/template.js b/ui/app/models/transform/template.js index a4b93ba84..4d8602de8 100644 --- a/ui/app/models/transform/template.js +++ b/ui/app/models/transform/template.js @@ -1,12 +1,10 @@ +import Model, { attr } from '@ember-data/model'; import { computed } from '@ember/object'; -import DS from 'ember-data'; import { apiPath } from 'vault/macros/lazy-capabilities'; import attachCapabilities from 'vault/lib/attach-capabilities'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; -const { attr } = DS; - -const Model = DS.Model.extend({ +const M = Model.extend({ idPrefix: 'template/', idForNav: computed('id', 'idPrefix', function() { let modelId = this.id || ''; @@ -41,6 +39,6 @@ const Model = DS.Model.extend({ backend: attr('string', { readOnly: true }), }); -export default attachCapabilities(Model, { +export default attachCapabilities(M, { updatePath: apiPath`${'backend'}/template/${'id'}`, }); diff --git a/ui/app/models/transform/transformation.js b/ui/app/models/transform/transformation.js deleted file mode 100644 index a99377051..000000000 --- a/ui/app/models/transform/transformation.js +++ /dev/null @@ -1,7 +0,0 @@ -import DS from 'ember-data'; - -export default DS.Model.extend({ - name: DS.attr('string'), - template: DS.belongsTo('transform/template'), - roles: DS.belongsTo('transform/role'), -}); diff --git a/ui/app/models/transit-key.js b/ui/app/models/transit-key.js index c3797b593..ffb203c74 100644 --- a/ui/app/models/transit-key.js +++ b/ui/app/models/transit-key.js @@ -1,11 +1,9 @@ +import Model, { attr } from '@ember-data/model'; import { alias } from '@ember/object/computed'; import { set, get, computed } from '@ember/object'; -import DS from 'ember-data'; import clamp from 'vault/utils/clamp'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; -const { attr } = DS; - const ACTION_VALUES = { encrypt: { isSupported: 'supportsEncryption', @@ -41,11 +39,15 @@ const ACTION_VALUES = { export: { isSupported: 'exportable', description: 'Get the named key', glyph: 'exit' }, }; -export default DS.Model.extend({ +export default Model.extend({ type: attr('string', { defaultValue: 'aes256-gcm96', }), - name: attr('string'), + name: attr('string', { + label: 'Name', + fieldValue: 'id', + readOnly: true, + }), deletionAllowed: attr('boolean'), derived: attr('boolean'), exportable: attr('boolean'), @@ -93,11 +95,11 @@ export default DS.Model.extend({ canDelete: computed('deletionAllowed', 'lastLoadTS', function() { const deleteAttrChanged = Boolean(this.changedAttributes().deletionAllowed); - return get(this, 'deletionAllowed') && deleteAttrChanged === false; + return this.deletionAllowed && deleteAttrChanged === false; }), keyVersions: computed('validKeyVersions', function() { - let maxVersion = Math.max(...get(this, 'validKeyVersions')); + let maxVersion = Math.max(...this.validKeyVersions); let versions = []; while (maxVersion > 0) { versions.unshift(maxVersion); @@ -106,18 +108,24 @@ export default DS.Model.extend({ return versions; }), - encryptionKeyVersions: computed('keyVerisons', 'minDecryptionVersion', 'latestVersion', function() { - const { keyVersions, minDecryptionVersion } = this.getProperties('keyVersions', 'minDecryptionVersion'); + encryptionKeyVersions: computed( + 'keyVerisons', + 'keyVersions', + 'latestVersion', + 'minDecryptionVersion', + function() { + const { keyVersions, minDecryptionVersion } = this; - return keyVersions - .filter(version => { - return version >= minDecryptionVersion; - }) - .reverse(); - }), + return keyVersions + .filter(version => { + return version >= minDecryptionVersion; + }) + .reverse(); + } + ), keysForEncryption: computed('minEncryptionVersion', 'latestVersion', function() { - let { minEncryptionVersion, latestVersion } = this.getProperties('minEncryptionVersion', 'latestVersion'); + let { minEncryptionVersion, latestVersion } = this; let minVersion = clamp(minEncryptionVersion - 1, 0, latestVersion); let versions = []; while (latestVersion > minVersion) { @@ -128,15 +136,15 @@ export default DS.Model.extend({ }), validKeyVersions: computed('keys', function() { - return Object.keys(get(this, 'keys')); + return Object.keys(this.keys); }), - exportKeyTypes: computed('exportable', 'type', function() { + exportKeyTypes: computed('exportable', 'supportsEncryption', 'supportsSigning', 'type', function() { let types = ['hmac']; - if (this.get('supportsSigning')) { + if (this.supportsSigning) { types.unshift('signing'); } - if (this.get('supportsEncryption')) { + if (this.supportsEncryption) { types.unshift('encryption'); } return types; diff --git a/ui/app/resolver.js b/ui/app/resolver.js deleted file mode 100644 index 2fb563d6c..000000000 --- a/ui/app/resolver.js +++ /dev/null @@ -1,3 +0,0 @@ -import Resolver from 'ember-resolver'; - -export default Resolver; diff --git a/ui/app/router.js b/ui/app/router.js index 1b5c8ce99..650aa1237 100644 --- a/ui/app/router.js +++ b/ui/app/router.js @@ -1,10 +1,10 @@ import EmberRouter from '@ember/routing/router'; -import config from './config/environment'; +import config from 'vault/config/environment'; -const Router = EmberRouter.extend({ - location: config.locationType, - rootURL: config.rootURL, -}); +export default class Router extends EmberRouter { + location = config.locationType; + rootURL = config.rootURL; +} Router.map(function() { this.route('vault', { path: '/' }, function() { @@ -122,7 +122,7 @@ Router.map(function() { }); this.route('policies', { path: '/policies/:type' }, function() { this.route('index', { path: '/' }); - this.route('create', { path: '/create' }); + this.route('create'); }); this.route('policy', { path: '/policy/:type' }, function() { this.route('show', { path: '/:policy_name' }); @@ -140,5 +140,3 @@ Router.map(function() { this.route('not-found', { path: '/*path' }); }); }); - -export default Router; diff --git a/ui/app/routes/application.js b/ui/app/routes/application.js index f541d94b3..7fd0fb582 100644 --- a/ui/app/routes/application.js +++ b/ui/app/routes/application.js @@ -14,7 +14,7 @@ export default Route.extend({ window.scrollTo(0, 0); }, error(error, transition) { - let controlGroup = this.get('controlGroup'); + let controlGroup = this.controlGroup; if (error instanceof ControlGroupError) { return controlGroup.handleError(error, transition); } @@ -22,7 +22,7 @@ export default Route.extend({ controlGroup.unmarkTokenForUnwrap(); } - let router = this.get('routing'); + let router = this.routing; //FIXME transition.intent likely needs to be replaced let errorURL = transition.intent.url; let { name, contexts, queryParams } = transition.intent; @@ -59,22 +59,22 @@ export default Route.extend({ return true; }, didTransition() { - let wizard = this.get('wizard'); + let wizard = this.wizard; if (wizard.get('currentState') !== 'active.feature') { return true; } next(() => { - let applicationURL = this.get('routing.currentURL'); - let activeRoute = this.get('routing.currentRouteName'); + let applicationURL = this.routing.currentURL; + let activeRoute = this.routing.currentRouteName; - if (this.get('wizard.setURLAfterTransition')) { + if (this.wizard.setURLAfterTransition) { this.set('wizard.setURLAfterTransition', false); this.set('wizard.expectedURL', applicationURL); this.set('wizard.expectedRouteName', activeRoute); } - let expectedRouteName = this.get('wizard.expectedRouteName'); - if (this.get('routing').isActive(expectedRouteName) === false) { + let expectedRouteName = this.wizard.expectedRouteName; + if (this.routing.isActive(expectedRouteName) === false) { wizard.transitionTutorialMachine(wizard.get('currentState'), 'PAUSE'); } }); diff --git a/ui/app/routes/vault.js b/ui/app/routes/vault.js index 02a0baa9f..56b377066 100644 --- a/ui/app/routes/vault.js +++ b/ui/app/routes/vault.js @@ -9,7 +9,7 @@ const SPLASH_DELAY = Ember.testing ? 0 : 300; export default Route.extend({ version: service(), beforeModel() { - return this.get('version').fetchVersion(); + return this.version.fetchVersion(); }, model() { // hardcode single cluster diff --git a/ui/app/routes/vault/cluster.js b/ui/app/routes/vault/cluster.js index ab2b78b07..96db4d842 100644 --- a/ui/app/routes/vault/cluster.js +++ b/ui/app/routes/vault/cluster.js @@ -2,7 +2,6 @@ import { inject as service } from '@ember/service'; import { computed } from '@ember/object'; import { reject } from 'rsvp'; import Route from '@ember/routing/route'; -import { getOwner } from '@ember/application'; import { task, timeout } from 'ember-concurrency'; import Ember from 'ember'; import ClusterRoute from 'vault/mixins/cluster-route'; @@ -20,9 +19,6 @@ export default Route.extend(ModelBoundaryRoute, ClusterRoute, { modelTypes: computed(function() { return ['node', 'secret', 'secret-engine']; }), - globalNamespaceModels: computed(function() { - return ['node', 'cluster']; - }), queryParams: { namespaceQueryParam: { @@ -36,31 +32,14 @@ export default Route.extend(ModelBoundaryRoute, ClusterRoute, { return cluster ? cluster.get('id') : null; }, - clearNonGlobalModels() { - // this method clears all of the ember data cached models except - // the model types blacklisted in `globalNamespaceModels` - let store = this.store; - let modelsToKeep = this.get('globalNamespaceModels'); - for (let model of getOwner(this) - .lookup('data-adapter:main') - .getModelTypes()) { - let { name } = model; - if (modelsToKeep.includes(name)) { - return; - } - store.unloadAll(name); - } - }, - async beforeModel() { const params = this.paramsFor(this.routeName); - this.clearNonGlobalModels(); - this.get('namespaceService').setNamespace(params.namespaceQueryParam); + this.namespaceService.setNamespace(params.namespaceQueryParam); const id = this.getClusterId(params); if (id) { - this.get('auth').setCluster(id); - await this.get('permissions').getPaths.perform(); - return this.get('version').fetchFeatures(); + this.auth.setCluster(id); + await this.permissions.getPaths.perform(); + return this.version.fetchFeatures(); } else { return reject({ httpStatus: 404, message: 'not found', path: params.cluster_name }); } @@ -68,7 +47,7 @@ export default Route.extend(ModelBoundaryRoute, ClusterRoute, { model(params) { const id = this.getClusterId(params); - return this.get('store').findRecord('cluster', id); + return this.store.findRecord('cluster', id); }, poll: task(function*() { @@ -92,11 +71,11 @@ export default Route.extend(ModelBoundaryRoute, ClusterRoute, { afterModel(model, transition) { this._super(...arguments); - this.get('currentCluster').setCluster(model); + this.currentCluster.setCluster(model); // Check that namespaces is enabled and if not, // clear the namespace by transition to this route w/o it - if (this.get('namespaceService.path') && !this.get('version.hasNamespaces')) { + if (this.namespaceService.path && !this.version.hasNamespaces) { return this.transitionTo(this.routeName, { queryParams: { namespace: '' } }); } return this.transitionToTargetRoute(transition); diff --git a/ui/app/routes/vault/cluster/access/control-group-accessor.js b/ui/app/routes/vault/cluster/access/control-group-accessor.js index b6d6c3142..c385dffab 100644 --- a/ui/app/routes/vault/cluster/access/control-group-accessor.js +++ b/ui/app/routes/vault/cluster/access/control-group-accessor.js @@ -6,15 +6,13 @@ export default Route.extend(UnloadModel, { version: service(), beforeModel() { - return this.get('version') - .fetchFeatures() - .then(() => { - return this._super(...arguments); - }); + return this.version.fetchFeatures().then(() => { + return this._super(...arguments); + }); }, model(params) { - return this.get('version').hasFeature('Control Groups') + return this.version.hasFeature('Control Groups') ? this.store.findRecord('control-group', params.accessor) : null; }, diff --git a/ui/app/routes/vault/cluster/access/control-groups-configure.js b/ui/app/routes/vault/cluster/access/control-groups-configure.js index 06ef92d35..cd32f1690 100644 --- a/ui/app/routes/vault/cluster/access/control-groups-configure.js +++ b/ui/app/routes/vault/cluster/access/control-groups-configure.js @@ -6,16 +6,14 @@ export default Route.extend(UnloadModel, { version: service(), beforeModel() { - return this.get('version') - .fetchFeatures() - .then(() => { - return this._super(...arguments); - }); + return this.version.fetchFeatures().then(() => { + return this._super(...arguments); + }); }, model() { let type = 'control-group-config'; - return this.get('version').hasFeature('Control Groups') + return this.version.hasFeature('Control Groups') ? this.store.findRecord(type, 'config').catch(e => { // if you haven't saved a config, the API 404s, so create one here to edit and return it if (e.httpStatus === 404) { diff --git a/ui/app/routes/vault/cluster/access/control-groups.js b/ui/app/routes/vault/cluster/access/control-groups.js index caf86865d..e08b8d1d3 100644 --- a/ui/app/routes/vault/cluster/access/control-groups.js +++ b/ui/app/routes/vault/cluster/access/control-groups.js @@ -6,14 +6,12 @@ export default Route.extend(UnloadModel, { version: service(), beforeModel() { - return this.get('version') - .fetchFeatures() - .then(() => { - return this._super(...arguments); - }); + return this.version.fetchFeatures().then(() => { + return this._super(...arguments); + }); }, model() { - return this.get('version').hasFeature('Control Groups') ? this.store.createRecord('control-group') : null; + return this.version.hasFeature('Control Groups') ? this.store.createRecord('control-group') : null; }, }); diff --git a/ui/app/routes/vault/cluster/access/identity.js b/ui/app/routes/vault/cluster/access/identity.js index 2cdd0478b..03cc052b8 100644 --- a/ui/app/routes/vault/cluster/access/identity.js +++ b/ui/app/routes/vault/cluster/access/identity.js @@ -1,6 +1,6 @@ +import AdapterError from '@ember-data/adapter/error'; import { set } from '@ember/object'; import Route from '@ember/routing/route'; -import DS from 'ember-data'; const MODEL_FROM_PARAM = { entities: 'entity', @@ -11,7 +11,7 @@ export default Route.extend({ model(params) { let model = MODEL_FROM_PARAM[params.item_type]; if (!model) { - const error = new DS.AdapterError(); + const error = new AdapterError(); set(error, 'httpStatus', 404); throw error; } diff --git a/ui/app/routes/vault/cluster/access/identity/aliases/show.js b/ui/app/routes/vault/cluster/access/identity/aliases/show.js index 073a1f81c..1436d0606 100644 --- a/ui/app/routes/vault/cluster/access/identity/aliases/show.js +++ b/ui/app/routes/vault/cluster/access/identity/aliases/show.js @@ -1,7 +1,7 @@ +import AdapterError from '@ember-data/adapter/error'; import { hash } from 'rsvp'; import { set } from '@ember/object'; import Route from '@ember/routing/route'; -import DS from 'ember-data'; import { TABS } from 'vault/helpers/tabs-for-identity-show'; export default Route.extend({ @@ -11,7 +11,7 @@ export default Route.extend({ let tabs = TABS[itemType]; let modelType = `identity/${itemType}`; if (!tabs.includes(section)) { - const error = new DS.AdapterError(); + const error = new AdapterError(); set(error, 'httpStatus', 404); throw error; } diff --git a/ui/app/routes/vault/cluster/access/identity/show.js b/ui/app/routes/vault/cluster/access/identity/show.js index e409aa738..2353d37f1 100644 --- a/ui/app/routes/vault/cluster/access/identity/show.js +++ b/ui/app/routes/vault/cluster/access/identity/show.js @@ -1,8 +1,8 @@ +import AdapterError from '@ember-data/adapter/error'; import { next } from '@ember/runloop'; import { hash } from 'rsvp'; import { set } from '@ember/object'; import Route from '@ember/routing/route'; -import DS from 'ember-data'; import { TABS } from 'vault/helpers/tabs-for-identity-show'; export default Route.extend({ @@ -12,7 +12,7 @@ export default Route.extend({ let tabs = TABS[itemType]; let modelType = `identity/${itemType}`; if (!tabs.includes(section)) { - const error = new DS.AdapterError(); + const error = new AdapterError(); set(error, 'httpStatus', 404); throw error; } diff --git a/ui/app/routes/vault/cluster/access/leases/list.js b/ui/app/routes/vault/cluster/access/leases/list.js index e56f23d49..6ebc8150b 100644 --- a/ui/app/routes/vault/cluster/access/leases/list.js +++ b/ui/app/routes/vault/cluster/access/leases/list.js @@ -47,7 +47,7 @@ export default Route.extend({ setupController(controller, model) { const params = this.paramsFor(this.routeName); const prefix = params.prefix ? params.prefix : ''; - const has404 = this.get('has404'); + const has404 = this.has404; controller.set('hasModel', true); controller.setProperties({ model: model.leases, diff --git a/ui/app/routes/vault/cluster/access/method.js b/ui/app/routes/vault/cluster/access/method.js index c29851ce9..0ebc0e9a4 100644 --- a/ui/app/routes/vault/cluster/access/method.js +++ b/ui/app/routes/vault/cluster/access/method.js @@ -1,6 +1,6 @@ +import AdapterError from '@ember-data/adapter/error'; import { set } from '@ember/object'; import Route from '@ember/routing/route'; -import DS from 'ember-data'; import { inject as service } from '@ember/service'; export default Route.extend({ @@ -10,7 +10,7 @@ export default Route.extend({ return this.store.findAll('auth-method').then(modelArray => { const model = modelArray.findBy('id', path); if (!model) { - const error = new DS.AdapterError(); + const error = new AdapterError(); set(error, 'httpStatus', 404); throw error; } diff --git a/ui/app/routes/vault/cluster/access/method/section.js b/ui/app/routes/vault/cluster/access/method/section.js index 30346bb18..bab327bc4 100644 --- a/ui/app/routes/vault/cluster/access/method/section.js +++ b/ui/app/routes/vault/cluster/access/method/section.js @@ -1,8 +1,7 @@ -/* eslint-disable prettier/prettier */ +import AdapterError from '@ember-data/adapter/error'; import { set } from '@ember/object'; import { inject as service } from '@ember/service'; import Route from '@ember/routing/route'; -import DS from 'ember-data'; export default Route.extend({ wizard: service(), @@ -10,7 +9,7 @@ export default Route.extend({ model(params) { const { section_name: section } = params; if (section !== 'configuration') { - const error = new DS.AdapterError(); + const error = new AdapterError(); set(error, 'httpStatus', 404); throw error; } diff --git a/ui/app/routes/vault/cluster/access/namespaces/create.js b/ui/app/routes/vault/cluster/access/namespaces/create.js index 039b41fda..20522da75 100644 --- a/ui/app/routes/vault/cluster/access/namespaces/create.js +++ b/ui/app/routes/vault/cluster/access/namespaces/create.js @@ -5,13 +5,11 @@ import UnloadModel from 'vault/mixins/unload-model-route'; export default Route.extend(UnloadModel, { version: service(), beforeModel() { - return this.get('version') - .fetchFeatures() - .then(() => { - return this._super(...arguments); - }); + return this.version.fetchFeatures().then(() => { + return this._super(...arguments); + }); }, model() { - return this.get('version.hasNamespaces') ? this.store.createRecord('namespace') : null; + return this.version.hasNamespaces ? this.store.createRecord('namespace') : null; }, }); diff --git a/ui/app/routes/vault/cluster/access/namespaces/index.js b/ui/app/routes/vault/cluster/access/namespaces/index.js index fbebdb819..c756e607d 100644 --- a/ui/app/routes/vault/cluster/access/namespaces/index.js +++ b/ui/app/routes/vault/cluster/access/namespaces/index.js @@ -6,14 +6,12 @@ export default Route.extend(UnloadModel, { version: service(), beforeModel() { this.store.unloadAll('namespace'); - return this.get('version') - .fetchFeatures() - .then(() => { - return this._super(...arguments); - }); + return this.version.fetchFeatures().then(() => { + return this._super(...arguments); + }); }, model() { - return this.get('version.hasNamespaces') + return this.version.hasNamespaces ? this.store.findAll('namespace').catch(e => { if (e.httpStatus === 404) { return []; diff --git a/ui/app/routes/vault/cluster/auth.js b/ui/app/routes/vault/cluster/auth.js index dcb83b78d..1c2409797 100644 --- a/ui/app/routes/vault/cluster/auth.js +++ b/ui/app/routes/vault/cluster/auth.js @@ -13,7 +13,7 @@ export default ClusterRouteBase.extend({ wizard: service(), beforeModel() { return this._super().then(() => { - return this.get('version').fetchFeatures(); + return this.version.fetchFeatures(); }); }, model() { @@ -27,17 +27,17 @@ export default ClusterRouteBase.extend({ afterModel() { if (config.welcomeMessage) { - this.get('flashMessages').stickyInfo(config.welcomeMessage); + this.flashMessages.stickyInfo(config.welcomeMessage); } }, activate() { - this.get('wizard').set('initEvent', 'LOGIN'); - this.get('wizard').transitionTutorialMachine(this.get('wizard.currentState'), 'TOLOGIN'); + this.wizard.set('initEvent', 'LOGIN'); + this.wizard.transitionTutorialMachine(this.wizard.currentState, 'TOLOGIN'); }, actions: { willTransition(transition) { if (transition.targetName !== this.routeName) { - this.get('wizard').transitionTutorialMachine(this.get('wizard.currentState'), 'INITDONE'); + this.wizard.transitionTutorialMachine(this.wizard.currentState, 'INITDONE'); } }, }, diff --git a/ui/app/routes/vault/cluster/init.js b/ui/app/routes/vault/cluster/init.js index a6fc4920b..820de51ed 100644 --- a/ui/app/routes/vault/cluster/init.js +++ b/ui/app/routes/vault/cluster/init.js @@ -6,7 +6,7 @@ export default ClusterRoute.extend({ activate() { // always start from idle instead of using the current state - this.get('wizard').transitionTutorialMachine('idle', 'INIT'); - this.get('wizard').set('initEvent', 'START'); + this.wizard.transitionTutorialMachine('idle', 'INIT'); + this.wizard.set('initEvent', 'START'); }, }); diff --git a/ui/app/routes/vault/cluster/policies.js b/ui/app/routes/vault/cluster/policies.js index 9c08f3b60..a33816e9b 100644 --- a/ui/app/routes/vault/cluster/policies.js +++ b/ui/app/routes/vault/cluster/policies.js @@ -8,11 +8,9 @@ export default Route.extend(ClusterRoute, { version: service(), beforeModel() { - return this.get('version') - .fetchFeatures() - .then(() => { - return this._super(...arguments); - }); + return this.version.fetchFeatures().then(() => { + return this._super(...arguments); + }); }, model(params) { diff --git a/ui/app/routes/vault/cluster/policies/create.js b/ui/app/routes/vault/cluster/policies/create.js index c7a1f1746..81b747b26 100644 --- a/ui/app/routes/vault/cluster/policies/create.js +++ b/ui/app/routes/vault/cluster/policies/create.js @@ -10,12 +10,12 @@ export default Route.extend(UnloadModelRoute, UnsavedModelRoute, { let policyType = this.policyType(); if ( policyType === 'acl' && - this.get('wizard.currentMachine') === 'policies' && - this.get('wizard.featureState') === 'idle' + this.wizard.currentMachine === 'policies' && + this.wizard.featureState === 'idle' ) { - this.get('wizard').transitionFeatureMachine(this.get('wizard.featureState'), 'CONTINUE'); + this.wizard.transitionFeatureMachine(this.wizard.featureState, 'CONTINUE'); } - if (!this.get('version.hasSentinel') && policyType !== 'acl') { + if (!this.version.hasSentinel && policyType !== 'acl') { return this.transitionTo('vault.cluster.policies', policyType); } return this.store.createRecord(`policy/${policyType}`, {}); diff --git a/ui/app/routes/vault/cluster/policies/index.js b/ui/app/routes/vault/cluster/policies/index.js index 93214b987..5f46e865f 100644 --- a/ui/app/routes/vault/cluster/policies/index.js +++ b/ui/app/routes/vault/cluster/policies/index.js @@ -8,8 +8,8 @@ export default Route.extend(ClusterRoute, ListRoute, { wizard: service(), activate() { - if (this.get('wizard.featureState') === 'details') { - this.get('wizard').transitionFeatureMachine('details', 'CONTINUE', this.policyType()); + if (this.wizard.featureState === 'details') { + this.wizard.transitionFeatureMachine('details', 'CONTINUE', this.policyType()); } }, @@ -19,7 +19,7 @@ export default Route.extend(ClusterRoute, ListRoute, { model(params) { let policyType = this.policyType(); - if (this.shouldReturnEmptyModel(policyType, this.get('version'))) { + if (this.shouldReturnEmptyModel(policyType, this.version)) { return; } return this.store diff --git a/ui/app/routes/vault/cluster/policy.js b/ui/app/routes/vault/cluster/policy.js index 22c32f3f1..69ac6db70 100644 --- a/ui/app/routes/vault/cluster/policy.js +++ b/ui/app/routes/vault/cluster/policy.js @@ -7,18 +7,16 @@ const ALLOWED_TYPES = ['acl', 'egp', 'rgp']; export default Route.extend(ClusterRoute, { version: service(), beforeModel() { - return this.get('version') - .fetchFeatures() - .then(() => { - return this._super(...arguments); - }); + return this.version.fetchFeatures().then(() => { + return this._super(...arguments); + }); }, model(params) { let policyType = params.type; if (!ALLOWED_TYPES.includes(policyType)) { return this.transitionTo('vault.cluster.policies', ALLOWED_TYPES[0]); } - if (!this.get('version.hasSentinel') && policyType !== 'acl') { + if (!this.version.hasSentinel && policyType !== 'acl') { return this.transitionTo('vault.cluster.policies', policyType); } return {}; diff --git a/ui/app/routes/vault/cluster/replication-dr-promote/details.js b/ui/app/routes/vault/cluster/replication-dr-promote/details.js index 3d716ad99..99614cc98 100644 --- a/ui/app/routes/vault/cluster/replication-dr-promote/details.js +++ b/ui/app/routes/vault/cluster/replication-dr-promote/details.js @@ -5,6 +5,6 @@ export default Base.extend({ replicationMode: service(), beforeModel() { this._super(...arguments); - this.get('replicationMode').setMode('dr'); + this.replicationMode.setMode('dr'); }, }); diff --git a/ui/app/routes/vault/cluster/replication-dr-promote/index.js b/ui/app/routes/vault/cluster/replication-dr-promote/index.js index 3d716ad99..99614cc98 100644 --- a/ui/app/routes/vault/cluster/replication-dr-promote/index.js +++ b/ui/app/routes/vault/cluster/replication-dr-promote/index.js @@ -5,6 +5,6 @@ export default Base.extend({ replicationMode: service(), beforeModel() { this._super(...arguments); - this.get('replicationMode').setMode('dr'); + this.replicationMode.setMode('dr'); }, }); diff --git a/ui/app/routes/vault/cluster/secrets/backend/configuration.js b/ui/app/routes/vault/cluster/secrets/backend/configuration.js index 3b89ec30f..88985ddf7 100644 --- a/ui/app/routes/vault/cluster/secrets/backend/configuration.js +++ b/ui/app/routes/vault/cluster/secrets/backend/configuration.js @@ -5,12 +5,8 @@ export default Route.extend({ wizard: service(), model() { let backend = this.modelFor('vault.cluster.secrets.backend'); - if (this.get('wizard.featureState') === 'list') { - this.get('wizard').transitionFeatureMachine( - this.get('wizard.featureState'), - 'CONTINUE', - backend.get('type') - ); + if (this.wizard.featureState === 'list') { + this.wizard.transitionFeatureMachine(this.wizard.featureState, 'CONTINUE', backend.get('type')); } return backend; }, diff --git a/ui/app/routes/vault/cluster/secrets/backend/create-root.js b/ui/app/routes/vault/cluster/secrets/backend/create-root.js index 87dd1aaec..18388ee15 100644 --- a/ui/app/routes/vault/cluster/secrets/backend/create-root.js +++ b/ui/app/routes/vault/cluster/secrets/backend/create-root.js @@ -36,11 +36,11 @@ export default EditBase.extend({ return this.store.createRecord(modelType, { keyType: 'ca' }); } if (modelType === 'transform') { - modelType = transformModel(transition.queryParams); + modelType = transformModel(transition.to.queryParams); } if (modelType !== 'secret' && modelType !== 'secret-v2') { - if (this.get('wizard.featureState') === 'details' && this.get('wizard.componentState') === 'transit') { - this.get('wizard').transitionFeatureMachine('details', 'CONTINUE', 'transit'); + if (this.wizard.featureState === 'details' && this.wizard.componentState === 'transit') { + this.wizard.transitionFeatureMachine('details', 'CONTINUE', 'transit'); } return this.store.createRecord(modelType); } diff --git a/ui/app/routes/vault/cluster/secrets/backend/list.js b/ui/app/routes/vault/cluster/secrets/backend/list.js index d8e26359b..7a4bf9ae7 100644 --- a/ui/app/routes/vault/cluster/secrets/backend/list.js +++ b/ui/app/routes/vault/cluster/secrets/backend/list.js @@ -98,7 +98,7 @@ export default Route.extend({ id: secret, backend, responsePath: 'data.keys', - page: params.page, + page: params.page || 1, pageFilter: params.pageFilter, }) .then(model => { @@ -146,7 +146,7 @@ export default Route.extend({ let model = resolvedModel.secrets; let backend = this.enginePathParam(); let backendModel = this.store.peekRecord('secret-engine', backend); - let has404 = this.get('has404'); + let has404 = this.has404; // only clear store cache if this is a new model if (secret !== controller.get('baseKey.id')) { this.store.clearAllDatasets(); diff --git a/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js b/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js index 0849a6545..edf7647ec 100644 --- a/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js +++ b/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js @@ -1,7 +1,7 @@ +import AdapterError from '@ember-data/adapter/error'; import { set } from '@ember/object'; import { resolve } from 'rsvp'; import { inject as service } from '@ember/service'; -import DS from 'ember-data'; import Route from '@ember/routing/route'; import utils from 'vault/lib/key-utils'; import UnloadModelRoute from 'vault/mixins/unload-model-route'; @@ -128,7 +128,7 @@ export default Route.extend(UnloadModelRoute, { // if it didn't fail the server read, and the version is not attached to the metadata, // this should 404 if (!version && secretModel.failedServerRead !== true) { - let error = new DS.AdapterError(); + let error = new AdapterError(); set(error, 'httpStatus', 404); throw error; } diff --git a/ui/app/routes/vault/cluster/settings/auth/configure/section.js b/ui/app/routes/vault/cluster/settings/auth/configure/section.js index c80082884..7574c5202 100644 --- a/ui/app/routes/vault/cluster/settings/auth/configure/section.js +++ b/ui/app/routes/vault/cluster/settings/auth/configure/section.js @@ -1,8 +1,8 @@ +import AdapterError from '@ember-data/adapter/error'; import { inject as service } from '@ember/service'; import { set } from '@ember/object'; import Route from '@ember/routing/route'; import RSVP from 'rsvp'; -import DS from 'ember-data'; import UnloadModelRoute from 'vault/mixins/unload-model-route'; export default Route.extend(UnloadModelRoute, { @@ -49,7 +49,7 @@ export default Route.extend(UnloadModelRoute, { } const modelType = this.modelType(backend.get('type'), section); if (!modelType) { - const error = new DS.AdapterError(); + const error = new AdapterError(); set(error, 'httpStatus', 404); throw error; } diff --git a/ui/app/routes/vault/cluster/settings/configure-secret-backend.js b/ui/app/routes/vault/cluster/settings/configure-secret-backend.js index 71e595ec2..22b85cc2a 100644 --- a/ui/app/routes/vault/cluster/settings/configure-secret-backend.js +++ b/ui/app/routes/vault/cluster/settings/configure-secret-backend.js @@ -1,6 +1,6 @@ +import AdapterError from '@ember-data/adapter/error'; import { set } from '@ember/object'; import Route from '@ember/routing/route'; -import DS from 'ember-data'; const CONFIGURABLE_BACKEND_TYPES = ['aws', 'ssh', 'pki']; @@ -10,7 +10,7 @@ export default Route.extend({ return this.store.query('secret-engine', { path: backend }).then(modelList => { let model = modelList && modelList.get('firstObject'); if (!model || !CONFIGURABLE_BACKEND_TYPES.includes(model.get('type'))) { - const error = new DS.AdapterError(); + const error = new AdapterError(); set(error, 'httpStatus', 404); throw error; } diff --git a/ui/app/routes/vault/cluster/settings/configure-secret-backend/section.js b/ui/app/routes/vault/cluster/settings/configure-secret-backend/section.js index 013724d8f..007cea5f3 100644 --- a/ui/app/routes/vault/cluster/settings/configure-secret-backend/section.js +++ b/ui/app/routes/vault/cluster/settings/configure-secret-backend/section.js @@ -1,6 +1,6 @@ +import AdapterError from '@ember-data/adapter/error'; import { set } from '@ember/object'; import Route from '@ember/routing/route'; -import DS from 'ember-data'; const SECTIONS_FOR_TYPE = { pki: ['cert', 'urls', 'crl', 'tidy'], @@ -28,7 +28,7 @@ export default Route.extend({ const sections = SECTIONS_FOR_TYPE[backendModel.get('type')]; const hasSection = sections.includes(sectionName); if (!backendModel || !hasSection) { - const error = new DS.AdapterError(); + const error = new AdapterError(); set(error, 'httpStatus', 404); throw error; } diff --git a/ui/app/routes/vault/cluster/tools/index.js b/ui/app/routes/vault/cluster/tools/index.js index 07740abfe..6256b28ee 100644 --- a/ui/app/routes/vault/cluster/tools/index.js +++ b/ui/app/routes/vault/cluster/tools/index.js @@ -5,7 +5,7 @@ import { toolsActions } from 'vault/helpers/tools-actions'; export default Route.extend({ currentCluster: service(), beforeModel(transition) { - const currentCluster = this.get('currentCluster.cluster.name'); + const currentCluster = this.currentCluster.cluster.name; const supportedActions = toolsActions(); if (transition.targetName === this.routeName) { transition.abort(); diff --git a/ui/app/routes/vault/cluster/unseal.js b/ui/app/routes/vault/cluster/unseal.js index ed061a8d3..917588e09 100644 --- a/ui/app/routes/vault/cluster/unseal.js +++ b/ui/app/routes/vault/cluster/unseal.js @@ -5,7 +5,7 @@ export default ClusterRoute.extend({ wizard: service(), activate() { - this.get('wizard').set('initEvent', 'UNSEAL'); - this.get('wizard').transitionTutorialMachine(this.get('wizard.currentState'), 'TOUNSEAL'); + this.wizard.set('initEvent', 'UNSEAL'); + this.wizard.transitionTutorialMachine(this.wizard.currentState, 'TOUNSEAL'); }, }); diff --git a/ui/app/serializers/application.js b/ui/app/serializers/application.js index 517bb3774..96f0bc2de 100644 --- a/ui/app/serializers/application.js +++ b/ui/app/serializers/application.js @@ -1,9 +1,9 @@ +import JSONSerializer from '@ember-data/serializer/json'; import { isNone, isBlank } from '@ember/utils'; import { assign } from '@ember/polyfills'; import { decamelize } from '@ember/string'; -import DS from 'ember-data'; -export default DS.JSONSerializer.extend({ +export default JSONSerializer.extend({ keyForAttribute: function(attr) { return decamelize(attr); }, @@ -14,7 +14,7 @@ export default DS.JSONSerializer.extend({ if (typeof key !== 'string') { return key; } - let pk = this.get('primaryKey') || 'id'; + let pk = this.primaryKey || 'id'; let model = { [pk]: key }; // if we've added _requestQuery in the adapter, we want // attach it to the individual models diff --git a/ui/app/serializers/cluster.js b/ui/app/serializers/cluster.js index 8f1d3bfea..83d5a3553 100644 --- a/ui/app/serializers/cluster.js +++ b/ui/app/serializers/cluster.js @@ -1,8 +1,8 @@ +import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest'; import { assign } from '@ember/polyfills'; import { decamelize } from '@ember/string'; -import DS from 'ember-data'; -export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, { +export default RESTSerializer.extend(EmbeddedRecordsMixin, { keyForAttribute: function(attr) { return decamelize(attr); }, diff --git a/ui/app/serializers/config.js b/ui/app/serializers/config.js index 7c005a360..e2fb2cc85 100644 --- a/ui/app/serializers/config.js +++ b/ui/app/serializers/config.js @@ -1,8 +1,8 @@ +import RESTSerializer from '@ember-data/serializer/rest'; import { assign } from '@ember/polyfills'; import { decamelize } from '@ember/string'; -import DS from 'ember-data'; -export default DS.RESTSerializer.extend({ +export default RESTSerializer.extend({ keyForAttribute: function(attr) { return decamelize(attr); }, diff --git a/ui/app/serializers/control-group.js b/ui/app/serializers/control-group.js index 4046c365b..7caeab2c4 100644 --- a/ui/app/serializers/control-group.js +++ b/ui/app/serializers/control-group.js @@ -1,8 +1,8 @@ +import { EmbeddedRecordsMixin } from '@ember-data/serializer/rest'; import { get } from '@ember/object'; -import DS from 'ember-data'; import ApplicationSerializer from './application'; -export default ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, { +export default ApplicationSerializer.extend(EmbeddedRecordsMixin, { attrs: { requestEntity: { embedded: 'always' }, authorizations: { embedded: 'always' }, diff --git a/ui/app/serializers/identity/entity.js b/ui/app/serializers/identity/entity.js index 6060bb03e..7dcea71ee 100644 --- a/ui/app/serializers/identity/entity.js +++ b/ui/app/serializers/identity/entity.js @@ -1,7 +1,7 @@ -import DS from 'ember-data'; +import { EmbeddedRecordsMixin } from '@ember-data/serializer/rest'; import IdentitySerializer from './_base'; -export default IdentitySerializer.extend(DS.EmbeddedRecordsMixin, { +export default IdentitySerializer.extend(EmbeddedRecordsMixin, { // we don't need to serialize relationships here serializeHasMany() {}, attrs: { diff --git a/ui/app/serializers/identity/group.js b/ui/app/serializers/identity/group.js index 37cb633f2..9a4b57618 100644 --- a/ui/app/serializers/identity/group.js +++ b/ui/app/serializers/identity/group.js @@ -1,7 +1,7 @@ -import DS from 'ember-data'; +import { EmbeddedRecordsMixin } from '@ember-data/serializer/rest'; import IdentitySerializer from './_base'; -export default IdentitySerializer.extend(DS.EmbeddedRecordsMixin, { +export default IdentitySerializer.extend(EmbeddedRecordsMixin, { attrs: { alias: { embedded: 'always' }, }, diff --git a/ui/app/serializers/lease.js b/ui/app/serializers/lease.js index 2271d2278..c0dc3bef4 100644 --- a/ui/app/serializers/lease.js +++ b/ui/app/serializers/lease.js @@ -1,7 +1,7 @@ +import RESTSerializer from '@ember-data/serializer/rest'; import { decamelize } from '@ember/string'; -import DS from 'ember-data'; -export default DS.RESTSerializer.extend({ +export default RESTSerializer.extend({ keyForAttribute: function(attr) { return decamelize(attr); }, diff --git a/ui/app/serializers/node.js b/ui/app/serializers/node.js index b2ee54b0f..a5d104825 100644 --- a/ui/app/serializers/node.js +++ b/ui/app/serializers/node.js @@ -1,8 +1,8 @@ +import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest'; import { assign } from '@ember/polyfills'; import { decamelize } from '@ember/string'; -import DS from 'ember-data'; -export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, { +export default RESTSerializer.extend(EmbeddedRecordsMixin, { keyForAttribute: function(attr) { return decamelize(attr); }, diff --git a/ui/app/serializers/path-filter-config.js b/ui/app/serializers/path-filter-config.js index d2a9ab9c3..0bd867388 100644 --- a/ui/app/serializers/path-filter-config.js +++ b/ui/app/serializers/path-filter-config.js @@ -1,7 +1,7 @@ +import RESTSerializer from '@ember-data/serializer/rest'; import { decamelize } from '@ember/string'; -import DS from 'ember-data'; -export default DS.RESTSerializer.extend({ +export default RESTSerializer.extend({ keyForAttribute: function(attr) { return decamelize(attr); }, diff --git a/ui/app/serializers/pki-certificate.js b/ui/app/serializers/pki-certificate.js index 6f37c51e2..b14d2a243 100644 --- a/ui/app/serializers/pki-certificate.js +++ b/ui/app/serializers/pki-certificate.js @@ -1,9 +1,9 @@ +import RESTSerializer from '@ember-data/serializer/rest'; import { isNone, isBlank } from '@ember/utils'; import { assign } from '@ember/polyfills'; import { decamelize } from '@ember/string'; -import DS from 'ember-data'; -export default DS.RESTSerializer.extend({ +export default RESTSerializer.extend({ keyForAttribute: function(attr) { return decamelize(attr); }, diff --git a/ui/app/serializers/pki-config.js b/ui/app/serializers/pki-config.js index 7c005a360..e2fb2cc85 100644 --- a/ui/app/serializers/pki-config.js +++ b/ui/app/serializers/pki-config.js @@ -1,8 +1,8 @@ +import RESTSerializer from '@ember-data/serializer/rest'; import { assign } from '@ember/polyfills'; import { decamelize } from '@ember/string'; -import DS from 'ember-data'; -export default DS.RESTSerializer.extend({ +export default RESTSerializer.extend({ keyForAttribute: function(attr) { return decamelize(attr); }, diff --git a/ui/app/serializers/replication-attributes.js b/ui/app/serializers/replication-attributes.js index 7077efd32..511b89289 100644 --- a/ui/app/serializers/replication-attributes.js +++ b/ui/app/serializers/replication-attributes.js @@ -1,7 +1,7 @@ +import RESTSerializer from '@ember-data/serializer/rest'; import { decamelize } from '@ember/string'; -import DS from 'ember-data'; -export default DS.RESTSerializer.extend({ +export default RESTSerializer.extend({ keyForAttribute: function(attr) { return decamelize(attr); }, diff --git a/ui/app/serializers/secret-v2.js b/ui/app/serializers/secret-v2.js index 0be535c77..2639cbeb9 100644 --- a/ui/app/serializers/secret-v2.js +++ b/ui/app/serializers/secret-v2.js @@ -1,7 +1,7 @@ +import { EmbeddedRecordsMixin } from '@ember-data/serializer/rest'; import ApplicationSerializer from './application'; -import DS from 'ember-data'; -export default ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, { +export default ApplicationSerializer.extend(EmbeddedRecordsMixin, { attrs: { versions: { embedded: 'always' }, }, diff --git a/ui/app/serializers/secret.js b/ui/app/serializers/secret.js index b6fe28be5..b352f7aea 100644 --- a/ui/app/serializers/secret.js +++ b/ui/app/serializers/secret.js @@ -27,7 +27,7 @@ export default ApplicationSerializer.extend({ return { id: fullSecretPath, backend: payload.backend }; }); } - let path = this.get('secretDataPath'); + let path = this.secretDataPath; // move response that is the contents of the secret from the dataPath // to `secret_data` so it will be `secretData` in the model payload.secret_data = get(payload, path); diff --git a/ui/app/serializers/ssh.js b/ui/app/serializers/ssh.js index 154fc8ef9..4e7c29209 100644 --- a/ui/app/serializers/ssh.js +++ b/ui/app/serializers/ssh.js @@ -1,9 +1,9 @@ +import RESTSerializer from '@ember-data/serializer/rest'; import { isNone, isBlank } from '@ember/utils'; import { assign } from '@ember/polyfills'; import { decamelize } from '@ember/string'; -import DS from 'ember-data'; -export default DS.RESTSerializer.extend({ +export default RESTSerializer.extend({ keyForAttribute: function(attr) { return decamelize(attr); }, diff --git a/ui/app/serializers/transit-key.js b/ui/app/serializers/transit-key.js index 2ae35aceb..9861a77b8 100644 --- a/ui/app/serializers/transit-key.js +++ b/ui/app/serializers/transit-key.js @@ -1,8 +1,8 @@ +import RESTSerializer from '@ember-data/serializer/rest'; import { assign } from '@ember/polyfills'; import { decamelize } from '@ember/string'; -import DS from 'ember-data'; -export default DS.RESTSerializer.extend({ +export default RESTSerializer.extend({ primaryKey: 'name', keyForAttribute: function(attr) { @@ -26,6 +26,7 @@ export default DS.RESTSerializer.extend({ payload.keys[version] = payload.keys[version] * 1000; } } + payload.id = payload.name; return [payload]; }, @@ -55,7 +56,8 @@ export default DS.RESTSerializer.extend({ deletion_allowed, }; } else { - return this._super(...arguments); + snapshot.id = snapshot.attr('name'); + return this._super(snapshot, requestType); } }, }); diff --git a/ui/app/services/auth.js b/ui/app/services/auth.js index be670c060..7b85c9c58 100644 --- a/ui/app/services/auth.js +++ b/ui/app/services/auth.js @@ -78,12 +78,11 @@ export default Service.extend({ method, dataType: 'json', headers: { - 'X-Vault-Token': this.get('currentToken'), + 'X-Vault-Token': this.currentToken, }, }; - let namespace = - typeof options.namespace === 'undefined' ? this.get('namespaceService.path') : options.namespace; + let namespace = typeof options.namespace === 'undefined' ? this.namespaceService.path : options.namespace; if (namespace) { defaults.headers['X-Vault-Namespace'] = namespace; } @@ -104,13 +103,13 @@ export default Service.extend({ }, renewCurrentToken() { - let namespace = this.get('authData.userRootNamespace'); + let namespace = this.authData.userRootNamespace; const url = '/v1/auth/token/renew-self'; return this.ajax(url, 'POST', { namespace }); }, revokeCurrentToken() { - let namespace = this.get('authData.userRootNamespace'); + let namespace = this.authData.userRootNamespace; const url = '/v1/auth/token/revoke-self'; return this.ajax(url, 'POST', { namespace }); }, @@ -128,8 +127,8 @@ export default Service.extend({ persistAuthData() { let [firstArg, resp] = arguments; - let tokens = this.get('tokens'); - let currentNamespace = this.get('namespaceService.path') || ''; + let tokens = this.tokens; + let currentNamespace = this.namespaceService.path || ''; let tokenName; let options; let backend; @@ -162,7 +161,9 @@ export default Service.extend({ userRootNamespace = ''; } if (typeof userRootNamespace === 'undefined') { - userRootNamespace = this.get('authData.userRootNamespace'); + if (this.authData) { + userRootNamespace = this.authData.userRootNamespace; + } } if (typeof userRootNamespace === 'undefined') { userRootNamespace = currentNamespace; @@ -180,7 +181,7 @@ export default Service.extend({ tokenName = this.generateTokenName( { backend, - clusterId: (options && options.clusterId) || this.get('activeCluster'), + clusterId: (options && options.clusterId) || this.activeCluster, }, resp.policies ); @@ -216,7 +217,7 @@ export default Service.extend({ }, tokenExpirationDate: computed('currentTokenName', 'expirationCalcTS', function() { - const tokenName = this.get('currentTokenName'); + const tokenName = this.currentTokenName; if (!tokenName) { return; } @@ -225,13 +226,13 @@ export default Service.extend({ return tokenExpirationEpoch ? expirationDate.setUTCMilliseconds(tokenExpirationEpoch) : null; }), - tokenExpired: computed(function() { - const expiration = this.get('tokenExpirationDate'); + get tokenExpired() { + const expiration = this.tokenExpirationDate; return expiration ? this.now() >= expiration : null; - }).volatile(), + }, renewAfterEpoch: computed('currentTokenName', 'expirationCalcTS', function() { - const tokenName = this.get('currentTokenName'); + const tokenName = this.currentTokenName; let { expirationCalcTS } = this; const data = this.getTokenData(tokenName); if (!tokenName || !data || !expirationCalcTS) { @@ -243,8 +244,8 @@ export default Service.extend({ }), renew() { - const tokenName = this.get('currentTokenName'); - const currentlyRenewing = this.get('isRenewing'); + const tokenName = this.currentTokenName; + const currentlyRenewing = this.isRenewing; if (currentlyRenewing) { return; } @@ -274,9 +275,9 @@ export default Service.extend({ }).on('init'), shouldRenew() { const now = this.now(); - const lastFetch = this.get('lastFetch'); - const renewTime = this.get('renewAfterEpoch'); - if (!this.currentTokenName || this.get('tokenExpired') || this.get('allowExpiration') || !renewTime) { + const lastFetch = this.lastFetch; + const renewTime = this.renewAfterEpoch; + if (!this.currentTokenName || this.tokenExpired || this.allowExpiration || !renewTime) { return false; } if (lastFetch && now - lastFetch >= this.IDLE_TIMEOUT) { @@ -324,45 +325,43 @@ export default Service.extend({ const adapter = this.clusterAdapter(); let resp = await adapter.authenticate(options); - let authData = await this.persistAuthData( - options, - resp.auth || resp.data, - this.get('namespaceService.path') - ); - await this.get('permissions').getPaths.perform(); + let authData = await this.persistAuthData(options, resp.auth || resp.data, this.namespaceService.path); + await this.permissions.getPaths.perform(); return authData; }, getAuthType() { - return this.get('authData.backend.type'); + if (!this.authData) return; + return this.authData.backend.type; }, deleteCurrentToken() { - const tokenName = this.get('currentTokenName'); + const tokenName = this.currentTokenName; this.deleteToken(tokenName); this.removeTokenData(tokenName); }, deleteToken(tokenName) { - const tokenNames = this.get('tokens').without(tokenName); + const tokenNames = this.tokens.without(tokenName); this.removeTokenData(tokenName); this.set('tokens', tokenNames); }, // returns the key for the token to use currentTokenName: computed('activeCluster', 'tokens', 'tokens.[]', function() { - const regex = new RegExp(this.get('activeCluster')); - return this.get('tokens').find(key => regex.test(key)); + const regex = new RegExp(this.activeCluster); + return this.tokens.find(key => regex.test(key)); }), currentToken: computed('currentTokenName', function() { - const name = this.get('currentTokenName'); + const name = this.currentTokenName; const data = name && this.getTokenData(name); + // data.token is undefined so that's why it returns current token undefined return name && data ? data.token : null; }), authData: computed('currentTokenName', function() { - const token = this.get('currentTokenName'); + const token = this.currentTokenName; if (!token) { return; } diff --git a/ui/app/services/console.js b/ui/app/services/console.js index babac4e7b..c6f237b74 100644 --- a/ui/app/services/console.js +++ b/ui/app/services/console.js @@ -1,5 +1,7 @@ // Low level service that allows users to input paths to make requests to vault // this service provides the UI synecdote to the cli commands read, write, delete, and list +import { filterBy } from '@ember/object/computed'; + import Service from '@ember/service'; import { getOwner } from '@ember/application'; @@ -28,20 +30,14 @@ export default Service.extend({ adapter() { return getOwner(this).lookup('adapter:console'); }, - commandHistory: computed('log.[]', function() { - return this.get('log').filterBy('type', 'command'); - }), + commandHistory: filterBy('log', 'type', 'command'), log: computed(function() { return []; }), commandIndex: null, shiftCommandIndex(keyCode, setCommandFn = () => {}) { - let [newIndex, newCommand] = shiftCommandIndex( - keyCode, - this.get('commandHistory'), - this.get('commandIndex') - ); + let [newIndex, newCommand] = shiftCommandIndex(keyCode, this.commandHistory, this.commandIndex); if (newCommand !== undefined && newIndex !== undefined) { this.set('commandIndex', newIndex); setCommandFn(newCommand); @@ -49,10 +45,10 @@ export default Service.extend({ }, clearLog(clearAll = false) { - let log = this.get('log'); + let log = this.log; let history; if (!clearAll) { - history = this.get('commandHistory').slice(); + history = this.commandHistory.slice(); history.setEach('hidden', true); } log.clear(); @@ -62,7 +58,7 @@ export default Service.extend({ }, logAndOutput(command, logContent) { - let log = this.get('log'); + let log = this.log; if (command) { log.pushObject({ type: 'command', content: command }); this.set('commandIndex', null); diff --git a/ui/app/services/control-group.js b/ui/app/services/control-group.js index 536f1b338..4fccf7558 100644 --- a/ui/app/services/control-group.js +++ b/ui/app/services/control-group.js @@ -69,12 +69,12 @@ export default Service.extend({ }, tokenForUrl(url) { - if (this.get('version.isOSS')) { + if (this.version.isOSS) { return null; } let pathForUrl = parseURL(url).pathname; pathForUrl = pathForUrl.replace('/v1/', ''); - let tokenInfo = this.get('tokenToUnwrap'); + let tokenInfo = this.tokenToUnwrap; if (tokenInfo && tokenInfo.creation_path === pathForUrl) { let { token, accessor, creation_time } = tokenInfo; return { token, accessor, creationTime: creation_time }; @@ -85,7 +85,7 @@ export default Service.extend({ checkForControlGroup(callbackArgs, response, wasWrapTTLRequested) { let creationPath = response && get(response, 'wrap_info.creation_path'); if ( - this.get('version.isOSS') || + this.version.isOSS || wasWrapTTLRequested || !response || (creationPath && WRAPPED_RESPONSE_PATHS.includes(creationPath)) || @@ -118,7 +118,7 @@ export default Service.extend({ urlFromTransition(transitionObj) { let transition = transitionObj.to; let [params, queryParams] = this.paramsFromTransition(transition, [], {}); - let url = this.get('router').urlFor(transition.name, ...params, { + let url = this.router.urlFor(transition.name, ...params, { queryParams, }); return url.replace('/ui', ''); @@ -130,7 +130,7 @@ export default Service.extend({ let data = { accessor, token, creation_path, creation_time, ttl }; data.uiParams = { url }; this.storeControlGroupToken(data); - return this.get('router').transitionTo('vault.cluster.access.control-group-accessor', accessor); + return this.router.transitionTo('vault.cluster.access.control-group-accessor', accessor); }, logFromError(error) { @@ -138,7 +138,7 @@ export default Service.extend({ let data = { accessor, token, creation_path, creation_time, ttl }; this.storeControlGroupToken(data); - let href = this.get('router').urlFor('vault.cluster.access.control-group-accessor', accessor); + let href = this.router.urlFor('vault.cluster.access.control-group-accessor', accessor); let lines = [ `A Control Group was encountered at ${error.creation_path}.`, `The Control Group Token is ${error.token}.`, diff --git a/ui/app/services/csp-event.js b/ui/app/services/csp-event.js index 21a394777..62a0284c3 100644 --- a/ui/app/services/csp-event.js +++ b/ui/app/services/csp-event.js @@ -8,8 +8,8 @@ export default Service.extend({ events: computed(function() { return []; }), - connectionViolations: computed('events.[].violatedDirective', function() { - return this.get('events').filter(e => e.violatedDirective.startsWith('connect-src')); + connectionViolations: computed('events.@each.violatedDirective', function() { + return this.events.filter(e => e.violatedDirective.startsWith('connect-src')); }), attach() { diff --git a/ui/app/services/namespace.js b/ui/app/services/namespace.js index 2f3c6f917..d28386ea4 100644 --- a/ui/app/services/namespace.js +++ b/ui/app/services/namespace.js @@ -23,9 +23,9 @@ export default Service.extend({ // uses the adapter and the raw response here since // models get wiped when switching namespaces and we // want to keep track of these separately - let store = this.get('store'); + let store = this.store; let adapter = store.adapterFor('namespace'); - let userRoot = this.get('auth.authData.userRootNamespace'); + let userRoot = this.auth.authData.userRootNamespace; try { let ns = yield adapter.findAll(store, 'namespace', null, { adapterOptions: { diff --git a/ui/app/services/path-help.js b/ui/app/services/path-help.js index 7beccd481..791b99870 100644 --- a/ui/app/services/path-help.js +++ b/ui/app/services/path-help.js @@ -3,8 +3,8 @@ shape of data at a specific path to hydrate a model with attrs it has less (or no) information about. */ +import Model from '@ember-data/model'; import Service from '@ember/service'; -import DS from 'ember-data'; import { encodePath } from 'vault/utils/path-encoding-helpers'; import { getOwner } from '@ember/application'; import { assign } from '@ember/polyfills'; @@ -50,7 +50,7 @@ export default Service.extend({ return this.registerNewModelWithProps(helpUrl, backend, newModel, modelName); } else { debug(`Creating new Model for ${modelType}`); - newModel = DS.Model.extend({}); + newModel = Model.extend({}); } // we don't have an apiPath for dynamic secrets diff --git a/ui/app/services/permissions.js b/ui/app/services/permissions.js index 8b2399be4..c58bb3f39 100644 --- a/ui/app/services/permissions.js +++ b/ui/app/services/permissions.js @@ -65,9 +65,7 @@ export default Service.extend({ } try { - let resp = yield this.get('store') - .adapterFor('permissions') - .query(); + let resp = yield this.store.adapterFor('permissions').query(); this.setPaths(resp); return; } catch (err) { @@ -108,7 +106,7 @@ export default Service.extend({ }, pathNameWithNamespace(pathName) { - const namespace = this.get('namespace').path; + const namespace = this.namespace.path; if (namespace) { return `${namespace}/${pathName}`; } else { @@ -129,7 +127,7 @@ export default Service.extend({ }, hasMatchingExactPath(pathName, capability) { - const exactPaths = this.get('exactPaths'); + const exactPaths = this.exactPaths; if (exactPaths) { const prefix = Object.keys(exactPaths).find(path => path.startsWith(pathName)); const hasMatchingPath = prefix && !this.isDenied(exactPaths[prefix]); @@ -144,7 +142,7 @@ export default Service.extend({ }, hasMatchingGlobPath(pathName, capability) { - const globPaths = this.get('globPaths'); + const globPaths = this.globPaths; if (globPaths) { const matchingPath = Object.keys(globPaths).find(k => { return pathName.includes(k) || pathName.includes(k.replace(/\/$/, '')); diff --git a/ui/app/services/replication-mode.js b/ui/app/services/replication-mode.js index 58c904620..b9200a0b6 100644 --- a/ui/app/services/replication-mode.js +++ b/ui/app/services/replication-mode.js @@ -4,7 +4,7 @@ export default Service.extend({ mode: null, getMode() { - this.get('mode'); + this.mode; }, setMode(mode) { diff --git a/ui/app/services/router.js b/ui/app/services/router.js deleted file mode 100644 index 63c058d69..000000000 --- a/ui/app/services/router.js +++ /dev/null @@ -1,99 +0,0 @@ -import Evented from '@ember/object/evented'; -import Service from '@ember/service'; - -import { inject as service } from '@ember/service'; -import { alias } from '@ember/object/computed'; - -let hasOwn = (obj, prop) => { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - -export function extractRouteArgs(args) { - args = args.slice(); - let possibleQueryParams = args[args.length - 1]; - - let queryParams; - if (possibleQueryParams && hasOwn(possibleQueryParams, 'queryParams')) { - queryParams = args.pop().queryParams; - } else { - queryParams = {}; - } - - let routeName = args.shift(); - - return { routeName, models: args, queryParams }; -} -//https://github.com/emberjs/ember.js/blob/abf753a3d494830dc9e95b1337b3654b671b11be/packages/ember-routing/lib/utils.js#L210 -export function shallowEqual(a, b) { - let k; - let aCount = 0; - let bCount = 0; - for (k in a) { - if (hasOwn(a, k)) { - if (a[k] !== b[k]) { - return false; - } - aCount++; - } - } - - for (k in b) { - if (hasOwn(b, k)) { - bCount++; - } - } - - return aCount === bCount; -} - -export default Service.extend(Evented, { - init() { - this._super(...arguments); - - this._router.on('routeWillChange', transition => { - this.trigger('routeWillChange', transition); - }); - - this._router.on('routeDidChange', transition => { - this.trigger('routeDidChange', transition); - }); - }, - - routing: service('-routing'), - _router: alias('routing.router'), - transitionTo() { - let r = this._router; - return r.transitionTo.call(r, ...arguments); - }, - replaceWith() { - let r = this._router; - return r.replaceWith.call(r, ...arguments); - }, - urlFor() { - let r = this._router; - return r.generate.call(r, ...arguments); - }, - currentURL: alias('_router.currentURL'), - currentRouteName: alias('_router.currentRouteName'), - rootURL: alias('_router.rootURL'), - location: alias('_router.location'), - - //adapted from: - // https://github.com/emberjs/ember.js/blob/abf753a3d494830dc9e95b1337b3654b671b11be/packages/ember-routing/lib/services/router.js#L220 - isActive(...args) { - let { routeName, models, queryParams } = extractRouteArgs(args); - let routerMicrolib = this._router._routerMicrolib; - - if (!routerMicrolib.isActiveIntent(routeName, models, null)) { - return false; - } - let hasQueryParams = Object.keys(queryParams).length > 0; - - if (hasQueryParams) { - this._router._prepareQueryParams(routeName, models, queryParams, true /* fromRouterService */); - return shallowEqual(queryParams, routerMicrolib.state.queryParams); - } - - return true; - }, -}); diff --git a/ui/app/services/store.js b/ui/app/services/store.js index e9aa21107..99609a0f4 100644 --- a/ui/app/services/store.js +++ b/ui/app/services/store.js @@ -1,10 +1,10 @@ +import Store from '@ember-data/store'; import { schedule } from '@ember/runloop'; import { copy } from 'ember-copy'; import { resolve, Promise } from 'rsvp'; import { dasherize } from '@ember/string'; import { assert } from '@ember/debug'; import { set, get, computed } from '@ember/object'; -import DS from 'ember-data'; import clamp from 'vault/utils/clamp'; import config from 'vault/config/environment'; @@ -27,7 +27,7 @@ export function keyForCache(query) { return JSON.stringify(cacheKeyObject); } -export default DS.Store.extend({ +export default Store.extend({ // this is a map of map that stores the caches lazyCaches: computed(function() { return new Map(); @@ -37,7 +37,7 @@ export default DS.Store.extend({ const cacheKey = keyForCache(key); const cache = this.lazyCacheForModel(modelName) || new Map(); cache.set(cacheKey, value); - const lazyCaches = this.get('lazyCaches'); + const lazyCaches = this.lazyCaches; const modelKey = normalizeModelName(modelName); lazyCaches.set(modelKey, cache); }, @@ -51,7 +51,7 @@ export default DS.Store.extend({ }, lazyCacheForModel(modelName) { - return this.get('lazyCaches').get(normalizeModelName(modelName)); + return this.lazyCaches.get(normalizeModelName(modelName)); }, // This is the public interface for the store extension - to be used just @@ -178,7 +178,7 @@ export default DS.Store.extend({ }, clearDataset(modelName) { - let cacheList = this.get('lazyCaches'); + let cacheList = this.lazyCaches; if (!cacheList.size) return; if (modelName && cacheList.has(modelName)) { cacheList.delete(modelName); diff --git a/ui/app/services/version.js b/ui/app/services/version.js index 8f3301287..01dc5051a 100644 --- a/ui/app/services/version.js +++ b/ui/app/services/version.js @@ -48,24 +48,20 @@ export default Service.extend({ }, getVersion: task(function*() { - if (this.get('version')) { + if (this.version) { return; } - let response = yield this.get('store') - .adapterFor('cluster') - .health(); + let response = yield this.store.adapterFor('cluster').health(); this.setVersion(response); return; }), getFeatures: task(function*() { - if (this.get('features.length') || this.get('isOSS')) { + if (this.features?.length || this.isOSS) { return; } try { - let response = yield this.get('store') - .adapterFor('cluster') - .features(); + let response = yield this.store.adapterFor('cluster').features(); this.setFeatures(response); return; } catch (err) { @@ -74,9 +70,9 @@ export default Service.extend({ }).keepLatest(), fetchVersion: function() { - return this.get('getVersion').perform(); + return this.getVersion.perform(); }, fetchFeatures: function() { - return this.get('getFeatures').perform(); + return this.getFeatures.perform(); }, }); diff --git a/ui/app/services/wizard.js b/ui/app/services/wizard.js index 56e96ceef..6d16a63a6 100644 --- a/ui/app/services/wizard.js +++ b/ui/app/services/wizard.js @@ -144,7 +144,7 @@ export default Service.extend(DEFAULTS, { this.saveExtState(COMPONENT_STATE, extendedState); } - let { actions, value } = FeatureMachine.transition(currentState, event, this.get('componentState')); + let { actions, value } = FeatureMachine.transition(currentState, event, this.componentState); this.saveState('featureState', value); this.saveExtState(FEATURE_STATE, value); this.executeActions(actions, event, 'feature'); @@ -254,7 +254,7 @@ export default Service.extend(DEFAULTS, { if (!resumeURL) { return; } - this.get('router') + this.router .transitionTo(resumeURL) .followRedirects() .then(() => { diff --git a/ui/app/templates/components/.gitkeep b/ui/app/templates/components/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/ui/app/templates/components/alphabet-edit.hbs b/ui/app/templates/components/alphabet-edit.hbs index 9774bbd82..40e7c59af 100644 --- a/ui/app/templates/components/alphabet-edit.hbs +++ b/ui/app/templates/components/alphabet-edit.hbs @@ -26,6 +26,7 @@ {{#if capabilities.canDelete}}
- {{#link-to - "vault.cluster.secrets.backend.list-root" - backendPath - class="button" - data-test-secret-generate-cancel=true - }} + Cancel - {{/link-to}} +
diff --git a/ui/app/templates/components/generated-item.hbs b/ui/app/templates/components/generated-item.hbs index 4a62b75cd..800d1192f 100644 --- a/ui/app/templates/components/generated-item.hbs +++ b/ui/app/templates/components/generated-item.hbs @@ -6,12 +6,9 @@ / - {{#link-to - "vault.cluster.access.method.item.list" - itemType - }} + {{pluralize itemType}} - {{/link-to}} + @@ -64,13 +61,13 @@ Save {{#if (eq mode "create")}} - {{#link-to 'vault.cluster.access.method.item.list' class="button" data-test-cancel-link=true}} + Cancel - {{/link-to}} + {{else}} - {{#link-to 'vault.cluster.access.method.item.show' model.id class="button" data-test-cancel-link=true}} + Cancel - {{/link-to}} + {{/if}} diff --git a/ui/app/templates/components/hover-copy-button.hbs b/ui/app/templates/components/hover-copy-button.hbs index 6899d066c..9e6023ffb 100644 --- a/ui/app/templates/components/hover-copy-button.hbs +++ b/ui/app/templates/components/hover-copy-button.hbs @@ -1,5 +1,5 @@ - +
- {{message-error model=model}} + {{#if (eq mode "merge")}} {{#if (or (eq mode "merge") (eq mode "create" ))}} - {{#link-to cancelLink class="button" data-test-cancel-link=true}} + Cancel - {{/link-to}} + {{else}} - {{#link-to cancelLink model.id "details" class="button" data-test-cancel-link=true}} + Cancel - {{/link-to}} + {{/if}}
diff --git a/ui/app/templates/components/identity/entity-nav.hbs b/ui/app/templates/components/identity/entity-nav.hbs index 786a7759e..221344247 100644 --- a/ui/app/templates/components/identity/entity-nav.hbs +++ b/ui/app/templates/components/identity/entity-nav.hbs @@ -8,23 +8,23 @@
{{#if model.meta.total}} - {{identity/lookup-input type=identityType}} + {{/if}} diff --git a/ui/app/templates/components/identity/item-alias/alias-details.hbs b/ui/app/templates/components/identity/item-alias/alias-details.hbs index 6fc14ba56..225f81d30 100644 --- a/ui/app/templates/components/identity/item-alias/alias-details.hbs +++ b/ui/app/templates/components/identity/item-alias/alias-details.hbs @@ -1,29 +1,27 @@ -{{info-table-row label="Name" value=model.name data-test-alias-name=true}} -{{info-table-row label="ID" value=model.id }} -{{#info-table-row label=(if (eq model.identityType "entity-alias") "Entity ID" "Group ID") value=model.canonicalId}} - {{#link-to "vault.cluster.access.identity.show" (if (eq model.identityType "entity-alias") "entities" "groups") model.canonicalId "details" - class="has-text-black is-font-mono" - }} - {{model.canonicalId}} - {{/link-to}} -{{/info-table-row}} -{{info-table-row label="Merged from Entity ID" value=model.mergedFromCanonicalIds}} -{{#info-table-row label="Mount" value=model.mountAccessor }} + + + + + {{@model.canonicalId}} + + + +
- {{model.mountPath}} + {{@model.mountPath}}
- {{model.mountType}} - {{model.mountAccessor}} + {{@model.mountType}} + {{@model.mountAccessor}}
-{{/info-table-row}} -{{#info-table-row label="Created" value=model.creationTime}} -
+ + -{{/info-table-row}} -{{#info-table-row label="Last Updated" value=model.lastUpdateTime}} - + + -{{/info-table-row}} + diff --git a/ui/app/templates/components/identity/item-alias/alias-metadata.hbs b/ui/app/templates/components/identity/item-alias/alias-metadata.hbs index 758a5c360..d0c0a7f79 100644 --- a/ui/app/templates/components/identity/item-alias/alias-metadata.hbs +++ b/ui/app/templates/components/identity/item-alias/alias-metadata.hbs @@ -1,4 +1,4 @@ -{{#each-in model.metadata as |key value|}} +{{#each-in @model.metadata as |key value|}}
@@ -15,6 +15,6 @@
{{else}} {{/each-in}} diff --git a/ui/app/templates/components/identity/item-aliases.hbs b/ui/app/templates/components/identity/item-aliases.hbs index 74dce5421..30a6f2216 100644 --- a/ui/app/templates/components/identity/item-aliases.hbs +++ b/ui/app/templates/components/identity/item-aliases.hbs @@ -1,4 +1,4 @@ -{{#each (if model.alias.id (array model.alias) model.aliases) as |item|}} +{{#each (if @model.alias.id (array @model.alias) @model.aliases) as |item|}} {{#linked-block "vault.cluster.access.identity.aliases.show" item.id @@ -7,12 +7,10 @@ }}
- {{#link-to "vault.cluster.access.identity.aliases.show" item.id "details" - class="has-text-black has-text-weight-semibold" - }}{{item.name}}{{/link-to}} + />{{item.name}}
{{item.id}}
@@ -22,12 +20,12 @@
- {{identity/popup-alias params=(array item)}} +
{{/linked-block}} {{else}} {{/each}} diff --git a/ui/app/templates/components/identity/item-details.hbs b/ui/app/templates/components/identity/item-details.hbs index 2d0ef95e8..e82976a22 100644 --- a/ui/app/templates/components/identity/item-details.hbs +++ b/ui/app/templates/components/identity/item-details.hbs @@ -12,10 +12,10 @@ {{/if}} {{/if}} - {{info-table-row label="Name" value=model.name data-test-identity-item-name=true}} - {{info-table-row label="Type" value=model.type }} - {{info-table-row label="ID" value=model.id }} - {{#info-table-row label="Merged Ids" value=model.mergedEntityIds }} + + + +
{{#each model.mergedEntityIds as |id|}}
@@ -23,15 +23,15 @@
{{/each}}
- {{/info-table-row}} - {{#info-table-row label="Created" value=model.creationTime}} +
+ - {{/info-table-row}} - {{#info-table-row label="Last Updated" value=model.lastUpdateTime}} + + - {{/info-table-row}} +
\ No newline at end of file diff --git a/ui/app/templates/components/identity/item-groups.hbs b/ui/app/templates/components/identity/item-groups.hbs index dfc32018b..045424a52 100644 --- a/ui/app/templates/components/identity/item-groups.hbs +++ b/ui/app/templates/components/identity/item-groups.hbs @@ -1,25 +1,21 @@ {{#if model.groupIds}} {{#each model.directGroupIds as |gid|}} - {{#link-to "vault.cluster.access.identity.show" "groups" gid "details" - class="list-item-row" - }}{{gid}} - {{/link-to}} + {{/each}} {{#each model.inheritedGroupIds as |gid|}} {{#linked-block "vault.cluster.access.identity.show" "groups" gid "details" class="list-item-row" }} - {{#link-to "vault.cluster.access.identity.show" "groups" gid "details" - class="has-text-black" - }}{{gid}} - {{/link-to}} + inherited {{/linked-block}} {{/each}} diff --git a/ui/app/templates/components/identity/item-members.hbs b/ui/app/templates/components/identity/item-members.hbs index 0b5e44e1f..c45e66f01 100644 --- a/ui/app/templates/components/identity/item-members.hbs +++ b/ui/app/templates/components/identity/item-members.hbs @@ -9,16 +9,14 @@ }}
- {{#link-to "vault.cluster.access.identity.show" "groups" gid "details" - class="is-block has-text-black has-text-weight-semibold" - }}{{gid}}{{/link-to}} + />{{gid}}
{{#if model.canEdit}} - {{identity/popup-members params=(array model "memberGroupIds" gid)}} + {{/if}}
@@ -34,16 +32,14 @@ }}
- {{#link-to "vault.cluster.access.identity.show" "entities" gid "details" - class="is-block has-text-black has-text-weight-semibold" - }}{{gid}}{{/link-to}} + />{{gid}}
{{#if model.canEdit}} - {{identity/popup-members params=(array model "memberEntityIds" gid)}} + {{/if}}
diff --git a/ui/app/templates/components/identity/item-metadata.hbs b/ui/app/templates/components/identity/item-metadata.hbs index 4041debf3..91873d83d 100644 --- a/ui/app/templates/components/identity/item-metadata.hbs +++ b/ui/app/templates/components/identity/item-metadata.hbs @@ -11,7 +11,7 @@
{{#if model.canEdit}} - {{identity/popup-metadata params=(array model key)}} + {{/if}}
@@ -21,9 +21,9 @@ @title="No metadata for {{model.name}}" @message="You can store custom data that you want to associate with a {{lowercase (humanize model.identityType)}}. Edit this {{lowercase (humanize model.identityType)}} to get started." > - {{#link-to "vault.cluster.access.identity.edit" model.id tagName="button" class="link"}} + Edit {{lowercase (humanize model.identityType)}} - {{/link-to}} + Learn more diff --git a/ui/app/templates/components/identity/item-parent-groups.hbs b/ui/app/templates/components/identity/item-parent-groups.hbs index 56f10b6c2..c0031c7c4 100644 --- a/ui/app/templates/components/identity/item-parent-groups.hbs +++ b/ui/app/templates/components/identity/item-parent-groups.hbs @@ -9,13 +9,11 @@ }}
- {{#link-to "vault.cluster.access.identity.show" "groups" gid "details" - class="is-block has-text-black has-text-weight-semibold" - }}{{gid}} - {{/link-to}} +
diff --git a/ui/app/templates/components/identity/item-policies.hbs b/ui/app/templates/components/identity/item-policies.hbs index 0896f0e86..5d675588e 100644 --- a/ui/app/templates/components/identity/item-policies.hbs +++ b/ui/app/templates/components/identity/item-policies.hbs @@ -1,4 +1,4 @@ -{{#each model.policies as |policyName|}} +{{#each @model.policies as |policyName|}} {{#linked-block "vault.cluster.policy.show" "acl" @@ -7,20 +7,18 @@ }}
- {{#link-to "vault.cluster.policy.show" "acl" policyName - class="is-block has-text-black has-text-weight-semibold" - }}{{policyName}} - {{/link-to}} + {{policyName}} +
{{#if model.canEdit}} - {{identity/popup-policy params=(array model policyName)}} + {{/if}}
{{/linked-block}} {{else}} {{/each}} diff --git a/ui/app/templates/components/identity/lookup-input.hbs b/ui/app/templates/components/identity/lookup-input.hbs index 92eb9d1d3..869bc8edc 100644 --- a/ui/app/templates/components/identity/lookup-input.hbs +++ b/ui/app/templates/components/identity/lookup-input.hbs @@ -17,18 +17,11 @@
{{#if (eq param "alias name")}} - {{mount-accessor-select - value=aliasMountAccessor - onChange=(action (mut aliasMountAccessor)) - }} + {{/if}}
- {{input - class="input" - value=paramValue - placeholder=(capitalize param) - }} +
diff --git a/ui/app/templates/components/identity/popup-alias.hbs b/ui/app/templates/components/identity/popup-alias.hbs index 9538265e1..2486db275 100644 --- a/ui/app/templates/components/identity/popup-alias.hbs +++ b/ui/app/templates/components/identity/popup-alias.hbs @@ -1,12 +1,12 @@ -{{#popup-menu name="alias-menu"}} + {{#with params.firstObject as |item|}} {{/with}} -{{/popup-menu}} + diff --git a/ui/app/templates/components/identity/popup-members.hbs b/ui/app/templates/components/identity/popup-members.hbs index c14a6197e..596e3e182 100644 --- a/ui/app/templates/components/identity/popup-members.hbs +++ b/ui/app/templates/components/identity/popup-members.hbs @@ -1,4 +1,4 @@ -{{#popup-menu name="member-edit-menu"}} + -{{/popup-menu}} + diff --git a/ui/app/templates/components/identity/popup-policy.hbs b/ui/app/templates/components/identity/popup-policy.hbs index a977c4a33..fa76378a9 100644 --- a/ui/app/templates/components/identity/popup-policy.hbs +++ b/ui/app/templates/components/identity/popup-policy.hbs @@ -1,15 +1,15 @@ -{{#popup-menu name="policy-menu"}} + -{{/popup-menu}} + diff --git a/ui/app/templates/components/kv-object-editor.hbs b/ui/app/templates/components/kv-object-editor.hbs index eb418a88a..3d1bb75bc 100644 --- a/ui/app/templates/components/kv-object-editor.hbs +++ b/ui/app/templates/components/kv-object-editor.hbs @@ -2,34 +2,19 @@ {{/if}} {{#each kvData as |row index|}}
- {{input - data-test-kv-key=true - value=row.name - placeholder="key" - change=(action "updateRow" row index) - class="input" - }} +
- {{textarea - data-test-kv-value=true - name=row.name - change=(action "updateRow" row index) - value=row.value - wrap="off" - class="input" - placeholder="value" - rows=1 - }} +