add lists modal stuff

This commit is contained in:
zeppi 2021-06-11 14:54:42 -04:00 committed by jessopb
parent cbf0be3f3c
commit 5680b19dc8

View file

@ -42,6 +42,7 @@ const ClaimCollectionAdd = (props: Props) => {
function handleAddCollection() { function handleAddCollection() {
addCollection(newCollectionName, [permanentUrl], isChannel ? 'collection' : 'playlist'); addCollection(newCollectionName, [permanentUrl], isChannel ? 'collection' : 'playlist');
setNewCollectionName(''); setNewCollectionName('');
setAddNewCollection(false);
} }
function altEnterListener(e: SyntheticKeyboardEvent<*>) { function altEnterListener(e: SyntheticKeyboardEvent<*>) {
@ -60,6 +61,18 @@ const ClaimCollectionAdd = (props: Props) => {
window.removeEventListener('keydown', altEnterListener); window.removeEventListener('keydown', altEnterListener);
} }
function handleDone() {
if (addNewCollection && newCollectionName) {
handleAddCollection();
}
closeModal();
}
function handleClearNew() {
setNewCollectionName('');
setAddNewCollection(false);
}
return ( return (
<Card <Card
title={__('Add To...')} title={__('Add To...')}
@ -107,13 +120,22 @@ const ClaimCollectionAdd = (props: Props) => {
onFocus={onTextareaFocus} onFocus={onTextareaFocus}
onBlur={onTextareaBlur} onBlur={onTextareaBlur}
inputButton={ inputButton={
<>
<Button <Button
button={'secondary'} button={'alt'}
icon={ICONS.ADD} icon={ICONS.ADD}
className={'button-toggle'}
disabled={!newCollectionName.length} disabled={!newCollectionName.length}
onClick={() => handleAddCollection()} onClick={() => handleAddCollection()}
ref={buttonref} ref={buttonref}
/> />
<Button
button={'alt'}
className={'button-toggle'}
icon={ICONS.REMOVE}
onClick={() => handleClearNew()}
/>
</>
} }
onChange={handleNameInput} onChange={handleNameInput}
/> />
@ -123,7 +145,7 @@ const ClaimCollectionAdd = (props: Props) => {
)} )}
</fieldset-section> </fieldset-section>
<div className="card__actions"> <div className="card__actions">
<Button button="secondary" label={__('Done')} onClick={closeModal} /> <Button button="secondary" label={__('Done')} disabled={addNewCollection} onClick={handleDone} />
</div> </div>
</div> </div>
} }