-
this.handleFieldChange('thumbnail', e)} />
From edce191c2961992db31ad31e695f83e261bd84ef Mon Sep 17 00:00:00 2001
From: Gazook89 <58999374+Gazook89@users.noreply.github.com>
Date: Sat, 5 Nov 2022 11:32:35 -0500
Subject: [PATCH 04/13] remove a silly rule
---
client/homebrew/editor/metadataEditor/validations.js | 3 ---
1 file changed, 3 deletions(-)
diff --git a/client/homebrew/editor/metadataEditor/validations.js b/client/homebrew/editor/metadataEditor/validations.js
index 48d037b54..0023c6008 100644
--- a/client/homebrew/editor/metadataEditor/validations.js
+++ b/client/homebrew/editor/metadataEditor/validations.js
@@ -12,9 +12,6 @@ module.exports = {
thumbnail : [
(value)=>{
return value?.length > 5 ? 'Max URL length of 5 characters' : null;
- },
- (value)=>{
- return (value ?? '')[0] !== 'W' ? 'URL must start with W' : null;
}
]
};
From 78da48b08dc2200b0d4e0b42a5b65917bd135123 Mon Sep 17 00:00:00 2001
From: Gazook89 <58999374+Gazook89@users.noreply.github.com>
Date: Sat, 5 Nov 2022 11:42:21 -0500
Subject: [PATCH 05/13] fix issue with async setState using `Event.persist()`
---
.../editor/metadataEditor/metadataEditor.jsx | 31 ++++++++++---------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.jsx b/client/homebrew/editor/metadataEditor/metadataEditor.jsx
index 76454e88b..e095d1c6c 100644
--- a/client/homebrew/editor/metadataEditor/metadataEditor.jsx
+++ b/client/homebrew/editor/metadataEditor/metadataEditor.jsx
@@ -56,6 +56,7 @@ const MetadataEditor = createClass({
},
handleFieldChange : function(name, e){
+ e.persist();
const inputRules = validations[name] ?? [];
const validationErr = inputRules.map((rule)=>rule(e.target.value)).filter(Boolean);
this.setState((prevState)=>({
@@ -63,20 +64,22 @@ const MetadataEditor = createClass({
...(prevState.errs ?? {}),
[name] : validationErr.length > 0 ? validationErr : undefined
}
- }));
- if(Object.values(this.state.errs ?? {}).filter(Boolean).length === 0){
- e.target.setCustomValidity('');
- this.props.onChange({
- ...this.props.metadata,
- [name] : e.target.value
- });
- } else {
- const errMessage = this.state.errs[name].map((err)=>{
- return `- ${err}`;
- }).join('\n');
- e.target.setCustomValidity(errMessage);
- e.target.reportValidity();
- };
+ }), ()=>{
+ if(Object.values(this.state.errs ?? {}).filter(Boolean).length === 0){
+ e.target.setCustomValidity('');
+ this.props.onChange({
+ ...this.props.metadata,
+ [name] : e.target.value
+ });
+ } else {
+ const errMessage = this.state.errs[name].map((err)=>{
+ return `- ${err}`;
+ }).join('\n');
+ e.target.setCustomValidity(errMessage);
+ e.target.reportValidity();
+ };
+ });
+
},
From aec1147aa53af84ebe128b0e0fe56117b7d4e011 Mon Sep 17 00:00:00 2001
From: Gazook89 <58999374+Gazook89@users.noreply.github.com>
Date: Sat, 5 Nov 2022 11:56:48 -0500
Subject: [PATCH 06/13] set `:invalid` input to light red background
---
client/homebrew/editor/metadataEditor/metadataEditor.less | 3 +++
1 file changed, 3 insertions(+)
diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.less b/client/homebrew/editor/metadataEditor/metadataEditor.less
index 9b2761306..a852ad41b 100644
--- a/client/homebrew/editor/metadataEditor/metadataEditor.less
+++ b/client/homebrew/editor/metadataEditor/metadataEditor.less
@@ -42,6 +42,9 @@
&>.value{
flex : 1 1 auto;
width : 50px;
+ &:invalid {
+ background : #ffb9b9;
+ }
}
&.thumbnail{
height : 1.4em;
From a13fd48cdae9d3ee5eea1c90801c160b3d983c47 Mon Sep 17 00:00:00 2001
From: Gazook89 <58999374+Gazook89@users.noreply.github.com>
Date: Sat, 5 Nov 2022 12:19:01 -0500
Subject: [PATCH 07/13] prevent crash on input to second field. small css
change
---
client/homebrew/editor/metadataEditor/metadataEditor.jsx | 2 +-
client/homebrew/editor/metadataEditor/metadataEditor.less | 3 +++
client/homebrew/editor/metadataEditor/validations.js | 4 ++--
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.jsx b/client/homebrew/editor/metadataEditor/metadataEditor.jsx
index e095d1c6c..47110c097 100644
--- a/client/homebrew/editor/metadataEditor/metadataEditor.jsx
+++ b/client/homebrew/editor/metadataEditor/metadataEditor.jsx
@@ -65,7 +65,7 @@ const MetadataEditor = createClass({
[name] : validationErr.length > 0 ? validationErr : undefined
}
}), ()=>{
- if(Object.values(this.state.errs ?? {}).filter(Boolean).length === 0){
+ if(Object.values(this.state.errs ?? {}).filter(Boolean).length === 0 || !this.state.errs[name]){
e.target.setCustomValidity('');
this.props.onChange({
...this.props.metadata,
diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.less b/client/homebrew/editor/metadataEditor/metadataEditor.less
index a852ad41b..f0974fb6c 100644
--- a/client/homebrew/editor/metadataEditor/metadataEditor.less
+++ b/client/homebrew/editor/metadataEditor/metadataEditor.less
@@ -46,6 +46,9 @@
background : #ffb9b9;
}
}
+ input[type='text'], textarea {
+ border : 1px solid gray;
+ }
&.thumbnail{
height : 1.4em;
label{
diff --git a/client/homebrew/editor/metadataEditor/validations.js b/client/homebrew/editor/metadataEditor/validations.js
index 0023c6008..3c35c8a38 100644
--- a/client/homebrew/editor/metadataEditor/validations.js
+++ b/client/homebrew/editor/metadataEditor/validations.js
@@ -1,12 +1,12 @@
module.exports = {
title : [
(value)=>{
- return value?.length > 10 ? 'Max URL length of 10 characters' : null;
+ return value?.length > 10 ? 'Max title length of 10 characters' : null;
}
],
description : [
(value)=>{
- return value?.length > 10 ? 'Max URL length of 10 characters' : null;
+ return value?.length > 10 ? 'Max description length of 10 characters' : null;
}
],
thumbnail : [
From b6c09683beaa8aa7d1297a4590f35809bfe5e080 Mon Sep 17 00:00:00 2001
From: Gazook89 <58999374+Gazook89@users.noreply.github.com>
Date: Sat, 5 Nov 2022 19:11:36 -0500
Subject: [PATCH 08/13] add language field validation (for future pr)
fix an oversight in validations
---
client/homebrew/editor/metadataEditor/validations.js | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/client/homebrew/editor/metadataEditor/validations.js b/client/homebrew/editor/metadataEditor/validations.js
index 3c35c8a38..8c4f27382 100644
--- a/client/homebrew/editor/metadataEditor/validations.js
+++ b/client/homebrew/editor/metadataEditor/validations.js
@@ -1,17 +1,22 @@
module.exports = {
title : [
(value)=>{
- return value?.length > 10 ? 'Max title length of 10 characters' : null;
+ return value?.length > 100 ? 'Max title length of 100 characters' : null;
}
],
description : [
(value)=>{
- return value?.length > 10 ? 'Max description length of 10 characters' : null;
+ return value?.length > 500 ? 'Max description length of 500 characters.' : null;
}
],
thumbnail : [
(value)=>{
- return value?.length > 5 ? 'Max URL length of 5 characters' : null;
+ return value?.length > 256 ? 'Max URL length of 256 characters.' : null;
+ }
+ ],
+ language : [
+ (value)=>{
+ return new RegExp(/[a-z]{2,3}(-.*)?/).test(value || '') === false ? 'Invalid language code.' : null;
}
]
};
From 970d03a5e42d07519789b24e6f161491d5253d36 Mon Sep 17 00:00:00 2001
From: Gazook89 <58999374+Gazook89@users.noreply.github.com>
Date: Sun, 6 Nov 2022 13:17:39 -0600
Subject: [PATCH 09/13] validate thumbnail is URL
---
client/homebrew/editor/metadataEditor/metadataEditor.jsx | 2 +-
client/homebrew/editor/metadataEditor/validations.js | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.jsx b/client/homebrew/editor/metadataEditor/metadataEditor.jsx
index 47110c097..d98a15113 100644
--- a/client/homebrew/editor/metadataEditor/metadataEditor.jsx
+++ b/client/homebrew/editor/metadataEditor/metadataEditor.jsx
@@ -275,7 +275,7 @@ const MetadataEditor = createClass({
this.handleFieldChange('thumbnail', e)} />
;
},
- // renderErrors : function(){
- // if(Object.values(this.state.errs ?? {}).filter(Boolean).length > 0) return;
- // return
- // },
-
render : function(){
return
From b23a09b1b8d8a5b4fd9fe8cc2430f4aa9cf74665 Mon Sep 17 00:00:00 2001
From: Trevor Buckner
Date: Thu, 17 Nov 2022 21:58:24 -0500
Subject: [PATCH 13/13] cleanup
---
client/homebrew/editor/metadataEditor/metadataEditor.jsx | 2 --
1 file changed, 2 deletions(-)
diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.jsx b/client/homebrew/editor/metadataEditor/metadataEditor.jsx
index 2f879f7e3..b5f9ddc25 100644
--- a/client/homebrew/editor/metadataEditor/metadataEditor.jsx
+++ b/client/homebrew/editor/metadataEditor/metadataEditor.jsx
@@ -15,8 +15,6 @@ const SYSTEMS = ['5e', '4e', '3.5e', 'Pathfinder'];
const homebreweryThumbnail = require('../../thumbnail.png');
-
-
const MetadataEditor = createClass({
displayName : 'MetadataEditor',
getDefaultProps : function() {