# Workspace

**Kind**: interface | **Module**: [Workspaces](https://docs.interop.io/desktop/reference/javascript/workspaces/index.md)

**Source**: https://docs.interop.io/desktop/reference/javascript/workspaces/workspace/index.html

An object describing a workspace

## Properties

- **`allowDrop`** (`boolean`, optional)
  Indicates if dropping outsize windows to the workspace is allowed
- **`allowDropBottom`** (`boolean`, optional)
  Indicates if dropping windows in the bottom-most zone of the workspace is allowed
- **`allowDropLeft`** (`boolean`, optional)
  Indicates if dropping windows in the left-most zone of the workspace is allowed
- **`allowDropRight`** (`boolean`, optional)
  Indicates if dropping windows in the right-most zone of the workspace is allowed
- **`allowDropTop`** (`boolean`, optional)
  Indicates if dropping windows in the top-most zone of the workspace is allowed
- **`allowExtract`** (`boolean`, optional)
  Indicates if extracting windows from the workspace is allowed
- **`allowSplitters`** (`boolean`, optional)
  Indicates if dragging of splitters is allowed in the workspace
- **`allowSystemHibernation`** (`boolean`, optional)
  Indicates whether the Workspace can be hibernated via the platform configuration.
  This setting doesn't apply to programmatic hibernation via the `hibernate()` method of a `Workspace` instance.
- **`allowWindowReorder`** (`boolean`, optional)
  Indicates if reordering windows in the workspace is allowed
- **`allowWorkspaceTabExtract`** (`boolean`, optional)
  Controls whether the workspace tab can be extracted.
  *Available only in **io.Connect Desktop**.*
- **`allowWorkspaceTabReorder`** (`boolean`, optional)
  Controls whether the workspace tab can be reordered
- **`children`** (`WorkspaceElement[]`, required)
  A collection containing the immediate children of this workspace
- **`frame`** (`Frame`, required)
  An object representing the frame containing this workspace
- **`frameId`** (`string`, required)
  The string id of the frame containing this workspace
- **`height`** (`number`, optional)
  Returns the current height of the workspace
- **`icon`** (`string`, optional)
  The icon related to the workspace in the same format as it was passed
- **`id`** (`string`, required)
  An unique string identifier of the workspace
- **`isHibernated`** (`boolean`, optional)
  Indicates if the workspace is hibernated
- **`isPinned`** (`boolean`, optional)
  Indicates if the workspace is in a pinned state or not
- **`isSelected`** (`boolean`, optional)
  Indicates if the workspace is selected in its frame. Can be undefined if using with an older version of **io.Connect Desktop** or **io.Connect Browser**.
- **`layoutName`** (`string | undefined`, required)
  The name of the originating layout of the current workspace if any
- **`loadingStrategy`** (`LoadingStrategy`, optional)
  Indicates the loading strategy for the Workspace.
  *Available only in **io.Connect Desktop**.*
- **`maxHeight`** (`number`, optional)
  Returns the maximum height of the workspace, calculated by the constraints of all elements inside it
- **`maxWidth`** (`number`, optional)
  Returns the maximum width of the workspace, calculated by the constraints of all elements inside it
- **`minHeight`** (`number`, optional)
  Returns the minimum height of the workspace, calculated by the constraints of all elements inside it
- **`minWidth`** (`number`, optional)
  Returns the minimum width of the workspace, calculated by the constraints of all elements inside it
- **`positionIndex`** (`number`, required)
  The position of this workspace regarding it's siblings
- **`showAddWindowButtons`** (`boolean`, optional)
  Indicates if the window add buttons within this workspace are visible to the user
- **`showCloseButton`** (`boolean`, optional)
  Indicates if the close button for this workspace is visible to the user
- **`showEjectButtons`** (`boolean`, optional)
  Indicates if the eject buttons of the windows within this workspace are visible to the user
- **`showSaveButton`** (`boolean`, optional)
  Indicates if the save button for this workspace is visible to the user
- **`showWindowCloseButtons`** (`boolean`, optional)
  Indicates if the close buttons of the windows within this workspace are visible to the user
- **`title`** (`string`, required)
  The title of the workspace
- **`width`** (`number`, optional)
  Returns the current width of the workspace
- **`windowDragMode`** (`"keepInside" | "autoEject"`, optional)
  Mode for dragging the windows that are part of the Workspace. If set to `"autoEject"` (available only in **io.Connect Desktop**), when the user drags a Workspace window, it will be ejected from the Workspace during the dragging operation and the user will be able to drop it back inside the Workspace, or out of the Workspace.
  If set to `"keepInside"`, the window won't be ejected from the Workspace when being dragged and the user will be able to drop it only inside the Workspace.

## Methods

### addColumn

Adds a new column to this workspace.

```ts
(definition?: BoxDefinition) => Promise<Column>
```

**Parameters**

- **`definition`** (`BoxDefinition`, optional)
  An object describing the available column settings.

**Returns**: `Promise<Column>`

### addGroup

Adds a new group to this workspace.

```ts
(definition?: BoxDefinition) => Promise<Group>
```

**Parameters**

- **`definition`** (`BoxDefinition`, optional)
  An object describing the available group settings.

**Returns**: `Promise<Group>`

### addRow

Adds a new row to this workspace.

```ts
(definition?: BoxDefinition) => Promise<Row>
```

**Parameters**

- **`definition`** (`BoxDefinition`, optional)
  An object describing the available row settings.

**Returns**: `Promise<Row>`

### addWindow

Adds a new window to this workspace.

```ts
(definition: WorkspaceWindowDefinition) => Promise<WorkspaceWindow>
```

**Parameters**

- **`definition`** (`WorkspaceWindowDefinition`, required)
  An object describing the available window settings.

**Returns**: `Promise<WorkspaceWindow>`

### bundleToColumn

Transforms this workspace into a workspace with one immediate child of type column and all existing elements are inserted as a child to that row.

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### bundleToRow

Transforms this workspace into a workspace with one immediate child of type row and all existing elements are inserted as a child to that row.

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### close

Closes this workspace and all of it's children.

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### focus

Gives focus to this workspace.

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### getAllBoxes

Returns all boxes in this workspace, which satisfy the provided predicate. If no predicate was provided, will return all boxes.

```ts
(predicate?: (box: WorkspaceBox) => boolean) => WorkspaceBox[]
```

**Parameters**

- **`predicate`** (`(box: WorkspaceBox) => boolean`, optional)
  A filtering function (predicate) called for each box present in this workspace.

**Returns**: `WorkspaceBox[]`

### getAllColumns

Returns all columns in this workspace, which satisfy the provided predicate. If no predicate was provided, will return all column.

```ts
(predicate?: (columns: Column) => boolean) => Column[]
```

**Parameters**

- **`predicate`** (`(columns: Column) => boolean`, optional)
  A filtering function (predicate) called for each column present in this workspace.

**Returns**: `Column[]`

### getAllGroups

Returns all groups in this workspace, which satisfy the provided predicate. If no predicate was provided, will return all groups.

```ts
(predicate?: (group: Group) => boolean) => Group[]
```

**Parameters**

- **`predicate`** (`(group: Group) => boolean`, optional)
  A filtering function (predicate) called for each group present in this workspace.

**Returns**: `Group[]`

### getAllRows

Returns all rows in this workspace, which satisfy the provided predicate. If no predicate was provided, will return all rows.

```ts
(predicate?: (row: Row) => boolean) => Row[]
```

**Parameters**

- **`predicate`** (`(row: Row) => boolean`, optional)
  A filtering function (predicate) called for each row present in this workspace.

**Returns**: `Row[]`

### getAllWindows

Returns all windows in this workspace, which satisfy the provided predicate. If no predicate was provided, will return all windows.

```ts
(predicate?: (window: WorkspaceWindow) => boolean) => WorkspaceWindow[]
```

**Parameters**

- **`predicate`** (`(window: WorkspaceWindow) => boolean`, optional)
  A filtering function (predicate) called for each window present in this workspace.

**Returns**: `WorkspaceWindow[]`

### getBox

Returns the first box in this workspace, which satisfies the provided predicate.

```ts
(predicate: (box: WorkspaceBox) => boolean) => WorkspaceBox
```

**Parameters**

- **`predicate`** (`(box: WorkspaceBox) => boolean`, required)
  A filtering function (predicate) called for each box present in this workspace.

**Returns**: `WorkspaceBox`

### getColumn

Returns the first column in this workspace, which satisfies the provided predicate.

```ts
(predicate: (column: Column) => boolean) => Column
```

**Parameters**

- **`predicate`** (`(column: Column) => boolean`, required)
  A filtering function (predicate) called for each column present in this workspace.

**Returns**: `Column`

### getContext

Gets the context for this workspace.

```ts
() => Promise<any>
```

**Returns**: `Promise<any>`

### getGroup

Returns the first group in this workspace, which satisfies the provided predicate.

```ts
(predicate: (group: Group) => boolean) => Group
```

**Parameters**

- **`predicate`** (`(group: Group) => boolean`, required)
  A filtering function (predicate) called for each group present in this workspace.

**Returns**: `Group`

### getIcon

Returns the workspace icon

```ts
() => Promise<string>
```

**Returns**: `Promise<string>`

### getRow

Returns the first row in this workspace, which satisfies the provided predicate.

```ts
(predicate: (row: Row) => boolean) => Row
```

**Parameters**

- **`predicate`** (`(row: Row) => boolean`, required)
  A filtering function (predicate) called for each row present in this workspace.

**Returns**: `Row`

### getWindow

Returns the first window in this workspace, which satisfies the provided predicate.

```ts
(predicate: (window: WorkspaceWindow) => boolean) => WorkspaceWindow
```

**Parameters**

- **`predicate`** (`(window: WorkspaceWindow) => boolean`, required)
  A filtering function (predicate) called for each window present in this workspace.

**Returns**: `WorkspaceWindow`

### hibernate

Puts the workspace in a hibernated state. All the windows are closed, but the workspace structure remains.

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### hideLoadingAnimation

Hides the loading animation of the workspace.
*Available only in **io.Connect Desktop**.*

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### lock

Locks the workspace using a provided config object, which restricts various modification functionalities of the workspace

```ts
(config?: WorkspaceLockConfig | ((config: WorkspaceLockConfig) => WorkspaceLockConfig)) => Promise<void>
```

**Parameters**

- **`config`** (`WorkspaceLockConfig | ((config: WorkspaceLockConfig) => WorkspaceLockConfig)`, optional)
  This can be either an object or a function. When the object is provided, it overrides all other lock properties. When a function is provided, it will be called with the current lock settings and it should return a lock config, which will override the current settings. The function is recommended in all cases where overriding of the settings is not desired.

**Returns**: `Promise<void>`

### onClosed

Notifies when this workspace is closed.

```ts
(callback: (closed?: WorkspaceClosedData) => void) => Promise<Unsubscribe>
```

**Parameters**

- **`callback`** (`(closed?: WorkspaceClosedData) => void`, required)
  Callback function to handle the event.

**Returns**: `Promise<Unsubscribe>`

### onContextUpdated

Notifies when the context for this workspace was updated.

```ts
(callback: (data: any) => void) => Promise<Unsubscribe>
```

**Parameters**

- **`callback`** (`(data: any) => void`, required)
  Callback function to handle the event.

**Returns**: `Promise<Unsubscribe>`

### onHibernated

Notifies when the Workspace is hibernated. Returns an unsubscribe function.

```ts
(callback: () => void) => Promise<IOConnectWorkspaces.Unsubscribe>
```

**Parameters**

- **`callback`** (`() => void`, required)
  Callback function for handling the event.

**Returns**: `Promise<IOConnectWorkspaces.Unsubscribe>`

### onLockConfigurationChanged

Notifies when the a change in the lock configuration of the workspace has been made

```ts
(callback: (config: IOConnectWorkspaces.WorkspaceLockConfig) => void) => Promise<IOConnectWorkspaces.Unsubscribe>
```

**Parameters**

- **`callback`** (`(config: IOConnectWorkspaces.WorkspaceLockConfig) => void`, required)
  Callback function to handle the event. Receives the new lock configuration as a parameter.

**Returns**: `Promise<IOConnectWorkspaces.Unsubscribe>`

### onResumed

Notifies when the Workspace is resumed after being hibernated. Returns an unsubscribe function.

```ts
(callback: () => void) => Promise<IOConnectWorkspaces.Unsubscribe>
```

**Parameters**

- **`callback`** (`() => void`, required)
  Callback function for handling the event.

**Returns**: `Promise<IOConnectWorkspaces.Unsubscribe>`

### onTabReordered

Notifies when the Workspace tab has been reordered. Returns an unsubscribe function.

*Since: io.Connect Browser 4.4*

```ts
(callback: () => void) => Promise<IOConnectWorkspaces.Unsubscribe>
```

**Parameters**

- **`callback`** (`() => void`, required)
  Callback function for handling the event.
  *Available only in **io.Connect Browser**.*

**Returns**: `Promise<IOConnectWorkspaces.Unsubscribe>`

### onWindowAdded

Notifies when a new window was added to this workspace and returns an unsubscribe function.
An added window means that the window has a place in the workspace (it is a valid workspace element), but does not guarantee that the contents of the window are loaded.

```ts
(callback: (window: WorkspaceWindow) => void) => Promise<Unsubscribe>
```

**Parameters**

- **`callback`** (`(window: WorkspaceWindow) => void`, required)
  Callback function to handle the event. Receives the added window as a parameter.

**Returns**: `Promise<Unsubscribe>`

### onWindowLoaded

Notifies when a window's content was loaded in this workspace and returns an unsubscribe function.
A loaded window is a window, which was added to a workspace, it's contents were loaded and is present in the windows collection.

```ts
(callback: (window: WorkspaceWindow) => void) => Promise<Unsubscribe>
```

**Parameters**

- **`callback`** (`(window: WorkspaceWindow) => void`, required)
  Callback function to handle the event. Receives the loaded window as a parameter.

**Returns**: `Promise<Unsubscribe>`

### onWindowMaximized

Notifies when a window was maximized in this workspace and returns an unsubscribe function.
A maximized window means that the window has been maximized either by an API call or from the maximize button by the user.

```ts
(callback: (window: IOConnectWorkspaces.WorkspaceWindow) => void) => Promise<IOConnectWorkspaces.Unsubscribe>
```

**Parameters**

- **`callback`** (`(window: IOConnectWorkspaces.WorkspaceWindow) => void`, required)
  Callback function to handle the event. Receives the maximized window as a parameter.

**Returns**: `Promise<IOConnectWorkspaces.Unsubscribe>`

### onWindowRemoved

Notifies when a window was removed from this workspace and returns an unsubscribe function.
Not supported in **io.Connect Browser**.

```ts
(callback: (removed: { windowId?: string; workspaceId: string; frameId: string }) => void) => Promise<Unsubscribe>
```

**Parameters**

- **`callback`** (`(removed: { windowId?: string; workspaceId: string; frameId: string }) => void`, required)
  Callback function to handle the event. Receives an object containing the ids of the removed window, and the respective workspace and frame as a parameter.

**Returns**: `Promise<Unsubscribe>`

### onWindowRestored

Notifies when a window was restored in this workspace and returns an unsubscribe function.
A restored window means that the window has been restored from a maximized state either by an API call or from the restored button by the user.

```ts
(callback: (window: IOConnectWorkspaces.WorkspaceWindow) => void) => Promise<IOConnectWorkspaces.Unsubscribe>
```

**Parameters**

- **`callback`** (`(window: IOConnectWorkspaces.WorkspaceWindow) => void`, required)
  Callback function to handle the event. Receives the restored window as a parameter.

**Returns**: `Promise<IOConnectWorkspaces.Unsubscribe>`

### onWindowSelected

Notifies when a window was selected in this workspace and returns an unsubscribe function.

```ts
(callback: (window: IOConnectWorkspaces.WorkspaceWindow) => void) => Promise<IOConnectWorkspaces.Unsubscribe>
```

**Parameters**

- **`callback`** (`(window: IOConnectWorkspaces.WorkspaceWindow) => void`, required)
  Callback function to handle the event. Receives the selected window as a parameter.

**Returns**: `Promise<IOConnectWorkspaces.Unsubscribe>`

### onWindowTabReordered

Notifies when the tab of a window participating in the Workspace has been reordered. Returns an unsubscribe function.

*Since: io.Connect Browser 4.4*

```ts
(callback: (window: WorkspaceWindow) => void) => Promise<IOConnectWorkspaces.Unsubscribe>
```

**Parameters**

- **`callback`** (`(window: WorkspaceWindow) => void`, required)
  Callback function for handling the event. Receives as an argument the `WorkspaceWindow` object describing the window whose tab has been reordered.
  *Available only in **io.Connect Browser**.*

**Returns**: `Promise<IOConnectWorkspaces.Unsubscribe>`

### pin

Changes the state of the workspace to pinned - moves the workspace tab to the index before all unpinned tabs, removes the save button, title, close button and shows the workspace icon

```ts
(options?: WorkspacePinOptions) => Promise<void>
```

**Parameters**

- **`options`** (`WorkspacePinOptions`, optional)
  - object which controls the pinning

**Returns**: `Promise<void>`

### refreshReference

Updates this workspace reference to reflect the current state of the workspace.

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### remove

Removes the first element of this workspace which satisfies the predicate.

```ts
(predicate: (child: WorkspaceElement) => boolean) => Promise<void>
```

**Parameters**

- **`predicate`** (`(child: WorkspaceElement) => boolean`, required)
  A filtering function (predicate) called for each element in this workspace.

**Returns**: `Promise<void>`

### removeChild

Removes the first immediate child of this workspaces which satisfies the predicate.

```ts
(predicate: (child: WorkspaceElement) => boolean) => Promise<void>
```

**Parameters**

- **`predicate`** (`(child: WorkspaceElement) => boolean`, required)
  A filtering function (predicate) called for immediate child of this workspace.

**Returns**: `Promise<void>`

### resume

Resumes a hibernated workspace. All the windows prior to the hibernation are reloaded.

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### saveLayout

Saves the current workspace structure as a layout. In **io.Connect Browser** this will throw an error if the name matches the name of a read-only layout.

```ts
(name: string, config?: SaveLayoutConfig) => Promise<void>
```

**Parameters**

- **`name`** (`string`, required)
  A string representing the name (also ID) of the new workspace layout.
- **`config`** (`SaveLayoutConfig`, optional)
  An optional object used to set various options for saving the workspace layout.

**Returns**: `Promise<void>`

### setContext

Sets the context for this workspace. This operation will completely overwrite the existing context.

```ts
(data: any) => Promise<void>
```

**Parameters**

- **`data`** (`any`, required)
  The new context value.

**Returns**: `Promise<void>`

### setIcon

Changes the workspace icon to the specified one

```ts
(icon: string) => Promise<void>
```

**Parameters**

- **`icon`** (`string`, required)

**Returns**: `Promise<void>`

### setLoadingStrategy

Sets the loading strategy for the Workspace at runtime.
This will override the current loading strategy for the Workspace that may have been specified via configuration or programmatically
when creating or restoring the Workspace. The loading strategy specified via this method will be preserved in the Workspace Layout
only if the Workspace is saved afterwards and the `"persistCurrentStrategy"` flag is set to `true` in the Workspaces App definition.
*Available only in **io.Connect Desktop**.*

*Since: io.Connect Desktop 9.8*

```ts
(strategy: LoadingStrategy) => Promise<void>
```

**Parameters**

- **`strategy`** (`LoadingStrategy`, required)
  Loading strategy for the Workspace.

**Returns**: `Promise<void>`

### setTitle

Sets a new title for this workspace.

```ts
(title: string) => Promise<void>
```

**Parameters**

- **`title`** (`string`, required)
  The new title value.

**Returns**: `Promise<void>`

### setWindowDragMode

Sets the mode for dragging the windows that are part of the Workspace.
*Available only in **io.Connect Desktop**.*

```ts
(mode: "keepInside" | "autoEject") => Promise<void>
```

**Parameters**

- **`mode`** (`"keepInside" | "autoEject"`, required)
  Mode for dragging the Workspace windows. If set to `"autoEject"`, when the user drags a Workspace window, it will be ejected from the Workspace during the dragging operation and the user will be able to drop it back inside the Workspace, or out of the Workspace.
  If set to `"keepInside"`, the window won't be ejected from the Workspace when being dragged and the user will be able to drop it only inside the Workspace.

**Returns**: `Promise<void>`

### showLoadingAnimation

Shows the loading animation of the workspace.
*Available only in **io.Connect Desktop**.*

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### snapshot

Returns a snapshot object describing the full current state of this workspace.

```ts
() => Promise<WorkspaceSnapshot>
```

**Returns**: `Promise<WorkspaceSnapshot>`

### unpin

Changes the state of the workspace to normal -  moves the workspace tab to the index after all pinned tabs, returns the save button, title, close button and hides the workspace icon

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### updateContext

Updated the context for this workspace. This operation will merge the existing context with the provided value.

```ts
(data: any) => Promise<void>
```

**Parameters**

- **`data`** (`any`, required)
  The context value to update.

**Returns**: `Promise<void>`

## Related types

- [BoxDefinition](https://docs.interop.io/desktop/reference/javascript/workspaces/boxdefinition/index.md)
- [Column](https://docs.interop.io/desktop/reference/javascript/workspaces/column/index.md)
- [Frame](https://docs.interop.io/desktop/reference/javascript/workspaces/frame/index.md)
- [Group](https://docs.interop.io/desktop/reference/javascript/workspaces/group/index.md)
- [LoadingStrategy](https://docs.interop.io/desktop/reference/javascript/workspaces/loadingstrategy/index.md)
- [Row](https://docs.interop.io/desktop/reference/javascript/workspaces/row/index.md)
- [SaveLayoutConfig](https://docs.interop.io/desktop/reference/javascript/workspaces/savelayoutconfig/index.md)
- [Unsubscribe](https://docs.interop.io/desktop/reference/javascript/workspaces/unsubscribe/index.md)
- [WorkspaceBox](https://docs.interop.io/desktop/reference/javascript/workspaces/workspacebox/index.md)
- [WorkspaceClosedData](https://docs.interop.io/desktop/reference/javascript/workspaces/workspacecloseddata/index.md)
- [WorkspaceElement](https://docs.interop.io/desktop/reference/javascript/workspaces/workspaceelement/index.md)
- [WorkspaceLockConfig](https://docs.interop.io/desktop/reference/javascript/workspaces/workspacelockconfig/index.md)
- [WorkspacePinOptions](https://docs.interop.io/desktop/reference/javascript/workspaces/workspacepinoptions/index.md)
- [WorkspaceSnapshot](https://docs.interop.io/desktop/reference/javascript/workspaces/workspacesnapshot/index.md)
- [WorkspaceWindow](https://docs.interop.io/desktop/reference/javascript/workspaces/workspacewindow/index.md)
- [WorkspaceWindowDefinition](https://docs.interop.io/desktop/reference/javascript/workspaces/workspacewindowdefinition/index.md)
