mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 07:09:48 +03:00
5047b9f3d7
refs https://github.com/TryGhost/Ghost/issues/9865, https://github.com/TryGhost/Ghost/issues/9942 - `integration`, `api-key`, and `webhook` models and respective mirage mocks - moves integration routes around to match ember's concept of nested routes (nested routes reflect nested UI not nested URLs) - adds custom integrations list to integrations screen - adds custom integration screen - allow editing of integration details - show list of webhooks - webhook creation modal NB: the `enableDeveloperExperiments` flag needs to be enabled in the `config.development.json` file for the custom integrations UI to be displayed until it's out of development.
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
import BaseValidator from './base';
|
|
import validator from 'npm:validator';
|
|
import {isBlank} from '@ember/utils';
|
|
|
|
export default BaseValidator.create({
|
|
properties: ['name', 'event', 'targetUrl'],
|
|
|
|
name(model) {
|
|
if (isBlank(model.name)) {
|
|
model.errors.add('name', 'Please enter a name');
|
|
model.hasValidated.pushObject('name');
|
|
this.invalidate();
|
|
} else if (!validator.isLength(model.name, 0, 191)) {
|
|
model.errors.add('name', 'Name is too long, max 191 chars');
|
|
model.hasValidated.pushObject('name');
|
|
this.invalidate();
|
|
}
|
|
},
|
|
|
|
event(model) {
|
|
if (isBlank(model.event)) {
|
|
model.errors.add('event', 'Please select an event');
|
|
model.hasValidated.pushObject('event');
|
|
this.invalidate();
|
|
}
|
|
},
|
|
|
|
targetUrl(model) {
|
|
if (isBlank(model.targetUrl)) {
|
|
model.errors.add('targetUrl', 'Please enter a target URL');
|
|
} else if (!validator.isURL(model.targetUrl || '', {require_protocol: false})) {
|
|
model.errors.add('targetUrl', 'Please enter a valid URL');
|
|
} else if (!validator.isLength(model.targetUrl, 0, 2000)) {
|
|
model.errors.add('targetUrl', 'Target URL is too long, max 2000 chars');
|
|
}
|
|
|
|
model.hasValidated.pushObject('targetUrl');
|
|
|
|
if (model.errors.has('targetUrl')) {
|
|
this.invalidate();
|
|
}
|
|
}
|
|
});
|