Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Add Variable deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
gregone committed Aug 9, 2021
1 parent efa0846 commit 250a7bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ui/app/components/project-config-variables/list-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class ProjectConfigVariablesListItemComponent extends Component<V

@action
async deleteVariable(variable) {
// await this.args.deleteVariable(variable);
await this.args.deleteVariable(variable);
}

@action
Expand Down
13 changes: 12 additions & 1 deletion ui/app/components/project-config-variables/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { ConfigSetRequest, ConfigGetRequest, ConfigVar, Project, Ref } from 'waypoint-pb';
import { Empty } from 'google-protobuf/google/protobuf/empty_pb';
import { inject as service } from '@ember/service';
import ApiService from 'waypoint/services/api';

Expand All @@ -28,6 +29,11 @@ export default class ProjectConfigVariablesListComponent extends Component<Proje
this.isCreating = false;
}

@action
async deleteVariable(variable) {
await this.saveVariableSettings(variable, undefined, true);
}

@action
addVariable() {
this.isCreating = true;
Expand All @@ -40,7 +46,8 @@ export default class ProjectConfigVariablesListComponent extends Component<Proje
@action
async saveVariableSettings(
variable: ConfigVar.AsObject,
initialVariable?: ConfigVar.AsObject
initialVariable?: ConfigVar.AsObject,
deleteVariable?: boolean
): Promise<any | void> {
let req = new ConfigSetRequest();

Expand All @@ -61,6 +68,10 @@ export default class ProjectConfigVariablesListComponent extends Component<Proje
newVar.setInternal(variable.internal);
}

if (deleteVariable) {
newVar.setUnset(new Empty());
}

req.setVariablesList([newVar]);
try {
await this.api.client.setConfig(req, this.api.WithMeta());
Expand Down

0 comments on commit 250a7bb

Please sign in to comment.