[Glitch] Fix controls for unchangeable properties on status edit not being disabled

Port 38845592c4 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Claire 2022-02-12 19:00:33 +01:00
parent c9669ee167
commit f3429d7354
5 changed files with 10 additions and 4 deletions

View file

@ -355,6 +355,7 @@ class ComposeForm extends ImmutablePureComponent {
onToggleSpoiler={spoilersAlwaysOn ? null : onChangeSpoilerness} onToggleSpoiler={spoilersAlwaysOn ? null : onChangeSpoilerness}
onUpload={onPaste} onUpload={onPaste}
privacy={privacy} privacy={privacy}
isEditing={isEditing}
sensitive={sensitive || (spoilersAlwaysOn && spoilerText && spoilerText.length > 0)} sensitive={sensitive || (spoilersAlwaysOn && spoilerText && spoilerText.length > 0)}
spoiler={spoilersAlwaysOn ? (spoilerText && spoilerText.length > 0) : spoiler} spoiler={spoilersAlwaysOn ? (spoilerText && spoilerText.length > 0) : spoiler}
/> />

View file

@ -138,6 +138,7 @@ class ComposerOptions extends ImmutablePureComponent {
resetFileKey: PropTypes.number, resetFileKey: PropTypes.number,
spoiler: PropTypes.bool, spoiler: PropTypes.bool,
showContentTypeChoice: PropTypes.bool, showContentTypeChoice: PropTypes.bool,
isEditing: PropTypes.bool,
}; };
// Handles file selection. // Handles file selection.
@ -202,6 +203,7 @@ class ComposerOptions extends ImmutablePureComponent {
resetFileKey, resetFileKey,
spoiler, spoiler,
showContentTypeChoice, showContentTypeChoice,
isEditing,
intl: { formatMessage }, intl: { formatMessage },
} = this.props; } = this.props;
@ -273,7 +275,7 @@ class ComposerOptions extends ImmutablePureComponent {
)} )}
<hr /> <hr />
<PrivacyDropdown <PrivacyDropdown
disabled={disabled} disabled={disabled || isEditing}
onChange={onChangeVisibility} onChange={onChangeVisibility}
onModalClose={onModalClose} onModalClose={onModalClose}
onModalOpen={onModalOpen} onModalOpen={onModalOpen}
@ -306,7 +308,7 @@ class ComposerOptions extends ImmutablePureComponent {
)} )}
<Dropdown <Dropdown
active={advancedOptions && advancedOptions.some(value => !!value)} active={advancedOptions && advancedOptions.some(value => !!value)}
disabled={disabled} disabled={disabled || isEditing}
icon='ellipsis-h' icon='ellipsis-h'
items={advancedOptions ? [ items={advancedOptions ? [
{ {

View file

@ -27,6 +27,7 @@ class PrivacyDropdown extends React.PureComponent {
onChange: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired,
noDirect: PropTypes.bool, noDirect: PropTypes.bool,
container: PropTypes.func, container: PropTypes.func,
disabled: PropTypes.bool,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
}; };

View file

@ -19,6 +19,7 @@ export default class Upload extends ImmutablePureComponent {
media: ImmutablePropTypes.map.isRequired, media: ImmutablePropTypes.map.isRequired,
onUndo: PropTypes.func.isRequired, onUndo: PropTypes.func.isRequired,
onOpenFocalPoint: PropTypes.func.isRequired, onOpenFocalPoint: PropTypes.func.isRequired,
isEditingStatus: PropTypes.func.isRequired,
}; };
handleUndoClick = e => { handleUndoClick = e => {
@ -32,7 +33,7 @@ export default class Upload extends ImmutablePureComponent {
} }
render () { render () {
const { intl, media } = this.props; const { intl, media, isEditingStatus } = this.props;
const focusX = media.getIn(['meta', 'focus', 'x']); const focusX = media.getIn(['meta', 'focus', 'x']);
const focusY = media.getIn(['meta', 'focus', 'y']); const focusY = media.getIn(['meta', 'focus', 'y']);
const x = ((focusX / 2) + .5) * 100; 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 style={{ transform: `scale(${scale})`, backgroundImage: `url(${media.get('preview_url')})`, backgroundPosition: `${x}% ${y}%` }}>
<div className={classNames('composer--upload_form--actions', { active: true })}> <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.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>
</div> </div>
)} )}

View file

@ -5,6 +5,7 @@ import { submitCompose } from 'flavours/glitch/actions/compose';
const mapStateToProps = (state, { id }) => ({ const mapStateToProps = (state, { id }) => ({
media: state.getIn(['compose', 'media_attachments']).find(item => item.get('id') === id), media: state.getIn(['compose', 'media_attachments']).find(item => item.get('id') === id),
isEditingStatus: state.getIn(['compose', 'id']) !== null,
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({