mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-22 23:21:08 +02:00
* updates api client vars to snake_case for custom messages * updates api client vars to snake_case for tools * updates api client vars to snake_case for sync * updates api client vars to snake_case for secrets engine * updates api client vars to snake_case for auth * updates api client vars to snake_case for usage * updates api client dep to point to gh repo * fixes custom-messages service unit tests * fixes configure-ssh test * fixes configure-ssh test...again
59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Route from '@ember/routing/route';
|
|
import { service } from '@ember/service';
|
|
import CustomMessage from 'vault/forms/custom-message';
|
|
import { addDays, startOfDay } from 'date-fns';
|
|
import timestamp from 'core/utils/timestamp';
|
|
|
|
export default class MessagesCreateRoute extends Route {
|
|
@service api;
|
|
|
|
queryParams = {
|
|
authenticated: {
|
|
refreshModel: true,
|
|
},
|
|
};
|
|
|
|
async getMessages(authenticated) {
|
|
try {
|
|
const { key_info } = await this.api.sys.uiConfigListCustomMessages(true, undefined, authenticated);
|
|
return Object.values(key_info);
|
|
} catch {
|
|
return [];
|
|
}
|
|
}
|
|
|
|
async model(params) {
|
|
const { authenticated } = params;
|
|
const message = new CustomMessage(
|
|
{
|
|
authenticated,
|
|
type: 'banner',
|
|
start_time: addDays(startOfDay(timestamp.now()), 1).toISOString(),
|
|
},
|
|
{ isNew: true }
|
|
);
|
|
|
|
const messages = await this.getMessages(authenticated);
|
|
|
|
return {
|
|
message,
|
|
messages,
|
|
authenticated,
|
|
};
|
|
}
|
|
|
|
setupController(controller, resolvedModel) {
|
|
super.setupController(controller, resolvedModel);
|
|
|
|
controller.breadcrumbs = [
|
|
{ label: 'Messages', route: 'messages', query: { authenticated: !!resolvedModel.authenticated } },
|
|
{ label: 'Create Message' },
|
|
];
|
|
}
|
|
}
|