2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-14 13:18:55 +00:00
|
|
|
*/
|
|
|
|
|
2018-10-26 16:36:15 +00:00
|
|
|
import Service, { inject as service } from '@ember/service';
|
|
|
|
import { assert } from '@ember/debug';
|
|
|
|
import { typeOf } from '@ember/utils';
|
2021-02-19 16:42:16 +00:00
|
|
|
import { get, set } from '@ember/object';
|
2020-09-30 11:33:01 +00:00
|
|
|
import { isChangeset } from 'validated-changeset';
|
2021-02-19 16:42:16 +00:00
|
|
|
import HTTPError from 'consul-ui/utils/http/error';
|
|
|
|
import { ACCESS_READ } from 'consul-ui/abilities/base';
|
2020-04-22 16:30:26 +00:00
|
|
|
|
ui: Adds initial CRUD for partitions (#11188)
* Add `is` and `test` helpers in a similar vein to `can`
Adds 2 new helpers in a similar vein to ember-cans can:
- `is` allows you to use vocab/phrases such as (is "something model") which calls isSomething() on the models ability.
- `test` allows you to use vocab/phrases such as (test "is something model") or (test "can something model")which calls isSomething() / canSomething() on the models ability. Mostly using the is helper and the can helper. It's basically the is/can helper combined.
* Adds TextInput component + related modifiers/helpers/machines/services (#11189)
Adds a few new components/modifiers/helpers to aid building forms.
- state-chart helper, used in lieu of a more generic approach for requiring our statecharts.
- A few modifications to our existing disabled modifier.
- A new 'validation' modifier, a super small form validation approach built to make use of state charts (optionally). Eventually we should be able to replace our current validation approach (ember-changeset-validations + extra deps) with this.
- A new TextInput component, which is the first of our new components specifically to make it easy to build forms with validations. This is still a WIP, I left some comments in pointing out where this one would be progressed, but as we don't need the planned functionality yet, I left it where it was. All of this will be fleshed out more at a later date.
Documentation is included for all of ^
* ui: Adds initial CRUD for partitions (#11190)
Adds basic CRUD support for partitions. Engineering-wise probably the biggest takeaway here is that we needed to write very little javascript code to add this entire feature, and the little javascript we did need to write was very straightforwards. Everything is pretty much just HTML. Another note to make is that both ember-changeset and ember-data (model layer things) are now completely abstracted away from the view layer of the application.
New components:
- Consul::Partition::Form
- Consul::Partition::List
- Consul::Partition::Notifications
- Consul::Partition::SearchBar
- Consul::Partition::Selector
See additional documentation here for more details
New Route templates:
- index.hbs partition listing/searching/filtering
- edit.hbs partition editing and creation
Additionally:
There is some additional debug work here for better observability and to prevent any errors regarding our href-to usage when a dc is not available in our documentation site.
Our softDelete functionality has been DRYed out a little to be used across two repos.
isLinkable was removed from our ListCollection component for lists like upstream and service listing, and instead use our new is helper from within the ListCollection, meaning we've added a few more lighterweight templateOnly components.
* ui: Exclude all debug-like files from the build (#11211)
This PR adds **/*-debug.* to our test/prod excluded files (realised I needed to add test-support.js also so added that here as its more or less the same thing). Conditionally juggling ES6 static imports (specifically debug ones) for this was also getting a little hairy, so I moved it all to use the same approach as our conditional routes. All in all it brings the vendor build back down to ~430kb gzipped.
2021-10-08 15:29:30 +00:00
|
|
|
export const softDelete = (repo, item) => {
|
|
|
|
// Some deletes need to be more of a soft delete.
|
|
|
|
// Therefore the partition still exists once we've requested a delete/removal.
|
|
|
|
// This makes 'removing' more of a custom action rather than a standard
|
|
|
|
// ember-data delete.
|
|
|
|
// Here we use the same request for a delete but we bypass ember-data's
|
|
|
|
// destroyRecord/unloadRecord and serialization so we don't get
|
|
|
|
// ember data error messages when the UI tries to update a 'DeletedAt' property
|
|
|
|
// on an object that ember-data is trying to delete
|
|
|
|
const res = repo.store.adapterFor(repo.getModelName()).rpc(
|
|
|
|
(adapter, request, serialized, unserialized) => {
|
|
|
|
return adapter.requestForDeleteRecord(request, serialized, unserialized);
|
|
|
|
},
|
|
|
|
(serializer, respond, serialized, unserialized) => {
|
|
|
|
return item;
|
|
|
|
},
|
|
|
|
item,
|
|
|
|
repo.getModelName()
|
|
|
|
);
|
|
|
|
return res;
|
2022-02-11 13:54:46 +00:00
|
|
|
};
|
2020-11-09 09:25:35 +00:00
|
|
|
export default class RepositoryService extends Service {
|
2021-02-19 16:42:16 +00:00
|
|
|
@service('store') store;
|
2021-10-07 11:38:04 +00:00
|
|
|
@service('env') env;
|
2021-02-19 16:42:16 +00:00
|
|
|
@service('repository/permission') permissions;
|
|
|
|
|
2020-11-09 09:25:35 +00:00
|
|
|
getModelName() {
|
2018-10-26 16:36:15 +00:00
|
|
|
assert('RepositoryService.getModelName should be overridden', false);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getPrimaryKey() {
|
2018-10-26 16:36:15 +00:00
|
|
|
assert('RepositoryService.getPrimaryKey should be overridden', false);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getSlugKey() {
|
2018-10-26 16:36:15 +00:00
|
|
|
assert('RepositoryService.getSlugKey should be overridden', false);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 16:42:16 +00:00
|
|
|
/**
|
2021-02-23 08:56:42 +00:00
|
|
|
* Creates a set of permissions based on an id/slug, loads in the access
|
|
|
|
* permissions for them and checks/validates
|
2021-02-19 16:42:16 +00:00
|
|
|
*/
|
2021-02-23 08:56:42 +00:00
|
|
|
async authorizeBySlug(cb, access, params) {
|
|
|
|
params.resources = await this.permissions.findBySlug(params, this.getModelName());
|
|
|
|
return this.validatePermissions(cb, access, params);
|
2021-02-19 16:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads in the access permissions and checks/validates them for a set of
|
|
|
|
* permissions
|
|
|
|
*/
|
2021-02-23 08:56:42 +00:00
|
|
|
async authorizeByPermissions(cb, access, params) {
|
|
|
|
params.resources = await this.permissions.authorize(params);
|
|
|
|
return this.validatePermissions(cb, access, params);
|
2021-02-19 16:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks already loaded permissions for certain access before calling cb to
|
|
|
|
* return the thing you wanted to check the permissions on
|
|
|
|
*/
|
2021-02-23 08:56:42 +00:00
|
|
|
async validatePermissions(cb, access, params) {
|
2021-02-19 16:42:16 +00:00
|
|
|
// inspect the permissions for this segment/slug remotely, if we have zero
|
|
|
|
// permissions fire a fake 403 so we don't even request the model/resource
|
2021-02-23 08:56:42 +00:00
|
|
|
if (params.resources.length > 0) {
|
2022-09-15 08:43:17 +00:00
|
|
|
const resource = params.resources.find((item) => item.Access === access);
|
2021-02-23 08:56:42 +00:00
|
|
|
if (resource && resource.Allow === false) {
|
2021-02-19 16:42:16 +00:00
|
|
|
// TODO: Here we temporarily make a hybrid HTTPError/ember-data HTTP error
|
|
|
|
// we should eventually use HTTPError's everywhere
|
|
|
|
const e = new HTTPError(403);
|
|
|
|
e.errors = [{ status: '403' }];
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
ui: Ensure we check intention service prefix permissions for per service (#11409)
Port of: Ensure we check intention service prefix permissions for per service (#11270)
Previously, when showing some action buttons for 'per service intentions' we used a global 'can I do something with any intention' permission to decide whether to show a certain button or not. If a user has a token that does not have 'global' intention permissions, but does have intention permissions on one or more specific services (for example via service / service_prefix), this meant that we did not show them certain buttons required to create/edit the intentions for this specific service.
This PR adds that extra permissions check so we now check the intentions permissions per service instead of using the 'global' "can I edit intentions" question/request.
**Notes:**
- If a HTML button is `disabled` this means tippy.js doesn't adopt the
popover properly and subsequently hide it from the user, so aswell as
just disabling the button so you can't active the popover, we also don't
even put the popover on the page
- If `ability.item` or `ability.item.Resources` are empty then assume no access
**We don't try to disable service > right hand side intention actions here**
Whether you can create intentions for a service depends on the
_destination_ of the intention you would like to create. For the
topology view going from the LHS to the center, this is straightforwards
as we only need to know the permissions for the central service, as when
you are going from the LHS to the center, the center is the
_destination_.
When going from the center to the RHS the _destination[s]_ are on the
RHS. This means we need to know the permissions for potentially 1000s of
services all in one go in order to know when to show a button or not.
We can't realistically discover the permissions for service > RHS
services as we'd have either make a HTTP request per right hand service,
or potentially make an incredibly large POST request for all the
potentially 1000s of services on the right hand side (more preferable to
1000s of HTTP requests).
Therefore for the moment at least we keep the old functionality (thin client)
for the middle to RHS here. If you do go to click on the button and you
don't have permissions to update the intention you will still not be
able to update it, only you won't know this until you click the button
(at which point you'll get a UI visible 403 error)
Note: We reversed the conditional here between 1.10 and 1.11
So this make 100% sense that the port is different here to 1.11
2021-11-04 12:10:28 +00:00
|
|
|
const item = await cb(params.resources);
|
2021-02-19 16:42:16 +00:00
|
|
|
// add the `Resource` information to the record/model so we can inspect
|
|
|
|
// them in other places like templates etc
|
ui: Ensure we check intention service prefix permissions for per service (#11409)
Port of: Ensure we check intention service prefix permissions for per service (#11270)
Previously, when showing some action buttons for 'per service intentions' we used a global 'can I do something with any intention' permission to decide whether to show a certain button or not. If a user has a token that does not have 'global' intention permissions, but does have intention permissions on one or more specific services (for example via service / service_prefix), this meant that we did not show them certain buttons required to create/edit the intentions for this specific service.
This PR adds that extra permissions check so we now check the intentions permissions per service instead of using the 'global' "can I edit intentions" question/request.
**Notes:**
- If a HTML button is `disabled` this means tippy.js doesn't adopt the
popover properly and subsequently hide it from the user, so aswell as
just disabling the button so you can't active the popover, we also don't
even put the popover on the page
- If `ability.item` or `ability.item.Resources` are empty then assume no access
**We don't try to disable service > right hand side intention actions here**
Whether you can create intentions for a service depends on the
_destination_ of the intention you would like to create. For the
topology view going from the LHS to the center, this is straightforwards
as we only need to know the permissions for the central service, as when
you are going from the LHS to the center, the center is the
_destination_.
When going from the center to the RHS the _destination[s]_ are on the
RHS. This means we need to know the permissions for potentially 1000s of
services all in one go in order to know when to show a button or not.
We can't realistically discover the permissions for service > RHS
services as we'd have either make a HTTP request per right hand service,
or potentially make an incredibly large POST request for all the
potentially 1000s of services on the right hand side (more preferable to
1000s of HTTP requests).
Therefore for the moment at least we keep the old functionality (thin client)
for the middle to RHS here. If you do go to click on the button and you
don't have permissions to update the intention you will still not be
able to update it, only you won't know this until you click the button
(at which point you'll get a UI visible 403 error)
Note: We reversed the conditional here between 1.10 and 1.11
So this make 100% sense that the port is different here to 1.11
2021-11-04 12:10:28 +00:00
|
|
|
// TODO: We mostly use this to authorize single items but we do
|
|
|
|
// occasionally get an array back here e.g. service-instances, so we
|
|
|
|
// should make this fact more obvious
|
2021-02-19 16:42:16 +00:00
|
|
|
if (get(item, 'Resources')) {
|
2021-02-23 08:56:42 +00:00
|
|
|
set(item, 'Resources', params.resources);
|
2021-02-19 16:42:16 +00:00
|
|
|
}
|
|
|
|
return item;
|
|
|
|
}
|
2020-11-09 09:25:35 +00:00
|
|
|
|
2021-10-07 11:38:04 +00:00
|
|
|
shouldReconcile(item, params) {
|
|
|
|
const dc = get(item, 'Datacenter');
|
|
|
|
if (dc !== params.dc) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (this.env.var('CONSUL_NSPACES_ENABLED')) {
|
|
|
|
const nspace = get(item, 'Namespace');
|
|
|
|
if (typeof nspace !== 'undefined' && nspace !== params.ns) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (this.env.var('CONSUL_PARTITIONS_ENABLED')) {
|
|
|
|
const partition = get(item, 'Partition');
|
2021-11-16 15:33:18 +00:00
|
|
|
if (typeof partition !== 'undefined' && partition !== params.partition) {
|
2021-10-07 11:38:04 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
reconcile(meta = {}, params = {}, configuration = {}) {
|
2020-03-19 10:28:21 +00:00
|
|
|
// unload anything older than our current sync date/time
|
|
|
|
if (typeof meta.date !== 'undefined') {
|
2022-09-15 08:43:17 +00:00
|
|
|
this.store.peekAll(this.getModelName()).forEach((item) => {
|
2021-10-07 11:38:04 +00:00
|
|
|
const date = get(item, 'SyncTime');
|
2022-02-11 13:54:46 +00:00
|
|
|
if (
|
|
|
|
!item.isDeleted &&
|
|
|
|
typeof date !== 'undefined' &&
|
|
|
|
date != meta.date &&
|
|
|
|
this.shouldReconcile(item, params)
|
|
|
|
) {
|
2021-10-07 11:38:04 +00:00
|
|
|
this.store.unloadRecord(item);
|
2020-03-19 10:28:21 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
peekOne(id) {
|
2020-06-10 15:07:06 +00:00
|
|
|
return this.store.peekRecord(this.getModelName(), id);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
2021-10-26 18:26:04 +00:00
|
|
|
peekAll() {
|
|
|
|
return this.store.peekAll(this.getModelName());
|
|
|
|
}
|
|
|
|
|
2021-09-22 17:26:36 +00:00
|
|
|
cached(params) {
|
|
|
|
const entries = Object.entries(params);
|
2022-09-15 08:43:17 +00:00
|
|
|
return this.store.peekAll(this.getModelName()).filter((item) => {
|
2021-09-22 17:26:36 +00:00
|
|
|
return entries.every(([key, value]) => item[key] === value);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-09-15 18:50:11 +00:00
|
|
|
// @deprecated
|
2021-10-07 11:38:04 +00:00
|
|
|
async findAllByDatacenter(params, configuration = {}) {
|
2021-09-15 18:50:11 +00:00
|
|
|
return this.findAll(...arguments);
|
|
|
|
}
|
|
|
|
|
2021-10-07 11:38:04 +00:00
|
|
|
async findAll(params = {}, configuration = {}) {
|
2018-12-04 17:04:44 +00:00
|
|
|
if (typeof configuration.cursor !== 'undefined') {
|
2021-02-23 08:56:42 +00:00
|
|
|
params.index = configuration.cursor;
|
|
|
|
params.uri = configuration.uri;
|
2018-12-04 17:04:44 +00:00
|
|
|
}
|
2021-10-07 11:38:04 +00:00
|
|
|
return this.query(params);
|
|
|
|
}
|
|
|
|
|
|
|
|
async query(params = {}, configuration = {}) {
|
|
|
|
let error, meta, res;
|
|
|
|
try {
|
|
|
|
res = await this.store.query(this.getModelName(), params);
|
|
|
|
meta = res.meta;
|
2022-02-11 13:54:46 +00:00
|
|
|
} catch (e) {
|
|
|
|
switch (get(e, 'errors.firstObject.status')) {
|
2021-10-07 11:38:04 +00:00
|
|
|
case '404':
|
|
|
|
case '403':
|
|
|
|
meta = {
|
2022-02-11 13:54:46 +00:00
|
|
|
date: Number.POSITIVE_INFINITY,
|
2021-10-07 11:38:04 +00:00
|
|
|
};
|
|
|
|
error = e;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
2022-02-11 13:54:46 +00:00
|
|
|
if (typeof meta !== 'undefined') {
|
2021-10-07 11:38:04 +00:00
|
|
|
this.reconcile(meta, params, configuration);
|
|
|
|
}
|
2022-02-11 13:54:46 +00:00
|
|
|
if (typeof error !== 'undefined') {
|
2021-10-07 11:38:04 +00:00
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
return res;
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-23 08:56:42 +00:00
|
|
|
async findBySlug(params, configuration = {}) {
|
|
|
|
if (params.id === '') {
|
|
|
|
return this.create({
|
|
|
|
Datacenter: params.dc,
|
|
|
|
Namespace: params.ns,
|
2021-09-15 18:50:11 +00:00
|
|
|
Partition: params.partition,
|
2021-02-23 08:56:42 +00:00
|
|
|
});
|
|
|
|
}
|
2018-12-04 17:04:44 +00:00
|
|
|
if (typeof configuration.cursor !== 'undefined') {
|
2021-02-23 08:56:42 +00:00
|
|
|
params.index = configuration.cursor;
|
|
|
|
params.uri = configuration.uri;
|
2018-12-04 17:04:44 +00:00
|
|
|
}
|
2021-02-19 16:42:16 +00:00
|
|
|
return this.authorizeBySlug(
|
2021-02-23 08:56:42 +00:00
|
|
|
() => this.store.queryRecord(this.getModelName(), params),
|
2021-02-19 16:42:16 +00:00
|
|
|
ACCESS_READ,
|
2021-02-23 08:56:42 +00:00
|
|
|
params
|
2021-02-19 16:42:16 +00:00
|
|
|
);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
create(obj) {
|
2018-10-26 16:36:15 +00:00
|
|
|
// TODO: This should probably return a Promise
|
ui: UI Release Merge (ui-staging merge) (#6527)
## HTTPAdapter (#5637)
## Ember upgrade 2.18 > 3.12 (#6448)
### Proxies can no longer get away with not calling _super
This means that we can't use create anymore to define dynamic methods.
Therefore we dynamically make 2 extended Proxies on demand, and then
create from those. Therefore we can call _super in the init method of
the extended Proxies.
### We aren't allowed to reset a service anymore
We never actually need to now anyway, this is a remnant of the refactor
from browser based confirmations. We fix it as simply as possible here
but will revisit and remove the old browser confirm functionality at a
later date
### Revert classes to use ES5 style to workaround babel transp. probs
Using a mixture of ES6 classes (and hence super) and arrow functions
means that when babel transpiles the arrow functions down to ES5, a
reference to this is moved before the call to super, hence causing a js
error.
Furthermore, we the testing environment no longer lets use use
apply/call on the constructor.
These errors only manifests during testing (only in the testing
environment), the application itself runs fine with no problems without
this change.
Using ES5 style class definitions give us freedom to do all of the above
without causing any errors, so we reverted these classes back to ES5
class definitions
### Skip test that seems to have changed due to a change in RSVP timing
This test tests a usecase/area of the API that will probably never ever
be used, it was more testing out the API. We've skipped the test for now
as this doesn't affect the application itself, but left a note to come
back here later to investigate further
### Remove enumerableContentDidChange
Initial testing looks like we don't need to call this function anymore,
the function no longer exists
### Rework Changeset.isSaving to take into account new ember APIs
Setting/hanging a computedProperty of an instantiated object no longer
works. Move to setting it on the prototype/class definition instead
### Change how we detect whether something requires listening
New ember API's have changed how you can detect whether something is a
computedProperty or not. It's not immediately clear if its even possible
now. Therefore we change how we detect whether something should be
listened to or not by just looking for presence of `addEventListener`
### Potentially temporary change of ci test scripts to ensure deps exist
All our tooling scripts run through a Makefile (for people familiar with
only using those), which then call yarn scripts which can be called
independently (for people familar with only using yarn).
The Makefile targets always check to make sure all the dependencies are
installed before running anything that requires them (building, testing
etc).
The CI scripts/targets didn't follow this same route and called the yarn
scripts directly (usually CI builds a cache of the dependencies first).
For some reason this cache isn't doing what it usually does, and it
looks as though, in CI, ember isn't installed.
This commit makes the CI scripts consistently use the same method as all
of the other tooling scripts (Makefile target > Install Deps if
required > call yarn script). This should install the dependencies if
for some reason the CI cache building doesn't complete/isn't successful.
Potentially this commit may be reverted if, the root of the problem is
elsewhere, although consistency is always good, so it might be a good
idea to leave this commit as is even if we need to debug and fix things
elsewhere.
### Make test-parallel consistent with the rest of the tooling scripts
As we are here making changes for CI purposes (making test-ci
consistent), we spotted that test-parallel is also inconsistent and also
the README manual instructions won't work without `ember` installed
globally.
This commit makes everything consistent and changes the manual
instructions to use the local ember instance that gets installed via
yarn
### Re-wrangle catchable to fit with new ember 3.12 APIs
In the upgrade from ember 3.8 > 3.12 the public interfaces for
ComputedProperties have changed slightly. `meta` is no longer a public
property of ComputedProperty but of a ComputedDecoratorImpl mixin
instead.
https://github.com/emberjs/ember.js/blob/7e4ba1096e3c2e3e0dde186d5ca52ff19cb8720a/packages/%40ember/-internals/metal/lib/computed.ts#L725
There seems to be no way, by just using publically available
methods, to replicate this behaviour so that we can create our own
'ComputedProperty` factory via injecting the ComputedProperty class as
we did previously.
https://github.com/hashicorp/consul/blob/3f333bada181aaf6340523ca2268a28d1a7db214/ui-v2/app/utils/computed/factory.js#L1-L18
Instead we dynamically hang our `Catchable` `catch` method off the
instantiated ComputedProperty. In doing it like this `ComputedProperty`
has already has its `meta` method mixed in so we don't have to manually
mix it in ourselves (which doesn't seem possible)
This functionality is only used during our work in trying to ensure
our EventSource/BlockingQuery work was as 'ember-like' as possible (i.e.
using the traditional Route.model hooks and ember-like Controller
properties). Our ongoing/upcoming work on a componentized approach to
data a.k.a `<DataSource />` means we will be able to remove the majority
of the code involved here now that it seems to be under an amount of
flux in ember.
### Build bindata_assetfs.go with new UI changes
2019-09-30 13:47:49 +00:00
|
|
|
return this.store.createRecord(this.getModelName(), obj);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
persist(item) {
|
2020-09-30 11:33:01 +00:00
|
|
|
// workaround for saving changesets that contain fragments
|
|
|
|
// firstly commit the changes down onto the object if
|
|
|
|
// its a changeset, then save as a normal object
|
|
|
|
if (isChangeset(item)) {
|
|
|
|
item.execute();
|
|
|
|
item = item.data;
|
|
|
|
}
|
2022-02-11 13:54:46 +00:00
|
|
|
set(item, 'SyncTime', undefined);
|
2018-10-26 16:36:15 +00:00
|
|
|
return item.save();
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
remove(obj) {
|
2018-10-26 16:36:15 +00:00
|
|
|
let item = obj;
|
|
|
|
if (typeof obj.destroyRecord === 'undefined') {
|
|
|
|
item = obj.get('data');
|
|
|
|
}
|
2019-12-17 18:47:37 +00:00
|
|
|
// TODO: Change this to use vanilla JS
|
|
|
|
// I think this was originally looking for a plain object
|
|
|
|
// as opposed to an ember one
|
2018-10-26 16:36:15 +00:00
|
|
|
if (typeOf(item) === 'object') {
|
ui: UI Release Merge (ui-staging merge) (#6527)
## HTTPAdapter (#5637)
## Ember upgrade 2.18 > 3.12 (#6448)
### Proxies can no longer get away with not calling _super
This means that we can't use create anymore to define dynamic methods.
Therefore we dynamically make 2 extended Proxies on demand, and then
create from those. Therefore we can call _super in the init method of
the extended Proxies.
### We aren't allowed to reset a service anymore
We never actually need to now anyway, this is a remnant of the refactor
from browser based confirmations. We fix it as simply as possible here
but will revisit and remove the old browser confirm functionality at a
later date
### Revert classes to use ES5 style to workaround babel transp. probs
Using a mixture of ES6 classes (and hence super) and arrow functions
means that when babel transpiles the arrow functions down to ES5, a
reference to this is moved before the call to super, hence causing a js
error.
Furthermore, we the testing environment no longer lets use use
apply/call on the constructor.
These errors only manifests during testing (only in the testing
environment), the application itself runs fine with no problems without
this change.
Using ES5 style class definitions give us freedom to do all of the above
without causing any errors, so we reverted these classes back to ES5
class definitions
### Skip test that seems to have changed due to a change in RSVP timing
This test tests a usecase/area of the API that will probably never ever
be used, it was more testing out the API. We've skipped the test for now
as this doesn't affect the application itself, but left a note to come
back here later to investigate further
### Remove enumerableContentDidChange
Initial testing looks like we don't need to call this function anymore,
the function no longer exists
### Rework Changeset.isSaving to take into account new ember APIs
Setting/hanging a computedProperty of an instantiated object no longer
works. Move to setting it on the prototype/class definition instead
### Change how we detect whether something requires listening
New ember API's have changed how you can detect whether something is a
computedProperty or not. It's not immediately clear if its even possible
now. Therefore we change how we detect whether something should be
listened to or not by just looking for presence of `addEventListener`
### Potentially temporary change of ci test scripts to ensure deps exist
All our tooling scripts run through a Makefile (for people familiar with
only using those), which then call yarn scripts which can be called
independently (for people familar with only using yarn).
The Makefile targets always check to make sure all the dependencies are
installed before running anything that requires them (building, testing
etc).
The CI scripts/targets didn't follow this same route and called the yarn
scripts directly (usually CI builds a cache of the dependencies first).
For some reason this cache isn't doing what it usually does, and it
looks as though, in CI, ember isn't installed.
This commit makes the CI scripts consistently use the same method as all
of the other tooling scripts (Makefile target > Install Deps if
required > call yarn script). This should install the dependencies if
for some reason the CI cache building doesn't complete/isn't successful.
Potentially this commit may be reverted if, the root of the problem is
elsewhere, although consistency is always good, so it might be a good
idea to leave this commit as is even if we need to debug and fix things
elsewhere.
### Make test-parallel consistent with the rest of the tooling scripts
As we are here making changes for CI purposes (making test-ci
consistent), we spotted that test-parallel is also inconsistent and also
the README manual instructions won't work without `ember` installed
globally.
This commit makes everything consistent and changes the manual
instructions to use the local ember instance that gets installed via
yarn
### Re-wrangle catchable to fit with new ember 3.12 APIs
In the upgrade from ember 3.8 > 3.12 the public interfaces for
ComputedProperties have changed slightly. `meta` is no longer a public
property of ComputedProperty but of a ComputedDecoratorImpl mixin
instead.
https://github.com/emberjs/ember.js/blob/7e4ba1096e3c2e3e0dde186d5ca52ff19cb8720a/packages/%40ember/-internals/metal/lib/computed.ts#L725
There seems to be no way, by just using publically available
methods, to replicate this behaviour so that we can create our own
'ComputedProperty` factory via injecting the ComputedProperty class as
we did previously.
https://github.com/hashicorp/consul/blob/3f333bada181aaf6340523ca2268a28d1a7db214/ui-v2/app/utils/computed/factory.js#L1-L18
Instead we dynamically hang our `Catchable` `catch` method off the
instantiated ComputedProperty. In doing it like this `ComputedProperty`
has already has its `meta` method mixed in so we don't have to manually
mix it in ourselves (which doesn't seem possible)
This functionality is only used during our work in trying to ensure
our EventSource/BlockingQuery work was as 'ember-like' as possible (i.e.
using the traditional Route.model hooks and ember-like Controller
properties). Our ongoing/upcoming work on a componentized approach to
data a.k.a `<DataSource />` means we will be able to remove the majority
of the code involved here now that it seems to be under an amount of
flux in ember.
### Build bindata_assetfs.go with new UI changes
2019-09-30 13:47:49 +00:00
|
|
|
item = this.store.peekRecord(this.getModelName(), item[this.getPrimaryKey()]);
|
2018-10-26 16:36:15 +00:00
|
|
|
}
|
2022-09-15 08:43:17 +00:00
|
|
|
return item.destroyRecord().then((item) => {
|
ui: UI Release Merge (ui-staging merge) (#6527)
## HTTPAdapter (#5637)
## Ember upgrade 2.18 > 3.12 (#6448)
### Proxies can no longer get away with not calling _super
This means that we can't use create anymore to define dynamic methods.
Therefore we dynamically make 2 extended Proxies on demand, and then
create from those. Therefore we can call _super in the init method of
the extended Proxies.
### We aren't allowed to reset a service anymore
We never actually need to now anyway, this is a remnant of the refactor
from browser based confirmations. We fix it as simply as possible here
but will revisit and remove the old browser confirm functionality at a
later date
### Revert classes to use ES5 style to workaround babel transp. probs
Using a mixture of ES6 classes (and hence super) and arrow functions
means that when babel transpiles the arrow functions down to ES5, a
reference to this is moved before the call to super, hence causing a js
error.
Furthermore, we the testing environment no longer lets use use
apply/call on the constructor.
These errors only manifests during testing (only in the testing
environment), the application itself runs fine with no problems without
this change.
Using ES5 style class definitions give us freedom to do all of the above
without causing any errors, so we reverted these classes back to ES5
class definitions
### Skip test that seems to have changed due to a change in RSVP timing
This test tests a usecase/area of the API that will probably never ever
be used, it was more testing out the API. We've skipped the test for now
as this doesn't affect the application itself, but left a note to come
back here later to investigate further
### Remove enumerableContentDidChange
Initial testing looks like we don't need to call this function anymore,
the function no longer exists
### Rework Changeset.isSaving to take into account new ember APIs
Setting/hanging a computedProperty of an instantiated object no longer
works. Move to setting it on the prototype/class definition instead
### Change how we detect whether something requires listening
New ember API's have changed how you can detect whether something is a
computedProperty or not. It's not immediately clear if its even possible
now. Therefore we change how we detect whether something should be
listened to or not by just looking for presence of `addEventListener`
### Potentially temporary change of ci test scripts to ensure deps exist
All our tooling scripts run through a Makefile (for people familiar with
only using those), which then call yarn scripts which can be called
independently (for people familar with only using yarn).
The Makefile targets always check to make sure all the dependencies are
installed before running anything that requires them (building, testing
etc).
The CI scripts/targets didn't follow this same route and called the yarn
scripts directly (usually CI builds a cache of the dependencies first).
For some reason this cache isn't doing what it usually does, and it
looks as though, in CI, ember isn't installed.
This commit makes the CI scripts consistently use the same method as all
of the other tooling scripts (Makefile target > Install Deps if
required > call yarn script). This should install the dependencies if
for some reason the CI cache building doesn't complete/isn't successful.
Potentially this commit may be reverted if, the root of the problem is
elsewhere, although consistency is always good, so it might be a good
idea to leave this commit as is even if we need to debug and fix things
elsewhere.
### Make test-parallel consistent with the rest of the tooling scripts
As we are here making changes for CI purposes (making test-ci
consistent), we spotted that test-parallel is also inconsistent and also
the README manual instructions won't work without `ember` installed
globally.
This commit makes everything consistent and changes the manual
instructions to use the local ember instance that gets installed via
yarn
### Re-wrangle catchable to fit with new ember 3.12 APIs
In the upgrade from ember 3.8 > 3.12 the public interfaces for
ComputedProperties have changed slightly. `meta` is no longer a public
property of ComputedProperty but of a ComputedDecoratorImpl mixin
instead.
https://github.com/emberjs/ember.js/blob/7e4ba1096e3c2e3e0dde186d5ca52ff19cb8720a/packages/%40ember/-internals/metal/lib/computed.ts#L725
There seems to be no way, by just using publically available
methods, to replicate this behaviour so that we can create our own
'ComputedProperty` factory via injecting the ComputedProperty class as
we did previously.
https://github.com/hashicorp/consul/blob/3f333bada181aaf6340523ca2268a28d1a7db214/ui-v2/app/utils/computed/factory.js#L1-L18
Instead we dynamically hang our `Catchable` `catch` method off the
instantiated ComputedProperty. In doing it like this `ComputedProperty`
has already has its `meta` method mixed in so we don't have to manually
mix it in ourselves (which doesn't seem possible)
This functionality is only used during our work in trying to ensure
our EventSource/BlockingQuery work was as 'ember-like' as possible (i.e.
using the traditional Route.model hooks and ember-like Controller
properties). Our ongoing/upcoming work on a componentized approach to
data a.k.a `<DataSource />` means we will be able to remove the majority
of the code involved here now that it seems to be under an amount of
flux in ember.
### Build bindata_assetfs.go with new UI changes
2019-09-30 13:47:49 +00:00
|
|
|
return this.store.unloadRecord(item);
|
2018-10-26 16:36:15 +00:00
|
|
|
});
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
invalidate() {
|
2019-12-17 18:47:37 +00:00
|
|
|
// TODO: This should probably return a Promise
|
ui: UI Release Merge (ui-staging merge) (#6527)
## HTTPAdapter (#5637)
## Ember upgrade 2.18 > 3.12 (#6448)
### Proxies can no longer get away with not calling _super
This means that we can't use create anymore to define dynamic methods.
Therefore we dynamically make 2 extended Proxies on demand, and then
create from those. Therefore we can call _super in the init method of
the extended Proxies.
### We aren't allowed to reset a service anymore
We never actually need to now anyway, this is a remnant of the refactor
from browser based confirmations. We fix it as simply as possible here
but will revisit and remove the old browser confirm functionality at a
later date
### Revert classes to use ES5 style to workaround babel transp. probs
Using a mixture of ES6 classes (and hence super) and arrow functions
means that when babel transpiles the arrow functions down to ES5, a
reference to this is moved before the call to super, hence causing a js
error.
Furthermore, we the testing environment no longer lets use use
apply/call on the constructor.
These errors only manifests during testing (only in the testing
environment), the application itself runs fine with no problems without
this change.
Using ES5 style class definitions give us freedom to do all of the above
without causing any errors, so we reverted these classes back to ES5
class definitions
### Skip test that seems to have changed due to a change in RSVP timing
This test tests a usecase/area of the API that will probably never ever
be used, it was more testing out the API. We've skipped the test for now
as this doesn't affect the application itself, but left a note to come
back here later to investigate further
### Remove enumerableContentDidChange
Initial testing looks like we don't need to call this function anymore,
the function no longer exists
### Rework Changeset.isSaving to take into account new ember APIs
Setting/hanging a computedProperty of an instantiated object no longer
works. Move to setting it on the prototype/class definition instead
### Change how we detect whether something requires listening
New ember API's have changed how you can detect whether something is a
computedProperty or not. It's not immediately clear if its even possible
now. Therefore we change how we detect whether something should be
listened to or not by just looking for presence of `addEventListener`
### Potentially temporary change of ci test scripts to ensure deps exist
All our tooling scripts run through a Makefile (for people familiar with
only using those), which then call yarn scripts which can be called
independently (for people familar with only using yarn).
The Makefile targets always check to make sure all the dependencies are
installed before running anything that requires them (building, testing
etc).
The CI scripts/targets didn't follow this same route and called the yarn
scripts directly (usually CI builds a cache of the dependencies first).
For some reason this cache isn't doing what it usually does, and it
looks as though, in CI, ember isn't installed.
This commit makes the CI scripts consistently use the same method as all
of the other tooling scripts (Makefile target > Install Deps if
required > call yarn script). This should install the dependencies if
for some reason the CI cache building doesn't complete/isn't successful.
Potentially this commit may be reverted if, the root of the problem is
elsewhere, although consistency is always good, so it might be a good
idea to leave this commit as is even if we need to debug and fix things
elsewhere.
### Make test-parallel consistent with the rest of the tooling scripts
As we are here making changes for CI purposes (making test-ci
consistent), we spotted that test-parallel is also inconsistent and also
the README manual instructions won't work without `ember` installed
globally.
This commit makes everything consistent and changes the manual
instructions to use the local ember instance that gets installed via
yarn
### Re-wrangle catchable to fit with new ember 3.12 APIs
In the upgrade from ember 3.8 > 3.12 the public interfaces for
ComputedProperties have changed slightly. `meta` is no longer a public
property of ComputedProperty but of a ComputedDecoratorImpl mixin
instead.
https://github.com/emberjs/ember.js/blob/7e4ba1096e3c2e3e0dde186d5ca52ff19cb8720a/packages/%40ember/-internals/metal/lib/computed.ts#L725
There seems to be no way, by just using publically available
methods, to replicate this behaviour so that we can create our own
'ComputedProperty` factory via injecting the ComputedProperty class as
we did previously.
https://github.com/hashicorp/consul/blob/3f333bada181aaf6340523ca2268a28d1a7db214/ui-v2/app/utils/computed/factory.js#L1-L18
Instead we dynamically hang our `Catchable` `catch` method off the
instantiated ComputedProperty. In doing it like this `ComputedProperty`
has already has its `meta` method mixed in so we don't have to manually
mix it in ourselves (which doesn't seem possible)
This functionality is only used during our work in trying to ensure
our EventSource/BlockingQuery work was as 'ember-like' as possible (i.e.
using the traditional Route.model hooks and ember-like Controller
properties). Our ongoing/upcoming work on a componentized approach to
data a.k.a `<DataSource />` means we will be able to remove the majority
of the code involved here now that it seems to be under an amount of
flux in ember.
### Build bindata_assetfs.go with new UI changes
2019-09-30 13:47:49 +00:00
|
|
|
this.store.unloadAll(this.getModelName());
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
}
|