Skip to content

Commit 096ee26

Browse files
committed
refactor: use buttons to get rid of deprecated javascript URLs
1 parent bb36b6d commit 096ee26

22 files changed

+74
-51
lines changed

src/components/BrowserFilter/BrowserFilter.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
}
139139

140140
.remove {
141+
@include buttonReset;
141142
display: inline-block;
142143
height: 14px;
143144
margin: 8px;

src/components/BrowserFilter/FilterRow.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ let FilterRow = ({
103103
options={constraints.map((c) => Constraints[c].name)}
104104
onChange={(c) => onChangeConstraint(constraintLookup[c])} />
105105
{compareValue(compareInfo, compareTo, onChangeCompareTo, active, parentContentId)}
106-
<a role='button' href='javascript:;' className={styles.remove} onClick={onDeleteRow}><Icon name='minus-solid' width={14} height={14} fill='rgba(0,0,0,0.4)' /></a>
106+
<button type='button' className={styles.remove} onClick={onDeleteRow}><Icon name='minus-solid' width={14} height={14} fill='rgba(0,0,0,0.4)' /></button>
107107
</div>
108108
);
109109

src/components/Button/Button.react.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ let Button = (props) => {
3939
styleOverride = { width: props.width, minWidth: props.width, ...props.additionalStyles };
4040
}
4141
return (
42-
<a
43-
href='javascript:;'
44-
role='button'
42+
<button
43+
type='button'
4544
style={styleOverride}
4645
className={classes.join(' ')}
4746
onClick={clickHandler}
4847
onFocus={(e) => { if (props.disabled) e.target.blur(); }} >
4948
<span>{props.value}</span>
50-
</a>
49+
</button>
5150
);
5251
}
5352

src/components/Button/Button.scss

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@
99

1010
.button {
1111
@include DosisFont;
12+
@include buttonReset($bg: none, $border: 1px solid $blue, $padding: 0 16px);
1213
display: inline-block;
1314
height: 30px;
14-
border: 1px solid $blue;
1515
line-height: 28px;
1616
outline: 0;
1717
text-decoration: none;
1818
text-align: center;
1919
border-radius: 5px;
20-
cursor: pointer;
2120
min-width: 110px;
22-
padding: 0 16px;
2321
font-size: 14px;
2422

2523
color: $blue;

src/components/Filter/Filter.react.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function deleteRow(filters, index) {
4747
let Filter = ({ schema, filters, renderRow, onChange, blacklist, className }, context) => {
4848
blacklist = blacklist || [];
4949
let available = Filters.availableFilters(schema, filters);
50+
console.log('c', context)
5051
return (
5152
<div>
5253
{filters.toArray().map((filter, i) => {
@@ -60,7 +61,7 @@ let Filter = ({ schema, filters, renderRow, onChange, blacklist, className }, co
6061
}
6162

6263
// Get the column preference of the current class.
63-
const currentColumnPreference = context.currentApp.columnPreference[className];
64+
const currentColumnPreference = context.currentApp.columnPreference && context.currentApp.columnPreference[className];
6465

6566
// Check if the preference exists.
6667
if (currentColumnPreference) {

src/components/PermissionsDialog/PermissionsDialog.react.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,13 +1061,12 @@ export default class PermissionsDialog extends React.Component {
10611061
if (!this.state.transitioning) {
10621062
trash = (
10631063
<div className={styles.delete}>
1064-
<a
1065-
href="javascript:;"
1066-
role="button"
1064+
<button
1065+
type='button'
10671066
onClick={this.deleteRow.bind(this, key, pointer)}
10681067
>
10691068
<Icon name="trash-solid" width={20} height={20} />
1070-
</a>
1069+
</button>
10711070
</div>
10721071
);
10731072
}

src/components/PermissionsDialog/PermissionsDialog.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@
314314
height: 50px;
315315
padding-top: 15px;
316316
text-align: right;
317+
318+
button {
319+
@include buttonReset;
320+
}
317321

318322
svg {
319323
vertical-align: top;

src/components/ProtectedFieldsDialog/ProtectedFieldsDialog.react.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,12 @@ export default class ProtectedFieldsDialog extends React.Component {
359359
if (!this.state.transitioning) {
360360
trash = (
361361
<div className={styles.delete}>
362-
<a
363-
href="javascript:;"
364-
role="button"
362+
<button
363+
type='button'
365364
onClick={this.deleteRow.bind(this, key)}
366365
>
367366
<Icon name="trash-solid" width={20} height={20} />
368-
</a>
367+
</button>
369368
</div>
370369
);
371370
}

src/components/ProtectedFieldsDialog/ProtectedFieldsDialog.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ $permissionsDialogWidth: calc(
176176
padding-top: 15px;
177177
text-align: right;
178178

179+
button {
180+
@include buttonReset;
181+
}
182+
179183
svg {
180184
vertical-align: top;
181185
cursor: pointer;

src/components/PushAudienceDialog/InstallationCondition.react.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,13 @@ export default class InstallationCondition extends React.Component {
115115
</div>
116116
);
117117

118-
//TODO Shoulse use <Button> and have a link type style without border.
119118
let labelDescription = (
120-
<a
121-
href='javascript:;'
122-
role='button'
119+
<button
120+
type='button'
123121
className={styles.description}
124122
onClick={this.props.onDeleteRow}>
125123
Remove
126-
</a>
124+
</button>
127125
);
128126

129127
return (

src/components/PushAudienceDialog/InstallationCondition.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
.description {
1818
margin-top: 2px;
1919
color: $pink;
20-
cursor: pointer;
20+
@include buttonReset;
2121
}
2222

2323
.valueInput {

src/components/PushAudiencesSelector/PushAudiencesOption.react.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,22 @@ export default class PushAudiencesOption extends PushAudiencesBaseRow {
8585
<div className={styles.subline}>
8686
{detailsView}
8787
{!this.state.isNewSegment ?
88-
<a
89-
role='button'
88+
<button
89+
type='button'
9090
className={[styles.moreDetails, !this.props.query ? styles.hideMoreDetails : ''].join(' ')}
91-
href='javascript:;'
9291
onClick={this.handleDetailsToggle.bind(this,this.props.query, this.props.schema)}>
9392
{this.state.expandedView ? 'less details' : 'more details'}
94-
</a> :
95-
<a
96-
role='button'
93+
</button> :
94+
<button
95+
type='button'
9796
className={[styles.moreDetails, !this.props.query ? styles.hideMoreDetails : ''].join(' ')}
98-
href='javascript:;'
9997
onClick={this.props.onEditAudience.bind(undefined, {
10098
name: this.props.name,
10199
filters: this.props.filters,
102100
query: this.props.query,
103101
})}>
104102
{'Edit audience'}
105-
</a>
103+
</button>
106104
}
107105
</div>
108106
</div>

src/components/PushAudiencesSelector/PushAudiencesOption.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
}
8989

9090
.moreDetails {
91+
@include buttonReset;
9192
color: $blue;
9293

9394
&.hideMoreDetails {

src/dashboard/Analytics/SlowQueries/SlowQueries.react.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,13 @@ class SlowQueries extends TableView {
164164
...newValue,
165165
mutated: true
166166
})} />
167-
<a
168-
href='javascript:;'
169-
role='button'
167+
<button
168+
type='button'
170169
onClick={this.handleDownload.bind(this)}
171170
className={styles.toolbarAction}>
172171
<Icon name='download' width={14} height={14} fill='#66637a' />
173172
Download
174-
</a>
173+
</button>
175174
</div>
176175
);
177176
}

src/dashboard/Analytics/SlowQueries/SlowQueries.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@import 'stylesheets/globals.scss';
99

1010
.toolbarAction {
11-
padding: 0px 20px;
11+
@include buttonReset($padding: 0px 20px);
1212
color: white;
1313

1414
> *:not(svg) {

src/dashboard/Data/Webhooks/Webhooks.react.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import TextInput from 'components/TextInput/TextInpu
2323
import Toolbar from 'components/Toolbar/Toolbar.react';
2424
import { ActionTypes as SchemaActionTypes } from 'lib/stores/SchemaStore';
2525
import { ActionTypes as WebhookActionTypes } from 'lib/stores/WebhookStore';
26+
import styles from './Webhooks.scss'
2627

2728
let TableWarning = ({ text }) => <div>
2829
<Icon name='warn-outline' fill='#343445' width={20} height={20}/><span style={{ position: 'relative', top: '2px' }}> {text}</span>
@@ -250,9 +251,9 @@ class Webhooks extends TableView {
250251
let rowStyle = hook.url ? { cursor: 'pointer' } : {};
251252
let deleteColumnContents = null;
252253
if (hook.url) {
253-
deleteColumnContents = <a role='button' href='javascript:;' onClick={showDelete}>
254+
deleteColumnContents = <button type='button' onClick={showDelete} className={styles.deleteButton}>
254255
<Icon name='trash-outline' fill='#343445' width={20} height={20}/>
255-
</a>;
256+
</button>;
256257
} else {
257258
let isOverridden = !!this.tableData().find(otherHook => otherHook.url &&
258259
otherHook.functionName == hook.functionName &&
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2016-present, Parse, LLC
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the license found in the LICENSE file in
6+
* the root directory of this source tree.
7+
*/
8+
@import 'stylesheets/globals.scss';
9+
10+
.deleteButton {
11+
@include buttonReset;
12+
}

src/dashboard/Push/Push.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
}
7171

7272
.localeRemoveButton {
73+
@include buttonReset;
7374
position: absolute;
7475
right: 15px;
7576
font-size: 12px;

src/dashboard/Push/PushAudiencesIndexRow.react.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,22 @@ export default class PushAudiencesIndexRow extends PushAudiencesBaseRow {
4040
<tr>
4141
<td className={styles.colName}>
4242
{this.props.name}
43-
<a
43+
<button
4444
className={styles.newPushButton}
45-
href='javascript:;'
46-
role='button'
45+
type='button'
4746
onClick={this.props.onSendPush.bind(undefined, this.props.id)}>
4847
Send a new push
49-
</a>
48+
</button>
5049
</td>
5150
<td className={styles.colSize}>{countDetails}</td>
5251
<td className={styles.colDetails}>
5352
{detailsView}
54-
<a
55-
role='button'
56-
href='javascript:;'
53+
<button
54+
type='button'
5755
className={[styles.moreDetails, !this.props.query ? styles.hideMoreDetails : ''].join(' ')}
5856
onClick={this.handleDetailsToggle.bind(this,this.props.query, this.props.schema)}>
5957
{this.state.expandedView ? 'less details' : 'more details' }
60-
</a>
58+
</button>
6159
</td>
6260
<td className={styles.colCreatedOn}>
6361
{DateUtils.yearMonthDayFormatter(this.props.createdAt)}
@@ -66,13 +64,12 @@ export default class PushAudiencesIndexRow extends PushAudiencesBaseRow {
6664
{this.props.timesUsed}
6765
</td>
6866
<td className={styles.colAction}>
69-
<a
67+
<button
7068
className={styles.removeIcon}
71-
role='button'
72-
href='javascript:;'
69+
type='button'
7370
onClick={this.props.onDelete.bind(undefined, this.props.id, this.props.name)}>
7471
<Icon name='trash-outline' fill='#343445' width={20} height={20} role='button'/>
75-
</a>
72+
</button>
7673
</td>
7774
</tr>
7875
);

src/dashboard/Push/PushAudiencesIndexRow.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
}
6161

6262
.moreDetails {
63+
@include buttonReset;
6364
color: $blue;
6465
font-size: 14px;
6566

@@ -73,6 +74,7 @@
7374
}
7475

7576
.newPushButton {
77+
@include buttonReset;
7678
font-size: 14px;
7779
display: block;
7880
margin: -5px 0 -10px 0;
@@ -84,6 +86,7 @@
8486

8587
//NOTE: May be used to global so SVG icons wrapped by <a> can have common styles.
8688
.removeIcon {
89+
@include buttonReset;
8790
&:hover, &:focus {
8891
svg {
8992
fill: $blue;

src/dashboard/Push/PushNew.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ let LocalizedMessageField = ({
7575
<div className={styles.localeContainer}>
7676
<div className={styles.localeTitle}>
7777
<span>Localized message</span>
78-
<a href='javascript:;' role='button' className={styles.localeRemoveButton} onClick={onClickRemove.bind(undefined, id, currentLocaleOption)}>REMOVE</a>
78+
<button type='button' className={styles.localeRemoveButton} onClick={onClickRemove.bind(undefined, id, currentLocaleOption)}>REMOVE</button>
7979
</div>
8080
<Field
8181
key={`message1_${id}`}

src/stylesheets/globals.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,11 @@ $sidebarCollapsedWidth: 54px;
194194
}
195195
}
196196
}
197+
198+
@mixin buttonReset($bg: none, $border: 0, $padding: 0) {
199+
border: $border;
200+
background: $bg;
201+
cursor: pointer;
202+
font-family: inherit;
203+
padding: $padding;
204+
}

0 commit comments

Comments
 (0)