mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-17 12:07:02 +02:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
77 lines
2.2 KiB
JavaScript
77 lines
2.2 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { action } from '@ember/object';
|
|
import { inject as service } from '@ember/service';
|
|
import { task } from 'ember-concurrency';
|
|
import { tracked } from '@glimmer/tracking';
|
|
|
|
/**
|
|
* @module Oidc::AssignmentForm
|
|
* Oidc::AssignmentForm components are used to display the create view for OIDC providers assignments.
|
|
*
|
|
* @example
|
|
* ```js
|
|
* <Oidc::AssignmentForm @model={this.model}
|
|
* @onCancel={transition-to "vault.cluster.access.oidc.assignment"} @param1={{param1}}
|
|
* @onSave={transition-to "vault.cluster.access.oidc.assignments.assignment.details" this.model.name}
|
|
* />
|
|
* ```
|
|
|
|
* @param {object} model - The parent's model
|
|
* @callback onCancel - callback triggered when cancel button is clicked
|
|
* @callback onSave - callback triggered when save button is clicked*
|
|
*/
|
|
|
|
export default class OidcAssignmentFormComponent extends Component {
|
|
@service store;
|
|
@service flashMessages;
|
|
@tracked modelValidations;
|
|
@tracked errorBanner;
|
|
|
|
@task
|
|
*save(event) {
|
|
event.preventDefault();
|
|
try {
|
|
const { isValid, state } = this.args.model.validate();
|
|
this.modelValidations = isValid ? null : state;
|
|
if (isValid) {
|
|
const { isNew, name } = this.args.model;
|
|
yield this.args.model.save();
|
|
this.flashMessages.success(`Successfully ${isNew ? 'created' : 'updated'} the assignment ${name}.`);
|
|
// this form is sometimes used in modal, passing the model notifies
|
|
// the parent if the save was successful
|
|
this.args.onSave(this.args.model);
|
|
}
|
|
} catch (error) {
|
|
const message = error.errors ? error.errors.join('. ') : error.message;
|
|
this.errorBanner = message;
|
|
}
|
|
}
|
|
|
|
@action
|
|
cancel() {
|
|
const method = this.args.model.isNew ? 'unloadRecord' : 'rollbackAttributes';
|
|
this.args.model[method]();
|
|
this.args.onCancel();
|
|
}
|
|
|
|
@action
|
|
handleOperation({ target }) {
|
|
this.args.model.name = target.value;
|
|
}
|
|
|
|
@action
|
|
onEntitiesSelect(selectedIds) {
|
|
this.args.model.entityIds = selectedIds;
|
|
}
|
|
|
|
@action
|
|
onGroupsSelect(selectedIds) {
|
|
this.args.model.groupIds = selectedIds;
|
|
}
|
|
}
|