From e5febc1feffbc28499cbee32b1fb767f47c2c8be Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Tue, 13 Dec 2022 21:06:47 -0600 Subject: [PATCH] update ui to include invitedAuthors array --- .../editor/metadataEditor/metadataEditor.jsx | 21 +++++++++++++-- .../editor/metadataEditor/metadataEditor.less | 20 +++++++++++--- .../stringArrayEditor/stringArrayEditor.jsx | 27 ++++++++++++------- client/homebrew/pages/editPage/editPage.jsx | 11 ++++++++ 4 files changed, 63 insertions(+), 16 deletions(-) diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.jsx b/client/homebrew/editor/metadataEditor/metadataEditor.jsx index ac644f1a1..227993ebd 100644 --- a/client/homebrew/editor/metadataEditor/metadataEditor.jsx +++ b/client/homebrew/editor/metadataEditor/metadataEditor.jsx @@ -250,6 +250,8 @@ const MetadataEditor = createClass({ render : function(){ return
+

Brew

+
this.handleFieldChange('tags', e)}/> - {this.renderAuthors()} -
@@ -296,6 +296,23 @@ const MetadataEditor = createClass({ {this.renderRenderOptions()} +
+ +

Authors

+ + {this.renderAuthors()} + + !this.props.metadata.authors.includes(v)]} + placeholder='invite author' unique={true} + values={this.props.metadata.invitedAuthors} + notes={['Invited authors are case sensitive.', 'After adding an invited author, send them the edit link. There, they can choose to accept or decline the invitation.']} + onChange={(e)=>this.handleFieldChange('invitedAuthors', e)}/> + +
+ +

Privacy

+
diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.less b/client/homebrew/editor/metadataEditor/metadataEditor.less index f0974fb6c..be1a9aa9c 100644 --- a/client/homebrew/editor/metadataEditor/metadataEditor.less +++ b/client/homebrew/editor/metadataEditor/metadataEditor.less @@ -10,6 +10,15 @@ height : calc(100vh - 54px); // 54px is the height of the navbar + snippet bar. probably a better way to dynamic get this. overflow-y : auto; + .sectionHead { + font-weight: 1000; + margin: 20px 0; + + &:first-of-type { + margin-top: 0; + } + } + & > div { margin-bottom: 10px; } @@ -30,6 +39,7 @@ } .field{ display : flex; + flex-wrap : wrap; width : 100%; min-width : 200px; &>label{ @@ -78,6 +88,11 @@ font-size : 0.8em; } } + + small { + font-size : 0.6em; + font-style : italic; + } } @@ -128,10 +143,6 @@ button.unpublish{ .button(@silver); } - small{ - font-size : 0.6em; - font-style : italic; - } } .delete.field .value{ @@ -196,6 +207,7 @@ } .field .list { display: flex; + flex: 1 0; flex-wrap: wrap; > * { diff --git a/client/homebrew/editor/stringArrayEditor/stringArrayEditor.jsx b/client/homebrew/editor/stringArrayEditor/stringArrayEditor.jsx index 790cfba95..4fc570cef 100644 --- a/client/homebrew/editor/stringArrayEditor/stringArrayEditor.jsx +++ b/client/homebrew/editor/stringArrayEditor/stringArrayEditor.jsx @@ -9,7 +9,9 @@ const StringArrayEditor = createClass({ label : '', values : [], valuePatterns : null, + validators : [], placeholder : '', + notes : [], unique : false, cannotEdit : [], onChange : ()=>{} @@ -83,7 +85,8 @@ const StringArrayEditor = createClass({ } const matchesPatterns = !this.props.valuePatterns || this.props.valuePatterns.some((pattern)=>!!(value || '').match(pattern)); const uniqueIfSet = !this.props.unique || !values.includes(value); - return matchesPatterns && uniqueIfSet; + const passesValidators = !this.props.validators || this.props.validators.every((validator)=>validator(value)); + return matchesPatterns && uniqueIfSet && passesValidators; }, handleValueInputKeyDown : function(event, index) { @@ -123,17 +126,21 @@ const StringArrayEditor = createClass({
); - return
+ return
-
- {valueElements} -
- this.handleValueInputKeyDown(e)} - onChange={(e)=>this.setState({ temporaryValue: e.target.value })}/> - {this.valueIsValid(this.state.temporaryValue) ?
{ e.stopPropagation(); this.addValue(this.state.temporaryValue); }}>
: null} +
+
+ {valueElements} +
+ this.handleValueInputKeyDown(e)} + onChange={(e)=>this.setState({ temporaryValue: e.target.value })}/> + {this.valueIsValid(this.state.temporaryValue) ?
{ e.stopPropagation(); this.addValue(this.state.temporaryValue); }}>
: null} +
+ + {this.props.notes ? this.props.notes.map((n)=>

{n}

) : null}
; } diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index 0f6c5387e..61c42297d 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -330,6 +330,17 @@ const EditPage = createClass({ ; } + if(this.state.errors.response.error.status === 409) { + console.log(this.state.errors.response); + const message = this.state.errors.response.body?.message; + return + Oops! +
+ {message ? message : 'Conflict: please refresh to get latest changes'} +
+
; + } + return Oops!