|
@@ -32,20 +32,19 @@ export default class Subscriptions extends Component<Props> {
|
|
|
this.context.form.setValue('events', this.props.events);
|
|
|
}
|
|
|
|
|
|
- UNSAFE_componentWillReceiveProps(nextProps: Props) {
|
|
|
- // if webhooks are disabled, unset the events
|
|
|
- if (nextProps.webhookDisabled && this.props.events.length) {
|
|
|
- this.save([]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- componentDidUpdate() {
|
|
|
- const {permissions, events} = this.props;
|
|
|
+ componentDidUpdate(prevProps: Props) {
|
|
|
+ const {webhookDisabled, permissions, events} = this.props;
|
|
|
|
|
|
const permittedEvents = events.filter(
|
|
|
resource => permissions[PERMISSIONS_MAP[resource]] !== 'no-access'
|
|
|
);
|
|
|
|
|
|
+ // When disabling webhooks unset the events
|
|
|
+ if (!prevProps.webhookDisabled && webhookDisabled && prevProps.events.length) {
|
|
|
+ this.save([]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (JSON.stringify(events) !== JSON.stringify(permittedEvents)) {
|
|
|
this.save(permittedEvents);
|
|
|
}
|