Skip to content
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

Added URL as a property on the frontend #228

Merged
merged 4 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion webapp/src/components/propertyValueElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ const PropertyValueElement = (props:Props): JSX.Element => {
const emailRegexp = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
return emailRegexp.test(val.toLowerCase())
}
case 'url': {
const urlRegexp = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w\-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\\w]*))?)/
return urlRegexp.test(val.toLowerCase())
}
case 'text':
return true
default:
Expand Down Expand Up @@ -93,7 +97,12 @@ const PropertyValueElement = (props:Props): JSX.Element => {
)
}

if (propertyTemplate.type === 'text' || propertyTemplate.type === 'number' || propertyTemplate.type === 'email') {
if (
propertyTemplate.type === 'text' ||
propertyTemplate.type === 'number' ||
propertyTemplate.type === 'email' ||
propertyTemplate.type === 'url'
) {
if (!readOnly) {
return (
<Editable
Expand Down
15 changes: 15 additions & 0 deletions webapp/src/widgets/__snapshots__/propertyMenu.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ exports[`widgets/PropertyMenu should match snapshot 1`] = `
class="noicon"
/>
</div>
<div
class="MenuOption TextOption menu-option"
>
<div
class="noicon"
/>
<div
class="menu-name"
>
URL
</div>
<div
class="noicon"
/>
</div>
<div
class="MenuOption TextOption menu-option"
>
Expand Down
5 changes: 5 additions & 0 deletions webapp/src/widgets/propertyMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ const PropertyMenu = React.memo((props: Props) => {
name={typeDisplayName(intl, 'email')}
onClick={() => props.onTypeChanged('email')}
/>
<Menu.Text
id='url'
name={typeDisplayName(intl, 'url')}
onClick={() => props.onTypeChanged('url')}
/>
<Menu.Text
id='select'
name={typeDisplayName(intl, 'select')}
Expand Down