From 3dcc6fb95a8c62825e45ce98112af09dc5b2a52f Mon Sep 17 00:00:00 2001 From: Ming Hay Luk Date: Mon, 15 Jul 2024 13:47:37 -0700 Subject: [PATCH] Adds success messaging for add to collection modal --- .../modal/add-to-collection/component.js | 30 +++++++++++++---- .../modal/add-to-collection/template.hbs | 7 ++++ .../modal/add-to-collection/component-test.js | 32 +++++++++++++------ 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/app/components/collection/modal/add-to-collection/component.js b/app/components/collection/modal/add-to-collection/component.js index 67085f7a8..c9543fc21 100644 --- a/app/components/collection/modal/add-to-collection/component.js +++ b/app/components/collection/modal/add-to-collection/component.js @@ -7,7 +7,9 @@ import { createCollectionBody, getCollectionsWithoutPipeline } from './util'; export default class CollectionModalAddToCollectionModalComponent extends Component { @service shuttle; - @tracked errorMessage; + @tracked errorMessage = null; + + @tracked successMessage = null; @tracked newCollectionName = ''; @@ -60,6 +62,7 @@ export default class CollectionModalAddToCollectionModalComponent extends Compon ) ) .then(() => { + this.successMessage = `Successfully created new collection: ${this.newCollectionName}`; this.newCollectionName = ''; this.newCollectionDescription = ''; }) @@ -95,6 +98,7 @@ export default class CollectionModalAddToCollectionModalComponent extends Compon async submitCollections() { this.isAwaitingResponse = true; this.errorMessage = null; + this.successMessage = null; return new Promise(resolve => { Promise.allSettled([ @@ -114,12 +118,24 @@ export default class CollectionModalAddToCollectionModalComponent extends Compon )}`; } } else { - this.selectedCollections.forEach(collection => { - document.getElementById( - `collection-${collection.id}` - ).disabled = true; - }); - this.selectedCollections = []; + const collectionNames = this.selectedCollections + .map(collection => collection.name) + .join(', '); + + if (collectionNames.length > 0) { + if (this.successMessage) { + this.successMessage += `. Also added pipeline to collections: ${collectionNames}`; + } else { + this.successMessage = `Successfully added pipeline to collections: ${collectionNames}`; + } + + this.selectedCollections.forEach(collection => { + document.getElementById( + `collection-${collection.id}` + ).disabled = true; + }); + this.selectedCollections = []; + } } resolve(); }); diff --git a/app/components/collection/modal/add-to-collection/template.hbs b/app/components/collection/modal/add-to-collection/template.hbs index e0869fe6b..798e14263 100644 --- a/app/components/collection/modal/add-to-collection/template.hbs +++ b/app/components/collection/modal/add-to-collection/template.hbs @@ -15,6 +15,13 @@ @icon="exclamation-triangle" /> {{/if}} + {{#if this.successMessage}} + + {{/if}}