From 278251541fa47dd489c6242b59cd1bc1dbc36519 Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Wed, 29 Nov 2023 11:51:13 +0800 Subject: [PATCH] fix: standardize notification format The standardized notifiaction format: _Entitytype_ "_entityname_" successfully _action_! adopted from kong/kong-admin#2963, kong/kong-admin#3009 --- src/components/EntityForm/EntityForm.vue | 5 +- src/components/EntityForm/helpers/index.js | 16 ++--- src/locales/en.json | 82 +++++++++++----------- src/pages/vaults/Form.vue | 2 +- 4 files changed, 50 insertions(+), 55 deletions(-) diff --git a/src/components/EntityForm/EntityForm.vue b/src/components/EntityForm/EntityForm.vue index 44eaa1d..c46cf59 100644 --- a/src/components/EntityForm/EntityForm.vue +++ b/src/components/EntityForm/EntityForm.vue @@ -351,7 +351,6 @@ export default { }, submit () { - const entityDisplay = this.entityName.toLowerCase() const action = this.isEditing ? 'updated' : 'created' this.pending = true @@ -366,7 +365,7 @@ export default { } this.onSubmit(this.getModel()) - .then(data => this.handleSubmit(entityDisplay, action, data)) + .then(data => this.handleSubmit(this.entityName, action, data)) .catch(this.handleError) }, @@ -469,7 +468,7 @@ export default { pickReadableField(this.formModel, this.entity) || 'undefined' !this.preventNotify && this.notify({ - message: `${nameDisplay} ${entity} successfully ${action}!`, + message: `${entity} "${nameDisplay}" successfully ${action}!`, type: 'success', }) }, diff --git a/src/components/EntityForm/helpers/index.js b/src/components/EntityForm/helpers/index.js index e75b396..60f6539 100644 --- a/src/components/EntityForm/helpers/index.js +++ b/src/components/EntityForm/helpers/index.js @@ -55,24 +55,18 @@ export const pickReadableField = (item, typeHint) => { switch (typeHint) { case 'services': case 'routes': - case 'plugins': case 'upstreams': case 'snis': - case 'vaults': case 'keys': case 'key-sets': - case 'applications': preferred = item.name break + case 'plugins': + preferred = item.instance_name || item.name + break case 'targets': preferred = item.target break - case 'developers': - preferred = item.email - break - case 'document_objects': - preferred = item.path - break case 'consumers': preferred = item.username || item.custom_id break @@ -80,9 +74,11 @@ export const pickReadableField = (item, typeHint) => { case 'ca_certificates': preferred = item.id break + case 'vaults': + preferred = item.prefix || item.name + break default: preferred = item.name || item.username || item.email || item.group || item.key || - (item.application && pickReadableField(item.application, 'applications')) || item.path || item.target break } diff --git a/src/locales/en.json b/src/locales/en.json index b2dce35..75cf045 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -74,9 +74,9 @@ "entities": { "service": { "description": "Gateway Service entities are abstractions of each of your own upstream services, e.g., a data transformation microservice, a billing API.", - "created": "Gateway Service {name} is successfully created!", - "updated": "Gateway Service {name} is successfully updated!", - "deleted": "Gateway Service {name} is successfully deleted!", + "created": "Gateway Service \"{name}\" successfully created!", + "updated": "Gateway Service \"{name}\" successfully updated!", + "deleted": "Gateway Service \"{name}\" successfully deleted!", "list.title": "Gateway Services", "detail.title": "Gateway Service: {name}", "create.form.title": "New Gateway Service", @@ -84,9 +84,9 @@ }, "route": { "description": "A Route defines rules to match client requests, and is associated with a Service.", - "created": "Route {name} is successfully created!", - "updated": "Route {name} is successfully updated!", - "deleted": "Route {name} is successfully deleted!", + "created": "Route \"{name}\" successfully created!", + "updated": "Route \"{name}\" successfully updated!", + "deleted": "Route \"{name}\" successfully deleted!", "list.title": "Routes", "detail.title": "Route: {name}", "create.form.title": "New Route", @@ -94,18 +94,18 @@ }, "consumer": { "description": "Consumers are the end users of a service.", - "created": "Consumer {name} is successfully created!", - "updated": "Consumer {name} is successfully updated!", - "deleted": "Consumer {name} is successfully deleted!", + "created": "Consumer \"{name}\" successfully created!", + "updated": "Consumer \"{name}\" successfully updated!", + "deleted": "Consumer \"{name}\" successfully deleted!", "list.title": "Consumers", "detail.title": "Consumer: {name}", "create.form.title": "New Consumer", "edit.form.title": "Edit Consumer" }, "consumer-credential": { - "created": "Credential is successfully created!", - "updated": "Credential is successfully updated!", - "deleted": "Credential is successfully deleted!", + "created": "Credential successfully created!", + "updated": "Credential successfully updated!", + "deleted": "Credential successfully deleted!", "empty": { "title": "No Plugins Enabled", "message": "Add one of the following Plugins for the ability to add credentials to this Consumer: {plugins}", @@ -116,20 +116,20 @@ }, "plugin": { "description": "Plugins allow you to extend Kong's capabilities with features like rate limiting, authentication, and logging.", - "created": "Plugin {name} is successfully created!", - "updated": "Plugin {name} is successfully updated!", - "deleted": "Plugin {name} is successfully deleted!", - "enabled": "Plugin {name} is successfully enabled!", - "disabled": "Plugin {name} is successfully disabled!", + "created": "Plugin \"{name}\" successfully created!", + "updated": "Plugin \"{name}\" successfully updated!", + "deleted": "Plugin \"{name}\" successfully deleted!", + "enabled": "Plugin \"{name}\" successfully enabled!", + "disabled": "Plugin \"{name}\" successfully disabled!", "list.title": "Plugins", "create.form.title": "New Plugin", "edit.form.title": "Edit Plugin" }, "upstream": { "description": "An Upstream represents a virtual hostname and can be used to load balance incoming requests over multiple Services.", - "created": "Upstream {name} is successfully created!", - "updated": "Upstream {name} is successfully updated!", - "deleted": "Upstream {name} is successfully deleted!", + "created": "Upstream \"{name}\" successfully created!", + "updated": "Upstream \"{name}\" successfully updated!", + "deleted": "Upstream \"{name}\" successfully deleted!", "list.title": "Upstreams", "detail.title": "Upstream: {name}", "create.form.title": "New Upstream", @@ -137,9 +137,9 @@ }, "certificate": { "description": "Certificates handle SSL/TLS termination for encrypted requests.", - "created": "Certificate {id} is successfully created!", - "updated": "Certificate {id} is successfully updated!", - "deleted": "Certificate {id} is successfully deleted!", + "created": "Certificate \"{id}\" successfully created!", + "updated": "Certificate \"{id}\" successfully updated!", + "deleted": "Certificate \"{id}\" successfully deleted!", "list.title": "Certificates", "detail.title": "Certificate: {id}", "create.form.title": "New Certificate", @@ -147,9 +147,9 @@ }, "ca-certificate": { "description": "CA certificates validate client or server certificates.", - "created": "CA Certificate {id} is successfully created!", - "updated": "CA Certificate {id} is successfully updated!", - "deleted": "CA Certificate {id} is successfully deleted!", + "created": "CA Certificate \"{id}\" successfully created!", + "updated": "CA Certificate \"{id}\" successfully updated!", + "deleted": "CA Certificate \"{id}\" successfully deleted!", "list.title": "CA Certificates", "detail.title": "CA Certificate: {id}", "create.form.title": "New CA Certificate", @@ -157,18 +157,18 @@ }, "sni": { "description": "An SNI object represents a many-to-one mapping of hostnames to a certificate.", - "created": "SNI {name} is successfully created!", - "updated": "SNI {name} is successfully updated!", - "deleted": "SNI {name} is successfully deleted!", + "created": "SNI \"{name}\" successfully created!", + "updated": "SNI \"{name}\" successfully updated!", + "deleted": "SNI \"{name}\" successfully deleted!", "list.title": "SNIs", "detail.title": "SNI: {name}", "create.form.title": "New SNI", "edit.form.title": "Edit SNI" }, "target": { - "created": "Target {name} is successfully created!", - "updated": "Target {name} is successfully updated!", - "deleted": "Target {name} is successfully deleted!", + "created": "Target \"{name}\" successfully created!", + "updated": "Target \"{name}\" successfully updated!", + "deleted": "Target \"{name}\" successfully deleted!", "marked.as.healthy": "Target successfully marked as healthy!", "marked.as.unhealthy": "Target successfully marked as unhealthy!", "list.title": "Targets", @@ -178,9 +178,9 @@ }, "vault": { "description": "Improve the security of your Kong Gateway deployment with centralized secrets.", - "created": "Vault {name} is successfully created!", - "updated": "Vault {name} is successfully updated!", - "deleted": "Vault {name} is successfully deleted!", + "created": "Vault \"{name}\" successfully created!", + "updated": "Vault \"{name}\" successfully updated!", + "deleted": "Vault \"{name}\" successfully deleted!", "list.title": "Vaults", "detail.title": "Vault: {name}", "create.form.title": "New Vault", @@ -188,9 +188,9 @@ }, "key": { "description": "A Key object holds a representation of asymmetric keys in various formats.", - "created": "Key {name} is successfully created!", - "updated": "Key {name} is successfully updated!", - "deleted": "Key {name} is successfully deleted!", + "created": "Key \"{name}\" successfully created!", + "updated": "Key \"{name}\" successfully updated!", + "deleted": "Key \"{name}\" successfully deleted!", "list.title": "Keys", "detail.title": "Key: {name}", "create.form.title": "New Key", @@ -198,9 +198,9 @@ }, "key-set": { "description": "A Key Set object holds a collection of asymmetric key objects.", - "created": "Key Set {name} is successfully created!", - "updated": "Key Set {name} is successfully updated!", - "deleted": "Key Set {name} is successfully deleted!", + "created": "Key Set \"{name}\" successfully created!", + "updated": "Key Set \"{name}\" successfully updated!", + "deleted": "Key Set \"{name}\" successfully deleted!", "list.title": "Key Sets", "detail.title": "Key Set: {name}", "create.form.title": "New Key Set", diff --git a/src/pages/vaults/Form.vue b/src/pages/vaults/Form.vue index 415de97..84428d3 100644 --- a/src/pages/vaults/Form.vue +++ b/src/pages/vaults/Form.vue @@ -62,7 +62,7 @@ const handleUpdate = (entity) => { appearance: 'success', message: t( isEditing.value ? 'entities.vault.updated' : 'entities.vault.created', - { name: entity.name ?? entity.id }, + { name: entity.prefix ?? entity.name ?? entity.id }, ), }) }