Skip to content

Commit

Permalink
doc: extra comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pozil committed May 23, 2024
1 parent 413734f commit 7036042
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ export default class WorkspaceAPICloseTab extends LightningElement {
@wire(IsConsoleNavigation) isConsoleNavigation;

async closeTab() {
// Ensure that we're in a console app
if (!this.isConsoleNavigation) {
return;
}

// Close current tab
const { tabId } = await getFocusedTabInfo();
await closeTab(tabId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ export default class WorkspaceAPIDisableTabClose extends LightningElement {
@wire(IsConsoleNavigation) isConsoleNavigation;

async disableTabClose(event) {
// Ensure that we're in a console app
if (!this.isConsoleNavigation) {
return;
}

// Toggle the ability to close the tab
const close = event.detail.checked;
const { tabId } = await getFocusedTabInfo();
await disableTabClose(tabId, close);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ export default class WorkspaceAPIFocusTab extends LightningElement {
@wire(IsConsoleNavigation) isConsoleNavigation;

async focusNextTab() {
// Ensure that we're in a console app
if (!this.isConsoleNavigation) {
return;
}

// Get current tab and figure out which tab is next
const { tabId } = await getFocusedTabInfo();
const allTabs = await getAllTabInfo();
const selectedTabIndex = allTabs.findIndex(
(possibleNextTab) => possibleNextTab.tabId === tabId
);
const nextTabId = allTabs[selectedTabIndex + 1].tabId;

// Focus on next tab
await focusTab(nextTabId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ export default class WorkspaceAPIHighlightTab extends LightningElement {
@wire(IsConsoleNavigation) isConsoleNavigation;

async highlightTab(event) {
// Ensure that we're in a console app
if (!this.isConsoleNavigation) {
return;
}

// Toggle highlight for current tab
const highlighted = event.detail.checked;
const { tabId } = await getFocusedTabInfo();
setTabHighlighted(tabId, highlighted, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ export default class WorkspaceAPIOpenSubtab extends LightningElement {
@wire(EnclosingTabId) enclosingTabId;

findEnclosingTabAndOpenSubtab() {
// Ensure that we're in a console app and that we have a tab open
if (!this.isConsoleNavigation || !this.enclosingTabId) {
return;
}

// Open sub tab
openSubtab(this.enclosingTabId, {
pageReference: {
type: 'standard__objectPage',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ export default class WorkspaceAPIOpenTab extends LightningElement {
@wire(IsConsoleNavigation) isConsoleNavigation;

async openTab() {
// Ensure that we're in a console app
if (!this.isConsoleNavigation) {
return;
}

// Open contact list a new tab
await openTab({
pageReference: {
type: 'standard__objectPage',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ export default class WorkspaceAPIRefreshTab extends LightningElement {
@wire(IsConsoleNavigation) isConsoleNavigation;

async refreshTab() {
// Ensure that we're in a console app
if (!this.isConsoleNavigation) {
return;
}

// Refresh current tab
const { tabId } = await getFocusedTabInfo();
await refreshTab(tabId, {
includeAllSubtabs: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ export default class WorkspaceAPISetTabIcon extends LightningElement {
@wire(IsConsoleNavigation) isConsoleNavigation;

async setTabIcon() {
// Ensure that we're in a console app
if (!this.isConsoleNavigation) {
return;
}

// Change current tab icon
const { tabId } = await getFocusedTabInfo();
setTabIcon(tabId, TAB_ICON, {
iconAlt: TAB_ICON_ALT_TEXT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ export default class WorkspaceAPISetTabLabel extends LightningElement {
@wire(IsConsoleNavigation) isConsoleNavigation;

async setTabLabel() {
// Ensure that we're in a console app
if (!this.isConsoleNavigation) {
return;
}

// Change current tab label
const { tabId } = await getFocusedTabInfo();
setTabLabel(tabId, TAB_LABEL);
}
Expand Down

0 comments on commit 7036042

Please sign in to comment.