Skip to content

Workspace Hub

The workspace hub is used to send and receive events on the client, regarding workspace operations. Extends MessageHub.

Basic Usage

Include the hub using the web link above. If you are making a standard Dirigible editor, the workspace hub is already included.

<script type="text/javascript" src="/services/web/service-workspace/workspace-hub.js"></script>
exampleView.controller('ExampleViewController', ($scope) => {
    const workspaceHub = new WorkspaceHub();
});

Functions


Function Description Returns
announceWorkspaceChanged(WorkspaceExtraParams) Sends a message containing information on which workspace has been changed. -
onWorkspaceChanged(handlerFunc) Triggered when a workspace has been changed. function
announceFileSaved(FileSavedParams) Sends a message containing information on which file has been saved. -
onFileSaved(handlerFunc) Triggered when a file has been saved. function
saveFile(FileSavedParams) Sends a message containing information on which file should be saved. -
onSaveFile(handlerFunc) Triggered when a file has to be saved. function
saveFile(PathParams) Sends a message containing information on which file should be saved. -
onSaveFile(handlerFunc) Triggered when a file has to be saved. function
saveAll() Tells all open editors to save their content. -
onSaveAll(handlerFunc) Triggered when all files should be saved. function
announcePublished(PathParams) Sends a message containing information on which file, folder or project has been published. -
onPublished(handlerFunc) Triggered when a file, folder or project has been published. function
announceUnpublished(PathParams) Sends a message containing information on which file, folder or project has been unpublished. -
onUnpublished(handlerFunc) Triggered when a file, folder or project has been unpublished. function
announceFileSelected(FileSelectedParams) Sends a message containing information on which file has been selected. -
onFileSelected(handlerFunc) Triggered when a file has been deleted. function
announceFileDeleted(PathParams) Sends a message containing information on which file has been deleted. -
onFileDeleted(handlerFunc) Triggered when a file has been deleted. function
announceFileRenamed(RenamedParams) Sends a message containing information on which file has been renamed. -
onFileRenamed(handlerFunc) Triggered when a file has been renamed. function
announceFileMoved(MovedParams) Sends a message containing information on which file has been moved. -
onFileMoved(handlerFunc) Triggered when a file has been moved. function
announceFolderDeleted(PathParams) Sends a message containing information on which folder has been deleted. -
onFolderDeleted(handlerFunc) Triggered when a folder has been deleted. function
announceFolderRenamed(RenamedParams) Sends a message containing information on which folder has been renamed. -
onFolderRenamed(handlerFunc) Triggered when a folder has been renamed. function
announceFolderMoved(MovedParams) Sends a message containing information on which folder has been moved. -
onFolderMoved(handlerFunc) Triggered when a file has been moved. function
announceProjectDeleted(ProjectParams) Sends a message containing information on which project has been deleted. -
onProjectDeleted(handlerFunc) Triggered when a project has been deleted. function
announceWorkspaceCreated(WorkspaceParams) Sends a message containing information on which workspace has been created. -
onWorkspaceCreated(handlerFunc) Triggered when a workspace has been created. function
announceWorkspaceModified(WorkspaceParams) Sends a message containing information on which workspace has been modified. -
onWorkspaceModified(handlerFunc) Triggered when a workspace has been modified. function
announceWorkspaceDeleted(WorkspaceParams) Sends a message containing information on which workspace has been deleted. -
onWorkspaceDeleted(handlerFunc) Triggered when a workspace has been created. function

Param definitions

Typedefs

WorkspaceExtraParams : Object
PathParams : Object
FileSavedParams : Object
FileSelectedParams : Object
RenamedParams : Object
MovedParams : Object
ProjectParams : Object
WorkspaceParams : Object

Note

Params in square brackets are optional.

WorkspaceExtraParams : Object

Param Type Description
workspace string Name of the changed workspace.
params Object.<any, any> Any extra parameters.

PathParams : Object

Param Type Description
path string Full file path, including file name.
[params] Object.<any, any> Extra parameters.

FileSavedParams : Object

Param Type Description
path string Full file path, including file name.
[status] string Git status of the file.
[contentType] string File content type.

FileSelectedParams : Object

Param Type Description
path string Full file path, including file name.
contentType string The file content type.
[params] Object.<any, any> Extra parameters that will be passed the listener.

RenamedParams : Object

Param Type Description
oldPath string Old file path, including file name.
newPath string New file path, including file name.
contentType string The file content type.

MovedParams : Object

Param Type Description
oldPath string Old file path, including file name.
newPath string New file path, including file name.

ProjectParams : Object

Param Type Description
project string Project name.
workspace string Workspace name.

WorkspaceParams : Object

Param Type Description
workspace string Workspace name.

Example

workspaceHub.announceFileSelected({
    path: '/workspace/project/folder/file.js',
    contentType: 'text/javascript',
});

const selectedListener = workspaceHub.onFileSelected((data) => {
    console.log(data.name);
    console.log(data.path);
    console.log(data.contentType ?? '');
});