-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[tags] Improve handling of values #4589
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| /*eslint react/jsx-key:0*/ | ||
| import React from 'react'; | ||
| import _ from 'underscore'; | ||
|
|
||
|
|
@@ -15,10 +16,18 @@ const UserContextType = React.createClass({ | |
| let children = []; | ||
|
|
||
| // Handle our native attributes special | ||
| user.id && builtins.push(['ID', user.id]); | ||
| user.email && builtins.push(['Email', user.email]); | ||
| user.username && builtins.push(['Username', user.username]); | ||
| user.ip_address && builtins.push(['IP Address', user.ip_address]); | ||
| user.id && builtins.push(['ID', <pre>{user.id}</pre>]); | ||
| user.email && builtins.push([ | ||
| 'Email', | ||
| <pre> | ||
| {user.email} | ||
| <a href={`mailto:${user.email}`} className="external-icon"> | ||
| <em className="icon-envelope" /> | ||
| </a> | ||
| </pre> | ||
| ]); | ||
| user.username && builtins.push(['Username', <pre>{user.username}</pre>]); | ||
| user.ip_address && builtins.push(['IP Address', <pre>{user.ip_address}</pre>]); | ||
|
|
||
| // We also attach user supplied data as 'user.data' | ||
| _.each(user.data, function(value, key) { | ||
|
|
@@ -30,7 +39,16 @@ const UserContextType = React.createClass({ | |
| <div className="pull-left"> | ||
| <Avatar user={user} size={96} gravatar={false} /> | ||
| </div> | ||
| <KeyValueList data={builtins} isContextData={false} /> | ||
| <table className="key-value table"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, I see why you removed I feel a better solution is to modify
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that sounds like a lot of work
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can do it in a follow-up. |
||
| {builtins.map(([key, value]) => { | ||
| return ( | ||
| <tr key={key}> | ||
| <td className="key" key="0">{key}</td> | ||
| <td className="value" key="1">{value}</td> | ||
| </tr> | ||
| ); | ||
| })} | ||
| </table> | ||
| {children && | ||
| <KeyValueList data={children} isContextData={true} /> | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,19 @@ | ||
| /*eslint react/jsx-key:0*/ | ||
| import React from 'react'; | ||
| import {Link} from 'react-router'; | ||
| import jQuery from 'jquery'; | ||
| import ApiMixin from '../mixins/apiMixin'; | ||
| import Count from '../components/count'; | ||
| import GroupState from '../mixins/groupState'; | ||
| import Avatar from '../components/avatar'; | ||
| import LoadingError from '../components/loadingError'; | ||
| import LoadingIndicator from '../components/loadingIndicator'; | ||
| import Pagination from '../components/pagination'; | ||
| import TimeSince from '../components/timeSince'; | ||
| import {isUrl, percent, deviceNameMapper} from '../utils'; | ||
| import {t, tn} from '../locale'; | ||
| import {t} from '../locale'; | ||
|
|
||
| const GroupTagValues = React.createClass({ | ||
| mixins: [ | ||
| ApiMixin, | ||
| GroupState | ||
| ApiMixin | ||
| ], | ||
|
|
||
| getInitialState() { | ||
|
|
@@ -47,7 +46,7 @@ const GroupTagValues = React.createClass({ | |
| error: false | ||
| }); | ||
|
|
||
| this.api.request('/issues/' + this.getGroup().id + '/tags/' + params.tagKey + '/', { | ||
| this.api.request(`/issues/${params.groupId}/tags/${params.tagKey}/`, { | ||
| success: (data) => { | ||
| this.setState({ | ||
| tagKey: data, | ||
|
|
@@ -62,7 +61,7 @@ const GroupTagValues = React.createClass({ | |
| } | ||
| }); | ||
|
|
||
| this.api.request('/issues/' + this.getGroup().id + '/tags/' + params.tagKey + '/values/?' + querystring, { | ||
| this.api.request(`/issues/${params.groupId}/tags/${params.tagKey}/values/?${querystring}`, { | ||
| success: (data, _, jqXHR) => { | ||
| this.setState({ | ||
| tagValueList: data, | ||
|
|
@@ -79,18 +78,21 @@ const GroupTagValues = React.createClass({ | |
| }); | ||
| }, | ||
|
|
||
| getUserDisplayName(item) { | ||
| return item.email || item.username || item.identifier || item.ipAddress || item.value; | ||
| }, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just: return item.email || item.username || item.identifier || item.ipAddress || item.value; |
||
|
|
||
| render() { | ||
| if (this.state.loading) { | ||
| return <LoadingIndicator />; | ||
| } else if (this.state.error) { | ||
| return <LoadingError onRetry={this.fetchData} />; | ||
| } | ||
|
|
||
| let {orgId, projectId} = this.props.params; | ||
| let tagKey = this.state.tagKey; | ||
| let children = this.state.tagValueList.map((tagValue, tagValueIdx) => { | ||
| let pct = percent(tagValue.count, tagKey.totalValues).toFixed(2); | ||
| let orgId = this.getOrganization().slug; | ||
| let projectId = this.getProject().slug; | ||
| return ( | ||
| <tr key={tagValueIdx}> | ||
| <td className="bar-cell"> | ||
|
|
@@ -101,10 +103,20 @@ const GroupTagValues = React.createClass({ | |
| <Link | ||
| to={{ | ||
| pathname: `/${orgId}/${projectId}/`, | ||
| query: {query: tagKey.key + ':' + '"' + tagValue.value + '"'} | ||
| query: {query: `${tagKey.key}:"${tagValue.value}"`} | ||
| }}> | ||
| {deviceNameMapper(tagValue.name)} | ||
| {tagKey.key === 'user' ? [ | ||
| <Avatar user={tagValue} size={16} className="avatar" />, | ||
| <span style={{marginLeft: 10}}>{this.getUserDisplayName(tagValue)}</span> | ||
| ] : | ||
| deviceNameMapper(tagValue.name) | ||
| } | ||
| </Link> | ||
| {tagValue.email && | ||
| <a href={`mailto:${tagValue.email}`} className="external-icon"> | ||
| <em className="icon-envelope" /> | ||
| </a> | ||
| } | ||
| {isUrl(tagValue.value) && | ||
| <a href={tagValue.value} className="external-icon"> | ||
| <em className="icon-open" /> | ||
|
|
@@ -121,22 +133,15 @@ const GroupTagValues = React.createClass({ | |
| return ( | ||
| <div> | ||
| <h3> | ||
| {tagKey.name + ' '} | ||
| <small>{tn( | ||
| '%2$d unique historical value', | ||
| '%2$d unique historical values', | ||
| tagKey.uniqueValues, | ||
| <Count value={tagKey.uniqueValues} /> | ||
| )}</small> | ||
| {tagKey.key == 'user' ? t('Affected Users') : tagKey.name} | ||
| <a href="export/" className="btn btn-default btn-sm" | ||
| style={{marginLeft: 10}}>{t('Export to CSV')}</a> | ||
| </h3> | ||
| <div className="alert alert-info alert-block"> | ||
| {t('Data is based on events seen in the last 7 days.')} | ||
| </div> | ||
| <table className="table table-striped"> | ||
| <thead> | ||
| <tr> | ||
| <th style={{width: 30}}>%</th> | ||
| <th>{t('Value')}</th> | ||
| <th></th> | ||
| <th style={{width: 200}}>{t('Last Seen')}</th> | ||
| </tr> | ||
| </thead> | ||
|
|
@@ -145,6 +150,7 @@ const GroupTagValues = React.createClass({ | |
| </tbody> | ||
| </table> | ||
| <Pagination pageLinks={this.state.pageLinks}/> | ||
| <p><small>{t('Note: Percentage of issue is based on events seen in the last 7 days.')}</small></p> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal, but I had to look up the API for this since the name didn't match what this actually was and couldn't tell if it was meant to be an instance of a class or a class itself with the variable being named
_cls.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its the class of serializer, not the literal class type