MCPcopy
hub / github.com/apache/caldera / addTab

Function addTab

static/js/core.js:44–71  ·  view source on GitHub ↗
(tabName, address, queryString = '')

Source from the content-addressed store, hash-verified

42 },
43
44 async addTab(tabName, address, queryString = '') {
45 // Field manual does not create a tab
46 if (tabName === 'fieldmanual') {
47 restRequest('GET', null, (data) => { this.setTabContent({ name: tabName, contentID: `tab-${tabName}`, address: address }, data); }, address);
48 return;
49 }
50
51 // If tab is already open, jump to it
52 const existingTabIndex = this.openTabs.findIndex((tab) => tab.name === tabName);
53 if (existingTabIndex !== -1) {
54 this.activeTabIndex = existingTabIndex;
55 this.checkQueryString(queryString);
56 return;
57 }
58
59 // Tab does not exist, create it
60 const tab = { name: tabName, contentID: `tab-${tabName}`, address: address };
61
62 this.openTabs.push(tab);
63 this.activeTabIndex = this.openTabs.length - 1;
64 try {
65 this.setTabContent(tab, await apiV2('GET', tab.address));
66 this.checkQueryString(queryString);
67 } catch (error) {
68 toast('Unable to load page', false);
69 console.error(error);
70 }
71 },
72
73 checkQueryString(queryString) {
74 if (history.pushState) {

Callers

nothing calls this directly

Calls 3

restRequestFunction · 0.85
apiV2Function · 0.85
toastFunction · 0.85

Tested by

no test coverage detected