Files
threshold-ui/ui/desktop/app/controllers/scopes/scope/projects/targets/target.js
T
Cameron Pereraandcameronperera 57e614e8db feat: 🎸 add search capability for host sources (#2861)
* feat: 🎸 add search capability for host sources

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-17094

* refactor: 💡 use Rose::Pagination component

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-17094

* refactor: 💡 move target detail body to index route

to fix whole page reload issue

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-17094

* Add missing copyright headers

* refactor: 💡 PR feedback

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-17094

---------

Co-authored-by: cameronperera <29386339+cameronperera@users.noreply.github.com>
2025-06-06 16:07:48 -05:00

52 lines
1.3 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import Controller, { inject as controller } from '@ember/controller';
import { service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class ScopesScopeProjectsTargetsTargetController extends Controller {
@controller('scopes/scope/projects/targets/index') targets;
// =services
@service store;
@service confirm;
// =attributes
queryParams = [{ isConnecting: { type: 'boolean' } }];
@tracked isConnecting = false;
isConnectionError = false;
// =actions
/**
* Connect method that calls parent connect method and handles
* connection errors unique to this route
* @param {TargetModel} target
* @param {HostModel} host
*/
@action
async connect(target, host) {
try {
await this.targets.connect(target, host);
} catch (error) {
this.isConnectionError = true;
this.confirm
.confirm(error.message, { isConnectError: true })
// Retry
.then(() => this.connect(target, host))
.catch(() => {
// Reset the flag as this was user initiated and we're not
// in a transition
this.isConnectionError = false;
});
}
}
}