-
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.
Browse files
Browse the repository at this point in the history
* Make links * Use projectId * Update user preferences if project id is in url * Add comment * Allow country codes to be fetched for surveys * Link directly to survey * Default to DL and alphabetise the country codes * Change tooltip text * Update copy * Hide button for surveys with no countries --------- Co-authored-by: Andrew <vanbeekandrew@gmail.com>
- 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