User Permissions

Programmatically there are no restrictions on what you can do. However you may want to restrict the actions that your users may perform.

The simplest restriction is to set Diagram.isEnabled to false. Users will not be able to do much of anything. In this example, even though the grouping, undo, and redo commands are enabled, the commands cannot execute because the diagram is disabled.

  diagram.commandHandler.archetypeGroupData =
    { key: "Group", isGroup: true, color: "blue" };

  var nodeDataArray = [
    { key: "Alpha" },
    { key: "Beta" },
    { key: "Delta", group: "Epsilon" },
    { key: "Gamma", group: "Epsilon" },
    { key: "Epsilon", isGroup: true }
  ];
  var linkDataArray = [
    { from: "Alpha", to: "Beta" },
    { from: "Beta", to: "Beta" },
    { from: "Gamma", to: "Delta" },
    { from: "Delta", to: "Alpha" }
  ];
  diagram.model = new go.GraphLinksModel(nodeDataArray, linkDataArray);
  diagram.undoManager.isEnabled = true;

  diagram.add($(go.Part,  // this is just a visual comment
                { location: new go.Point(200, 50) },
                $(go.TextBlock, "Diagram.isEnabled == false",
                  { font: "16pt bold", stroke: "red" })
              ));

  diagram.isEnabled = false;  // Disable the diagram!

More common is to set Diagram.isReadOnly to true. This allows users to scroll and zoom and to select parts, but not to insert or delete or drag or modify parts. (If you want to allow scroll and zoom but not selection, you can disable selection, as discussed below.)

  diagram.commandHandler.archetypeGroupData =
    { key: "Group", isGroup: true, color: "blue" };

  var nodeDataArray = [
    { key: "Alpha" },
    { key: "Beta" },
    { key: "Delta", group: "Epsilon" },
    { key: "Gamma", group: "Epsilon" },
    { key: "Epsilon", isGroup: true }
  ];
  var linkDataArray = [
    { from: "Alpha", to: "Beta" },
    { from: "Beta", to: "Beta" },
    { from: "Gamma", to: "Delta" },
    { from: "Delta", to: "Alpha" }
  ];
  diagram.model = new go.GraphLinksModel(nodeDataArray, linkDataArray);
  diagram.undoManager.isEnabled = true;

  diagram.add($(go.Part,  // this is just a visual comment
                { location: new go.Point(200, 50) },
                $(go.TextBlock, "Diagram.isReadOnly == true",
                  { font: "16pt bold", stroke: "red" })
              ));

  diagram.isReadOnly = true;  // Disable diagram modifications, but allow navigation and selection

Another possibility is to set Diagram.isModelReadOnly to true. This allows users to scroll, zoom, select, and move parts, but not to insert or delete parts, including not adding or removing links nor adding or removing group members.

The Diagram.isModelReadOnly property just gets and sets the Model.isReadOnly property.

  diagram.commandHandler.archetypeGroupData =
    { key: "Group", isGroup: true, color: "blue" };

  var nodeDataArray = [
    { key: "Alpha" },
    { key: "Beta" },
    { key: "Delta", group: "Epsilon" },
    { key: "Gamma", group: "Epsilon" },
    { key: "Epsilon", isGroup: true }
  ];
  var linkDataArray = [
    { from: "Alpha", to: "Beta" },
    { from: "Beta", to: "Beta" },
    { from: "Gamma", to: "Delta" },
    { from: "Delta", to: "Alpha" }
  ];
  diagram.model = new go.GraphLinksModel(nodeDataArray, linkDataArray);
  diagram.undoManager.isEnabled = true;

  diagram.add($(go.Part,  // this is just a visual comment
                { location: new go.Point(200, 50) },
                $(go.TextBlock, "Diagram.isModelReadOnly == true",
                  { font: "16pt bold", stroke: "red" })
              ));

  diagram.isModelReadOnly = true;  // Disable adding or removing parts

Specific permissions

More precise restrictions on the user can be imposed by setting properties of the Diagram or of a particular Layer or of a particular Part or GraphObject.

Some restrictions, such as Diagram.allowZoom, only make sense when applying to the whole diagram. Others may also apply to individual parts, such as Part.copyable and Layer.allowCopy corresponding to Diagram.allowCopy. Finally some may apply to any GraphObject, for example properties for ports such as GraphObject.toLinkable, or to text objects such as TextBlock.editable.

Here is a listing of what users can do and the properties that limit that functionality. Most of these properties have a default value of true.

Cut command

Copy command

Paste command

Delete command

Drag-and-drop within diagram

Drag-and-drop out of diagram

Drag-and-drop into diagram

In-place text editing

Group command

Ungroup command

Click-creating

Drawing a new link

Relinking an existing link

Reshaping a link

Resizing an object

Rotating an object

Arrow and Page commands, panning/scrolling the diagram

SelectAll command, click selecting, drag selecting

Undo/Redo commands

Zoom commands, zooming/rescaling the diagram