Skip to content

Commit

Permalink
fix: standardize notification format
Browse files Browse the repository at this point in the history
The standardized notifiaction format:

_Entitytype_ "_entityname_" successfully _action_!

adopted from Kong/kong-admin#2963, Kong/kong-admin#3009
  • Loading branch information
nekolab committed Nov 29, 2023
1 parent 9b668f5 commit 2782515
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 55 deletions.
5 changes: 2 additions & 3 deletions src/components/EntityForm/EntityForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ export default {
},
submit () {
const entityDisplay = this.entityName.toLowerCase()
const action = this.isEditing ? 'updated' : 'created'
this.pending = true
Expand All @@ -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)
},
Expand Down Expand Up @@ -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',
})
},
Expand Down
16 changes: 6 additions & 10 deletions src/components/EntityForm/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,30 @@ 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
case 'certificates':
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
}
Expand Down
82 changes: 41 additions & 41 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,38 +74,38 @@
"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",
"edit.form.title": "Edit Gateway Service"
},
"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",
"edit.form.title": "Edit Route"
},
"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}",
Expand All @@ -116,59 +116,59 @@
},
"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",
"edit.form.title": "Edit Upstream"
},
"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",
"edit.form.title": "Edit Certificate"
},
"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",
"edit.form.title": "Edit CA Certificate"
},
"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",
Expand All @@ -178,29 +178,29 @@
},
"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",
"edit.form.title": "Edit Vault"
},
"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",
"edit.form.title": "Edit Key"
},
"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",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/vaults/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
),
})
}
Expand Down

0 comments on commit 2782515

Please sign in to comment.