Merge pull request #250 from openreplay/metadata-disable

Metadata disable on delete
This commit is contained in:
Shekar Siri 2021-12-15 14:56:41 +05:30 committed by GitHub
commit 651396e49a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 7 deletions

View file

@ -23,7 +23,7 @@ import { confirm } from 'UI/Confirmation';
})
@withPageTitle('Metadata - OpenReplay Preferences')
class CustomFields extends React.Component {
state = { showModal: false, currentSite: this.props.sites.get(0) };
state = { showModal: false, currentSite: this.props.sites.get(0), deletingItem: null };
componentWillMount() {
const activeSite = this.props.sites.get(0);
@ -60,15 +60,15 @@ class CustomFields extends React.Component {
confirmation: `Are you sure you want to remove?`
})) {
const { currentSite } = this.state;
this.props.remove(currentSite.id, field.index).then(() => {
});
this.setState({ deletingItem: field.index });
this.props.remove(currentSite.id, field.index)
.then(() => this.setState({ deletingItem: null }));
}
}
render() {
const { fields, field, loading } = this.props;
const { showModal, currentSite } = this.state;
const { showModal, currentSite, deletingItem } = this.state;
return (
<div>
<SlideModal
@ -105,6 +105,7 @@ class CustomFields extends React.Component {
<div className={ styles.list }>
{ fields.filter(i => i.index).map(field => (
<ListItem
disabled={deletingItem && deletingItem === field.index}
key={ field._key }
field={ field }
onEdit={ this.init }

View file

@ -3,9 +3,9 @@ import cn from 'classnames'
import { Icon } from 'UI';
import styles from './listItem.css';
const ListItem = ({ field, onEdit, onDelete }) => {
const ListItem = ({ field, onEdit, onDelete, disabled }) => {
return (
<div className={ cn(styles.wrapper, field.index === 0 ? styles.preDefined : '' ) } onClick={ () => field.index != 0 && onEdit(field) } >
<div className={ cn(styles.wrapper, field.index === 0 ? styles.preDefined : '', { [styles.disabled] : disabled} ) } onClick={ () => field.index != 0 && onEdit(field) } >
<span>{ field.key }</span>
<div className={ styles.actions } data-hidden={ field.index === 0}>
<div className={ styles.button } onClick={ (e) => { e.stopPropagation(); onDelete(field) } }>

View file

@ -47,4 +47,9 @@
border-radius: 10px;
background-color: $gray-lightest;
box-shadow: 0 0 0 1px $gray-light inset;
}
.disabled {
opacity: 0.5;
pointer-events: none;
}