mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-19 13:41:10 +02:00
* Address comments * Fix serailizer warning mesage * Reset pageFilter when exiting * Add start and end time validation and fix bugs * Fix failing tests * Add validation tests * Set end time in contorller * Address feedback * Remove new date * Put new Date back
54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { action } from '@ember/object';
|
|
import Component from '@glimmer/component';
|
|
import { tracked } from '@glimmer/tracking';
|
|
import { datetimeLocalStringFormat } from 'core/utils/date-formatters';
|
|
|
|
/**
|
|
* @module Messages::MessageExpirationDateForm
|
|
* Messages::MessageExpirationDateForm components are used to display list of messages.
|
|
* @example
|
|
* ```js
|
|
* <Messages::MessageExpirationDateForm @message={{this.message}} @attr={{attr}} />
|
|
* ```
|
|
* @param {array} messages - array message objects
|
|
*/
|
|
|
|
export default class MessageExpirationDateForm extends Component {
|
|
datetimeLocalStringFormat = datetimeLocalStringFormat;
|
|
@tracked groupValue = 'never';
|
|
@tracked messageEndTime = '';
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
|
|
if (this.args.message.endTime) {
|
|
this.groupValue = 'specificDate';
|
|
this.messageEndTime = this.args.message.endTime;
|
|
}
|
|
}
|
|
|
|
get validationError() {
|
|
const validations = this.args.modelValidations || {};
|
|
const state = validations[this.args.attr.name];
|
|
return state && !state.isValid ? state.errors.join(' ') : null;
|
|
}
|
|
|
|
@action
|
|
specificDateChange() {
|
|
this.groupValue = 'specificDate';
|
|
this.args.message.endTime = this.messageEndTime;
|
|
}
|
|
|
|
@action
|
|
onFocusOut(e) {
|
|
this.messageEndTime = e.target.value;
|
|
this.args.message.endTime = this.messageEndTime;
|
|
this.groupValue = 'specificDate';
|
|
}
|
|
}
|