Skip to content

Commit d1a7c00

Browse files
committed
doc: Update README
1 parent 19f046a commit d1a7c00

File tree

1 file changed

+2
-153
lines changed

1 file changed

+2
-153
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.

0 commit comments

Comments
 (0)