Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

[MM-13298] Remove usage of localizeMessage for aria-label and title attributes #2245

Merged
merged 1 commit into from
Jan 15, 2019

Conversation

kosgrz
Copy link
Contributor

@kosgrz kosgrz commented Jan 6, 2019

Summary

Remove usage of localizeMessage for aria-label and title attributes in HTML tags. Remove duplicate tooltip caused by the usage of OverlayTrigger and title attribute.

Ticket Link

Jira ticket | GitHub Issue #9948

Checklist

  • Ran make check-style to check for style errors (required for all pull requests)
  • Ran make test to ensure unit and component tests passed
  • Added or updated unit tests (required for all new features)

@hanzei hanzei added the 2: Dev Review Requires review by a core commiter label Jan 7, 2019
@hanzei hanzei requested review from hmhealey and saturninoabril and removed request for hmhealey January 7, 2019 11:30
Copy link
Member

@saturninoabril saturninoabril left a comment

Choose a reason for hiding this comment

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

Thanks @kosgrz, looks good to me. Just one small comment re: one missed localizeMessage.

Also, looks like we can have a collection of icons, like below to name a few:

  • Success Icon
  • Reload Icon
  • Collapse Icon
  • Loading Icon
  • Warning Icon

That might be good to have here, or a separate PR will do as well.

components/emoji_picker/emoji_picker.jsx Outdated Show resolved Hide resolved
@kosgrz
Copy link
Contributor Author

kosgrz commented Jan 7, 2019

Thanks for the review @saturninoabril.

Also, looks like we can have a collection of icons, like below to name a few:
Success Icon
Reload Icon
Collapse Icon
Loading Icon
Warning Icon

I don't know I understand correctly. Do you mean I should extract these icons to separate components and use them in proper places?

So for example if I have this code fragment in cluster_settings.jsx:

if (this.state.showWarning) {
    warning = (
        <div
            style={style.warning}
            className='alert alert-warning'
        >
            <FormattedMessage
                id='generic_icons.warning'
                defaultMessage='Warning Icon'
            >
                {(title) => (
                    <i
                        className='fa fa-warning'
                        title={title}
                    />
                )}
            </FormattedMessage>
            <FormattedMarkdownMessage
                id='admin.cluster.should_not_change'
                defaultMessage='WARNING: These settings may...'
            />
        </div>
    );
}

I instead should extract FormattedMessage with the i tag to a new React component named WarningIcon with the following content:

export default class WarningIcon extends React.PureComponent {
    render() {
        return (
            <FormattedMessage
                id='generic_icons.warning'
                defaultMessage='Warning Icon'
            >
                {(title) => (
                    <i
                        className='fa fa-warning'
                        title={title}
                    />
                )}
            </FormattedMessage>
        );
    }
}

and use it in cluster_settings.jsx as follows:

if (this.state.showWarning) {
    warning = (
        <div
            style={style.warning}
            className='alert alert-warning'
        >
            <WarningIcon/>
            <FormattedMarkdownMessage
                id='admin.cluster.should_not_change'
                defaultMessage='WARNING: These settings may...'
            />
        </div>
    );
}

Is my understanding correct?

@saturninoabril
Copy link
Member

saturninoabril commented Jan 8, 2019

@kosgrz Yes, that's exactly. Maybe create a folder like /components/icon or rename /components/svg to /components/icon and put all those new components into it.

UPDATE: I'll bring up first the case of moving other components from components/svg to Devs and will deal with it separately in case.

@hmhealey
Copy link
Member

hmhealey commented Jan 9, 2019

I agree that we can move the other icons later. It probably makes sense to consolidate them, but I think it's fine leaving them where they are for now

Copy link
Member

@saturninoabril saturninoabril left a comment

Choose a reason for hiding this comment

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

Thanks @kosgrz, all are good to me except to last comments on function binding and snapshot tests for new icon components.

@@ -45,6 +46,8 @@ export default class AddUsersToTeam extends React.Component {
addError: null,
loadingUsers: true,
};

this.renderOption = this.renderOption.bind(this);
Copy link
Member

Choose a reason for hiding this comment

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

In case this needs to bind, instead of adding above line you may convert the function into arrow function.

renderOption = (option, isSelected, onAdd) => {...}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the notice. I forgot about this benefit of arrow functions when I was writing this code. Nevertheless, this line is now unnecessary since I use just the AddIcon component inside renderOption instead of this.context.intl.formatMessage and I don't need to have access to this. I deleted this line in the last update of this PR.

>
{(title) => (
<span
className='fa fa-angle-down header-dropdown__icon'
Copy link
Member

Choose a reason for hiding this comment

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

No action for now.
In the future, this needs to update once our UI come up with the standard dropdown icon of either fa-chevron-down or fa-angle-down.

Ticket - https://mattermost.atlassian.net/browse/MM-13758

components/icon/add_icon.jsx Show resolved Hide resolved
…ttributes

* Remove usage of localizeMessage for aria-label and title attributes in HTML tags
* Remove duplicate tooltip caused by the usage of OverlayTrigger and title attribute
Copy link
Member

@saturninoabril saturninoabril left a comment

Choose a reason for hiding this comment

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

Thanks @kosgrz for your contribution!

@saturninoabril saturninoabril merged commit 55e0ee3 into mattermost:master Jan 15, 2019
@hanzei hanzei added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter labels Jan 15, 2019
@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Jan 23, 2019
@lindalumitchell lindalumitchell added the Tests/Not Needed Does not require new release tests label Feb 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation Tests/Not Needed Does not require new release tests
Projects
None yet
6 participants