MCPcopy Create free account
hub / github.com/cryptii/cryptii / viewAddButtonDidClick

Method viewAddButtonDidClick

src/Pipe.js:926–945  ·  view source on GitHub ↗

* Triggered when view add button has been clicked. * @protected * @param {PipeView} view * @param {number} index

(view, index)

Source from the content-addressed store, hash-verified

924 * @param {number} index
925 */
926 async viewAddButtonDidClick (view, index) {
927 // Track action
928 EventManager.trigger('pipeAddButtonClick', { pipe: this, index })
929
930 // Offer all bricks in the modal view
931 const modalView = this.getLibraryModalView()
932 modalView.clearFilter()
933
934 let name
935 try {
936 name = await modalView.prompt()
937 } catch (error) {
938 // Stop here when user cancels the modal view
939 return
940 }
941
942 // Create brick and add it to the pipe
943 const brick = this.getBrickFactory().create(name)
944 this.spliceBricks(index, 0, [brick])
945 }
946
947 /**
948 * Triggered when a brick is dropped on given index.

Callers 1

_createPipePartMethod · 0.80

Calls 7

getLibraryModalViewMethod · 0.95
getBrickFactoryMethod · 0.95
spliceBricksMethod · 0.95
triggerMethod · 0.80
clearFilterMethod · 0.80
promptMethod · 0.80
createMethod · 0.45

Tested by

no test coverage detected