Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Monitoring] Capitalize the license type #20683

Merged
merged 5 commits into from
Jul 13, 2018
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion x-pack/plugins/monitoring/public/views/license/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ export class LicenseViewController {
expiryDate = formatDateTimeLocal(license.expiry_date);
}

const capitalizedType = license.type[0].toUpperCase() + license.type.slice(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does fix the issue, but I think that this is the wrong place to fix it. We have two examples of this component being used and it's already been used differently between the two.

Instead of fixing it at the caller level, I think we should just do the case management of the license type inside of the component, which eliminates the need to think about it and simplifies caller code.

If you modify type there to have this behavior (you will also want to explicitly lowercase the type.slice(1) portion for parity; you should probably also use type.substr(1) like the other code), then this code change can go away and the code that you're effectively copying can also be removed:

const typeTitleCase = type.charAt(0).toUpperCase() + type.substr(1).toLowerCase();

You may also be interested in Lodash's startCase function.


// Mount the React component to the template
render(
<License
isPrimaryCluster={isPrimaryCluster}
status={license.status}
type={license.type}
type={capitalizedType}
isExpired={isExpired}
expiryDate={expiryDate}
uploadLicensePath={uploadLicensePath}
Expand Down