Skip to content

Commit cd8bd23

Browse files
committed
🐛 DEVEP-2353: ActionButtons should open git urls in separate tab
1 parent 73095c7 commit cd8bd23

File tree

1 file changed

+35
-29
lines changed

1 file changed

+35
-29
lines changed

src/ActionButtons/index.js

+35-29
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,49 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
99
OF ANY KIND, either express or implied. See the License for the specific language
1010
governing permissions and limitations under the License.
1111
*/
12-
import React from 'react'
12+
/** @jsx jsx */
13+
import { css, jsx } from '@emotion/react'
1314
import PropTypes from 'prop-types'
1415
import { ActionButton, Text } from '@adobe/react-spectrum'
1516

1617
import Bug from '@spectrum-icons/workflow/Bug'
1718
import Edit from '@spectrum-icons/workflow/Edit'
1819

19-
const ActionButtons = ({ gitUrl, filePath, branch, issues, ...props }) => (
20+
const ActionLink = ({ href, children }) => (
21+
<a
22+
href={href}
23+
css={css`
24+
text-decoration: none;
25+
`}
26+
target='_blank'
27+
rel='noopener noreferrer nofollow'
28+
>
29+
{children}
30+
</a>
31+
)
32+
33+
const ActionButtons = ({
34+
gitUrl = '',
35+
filePath = '',
36+
branch = '',
37+
issues,
38+
...props
39+
}) => (
2040
<div {...props}>
21-
<ActionButton
22-
isQuiet
23-
onPress={() => {
24-
document.location.href = `${gitUrl}/edit/${branch}/${filePath}`
25-
}}
26-
aria-label='Edit page'
27-
>
28-
<Edit size='S' />
29-
<Text>Edit this page</Text>
30-
</ActionButton>
31-
<ActionButton
32-
isQuiet
33-
onPress={() => {
34-
issues
35-
? (document.location.href = issues)
36-
: (document.location.href = `${gitUrl}/issues/new?body=Issue%20in%20${filePath}`)
37-
}}
38-
aria-label='Log issue'
41+
<ActionLink href={`${gitUrl}/edit/${branch}/${filePath}`}>
42+
<ActionButton isQuiet aria-label='Edit page' excludeFromTabOrder>
43+
<Edit size='S' />
44+
<Text>Edit this page</Text>
45+
</ActionButton>
46+
</ActionLink>
47+
<ActionLink
48+
href={issues || `${gitUrl}/issues/new?body=Issue%20in%20${filePath}`}
3949
>
40-
<Bug size='S' />
41-
<Text>Log an issue</Text>
42-
</ActionButton>
50+
<ActionButton isQuiet aria-label='Log issue' excludeFromTabOrder>
51+
<Bug size='S' />
52+
<Text>Log an issue</Text>
53+
</ActionButton>
54+
</ActionLink>
4355
</div>
4456
)
4557

@@ -49,10 +61,4 @@ ActionButtons.propTypes = {
4961
gitUrl: PropTypes.string
5062
}
5163

52-
ActionButtons.defaultProps = {
53-
branch: '',
54-
filePath: '',
55-
gitUrl: ''
56-
}
57-
5864
export { ActionButtons }

0 commit comments

Comments
 (0)