feat: 🎸 Add aliases to list view (#2256)
✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13487
This commit is contained in:
1 parent
f246c24a08
commit
79a932bebb
11 files changed
+162
-89
No files matched your search
@@ -283,8 +283,8 @@ export default class ApplicationAdapter extends RESTAdapter.extend(
|
||||
const baseError = {
|
||||
isInvalid: true,
|
||||
status,
|
||||
code: payload.kind,
|
||||
detail: payload.message,
|
||||
code: payload?.kind,
|
||||
detail: payload?.message,
|
||||
source: { pointer: '/data' },
|
||||
};
|
||||
// Normalize field-specific errors, if any.
|
||||
@@ -319,6 +319,6 @@ export default class ApplicationAdapter extends RESTAdapter.extend(
|
||||
* @return {String} detailed error message
|
||||
*/
|
||||
generatedDetailedMessage(status, headers, payload /*, requestData*/) {
|
||||
return payload.message;
|
||||
return payload?.message;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
import { inject as service } from '@ember/service';
|
||||
import { getOwner, setOwner } from '@ember/application';
|
||||
import { pluralize } from 'ember-inflector';
|
||||
import { generateMQLExpression } from '../utils/mql-query';
|
||||
import { paginateResults } from '../utils/paginate-results';
|
||||
|
||||
@@ -13,11 +12,22 @@ import { paginateResults } from '../utils/paginate-results';
|
||||
* Not all types are yet supported by the client daemon so we'll
|
||||
* just whitelist the ones we need to start with. Keys are the resource
|
||||
* types and the values are the fields that are searchable by the client.
|
||||
* @type {{session: string[], target: string[]}}
|
||||
* @type {{session: string[], alias: string[], target: string[]}}
|
||||
*/
|
||||
const supportedTypes = {
|
||||
target: ['id', 'name', 'description', 'address', 'scope_id'],
|
||||
session: ['id', 'type', 'status', 'endpoint', 'scope_id', 'target_id'],
|
||||
alias: ['id', 'type', 'value', 'destination_id'],
|
||||
};
|
||||
|
||||
/**
|
||||
* Map the model resource name to the client daemon resource name
|
||||
* @type {{session: string, alias: string, target: string}}
|
||||
*/
|
||||
export const resourceNames = {
|
||||
target: 'targets',
|
||||
session: 'sessions',
|
||||
alias: 'resolvable-aliases',
|
||||
};
|
||||
|
||||
const fetchControllerData = async (context, next) => {
|
||||
@@ -88,7 +98,7 @@ export default class ClientDaemonHandler {
|
||||
query: searchQuery,
|
||||
auth_token_id,
|
||||
token,
|
||||
resource: pluralize(type),
|
||||
resource: resourceNames[type],
|
||||
};
|
||||
|
||||
let clientDaemonResults = {};
|
||||
|
||||
@@ -135,6 +135,12 @@ export default class TargetModel extends GeneratedTargetModel {
|
||||
return Boolean(pendingOrActiveSessions.length);
|
||||
}
|
||||
|
||||
get associatedAliases() {
|
||||
return this.store
|
||||
.peekAll('alias')
|
||||
.filter((alias) => alias?.destination_id === this.id);
|
||||
}
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user