Skip to content

Commit

Permalink
UI: upgrade Ember to 5.4 (#26708)
Browse files Browse the repository at this point in the history
  • Loading branch information
hashishaw authored May 7, 2024
1 parent ec1f261 commit c02787c
Show file tree
Hide file tree
Showing 47 changed files with 1,162 additions and 1,938 deletions.
3 changes: 3 additions & 0 deletions changelog/26708.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:change
ui: Upgrade Ember to version 5.4
```
2 changes: 0 additions & 2 deletions ui/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
Expand All @@ -15,7 +14,6 @@
/coverage/
!.*
.*/
.eslintcache

# ember-try
/.node_modules.ember-try/
Expand Down
3 changes: 3 additions & 0 deletions ui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ module.exports = {
// test files
files: ['tests/**/*-test.{js,ts}'],
extends: ['plugin:qunit/recommended'],
rules: {
'qunit/require-expect': 'off',
},
},
{
files: ['**/*.ts'],
Expand Down
10 changes: 3 additions & 7 deletions ui/.gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist/
/tmp/
/declarations/

# dependencies
/bower_components/
/node_modules/

# misc
/.sass-cache
/.env*
/.pnp*
/.eslintcache
/connect.lock
/coverage/
/libpeerconnection.log
/npm-debug.log*
/testem.log
/yarn-error.log
package-lock.json

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/npm-shrinkwrap.json.ember-try
/package.json.ember-try
/package-lock.json.ember-try
Expand Down
14 changes: 1 addition & 13 deletions ui/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*
.eslintcache
.lint-todo/
.*/

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/npm-shrinkwrap.json.ember-try
/package.json.ember-try
/package-lock.json.ember-try
/yarn.lock.ember-try
2 changes: 1 addition & 1 deletion ui/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"ignore_dirs": ["tmp", "dist"]
"ignore_dirs": ["dist"]
}
1 change: 1 addition & 0 deletions ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This README outlines the details of collaborating on this Ember application.

| Vault Version | Ember Version |
| ------------- | ------------- |
| 1.17.x | 5.4.2 |
| 1.15.x | 4.12.0 |
| 1.14.x | 4.4.0 |
| 1.13.x | 4.4.0 |
Expand Down
10 changes: 0 additions & 10 deletions ui/app/components/basic-dropdown/trigger.js

This file was deleted.

1 change: 1 addition & 0 deletions ui/app/components/dashboard/quick-actions-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

<SearchSelect
class="is-flex-grow-1"
@ariaLabel={{this.searchSelectParams.title}}
@selectLimit="1"
@models={{array this.searchSelectParams.model}}
@placeholder={{this.searchSelectParams.placeholder}}
Expand Down
9 changes: 6 additions & 3 deletions ui/app/helpers/-date-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ export default Helper.extend({
* as the run loop queue is never clear so tests will stay locked waiting
* for queue to clear.
*/
this.intervalTimer = setTimeout(() => {
run(() => this.recompute());
}, parseInt(interval, 10));
this.intervalTimer = setTimeout(
() => {
run(() => this.recompute());
},
parseInt(interval, 10)
);
}
},

Expand Down
2 changes: 1 addition & 1 deletion ui/app/initializers/deprecation-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function initialize() {
registerDeprecationHandler((message, options, next) => {
// filter deprecations that are scheduled to be removed in a specific version
// when upgrading or addressing deprecation warnings be sure to update this or remove if not needed
if (options?.until.includes('5.0')) {
if (options?.until.includes('5.0') && options?.id.startsWith('ember-data')) {
return;
}
next(message, options);
Expand Down
1 change: 1 addition & 0 deletions ui/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<div class="page-container">
{{outlet}}
</div>
<BasicDropdownWormhole />
</Sidebar::Frame>
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
{{! component only computes inputValue on init -- ensure Ember Data hasMany promise has resolved }}
{{#if @model.mfa_methods.isFulfilled}}
<SearchSelect
@id="methods"
@placeholder="Type to search for existing MFA methods"
@inputValue={{map-by "id" @model.mfa_methods}}
@shouldRenderName={{true}}
Expand Down Expand Up @@ -114,6 +115,7 @@
/>
{{else}}
<SearchSelect
@id="existing-targets"
@placeholder="Search for an existing target"
@options={{this.searchSelect.options}}
@parentManageSelected={{this.searchSelect.selected}}
Expand Down
2 changes: 1 addition & 1 deletion ui/config/ember-cli-update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"packages": [
{
"name": "ember-cli",
"version": "4.12.1",
"version": "5.4.2",
"blueprints": [
{
"name": "app",
Expand Down
5 changes: 3 additions & 2 deletions ui/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ const appConfig = {
serviceWorkerScope: config.serviceWorkerScope,
skipWaitingOnMessage: true,
},
babel: {
plugins: [require.resolve('ember-concurrency/async-arrow-task-transform')],
},
svgJar: {
//optimize: false,
//paths: [],
optimizer: {},
sourceDirs: ['public'],
rootURL: '/ui/',
Expand Down
9 changes: 9 additions & 0 deletions ui/lib/core/addon/components/search-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { resolve } from 'rsvp';
import { filterOptions, defaultMatcher } from 'ember-power-select/utils/group-utils';
import { removeFromArray } from 'vault/helpers/remove-from-array';
import { addToArray } from 'vault/helpers/add-to-array';
import { assert } from '@ember/debug';
/**
* @module SearchSelect
* The `SearchSelect` is an implementation of the [ember-power-select](https://github.com/cibernox/ember-power-select) used for form elements where options come dynamically from the API.
Expand Down Expand Up @@ -74,6 +75,14 @@ export default class SearchSelect extends Component {
@tracked dropdownOptions = []; // options that will render in dropdown, updates as selections are added/discarded
@tracked allOptions = []; // both selected and unselected options, used for wildcard filter

constructor() {
super(...arguments);
assert(
'one of @id, @label, or @ariaLabel must be passed to search-select component',
this.args.id || this.args.label || this.args.ariaLabel
);
}

get hidePowerSelect() {
return this.selectedOptions.length >= this.args.selectLimit;
}
Expand Down
40 changes: 23 additions & 17 deletions ui/lib/core/addon/utils/client-count-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,13 @@ export const formatByNamespace = (namespaceArray: NamespaceObject[]) => {
// when querying historical data the response will always contain the latest client type keys because the activity log is
// constructed based on the version of Vault the user is on (key values will be 0)
export const destructureClientCounts = (verboseObject: Counts | ByNamespaceClients) => {
return CLIENT_TYPES.reduce((newObj: Record<ClientTypes, Counts[ClientTypes]>, clientType: ClientTypes) => {
newObj[clientType] = verboseObject[clientType];
return newObj;
}, {} as Record<ClientTypes, Counts[ClientTypes]>);
return CLIENT_TYPES.reduce(
(newObj: Record<ClientTypes, Counts[ClientTypes]>, clientType: ClientTypes) => {
newObj[clientType] = verboseObject[clientType];
return newObj;
},
{} as Record<ClientTypes, Counts[ClientTypes]>
);
};

export const sortMonthsByTimestamp = (monthsArray: ActivityMonthBlock[] | EmptyActivityMonthBlock[]) => {
Expand All @@ -173,19 +176,22 @@ export const namespaceArrayToObject = (
// mounts_by_key is is used to filter further in a namespace and get monthly activity by mount
// it's an object inside the namespace block where the keys are mount paths
// and the values include new and total client counts for that mount in that month
const mounts_by_key = ns.mounts.reduce((mountObj: { [key: string]: MountByKey }, mount) => {
const newMountClients = newNsClients.mounts.find((m) => m.label === mount.label);

if (newMountClients) {
mountObj[mount.label] = {
...mount,
timestamp,
month,
new_clients: { month, timestamp, ...newMountClients },
};
}
return mountObj;
}, {} as { [key: string]: MountByKey });
const mounts_by_key = ns.mounts.reduce(
(mountObj: { [key: string]: MountByKey }, mount) => {
const newMountClients = newNsClients.mounts.find((m) => m.label === mount.label);

if (newMountClients) {
mountObj[mount.label] = {
...mount,
timestamp,
month,
new_clients: { month, timestamp, ...newMountClients },
};
}
return mountObj;
},
{} as { [key: string]: MountByKey }
);

nsObject[ns.label] = {
...destructureClientCounts(ns),
Expand Down
5 changes: 5 additions & 0 deletions ui/lib/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

module.exports = {
name: require('./package').name,

babel: {
plugins: [require.resolve('ember-concurrency/async-arrow-task-transform')],
},

isDevelopingAddon() {
return true;
},
Expand Down
1 change: 1 addition & 0 deletions ui/lib/kubernetes/addon/components/page/overview.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<div class="has-top-margin-m is-flex">
<SearchSelect
class="is-flex-grow-1"
@ariaLabel="Role"
@placeholder="Type to find a role..."
@disallowNewItems={{true}}
@options={{this.roleOptions}}
Expand Down
3 changes: 3 additions & 0 deletions ui/lib/kubernetes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module.exports = buildEngine({
lazyLoading: {
enabled: false,
},
babel: {
plugins: [require.resolve('ember-concurrency/async-arrow-task-transform')],
},
isDevelopingAddon() {
return true;
},
Expand Down
4 changes: 4 additions & 0 deletions ui/lib/kv/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ module.exports = buildEngine({
enabled: false,
},

babel: {
plugins: [require.resolve('ember-concurrency/async-arrow-task-transform')],
},

isDevelopingAddon() {
return true;
},
Expand Down
3 changes: 2 additions & 1 deletion ui/lib/kv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ember-engine"
],
"dependencies": {
"ember-auto-import": "*",
"ember-cli-htmlbars": "*",
"ember-cli-babel": "*",
"ember-concurrency": "*",
Expand All @@ -16,4 +17,4 @@
"../core"
]
}
}
}
1 change: 1 addition & 0 deletions ui/lib/ldap/addon/components/page/overview.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<div class="has-top-margin-m is-flex">
<SearchSelect
class="is-flex-1"
@ariaLabel="Role"
@placeholder="Select a role"
@disallowNewItems={{true}}
@options={{@roles}}
Expand Down
4 changes: 4 additions & 0 deletions ui/lib/ldap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ module.exports = buildEngine({
enabled: false,
}),

babel: {
plugins: [require.resolve('ember-concurrency/async-arrow-task-transform')],
},

isDevelopingAddon() {
return true;
},
Expand Down
16 changes: 8 additions & 8 deletions ui/lib/pki/addon/components/page/pki-issuer-rotate-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ export default class PagePkiIssuerRotateRootComponent extends Component<Args> {
const endpoint = `/v1/${this.secretMountPath.currentPath}/issuer/${this.args.newRootModel.issuerId}/${format}`;
const adapter = this.store.adapterFor('application');
try {
return adapter
.rawRequest(endpoint, 'GET', { unauthenticated: true })
.then(function (response: Response) {
if (format === 'der') {
return response.blob();
}
return response.text();
});
return adapter.rawRequest(endpoint, 'GET', { unauthenticated: true }).then(function (
response: Response
) {
if (format === 'der') {
return response.blob();
}
return response.text();
});
} catch (e) {
return null;
}
Expand Down
3 changes: 3 additions & 0 deletions ui/lib/pki/addon/components/page/pki-overview.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<div class="has-top-margin-m is-flex">
<SearchSelect
class="is-flex-grow-1"
@ariaLabel="Role"
@selectLimit="1"
@models={{array "pki/role"}}
@backend={{@engine.id}}
Expand All @@ -58,6 +59,7 @@
<div class="has-top-margin-m {{unless this.certificateValue 'is-flex'}}">
<SearchSelect
class="is-flex-grow-1"
@ariaLabel="Certificate serial number"
@selectLimit="1"
@models={{array "pki/certificate/base"}}
@backend={{@engine.id}}
Expand All @@ -83,6 +85,7 @@
<div class="has-top-margin-m is-flex">
<SearchSelect
class="is-flex-grow-1"
@ariaLabel="Issuer name or ID"
@selectLimit="1"
@models={{array "pki/issuer"}}
@backend={{@engine.id}}
Expand Down
3 changes: 3 additions & 0 deletions ui/lib/pki/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module.exports = buildEngine({
lazyLoading: {
enabled: false,
},
babel: {
plugins: [require.resolve('ember-concurrency/async-arrow-task-transform')],
},
isDevelopingAddon() {
return true;
},
Expand Down
Loading

0 comments on commit c02787c

Please sign in to comment.