mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-15 15:10:31 -08:00
Ease restrictions on URL inputs (#124)
This commit is contained in:
parent
cbd7179348
commit
23db4d0f4f
3 changed files with 18 additions and 4 deletions
|
|
@ -15,6 +15,13 @@ const kits = {
|
|||
}
|
||||
return null;
|
||||
},
|
||||
// accept link without protocol prefix
|
||||
lessStrictUrl: (val, _, fieldName) => {
|
||||
if (!isUrl(val) && !isUrl(`http://${val}`)) {
|
||||
return '{fieldName} is not valid.'.replace('{fieldName}', fieldName);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
licenseKey: (val, ruleVal, fieldName) => {
|
||||
if (!isValidLicenseKey(val)) {
|
||||
return '{fieldName} is not valid.'.replace('{fieldName}', fieldName);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import {
|
|||
} from '../../constants/actions';
|
||||
|
||||
import validate from '../../helpers/validate';
|
||||
import isUrl from '../../helpers/is-url';
|
||||
import hasErrors from '../../helpers/has-errors';
|
||||
|
||||
import { requestCreateWorkspace } from '../../senders';
|
||||
|
|
@ -182,9 +183,12 @@ export const save = () => (dispatch, getState) => {
|
|||
return dispatch(updateForm(validatedChanges));
|
||||
}
|
||||
|
||||
const url = form.homeUrl.trim();
|
||||
const homeUrl = isUrl(url) ? url : `http://${url}`;
|
||||
|
||||
requestCreateWorkspace(
|
||||
form.name,
|
||||
form.homeUrl.trim(),
|
||||
homeUrl,
|
||||
form.internetIcon || form.picturePath,
|
||||
Boolean(form.transparentBackground),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@ import {
|
|||
UPDATE_EDIT_WORKSPACE_FORM,
|
||||
} from '../../constants/actions';
|
||||
|
||||
import validate from '../../helpers/validate';
|
||||
import hasErrors from '../../helpers/has-errors';
|
||||
import isUrl from '../../helpers/is-url';
|
||||
import validate from '../../helpers/validate';
|
||||
|
||||
import {
|
||||
requestSetWorkspace,
|
||||
|
|
@ -23,7 +24,7 @@ const getValidationRules = () => ({
|
|||
homeUrl: {
|
||||
fieldName: 'Home URL',
|
||||
required: true,
|
||||
url: true,
|
||||
lessStrictUrl: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -93,12 +94,14 @@ export const save = () => (dispatch, getState) => {
|
|||
}
|
||||
|
||||
const id = remote.getGlobal('editWorkspaceId');
|
||||
const url = form.homeUrl.trim();
|
||||
const homeUrl = isUrl(url) ? url : `http://${url}`;
|
||||
|
||||
requestSetWorkspace(
|
||||
id,
|
||||
{
|
||||
name: form.name,
|
||||
homeUrl: form.homeUrl.trim(),
|
||||
homeUrl,
|
||||
// prefs
|
||||
disableAudio: Boolean(form.disableAudio),
|
||||
disableNotifications: Boolean(form.disableNotifications),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue