Skip to content

Commit

Permalink
Merge branch 'master' into eagle-1371
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Wicenec committed Dec 18, 2024
2 parents c01dda8 + f23faa6 commit d37ca7e
Show file tree
Hide file tree
Showing 18 changed files with 117 additions and 122 deletions.
2 changes: 0 additions & 2 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ User Options

**Confirm Reload Palettes** - Prompt user to confirm when loading a palette that is already loaded.

**Open Default Palette on Startup** - Open a default palette on startup. The palette contains an example of all known node categories.

**Confirm Delete** - Prompt user to confirm when deleting node(s) or edge(s) from a graph.

**Disable JSON Validation** - Allow EAGLE to load/save/send-to-translator graphs and palettes that would normally fail validation against schema.
Expand Down
5 changes: 5 additions & 0 deletions e2e/creatingASimpleGraph.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ test('Creating a Simple Graph', async ({ page }) => {
await page.waitForTimeout(500);
await page.getByRole('button', { name: 'OK' }).click()

//expand the 'Builtin Components' palette
await page.locator('#palette0').click();
await page.waitForTimeout(250);

//add a helloworld app to the graph by clicking it's icon
await page.locator('#addPaletteNodeHelloWorldApp').click();

//agree to create a new graph with it's auto-generated name
await page.waitForTimeout(500);
await page.getByRole('button', { name: 'OK' }).click();
Expand Down
4 changes: 4 additions & 0 deletions e2e/creatingAndEditingPalettes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ test('Creating and editing Palettes', async ({ page }) => {
await page.waitForTimeout(500);
await page.getByRole('button', { name: 'OK' }).click()

//expand the 'Builtin Components' palette
await page.locator('#palette0').click();
await page.waitForTimeout(250);

//right click the hello world app in the palette
await page.locator('#palette_0_CopyApp').click({
button: 'right'
Expand Down
4 changes: 4 additions & 0 deletions e2e/parameterTableAndKeyboardShortcuts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ test('Parameter Tables and keyboard Shortcuts', async ({ page }) => {
await page.waitForTimeout(500);
await page.getByRole('button', { name: 'OK' }).click()

//expand the 'Builtin Components' palette
await page.locator('#palette0').click();
await page.waitForTimeout(250);

//add a helloworld app to the graph by clicking it's icon
await page.locator('#addPaletteNodeHelloWorldApp').click();
//agree to create a new graph with it's auto-generated name
Expand Down
106 changes: 35 additions & 71 deletions src/Eagle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1248,9 +1248,6 @@ export class Eagle {
// show errors (if found)
this._handleLoadingErrors(errorsWarnings, Utils.getFileNameFromFullPath(fileFullPath), Repository.Service.File);

// sort the palette
p.sort();

// add new palette to the START of the palettes array
this.palettes.unshift(p);

Expand Down Expand Up @@ -1483,7 +1480,7 @@ export class Eagle {
break;
case Repository.Service.Url:
this.loadPalettes([
{name:palette.fileInfo().name, filename:palette.fileInfo().downloadUrl, readonly:palette.fileInfo().readonly}
{name:palette.fileInfo().name, filename:palette.fileInfo().downloadUrl, readonly:palette.fileInfo().readonly, expanded: true}
], (errorsWarnings: Errors.ErrorsWarnings, palettes: Palette[]):void => {
for (const palette of palettes){
if (palette !== null){
Expand Down Expand Up @@ -1904,9 +1901,17 @@ export class Eagle {
}

loadDefaultPalettes = () : void => {
// get collapsed/expanded state of palettes from html locaStorage
let templatePaletteExpanded: boolean = Setting.findValue(Setting.OPEN_TEMPLATE_PALETTE);
let builtinPaletteExpanded: boolean = Setting.findValue(Setting.OPEN_BUILTIN_PALETTE);
templatePaletteExpanded = templatePaletteExpanded === null ? false : templatePaletteExpanded;
builtinPaletteExpanded = builtinPaletteExpanded === null ? false : builtinPaletteExpanded;


// fetch the palettes
this.loadPalettes([
{name:Palette.BUILTIN_PALETTE_NAME, filename:Daliuge.PALETTE_URL, readonly:true},
{name:Palette.DYNAMIC_PALETTE_NAME, filename:Daliuge.TEMPLATE_URL, readonly:true}
{name:Palette.BUILTIN_PALETTE_NAME, filename:Daliuge.PALETTE_URL, readonly:true, expanded: builtinPaletteExpanded},
{name:Palette.TEMPLATE_PALETTE_NAME, filename:Daliuge.TEMPLATE_URL, readonly:true, expanded: templatePaletteExpanded}
], (errorsWarnings: Errors.ErrorsWarnings, palettes: Palette[]):void => {
const showErrors: boolean = Setting.findValue(Setting.SHOW_FILE_LOADING_ERRORS);

Expand All @@ -1928,7 +1933,7 @@ export class Eagle {
});
}

loadPalettes = (paletteList: {name:string, filename:string, readonly:boolean}[], callback: (errorsWarnings: Errors.ErrorsWarnings, data: Palette[]) => void ) : void => {
loadPalettes = (paletteList: {name:string, filename:string, readonly:boolean, expanded: boolean}[], callback: (errorsWarnings: Errors.ErrorsWarnings, data: Palette[]) => void ) : void => {
const results: Palette[] = [];
const complete: boolean[] = [];
const errorsWarnings: Errors.ErrorsWarnings = {"errors":[], "warnings":[]};
Expand Down Expand Up @@ -2276,8 +2281,8 @@ export class Eagle {
const errorsWarnings: Errors.ErrorsWarnings = {"errors":[], "warnings":[]};
const newPalette = Palette.fromOJSJson(data, file, errorsWarnings);

// sort items in palette
newPalette.sort();
// all new (or reloaded) palettes should have 'expanded' flag set to true
newPalette.expanded(true);

// add to list of palettes
this.palettes.unshift(newPalette);
Expand Down Expand Up @@ -2337,6 +2342,23 @@ export class Eagle {
this.resetEditor()
}

sortPalette = (palette: Palette): void => {
// close the palette menu
this.closePaletteMenus();

const preSortCopy = palette.getNodes().slice();

palette.sort();

// check whether anything changed order, if so, mark as modified
for (let i = 0; i < palette.getNodes().length; i++) {
if (palette.getNodes()[i].getId() !== preSortCopy[i].getId()) {
palette.fileInfo().modified = true;
break;
}
}
}

getParentNameAndId = (parentId: NodeId) : string => {
if(parentId === null){
return ""
Expand Down Expand Up @@ -2364,42 +2386,6 @@ export class Eagle {
Utils.showNotification("Success", "Confirmation message pop ups re-enabled", "success");
}

// toggles the default palettes on or off
// if currently shown, just remove them from the palettes list
// if currently not shown, fetch them from the remove source and add to palettes list
toggleDefaultPalettes = () : void => {
const allowGraphEditing: boolean = Setting.find(Setting.ALLOW_GRAPH_EDITING).value() as boolean;
const allowPaletteEditing: boolean = Setting.find(Setting.ALLOW_PALETTE_EDITING).value() as boolean;
const openDefaultPalette: boolean = Setting.find(Setting.OPEN_DEFAULT_PALETTE).value() as boolean;

// if:
// - user is loading palettes
// - allow palette editing is off
// - allow graph editing is off
// then the palettes tab is invisible anyway, and the user will not see the palettes loaded, so notify them of this corner case
if (openDefaultPalette && !allowGraphEditing && !allowPaletteEditing){
Utils.showNotification("Palettes Disabled", "Palettes are not visible in the current UI mode", "warning");
}

const eagle: Eagle = Eagle.getInstance();

const builtinPalette: Palette = this.findPalette(Palette.BUILTIN_PALETTE_NAME, false);
const dynamicPalette: Palette = this.findPalette(Palette.DYNAMIC_PALETTE_NAME, false);

// always close the palettes
if (builtinPalette !== null){
eagle.closePalette(builtinPalette);
}
if (dynamicPalette !== null){
eagle.closePalette(dynamicPalette);
}

// reload them if applicable
if (openDefaultPalette){
eagle.loadDefaultPalettes();
}
}

// TODO: shares some code with saveFileToLocal(), we should try to factor out the common stuff at some stage
savePaletteToDisk = (palette : Palette) : void => {
console.log("savePaletteToDisk()", palette.fileInfo().name, palette.fileInfo().type);
Expand Down Expand Up @@ -3264,7 +3250,6 @@ export class Eagle {

// mark the palette as modified
destinationPalette.fileInfo().modified = true;
destinationPalette.sort();
}
});
}
Expand Down Expand Up @@ -3758,8 +3743,8 @@ export class Eagle {
private buildWritablePaletteNamesList = () : string[] => {
const paletteNames : string[] = [];
for (const palette of this.palettes()){
// skip the dynamically generated palette that contains all nodes
if (palette.fileInfo().name === Palette.DYNAMIC_PALETTE_NAME){
// skip the template palette that contains all nodes
if (palette.fileInfo().name === Palette.TEMPLATE_PALETTE_NAME){
continue;
}
// skip the built-in palette
Expand Down Expand Up @@ -4141,7 +4126,6 @@ export class Eagle {
// add to destination palette
destinationPalette.addNode(sourceComponent, true);
destinationPalette.fileInfo().modified = true;
destinationPalette.sort();
}
}

Expand Down Expand Up @@ -4242,11 +4226,6 @@ export class Eagle {

this.checkGraph();
this.undo().pushSnapshot(this, "Edit Field");

// if we summoned this editField modal from the params table, now that we are done, re-open the params table
if (modalType === Eagle.ModalType.Field){
$('.parameterTable').modal("show");
}
});
}
};
Expand Down Expand Up @@ -4679,9 +4658,9 @@ export namespace Eagle

export enum BottomWindowMode {
None = "None",
ParameterTable = "ParameterTable",
NodeParameterTable = "NodeParameterTable",
GraphConfigsTable = "GraphConfigsTable",
GraphConfigAttributesTable = "GraphConfigAttributesTable",
ConfigParameterTable = "ConfigParameterTable",
GraphErrors = "GraphErrors"
}

Expand Down Expand Up @@ -4779,21 +4758,6 @@ $( document ).ready(function() {
RightClick.closeCustomContextMenu(true);
});

$(".tableParameter").on("click", function(){
console.log(this)
})

//expand palettes when using searchbar and return to prior collapsed state on completion.
$("#paletteList .componentSearchBar").on("keyup",function(){
if ($("#paletteList .componentSearchBar").val() !== ""){
$("#paletteList .accordion-button.collapsed").addClass("wasCollapsed")
$("#paletteList .accordion-button.collapsed").trigger("click")
}else{
$("#paletteList .accordion-button.wasCollapsed").trigger("click")
$("#paletteList .accordion-button.wasCollapsed").removeClass("wasCollapsed")
}
})

$(document).on('click', '.hierarchyEdgeExtra', function(event: JQuery.TriggeredEvent){
const e: MouseEvent = event.originalEvent as MouseEvent;
const eagle: Eagle = Eagle.getInstance();
Expand Down
2 changes: 1 addition & 1 deletion src/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ export class Field {
}

//check if the node name matches, but only if using the key parameter table modal
if(Setting.findValue(Setting.BOTTOM_WINDOW_MODE) === Eagle.BottomWindowMode.GraphConfigAttributesTable){
if(Setting.findValue(Setting.BOTTOM_WINDOW_MODE) === Eagle.BottomWindowMode.ConfigParameterTable){
if(Eagle.getInstance().logicalGraph().findNodeById(that.nodeId()).getName().toLowerCase().indexOf(term) >= 0){
result = true
}
Expand Down
4 changes: 2 additions & 2 deletions src/KeyboardShortcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ export class KeyboardShortcut {
new KeyboardShortcut("open_settings", "Open setting", [new Key("o")], "keydown", true, false, ['menu','options'], KeyboardShortcut.true, KeyboardShortcut.true, KeyboardShortcut.true, (eagle): void => {eagle.smartToggleModal('settingsModal');}),
new KeyboardShortcut("open_help", "Open Online Documentation", [new Key("h")], "keydown", true, false, ['read me','guide','documentation'], KeyboardShortcut.true, KeyboardShortcut.true, KeyboardShortcut.true, (eagle): void => {eagle.onlineDocs();}),
new KeyboardShortcut("open_keyboard_shortcut_modal", "Open Keyboard Shortcut Modal", [new Key("k")], "keydown", true, false, ['shortcuts'], KeyboardShortcut.true, KeyboardShortcut.true, KeyboardShortcut.true, (eagle): void => {eagle.smartToggleModal('shortcutsModal')}),
new KeyboardShortcut("open_parameter_table", "Open Parameter Table Modal", [new Key("t")], "keydown", true, false, ['fields','field','node','table'], KeyboardShortcut.true, KeyboardShortcut.notInStudentMode, KeyboardShortcut.notInStudentMode, (eagle): void => {ParameterTable.toggleTable(Eagle.BottomWindowMode.ParameterTable, ParameterTable.SelectType.Normal);}),
new KeyboardShortcut("open_graph_attributes_configuration_table", "Open Graph Attributes Configuration Table Modal", [new Key("t", KeyboardShortcut.Modifier.Shift)], "keydown", true, false, ['fields','field','node','graph','table','favourites'], KeyboardShortcut.true, KeyboardShortcut.true, KeyboardShortcut.true, (eagle): void => {ParameterTable.toggleTable(Eagle.BottomWindowMode.GraphConfigAttributesTable, ParameterTable.SelectType.Normal);}),
new KeyboardShortcut("open_parameter_table", "Open Parameter Table Modal", [new Key("t")], "keydown", true, false, ['fields','field','node','table'], KeyboardShortcut.true, KeyboardShortcut.notInStudentMode, KeyboardShortcut.notInStudentMode, (eagle): void => {ParameterTable.toggleTable(Eagle.BottomWindowMode.NodeParameterTable, ParameterTable.SelectType.Normal);}),
new KeyboardShortcut("open_graph_attributes_configuration_table", "Open Graph Attributes Configuration Table Modal", [new Key("t", KeyboardShortcut.Modifier.Shift)], "keydown", true, false, ['fields','field','node','graph','table','favourites'], KeyboardShortcut.true, KeyboardShortcut.true, KeyboardShortcut.true, (eagle): void => {ParameterTable.toggleTable(Eagle.BottomWindowMode.ConfigParameterTable, ParameterTable.SelectType.Normal);}),
new KeyboardShortcut("undo", "Undo", [new Key("z")], "keydown", true, false, ['back','history'], KeyboardShortcut.true, KeyboardShortcut.true, KeyboardShortcut.true, (eagle): void => {eagle.undo().prevSnapshot(eagle)}),
new KeyboardShortcut("redo", "Redo", [new Key("z", KeyboardShortcut.Modifier.Shift)], "keydown", true, false, ['forward','history'], KeyboardShortcut.true, KeyboardShortcut.true, KeyboardShortcut.true, (eagle): void => {eagle.undo().nextSnapshot(eagle)}),
new KeyboardShortcut("check_graph", "Check Graph", [new Key("!", KeyboardShortcut.Modifier.Shift)], "keydown", true, false, ['error','errors','fix'], KeyboardShortcut.true, KeyboardShortcut.allowGraphEditing, KeyboardShortcut.allowGraphEditing, (eagle): void => {eagle.showGraphErrors();}),
Expand Down
24 changes: 23 additions & 1 deletion src/Palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ import { FileInfo } from './FileInfo';
import { Node } from './Node';
import { Repository } from "./Repository";
import { RepositoryFile } from './RepositoryFile';
import { Setting } from "./Setting";
import { Utils } from './Utils';
import { UiModeSystem } from "./UiModes";

export class Palette {
fileInfo : ko.Observable<FileInfo>;
private nodes : ko.ObservableArray<Node>;
private searchExclude : ko.Observable<boolean>;
expanded: ko.Observable<boolean>;

public static readonly DYNAMIC_PALETTE_NAME: string = "Component Templates";
public static readonly TEMPLATE_PALETTE_NAME: string = "Component Templates";
public static readonly BUILTIN_PALETTE_NAME: string = "Builtin Components";

constructor(){
Expand All @@ -50,6 +53,7 @@ export class Palette {
this.fileInfo().builtIn = false;
this.nodes = ko.observableArray([]);
this.searchExclude = ko.observable(false);
this.expanded = ko.observable(false);
}

static fromOJSJson(data : string, file : RepositoryFile, errorsWarnings : Errors.ErrorsWarnings) : Palette {
Expand Down Expand Up @@ -288,4 +292,22 @@ export class Palette {
// notification
Utils.showNotification("Palette URL", "Copied to clipboard", "success");
}

toggle = (palette: Palette, event: Event): void => {
// get collapse/expand state of the accordion
const expanded: boolean = (<any>event.currentTarget).ariaExpanded === 'true';

// set internal variable in the palette
this.expanded(expanded);

// if this palette one of the built-in ones, then save the state to localStorage
if (this.fileInfo().name === Palette.BUILTIN_PALETTE_NAME){
Setting.setValue(Setting.OPEN_BUILTIN_PALETTE, expanded);
UiModeSystem.saveToLocalStorage();
}
if (this.fileInfo().name === Palette.TEMPLATE_PALETTE_NAME){
Setting.setValue(Setting.OPEN_TEMPLATE_PALETTE, expanded);
UiModeSystem.saveToLocalStorage();
}
}
}
Loading

0 comments on commit d37ca7e

Please sign in to comment.