SoapboxConfig: Rudimentary deletion of rows
This commit is contained in:
parent
2470e59596
commit
d310fb4f18
|
@ -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>
|
||||
))
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue