Files
threshold-ui/ui/desktop/app/routes/scopes.js
T

31 lines
933 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
2020-11-09 10:51:11 -05:00
import Route from '@ember/routing/route';
2020-11-09 12:14:54 -05:00
import { A } from '@ember/array';
import { inject as service } from '@ember/service';
2020-11-09 10:51:11 -05:00
export default class ScopesRoute extends Route {
// =services
@service store;
2020-11-09 12:14:54 -05:00
// =methods
2020-11-09 10:51:11 -05:00
2020-11-09 12:14:54 -05:00
/**
* Attempt to load all scopes from the API. This is allowed
* to fail, since in some cases the user may not have permission to read a
* scope directly, but may have permission to read resources under it.
* If scopes fails to load, we still proceed using an empty array.
* @param {object} params
* @param {string} params.scope_id
* @return {Promise{[ScopeModel]}}
*/
2020-11-09 10:51:11 -05:00
model() {
2020-11-09 12:14:54 -05:00
// NOTE: In the absence of a `scope_id` query parameter, this endpoint is
// expected to default to the global scope, thus returning org scopes.
return this.store.findAll('scope').catch(() => A([]));
2020-11-09 10:51:11 -05:00
}
}