-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5811 from beyondessential/dev
merge: update branch with latest dev
- Loading branch information
Showing
6 changed files
with
125 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/admin-panel/src/table/columnTypes/ExternalLinkButton.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Tupaia | ||
* Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd | ||
*/ | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Link } from '@material-ui/core'; | ||
import { OpenInNewRounded } from '@material-ui/icons'; | ||
import { ColumnActionButton } from './ColumnActionButton'; | ||
import { makeSubstitutionsInString } from '../../utilities'; | ||
|
||
export const ExternalLinkButton = ({ actionConfig, row }) => { | ||
const getUrl = () => { | ||
if (actionConfig.generateUrl) { | ||
return actionConfig.generateUrl(row.original); | ||
} | ||
return makeSubstitutionsInString(actionConfig.url, row.original); | ||
}; | ||
const fullUrl = getUrl(); | ||
if (!fullUrl) return null; | ||
|
||
return ( | ||
<ColumnActionButton | ||
className="link-button" | ||
title={actionConfig.title} | ||
component={Link} | ||
href={fullUrl} | ||
target="_blank" | ||
> | ||
<OpenInNewRounded /> | ||
</ColumnActionButton> | ||
); | ||
}; | ||
|
||
ExternalLinkButton.propTypes = { | ||
actionConfig: PropTypes.object.isRequired, | ||
row: PropTypes.object.isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters