Readonly
typeType of the content item. Always stack, but useful for distinguishing between a TabStack and ColumnOrRow.
Experimental
Adds or creates a view in this TabStack.
The identity of an existing view to add, or options to create a view.
Optional view options: index number used to insert the view into the stack at that index. Defaults to 0 (front of the stack)
Resolves with the identity of the added view.
Known Issue: If adding a view overflows the tab-container, the added view will be set as active and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
If the view does not exist or fails to create.
If the TabStack has been destroyed.
if (!fin.me.isView) {
throw new Error('Not running in a platform View.');
}
const stack = await fin.me.getCurrentStack();
// Alternatively, you can wrap any view and get the stack from there
// const viewFromSomewhere = fin.View.wrapSync(someView.identity);
// const stack = await viewFromSomewhere.getCurrentStack();
const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
console.log('Identity of the google view just added', { googleViewIdentity });
// pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
console.log('Identity of the apple view just added', { appleViewIdentity });
Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
Optional
position?: LayoutPositionif (!fin.me.isView) {
throw new Error('Not running in a platform View.');
}
const stack = await fin.me.getCurrentStack();
const columnOrRow = await stack.getParent();
// Create view references by supplying a 'name' and 'url'
const views = [
// if 'name' is undefined, one will be generated
// if 'url' is undefined, it will default the view URL to 'about:blank'
{ name: 'google-view', url: 'http://google.com/'},
{ name: 'of-developers-view', url: 'http://developers.openfin.co/'},
];
// Create a view beforehand to be included in the new tab stack
const outsideView = await fin.View.create({
name: 'outside-bloomberg-view',
url: 'https://bloomberg.com/',
target: fin.me.identity,
});
// Views to add can be identities, or the reference views mentioned above
const viewsToAdd = [outsideView.identity, ...views];
// Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
// Or
let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
Checks if the TabStack or ColumnOrRow exists
if (!fin.me.isView) {
throw new Error('Not running in a platform View.');
}
const stack = await fin.me.getCurrentStack();
// Retrieves the parent ColumnOrRow
const columnOrRow = await stack.getParent();
let exists = await stack.exists();
// or
let exists = await columnOrRow.exists();
// The entity exists: true
console.log(`The entity exists: ${exists}`);
Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow
if (!fin.me.isView) {
throw new Error('Not running in a platform View.');
}
const stack = await fin.me.getCurrentStack();
const columnOrRow = await stack.getParent();
// Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
let rightStacks = await columnOrRow.getAdjacentStacks('right');
let leftStacks = await columnOrRow.getAdjacentStacks('left');
// or
let rightStacks = await stack.getAdjacentStacks('right');
let leftStacks = await stack.getAdjacentStacks('left');
console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
Retrieves the parent of the TabStack or ColumnOrRow
if (!fin.me.isView) {
throw new Error('Not running in a platform View.');
}
const stack = await fin.me.getCurrentStack();
// Retrieves the parent ColumnOrRow
const columnOrRow = await stack.getParent();
// undefined if entity is the root item
let parent = await columnOrRow.getParent();
// or
let parent = await stack.getParent();
Experimental
Retrieves a list of all views belonging to this TabStack.
Known Issue: If adding a view overflows the tab-container width, the added view will be set as active and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged. If that happens and then getViews() is called, it will return the identities in a different order than than the currently rendered tab order.
If the TabStack has been destroyed.
if (!fin.me.isView) {
throw new Error('Not running in a platform View.');
}
const stack = await fin.me.getCurrentStack();
// Alternatively, you can wrap any view and get the stack from there
// const viewFromSomewhere = fin.View.wrapSync(someView.identity);
// const stack = await viewFromSomewhere.getCurrentStack();
const views = await stack.getViews();
console.log(`Stack contains ${views.length} view(s)`);
Checks if the TabStack or ColumnOrRow is the root content item
if (!fin.me.isView) {
throw new Error('Not running in a platform View.');
}
const stack = await fin.me.getCurrentStack();
const isRoot = await stack.isRoot();
// The TabStack is root: false
console.log(`The TabStack is root: ${isRoot}`);
// Retrieves the parent ColumnOrRow
const parent = await stack.getParent();
const parentIsRoot = await parent.isRoot();
// The parent ColumnOrRow is root: true
console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
Removes a view from this TabStack.
Identity of the view to remove.
Throws an exception if the view identity does not exist or was already destroyed.
If the view does not exist or does not belong to the stack.
If the TabStack has been destroyed.
if (!fin.me.isView) {
throw new Error('Not running in a platform View.');
}
const stack = await fin.me.getCurrentStack();
const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
await stack.removeView(googleViewIdentity);
try {
await stack.removeView(googleViewIdentity);
} catch (error) {
// Tried to remove a view ('google-view') which does not belong to the stack.
console.log(error);
}
Experimental
Sets the active view of the TabStack without focusing it.
Identity of the view to activate.
Promise which resolves with void once the view has been activated.
If the TabStack has been destroyed.
If the view does not exist.
Change the active tab of a known View's TabStack:
const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
const stack = await targetView.getCurrentStack();
await stack.setActiveView(targetView.identity);
Set the current View as active within its TabStack:
const stack = await fin.me.getCurrentStack();
await stack.setActiveView(fin.me.identity);
Static
get
A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.