Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync our master branch with upstream master branch #13

Merged
merged 27 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3ae8639
Fix link hover stroke opacity
Dec 6, 2022
eb9f37c
Merge pull request #280 from pixix4/bugfix/link-hover-stroke-opacity
zHaytam Aug 25, 2023
4cfc10f
Add Radius example to Path Generators documentation
zHaytam Sep 30, 2023
1e6fb86
Merge branch 'develop' of https://github.com/Blazor-Diagrams/Blazor.D…
zHaytam Sep 30, 2023
832a030
fix type of diagram
suraj-desai-wtg Oct 16, 2023
2403206
Adding check for target being a portModel
K0369 Oct 16, 2023
93b154b
Fixing nodes not updating on change of the link target
K0369 Oct 16, 2023
ff0fd5a
fixing NRE of onLinkRemoved in landing showcase diagram
K0369 Oct 22, 2023
95a9734
refactoring link target refreshing in landing showcase diagram
K0369 Oct 22, 2023
f1032af
Demo-site: changing signature of onChange to reflect actual values
K0369 Oct 22, 2023
9836fa3
Add Route property to BaseLinkModel
zHaytam Oct 22, 2023
12ea521
Merge pull request #364 from K0369/bugfix/nre-on-demo-site
zHaytam Oct 23, 2023
c15bec5
Merge branch 'develop' of https://github.com/Blazor-Diagrams/Blazor.D…
zHaytam Oct 23, 2023
900d352
Merge branch 'develop' into pr/363
zHaytam Oct 23, 2023
4b6fe1d
Merge pull request #363 from Suraj0500/suraj/fix-null-reference-excep…
zHaytam Oct 23, 2023
6321a29
Adding check for "ShouldDelete"-constraint to remove control
K0369 Oct 23, 2023
58bcdb3
Adding unit tests
K0369 Oct 23, 2023
27422d0
Fixing #369 by adding invariant culture conversion
K0369 Oct 23, 2023
2209b52
Merge pull request #370 from K0369/#369-unit-test-failing-on-non-engl…
zHaytam Oct 26, 2023
e586245
Adding functionality for GroupModel Removal to RemoveControl
K0369 Oct 26, 2023
605028d
Merge pull request #371 from K0369/bugfix/#359-should-delete-constrai…
zHaytam Oct 27, 2023
434de93
Update Versions and CHANGELOG
zHaytam Oct 27, 2023
11798a1
Add new workflow to push to nuget
zHaytam Oct 27, 2023
9cb0e13
Merge pull request #372 from Blazor-Diagrams/develop
zHaytam Oct 27, 2023
0d35925
Update push.yml
zHaytam Oct 27, 2023
46d9800
Update push.yml
zHaytam Oct 27, 2023
b2094e0
Merge remote-tracking branch 'upstream/master' into heather/sync
Heathermcx Dec 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: PushToNuget
env:
NUGET_DIR: '${{ github.workspace }}/nuget'

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Pack Blazor.Diagrams.Core
working-directory: src/Blazor.Diagrams.Core
run: 'dotnet pack -p:GeneratePackageOnBuild=false --configuration Release --output ${{ env.NUGET_DIR }}'

- name: Pack Blazor.Diagrams
working-directory: src/Blazor.Diagrams
run: 'dotnet pack -p:GeneratePackageOnBuild=false --configuration Release --output ${{ env.NUGET_DIR }}'

- name: Pack Blazor.Diagrams.Algorithms
working-directory: src/Blazor.Diagrams.Algorithms
run: 'dotnet pack -p:GeneratePackageOnBuild=false --configuration Release --output ${{ env.NUGET_DIR }}'

- name: Push Blazor.Diagrams.Core
run: 'dotnet nuget push ${{ env.NUGET_DIR }}/Z.Blazor.Diagrams.Core.3.0.1.nupkg --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate'

- name: Push Blazor.Diagrams
run: 'dotnet nuget push ${{ env.NUGET_DIR }}/Z.Blazor.Diagrams.3.0.1.nupkg --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate'

- name: Push Blazor.Diagrams.Algorithms
run: 'dotnet nuget push ${{ env.NUGET_DIR }}/Z.Blazor.Diagrams.Algorithms.3.0.1.nupkg --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate'
1 change: 1 addition & 0 deletions Blazor.Diagrams.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.github\workflows\build.yml = .github\workflows\build.yml
CHANGELOG.md = CHANGELOG.md
.github\workflows\main.yml = .github\workflows\main.yml
.github\workflows\push.yml = .github\workflows\push.yml
README.md = README.md
EndProjectSection
EndProject
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Diagrams (3.0.1) - 2023-10-27

### Added

- `Route` property to `BaseLinkModel` to hold the result of the executed router

### Fixed

- Constraints not checked when using `RemoveControl` (thanks to @[K0369](https://github.com/K0369))
- NRE Exception on the landing page demo when dragging a new link and not linking it to something (thanks to @[K0369](https://github.com/K0369))
- `LinkVertexWidgetTests` failing on cultures that are not using a dot as decimal separator (thanks to @[K0369](https://github.com/K0369))
- NRE exception in the Diagram Demo project (thanks to @[Suraj0500](https://github.com/Suraj0500))

## Diagrams (3.0.0) - 2023-08-14

Finally, the new documentation website is here!
Expand Down
2 changes: 1 addition & 1 deletion docs/Diagram-Demo/Pages/Diagrams.razor
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ or it will not be rendered.
</div>

@code {
private Diagram Diagram { get; set; }
private BlazorDiagram Diagram { get; set; }

protected override void OnInitialized()
{
Expand Down
14 changes: 10 additions & 4 deletions site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,24 @@ private void OnLinkAdded(BaseLinkModel link)
link.TargetChanged += OnLinKTargetChanged;
}

private void OnLinKTargetChanged(BaseLinkModel link, Anchor? oldTarget, Anchor? newTarget)
private void OnLinKTargetChanged(BaseLinkModel link, Anchor oldTarget, Anchor newTarget)
{
if (oldTarget == null && newTarget != null) // First attach
// only refresh on the first time the link is attached
if (oldTarget is PositionAnchor
&& newTarget.Model is PortModel targetModel
&& link.IsAttached)
{
(newTarget.Model as PortModel)!.Parent.Refresh();
targetModel.Parent.Refresh();
}
}

private void OnLinkRemoved(BaseLinkModel link)
{
(link.Source.Model as PortModel)!.Parent.Refresh();
if (link.Target != null) (link.Target.Model as PortModel)!.Parent.Refresh();
if (link.Target is SinglePortAnchor anchor && anchor.Model is PortModel portModel)
{
portModel.Parent.Refresh();
}
link.TargetChanged -= OnLinKTargetChanged;
}
}
10 changes: 6 additions & 4 deletions site/Site/Pages/Documentation/Links/PathGenerators.razor
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ link.PathGenerator = new SmoothPathGenerator();
<h2>Straight Path Generator</h2>

<p>
The <code>StraightPathGenerator</code> generates straight lines.
The <code>StraightPathGenerator</code> generates straight lines.<br />
You can also choose a radius for when the path contains vertices or direction changes.
</p>

<h3>Usage</h3>
Expand Down Expand Up @@ -78,12 +79,13 @@ link.PathGenerator = new StraightPathGenerator();
// Straight Path Generator
var stpgNode1 = _stpgDiagram.Nodes.Add(new NodeModel(new Point(150, 50)));
var stpgNode2 = _stpgDiagram.Nodes.Add(new NodeModel(new Point(450, 110)));
var stpgBottomPort1 = stpgNode1.AddPort(PortAlignment.BottomRight);
var stpgBottomPort1 = stpgNode1.AddPort(PortAlignment.Bottom);
var stpgRightPort1 = stpgNode1.AddPort(PortAlignment.Right);
var stpgBottomPort2 = stpgNode2.AddPort(PortAlignment.BottomLeft);
var stpgLeftPort2 = stpgNode2.AddPort(PortAlignment.Left);
_stpgDiagram.Links.Add(new LinkModel(stpgBottomPort1, stpgBottomPort2)).PathGenerator = new StraightPathGenerator();
_stpgDiagram.Links.Add(new LinkModel(stpgRightPort1, stpgLeftPort2)).PathGenerator = new StraightPathGenerator();

var link = _stpgDiagram.Links.Add(new LinkModel(stpgBottomPort1, stpgBottomPort2));
link.PathGenerator = new StraightPathGenerator(10);
link.AddVertex(new Point(200, 250));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>zHaytam</Authors>
<Description>Algorithms for Z.Blazor.Diagrams</Description>
<AssemblyVersion>3.0.0</AssemblyVersion>
<FileVersion>3.0.0</FileVersion>
<AssemblyVersion>3.0.1</AssemblyVersion>
<FileVersion>3.0.1</FileVersion>
<RepositoryUrl>https://github.com/zHaytam/Blazor.Diagrams</RepositoryUrl>
<Version>3.0.0</Version>
<Version>3.0.1</Version>
<PackageId>Z.Blazor.Diagrams.Algorithms</PackageId>
<PackageTags>blazor diagrams diagramming svg drag algorithms layouts</PackageTags>
<Product>Z.Blazor.Diagrams.Algorithms</Product>
Expand Down
6 changes: 3 additions & 3 deletions src/Blazor.Diagrams.Core/Blazor.Diagrams.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>zHaytam</Authors>
<Description>A fully customizable and extensible all-purpose diagrams library for Blazor</Description>
<AssemblyVersion>3.0.0</AssemblyVersion>
<FileVersion>3.0.0</FileVersion>
<AssemblyVersion>3.0.1</AssemblyVersion>
<FileVersion>3.0.1</FileVersion>
<RepositoryUrl>https://github.com/Blazor-Diagrams/Blazor.Diagrams</RepositoryUrl>
<Version>3.0.0</Version>
<Version>3.0.1</Version>
<PackageId>Z.Blazor.Diagrams.Core</PackageId>
<PackageTags>blazor diagrams diagramming svg drag</PackageTags>
<Product>Z.Blazor.Diagrams.Core</Product>
Expand Down
36 changes: 31 additions & 5 deletions src/Blazor.Diagrams.Core/Controls/Default/RemoveControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,44 @@ public RemoveControl(IPositionProvider positionProvider)

public override Point? GetPosition(Model model) => _positionProvider.GetPosition(model);

public override ValueTask OnPointerDown(Diagram diagram, Model model, PointerEventArgs _)
public override async ValueTask OnPointerDown(Diagram diagram, Model model, PointerEventArgs _)
{
switch (model)
if (await ShouldDeleteModel(diagram, model))
{
DeleteModel(diagram, model);
}
}

private static void DeleteModel(Diagram diagram, Model model)
{
switch (model)
{
case GroupModel group:
diagram.Groups.Delete(group);
return;
case NodeModel node:
diagram.Nodes.Remove(node);
break;
return;

case BaseLinkModel link:
diagram.Links.Remove(link);
break;
return;
}
}

private static async ValueTask<bool> ShouldDeleteModel(Diagram diagram, Model model)
{
if (model.Locked)
{
return false;
}

return ValueTask.CompletedTask;
return model switch
{
GroupModel group => await diagram.Options.Constraints.ShouldDeleteGroup.Invoke(group),
NodeModel node => await diagram.Options.Constraints.ShouldDeleteNode.Invoke(node),
BaseLinkModel link => await diagram.Options.Constraints.ShouldDeleteLink.Invoke(link),
_ => false,
};
}
}
3 changes: 3 additions & 0 deletions src/Blazor.Diagrams.Core/Models/Base/BaseLinkModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected BaseLinkModel(string id, Anchor source, Anchor target) : base(id)
public Anchor Source { get; private set; }
public Anchor Target { get; private set; }
public Diagram? Diagram { get; internal set; }
public Point[]? Route { get; private set; }
public PathGeneratorResult? PathGeneratorResult { get; private set; }
public bool IsAttached => Source is not PositionAnchor && Target is not PositionAnchor;
public Router? Router { get; set; }
Expand Down Expand Up @@ -129,11 +130,13 @@ private void GeneratePath()
var target = Target.GetPosition(this, route);
if (source != null && target != null)
{
Route = route;
PathGeneratorResult = pathGenerator.GetResult(Diagram, this, route, source, target);
return;
}
}

Route = null;
PathGeneratorResult = null;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Blazor.Diagrams/Blazor.Diagrams.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<Nullable>enable</Nullable>
<Authors>zHaytam</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<AssemblyVersion>3.0.0</AssemblyVersion>
<FileVersion>3.0.0</FileVersion>
<AssemblyVersion>3.0.1</AssemblyVersion>
<FileVersion>3.0.1</FileVersion>
<RepositoryUrl>https://github.com/Blazor-Diagrams/Blazor.Diagrams</RepositoryUrl>
<Description>A fully customizable and extensible all-purpose diagrams library for Blazor</Description>
<Version>3.0.0</Version>
<Version>3.0.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageTags>blazor diagrams diagramming svg drag</PackageTags>
<PackageId>Z.Blazor.Diagrams</PackageId>
Expand Down
4 changes: 2 additions & 2 deletions src/Blazor.Diagrams/Components/LinkWidget.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private RenderFragment GetSelectionHelperPath(string color, string d, int index)
builder.AddAttribute(3, "stroke-width", 12);
builder.AddAttribute(4, "d", d);
builder.AddAttribute(5, "stroke-linecap", "butt");
builder.AddAttribute(6, "stroke-opacity", _hovered ? 0.05 : 0);
builder.AddAttribute(6, "stroke-opacity", _hovered ? "0.05" : "0");
builder.AddAttribute(7, "fill", "none");
builder.AddAttribute(8, "onmouseenter", EventCallback.Factory.Create<MouseEventArgs>(this, OnMouseEnter));
builder.AddAttribute(9, "onmouseleave", EventCallback.Factory.Create<MouseEventArgs>(this, OnMouseLeave));
Expand Down Expand Up @@ -59,4 +59,4 @@ private LinkVertexModel CreateVertex(double clientX, double clientY, int index)
Link.Refresh();
return vertex;
}
}
}
5 changes: 3 additions & 2 deletions src/Blazor.Diagrams/wwwroot/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ var s = {
}
},
unobserve: (element, id) => {
if (!element) return;
s.ro.unobserve(element);
if (element) {
s.ro.unobserve(element);
}
delete s.tracked[id];
delete s.canvases[id];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Blazor.Diagrams/wwwroot/script.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified src/Blazor.Diagrams/wwwroot/script.min.js.gz
Binary file not shown.
Loading
Loading