Update webhook settings UI and functionality
This commit is contained in:
parent
29252679a1
commit
5bf0724c2f
1 changed files with 63 additions and 43 deletions
|
@ -7,6 +7,8 @@ import {
|
||||||
CircularProgress,
|
CircularProgress,
|
||||||
Container,
|
Container,
|
||||||
Divider,
|
Divider,
|
||||||
|
FormControl,
|
||||||
|
FormHelperText,
|
||||||
Input,
|
Input,
|
||||||
Typography,
|
Typography,
|
||||||
} from '@mui/joy'
|
} from '@mui/joy'
|
||||||
|
@ -28,6 +30,7 @@ import {
|
||||||
PutWebhookURL,
|
PutWebhookURL,
|
||||||
UpdatePassword,
|
UpdatePassword,
|
||||||
} from '../../utils/Fetcher'
|
} from '../../utils/Fetcher'
|
||||||
|
import { isPlusAccount } from '../../utils/Helpers'
|
||||||
import PassowrdChangeModal from '../Modals/Inputs/PasswordChangeModal'
|
import PassowrdChangeModal from '../Modals/Inputs/PasswordChangeModal'
|
||||||
import APITokenSettings from './APITokenSettings'
|
import APITokenSettings from './APITokenSettings'
|
||||||
import NotificationSetting from './NotificationSetting'
|
import NotificationSetting from './NotificationSetting'
|
||||||
|
@ -327,52 +330,69 @@ const Settings = () => {
|
||||||
services when events happen in your Circle. Use the webhook URL
|
services when events happen in your Circle. Use the webhook URL
|
||||||
below to
|
below to
|
||||||
</Typography>
|
</Typography>
|
||||||
<Checkbox
|
<FormControl sx={{ mt: 1 }}>
|
||||||
checked={webhookURL !== null}
|
<Checkbox
|
||||||
onClick={() => {
|
checked={webhookURL !== null}
|
||||||
if (webhookURL === null) {
|
|
||||||
setWebhookURL('')
|
|
||||||
} else {
|
|
||||||
setWebhookURL(null)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
variant='soft'
|
|
||||||
label={'Enable Webhook'}
|
|
||||||
/>
|
|
||||||
<>
|
|
||||||
{webhookURL !== null && (
|
|
||||||
<Typography level='title-sm'>
|
|
||||||
Webhook URL
|
|
||||||
<Input
|
|
||||||
value={webhookURL ? webhookURL : ''}
|
|
||||||
onChange={e => setWebhookURL(e.target.value)}
|
|
||||||
size='lg'
|
|
||||||
sx={{
|
|
||||||
width: '220px',
|
|
||||||
mb: 1,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Typography level='body-sm' color='danger'>
|
|
||||||
{webhookError}
|
|
||||||
</Typography>
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
<Button
|
|
||||||
variant='soft'
|
|
||||||
sx={{ width: '110px' }}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
PutWebhookURL(webhookURL).then(resp => {
|
if (webhookURL === null) {
|
||||||
if (resp.ok) {
|
setWebhookURL('')
|
||||||
alert('Webhook URL updated successfully.')
|
} else {
|
||||||
} else {
|
setWebhookURL(null)
|
||||||
alert('Failed to update webhook URL.')
|
}
|
||||||
}
|
}}
|
||||||
})
|
variant='soft'
|
||||||
|
label='Enable Webhook'
|
||||||
|
disabled={!isPlusAccount(userProfile)}
|
||||||
|
overlay
|
||||||
|
/>
|
||||||
|
<FormHelperText
|
||||||
|
sx={{
|
||||||
|
opacity: !isPlusAccount(userProfile) ? 0.5 : 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Save
|
Enable webhook notifications for tasks and things updates.{' '}
|
||||||
</Button>
|
{userProfile && !isPlusAccount(userProfile) && (
|
||||||
</>
|
<Chip variant='soft' color='warning'>
|
||||||
|
Not available in Basic Plan
|
||||||
|
</Chip>
|
||||||
|
)}
|
||||||
|
</FormHelperText>
|
||||||
|
<>
|
||||||
|
{webhookURL !== null && (
|
||||||
|
<Typography level='title-sm'>
|
||||||
|
Webhook URL
|
||||||
|
<Input
|
||||||
|
value={webhookURL ? webhookURL : ''}
|
||||||
|
onChange={e => setWebhookURL(e.target.value)}
|
||||||
|
size='lg'
|
||||||
|
sx={{
|
||||||
|
width: '220px',
|
||||||
|
mb: 1,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Typography level='body-sm' color='danger'>
|
||||||
|
{webhookError}
|
||||||
|
</Typography>
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
variant='soft'
|
||||||
|
sx={{ width: '110px', mt: 1 }}
|
||||||
|
onClick={() => {
|
||||||
|
PutWebhookURL(webhookURL).then(resp => {
|
||||||
|
if (resp.ok) {
|
||||||
|
alert('Webhook URL updated successfully.')
|
||||||
|
} else {
|
||||||
|
alert('Failed to update webhook URL.')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
disabled={!isPlusAccount(userProfile)}
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
</FormControl>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue