Skip to content

Commit 4079d9a

Browse files
authored
Merge pull request #28 from jcdcdev/dev/v15
15.1.3
2 parents ba2cc53 + 0cd31fd commit 4079d9a

File tree

5 files changed

+353
-161
lines changed

5 files changed

+353
-161
lines changed

.github/README.md

Lines changed: 2 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -16,162 +16,11 @@ This packages aims to help developers quickly put together Umbraco Trees using C
1616
- Easy to define section permissions
1717
- ✨ Custom Entity Actions!
1818

19-
> [!IMPORTANT]
20-
> Version 15 will only receive security updates and no new features.
19+
> [!WARNING]
20+
> Version 15 is no longer supported and is End of Life (EOL).
2121
2222
> Please review the [security policy](https://github.com/jcdcdev/Umbraco.Community.SimpleTrees?tab=security-ov-file#supported-versions) for more information.
2323
24-
## Quick Start
25-
26-
### Install Package
27-
28-
```csharp
29-
dotnet add package Umbraco.Community.SimpleTrees
30-
```
31-
32-
### Register Tree
33-
34-
By default, this will display in the content section.
35-
36-
```csharp title="ExampleTree.cs"
37-
using Umbraco.Cms.Core.Models;
38-
using Umbraco.Community.SimpleTrees.Core.Models;
39-
40-
namespace Umbraco.Community.SimpleTrees.TestSite.Trees;
41-
42-
public class MyTree : SimpleTree
43-
{
44-
public override Task<PagedModel<ISimpleTreeItem>> GetTreeRootAsync(int skip, int take, bool foldersOnly)
45-
{
46-
var data = new List<ISimpleTreeItem>
47-
{
48-
CreateRootItem("James", Guid.NewGuid().ToString(), "icon-user"),
49-
CreateRootItem("Tim", Guid.NewGuid().ToString(), "icon-user"),
50-
};
51-
52-
return Task.FromResult(new PagedModel<ISimpleTreeItem>(data.Count, data));
53-
}
54-
55-
public override Task<PagedModel<ISimpleTreeItem>> GetTreeChildrenAsync(string entityType, string parentUnique, int skip, int take, bool foldersOnly) => Task.FromResult(EmptyResult());
56-
57-
public override string Name => "My Tree";
58-
}
59-
```
60-
61-
### Create Views
62-
63-
- Your views **must** go in `/Views/Trees`
64-
- You views **must** be the name of your tree entities
65-
- For example: `MyTree.cs` => `/Views/Trees/MyItem.cshtml` & `/Views/Trees/MyRoot.cshtml`
66-
67-
```csharp title="Views/Trees/MyItem.cshtml"
68-
@inherits Umbraco.Community.SimpleTrees.Web.SimpleTreeViewPage
69-
70-
<uui-box headline="This is a custom tree item">
71-
<div>
72-
<table>
73-
<thead>
74-
<tr>
75-
<th>Entity Type</th>
76-
<th>Unique</th>
77-
</tr>
78-
</thead>
79-
<tbody>
80-
<tr>
81-
<td>@Model.EntityType</td>
82-
<td>@Model.Unique</td>
83-
</tr>
84-
</table>
85-
</div>
86-
</uui-box>
87-
```
88-
89-
90-
## Extending
91-
92-
### Entity Actions
93-
94-
It is possible to implement two Entity Actions
95-
96-
#### Url Actions
97-
98-
When clicked, the user will be taken to the specific URL.
99-
100-
```csharp title="NuGetPackageItemEntityUrlAction.cs"
101-
using Umbraco.Community.SimpleTrees.Core.Models;
102-
103-
namespace Umbraco.Community.SimpleTrees.TestSite.Trees;
104-
105-
public class NuGetPackageItemEntityUrlAction : SimpleEntityUrlAction
106-
{
107-
public override string Icon => "icon-link";
108-
public override string Name => "Go to Package";
109-
public override Type[] ForTreeItems => [typeof(NuGetPackageTree)];
110-
public override Type[] ForSimpleEntityTypes => [typeof(NuGetPackageVersionEntityType)];
111-
112-
public override Task<Uri> GetUrlAsync(string unique, string entityType)
113-
{
114-
var uri = new Uri("https://www.nuget.org/packages/" + unique);
115-
return Task.FromResult(uri);
116-
}
117-
}
118-
```
119-
120-
#### Execute Actions
121-
122-
When clicked, you custom logic will be executed. You can also return a helpful response to the user.
123-
124-
```csharp title="NuGetPackageItemEntityExecuteAction"
125-
using System.Net.Http.Headers;
126-
using Umbraco.Community.SimpleTrees.Core.Models;
127-
using Umbraco.Community.SimpleTrees.Web.Models;
128-
129-
namespace Umbraco.Community.SimpleTrees.TestSite.Trees;
130-
131-
public class NuGetPackageItemEntityExecuteAction : SimpleEntityExecuteAction
132-
{
133-
private readonly HttpClient _client;
134-
135-
public NuGetPackageItemEntityExecuteAction(HttpClient client)
136-
{
137-
var url = "https://functions.marketplace.umbraco.com/api/";
138-
client.BaseAddress = new Uri(url);
139-
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Umbraco.Community.SimpleTrees.TestSite", "1.0"));
140-
_client = client;
141-
}
142-
143-
public override string Icon => "icon-refresh";
144-
public override string Name => "Sync Package";
145-
public override Type[] ForTreeItems => [typeof(NuGetPackageTree)];
146-
147-
public override async Task<SimpleEntityActionExecuteResponse> ExecuteAsync(string unique, string entityType)
148-
{
149-
try
150-
{
151-
var split = unique.Split('_');
152-
var packageId = split[0];
153-
var model = new MarketplaceRequest
154-
{
155-
PackageId = packageId,
156-
};
157-
158-
var result = await _client.PostAsJsonAsync("InitiateSinglePackageSyncFunction", model);
159-
if (!result.IsSuccessStatusCode)
160-
{
161-
return SimpleEntityActionExecuteResponse.Error("Failed to initiate package update", $"Status Code: {result.StatusCode}, Reason: {result.ReasonPhrase}");
162-
}
163-
164-
var message = $"Package {packageId} update has been initiated. You can check the progress in the Umbraco Marketplace.";
165-
return SimpleEntityActionExecuteResponse.Success("Package update initiated successfully", message);
166-
}
167-
catch (Exception ex)
168-
{
169-
return SimpleEntityActionExecuteResponse.Error("An error occurred while initiating the package update", ex.Message);
170-
}
171-
}
172-
}
173-
```
174-
17524
## Contributing
17625

17726
Contributions to this package are most welcome! Please visit the [Contributing](https://github.com/jcdcdev/Umbraco.Community.SimpleTrees/contribute) page.

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Build
10-
uses: jcdcdev/jcdcdev.Umbraco.Github.Build@main
10+
uses: jcdcdev/jcdcdev.Umbraco.GitHub.Build@v0
1111
with:
1212
project-name: Umbraco.Community.SimpleTrees
1313
project-path: src/Umbraco.Community.SimpleTrees/Umbraco.Community.SimpleTrees.csproj
1414
npm-working-dir: src/Umbraco.Community.SimpleTrees.Client
1515
npm-enabled: true
1616
umbraco-version: 15
1717
dotnet-version: "9"
18-
npm-version: "22.x"
18+
npm-version: "22.x"

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 🚀 Release
22
on:
33
workflow_dispatch:
44
pull_request:
5-
types: [ closed ]
5+
types: [closed]
66
jobs:
77
release:
88
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414
- name: Build
1515
id: build
16-
uses: jcdcdev/jcdcdev.Umbraco.GitHub.Build@main
16+
uses: jcdcdev/jcdcdev.Umbraco.GitHub.Build@v0
1717
with:
1818
project-name: Umbraco.Community.SimpleTrees
1919
project-path: src/Umbraco.Community.SimpleTrees/Umbraco.Community.SimpleTrees.csproj
@@ -23,9 +23,9 @@ jobs:
2323
umbraco-version: 15
2424
dotnet-version: "9"
2525
- name: Release
26-
uses: jcdcdev/jcdcdev.Umbraco.GitHub.Release@main
26+
uses: jcdcdev/jcdcdev.Umbraco.GitHub.Release@v0
2727
with:
2828
artifact-name: ${{ steps.build.outputs.artifact-name }}
2929
version: ${{ steps.build.outputs.version }}
3030
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
31-
github-token: ${{ secrets.GITHUB_TOKEN }}
31+
github-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)