SoapboxConfig: Rudimentary deletion of rows

This commit is contained in:
Alex Gleason 2020-08-23 22:41:22 -05:00
parent 2470e59596
commit d310fb4f18
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 11 additions and 3 deletions

View File

@ -110,6 +110,13 @@ class SoapboxConfig extends ImmutablePureComponent {
};
};
handleDeleteItem = path => {
return e => {
const soapbox = this.state.soapbox.deleteIn(path);
this.setState({ soapbox });
};
};
handleItemChange = (path, key, field, template) => {
return this.handleChange(
path, (e) =>
@ -238,6 +245,7 @@ class SoapboxConfig extends ImmutablePureComponent {
value={field.get('url')}
onChange={this.handlePromoItemChange(i, 'url', field)}
/>
<a onClick={this.handleDeleteItem(['promoPanel', 'items', i])}>Delete</a>
</div>
))
}
@ -268,6 +276,7 @@ class SoapboxConfig extends ImmutablePureComponent {
value={field.get('url')}
onChange={this.handleHomeFooterItemChange(i, 'url', field)}
/>
<a onClick={this.handleDeleteItem(['navlinks', 'homeFooter', i])}>Delete</a>
</div>
))
}
@ -293,6 +302,7 @@ class SoapboxConfig extends ImmutablePureComponent {
value={field}
onChange={this.handleChange(['customCss', i], (e) => e.target.value)}
/>
<a onClick={this.handleDeleteItem(['customCss', i])}>Delete</a>
</div>
))
}

View File

@ -6,9 +6,7 @@ const initialState = ImmutableMap();
const updateFromAdmin = (state, config) => {
// TODO: Generalize this with an API similar to `Pleroma.Config` in Pleroma BE
const soapboxConfig = config.getIn(['configs', 0, 'value', 0, 'tuple', 1]);
if (soapboxConfig) return state.mergeDeep(soapboxConfig);
return state;
return config.getIn(['configs', 0, 'value', 0, 'tuple', 1], state);
};
export default function soapbox(state = initialState, action) {