]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Fix controls for unchangeable properties on status edit not being disabled
authorClaire <claire.github-309c@sitedethib.com>
Sat, 12 Feb 2022 18:00:33 +0000 (19:00 +0100)
committerClaire <claire.github-309c@sitedethib.com>
Sat, 12 Feb 2022 21:36:39 +0000 (22:36 +0100)
Port 38845592c4b4456b5b407bd320249613a0f16e13 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
app/javascript/flavours/glitch/features/compose/components/compose_form.js
app/javascript/flavours/glitch/features/compose/components/options.js
app/javascript/flavours/glitch/features/compose/components/privacy_dropdown.js
app/javascript/flavours/glitch/features/compose/components/upload.js
app/javascript/flavours/glitch/features/compose/containers/upload_container.js

index 47dc87f163cfa2d40082b7cbe9a9ee9dc7defb43..c75906ce72874dec296eb89ba2c5247bbf68405b 100644 (file)
@@ -355,6 +355,7 @@ class ComposeForm extends ImmutablePureComponent {
             onToggleSpoiler={spoilersAlwaysOn ? null : onChangeSpoilerness}
             onUpload={onPaste}
             privacy={privacy}
+            isEditing={isEditing}
             sensitive={sensitive || (spoilersAlwaysOn && spoilerText && spoilerText.length > 0)}
             spoiler={spoilersAlwaysOn ? (spoilerText && spoilerText.length > 0) : spoiler}
           />
index 085da18ea4ea45467d569481f1218d66645d4939..3a31e214d8a274de23bf09b72bf893063b1b5a2e 100644 (file)
@@ -138,6 +138,7 @@ class ComposerOptions extends ImmutablePureComponent {
     resetFileKey: PropTypes.number,
     spoiler: PropTypes.bool,
     showContentTypeChoice: PropTypes.bool,
+    isEditing: PropTypes.bool,
   };
 
   //  Handles file selection.
@@ -202,6 +203,7 @@ class ComposerOptions extends ImmutablePureComponent {
       resetFileKey,
       spoiler,
       showContentTypeChoice,
+      isEditing,
       intl: { formatMessage },
     } = this.props;
 
@@ -273,7 +275,7 @@ class ComposerOptions extends ImmutablePureComponent {
         )}
         <hr />
         <PrivacyDropdown
-          disabled={disabled}
+          disabled={disabled || isEditing}
           onChange={onChangeVisibility}
           onModalClose={onModalClose}
           onModalOpen={onModalOpen}
@@ -306,7 +308,7 @@ class ComposerOptions extends ImmutablePureComponent {
         )}
         <Dropdown
           active={advancedOptions && advancedOptions.some(value => !!value)}
-          disabled={disabled}
+          disabled={disabled || isEditing}
           icon='ellipsis-h'
           items={advancedOptions ? [
             {
index 3bf25b3a4c508f7e1b3dbe0f0c07c3af916b7de3..c8e783d223b8be737ca67698e8a3af27214575b0 100644 (file)
@@ -27,6 +27,7 @@ class PrivacyDropdown extends React.PureComponent {
     onChange: PropTypes.func.isRequired,
     noDirect: PropTypes.bool,
     container: PropTypes.func,
+    disabled: PropTypes.bool,
     intl: PropTypes.object.isRequired,
   };
 
index 425b0fe5e8b161071f11234ca5e93a91fdc89034..338bfca37ceec538dc25c04378e88237784ee8b2 100644 (file)
@@ -19,6 +19,7 @@ export default class Upload extends ImmutablePureComponent {
     media: ImmutablePropTypes.map.isRequired,
     onUndo: PropTypes.func.isRequired,
     onOpenFocalPoint: PropTypes.func.isRequired,
+    isEditingStatus: PropTypes.func.isRequired,
   };
 
   handleUndoClick = e => {
@@ -32,7 +33,7 @@ export default class Upload extends ImmutablePureComponent {
   }
 
   render () {
-    const { intl, media } = this.props;
+    const { intl, media, isEditingStatus } = this.props;
     const focusX = media.getIn(['meta', 'focus', 'x']);
     const focusY = media.getIn(['meta', 'focus', 'y']);
     const x = ((focusX /  2) + .5) * 100;
@@ -45,7 +46,7 @@ export default class Upload extends ImmutablePureComponent {
             <div style={{ transform: `scale(${scale})`, backgroundImage: `url(${media.get('preview_url')})`, backgroundPosition: `${x}% ${y}%` }}>
               <div className={classNames('composer--upload_form--actions', { active: true })}>
                 <button className='icon-button' onClick={this.handleUndoClick}><Icon id='times' /> <FormattedMessage id='upload_form.undo' defaultMessage='Delete' /></button>
-                <button className='icon-button' onClick={this.handleFocalPointClick}><Icon id='pencil' /> <FormattedMessage id='upload_form.edit' defaultMessage='Edit' /></button>
+                {!isEditingStatus && (<button className='icon-button' onClick={this.handleFocalPointClick}><Icon id='pencil' /> <FormattedMessage id='upload_form.edit' defaultMessage='Edit' /></button>)}
               </div>
             </div>
           )}
index f3ca4ce7bbde862a15c3ffab953a2ac3e85e8ac6..d6256fe966fe251c64bbc1974c4d4df228f70097 100644 (file)
@@ -5,6 +5,7 @@ import { submitCompose } from 'flavours/glitch/actions/compose';
 
 const mapStateToProps = (state, { id }) => ({
   media: state.getIn(['compose', 'media_attachments']).find(item => item.get('id') === id),
+  isEditingStatus: state.getIn(['compose', 'id']) !== null,
 });
 
 const mapDispatchToProps = dispatch => ({