Skip to content

Commit 971e747

Browse files
committed
update unit test for user group
1 parent edc9287 commit 971e747

File tree

8 files changed

+150
-116
lines changed

8 files changed

+150
-116
lines changed

src/Umbraco.Cms.Api.Management/ViewModels/UserGroup/UserGroupBase.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ public class UserGroupBase
2222
/// </summary>
2323
public required string Alias { get; init; }
2424

25+
/// <summary>
26+
/// The description of the user group
27+
/// </summary>
28+
public string? Description { get; set; }
29+
2530
/// <summary>
2631
/// The Icon for the user group
2732
/// </summary>
@@ -79,9 +84,4 @@ public class UserGroupBase
7984
/// </summary>
8085
public required ISet<string> FallbackPermissions { get; init; }
8186
public required ISet<IPermissionPresentationModel> Permissions { get; init; }
82-
83-
/// <summary>
84-
/// The description of the user group
85-
/// </summary>
86-
public string? Description { get; set; }
8787
}

src/Umbraco.Core/Models/Membership/IReadOnlyUserGroup.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ public interface IReadOnlyUserGroup
99
{
1010
string? Name { get; }
1111

12+
string Alias { get; }
13+
14+
string? Description { get { return null; } }
15+
1216
string? Icon { get; }
1317

1418
int Id { get; }
@@ -19,11 +23,6 @@ public interface IReadOnlyUserGroup
1923

2024
int? StartMediaId { get; }
2125

22-
/// <summary>
23-
/// The alias
24-
/// </summary>
25-
string Alias { get; }
26-
2726
// This is set to return true as default to avoid breaking changes.
2827
bool HasAccessToAllLanguages => true;
2928

@@ -36,6 +35,4 @@ public interface IReadOnlyUserGroup
3635
IEnumerable<int> AllowedLanguages => Enumerable.Empty<int>();
3736

3837
public bool HasAccessToLanguage( int languageId) => HasAccessToAllLanguages || AllowedLanguages.Contains(languageId);
39-
40-
string? Description { get; }
41-
}
38+
}

src/Umbraco.Core/Models/Membership/IUserGroup.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ public interface IUserGroup : IEntity, IRememberBeingDirty
2525
/// <summary>
2626
/// The description
2727
/// </summary>
28-
string? Description { get; set; }
28+
string? Description {
29+
get => null;
30+
set { }
31+
}
2932

3033
/// <summary>
3134
/// If this property is true it will give the group access to all languages

src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ protected virtual void DefinePlan()
143143

144144
// To 17.0.1
145145
To<V_17_0_1.EnsureUmbracoPropertyDataColumnCasing>("{BE5CA411-E12D-4455-A59E-F12A669E5363}");
146-
To<V_17_0_1.AddDescriptionToUserGroup>("{D3C5E3C4-1F4C-4D1A-8E2C-1C8D8E2F5B6A}");
146+
147+
// To 17.1.0
148+
To<V_17_1_0.AddDescriptionToUserGroup>("{F1A2B3C4-D5E6-4789-ABCD-1234567890AB}");
147149

148150
// To 18.0.0
149151
// TODO (V18): Enable on 18 branch

src/Umbraco.Infrastructure/Migrations/Upgrade/V_17_0_1/AddDescriptionToUserGroup.cs

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Umbraco.Cms.Core;
2+
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
3+
4+
namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_17_1_0
5+
{
6+
/// <summary>
7+
/// Migration to add a description column to the user group table.
8+
/// </summary>
9+
public class AddDescriptionToUserGroup : AsyncMigrationBase
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the <see cref="AddDescriptionToUserGroup"/> class.
13+
/// </summary>
14+
/// <param name="context">The migration context.</param>
15+
public AddDescriptionToUserGroup(
16+
IMigrationContext context)
17+
: base(context)
18+
{
19+
}
20+
21+
/// <inheritdoc/>
22+
protected override async Task MigrateAsync()
23+
{
24+
if (TableExists(Constants.DatabaseSchema.Tables.UserGroup))
25+
{
26+
return;
27+
}
28+
29+
string columnName = "description";
30+
var hasColumn = Context.SqlContext.SqlSyntax.GetColumnsInSchema(Context.Database).ToList().Any(c =>
31+
c.TableName == Constants.DatabaseSchema.Tables.UserGroup &&
32+
c.ColumnName == columnName);
33+
34+
if (!hasColumn)
35+
{
36+
AddColumn<UserGroupDto>(Constants.DatabaseSchema.Tables.UserGroup, columnName);
37+
}
38+
}
39+
}
40+
}

src/Umbraco.Web.UI.Client/src/packages/multi-url-picker/link-picker-modal/link-picker-modal.element.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement<UmbLinkPicker
193193
const query = (event.target.value as string) ?? '';
194194
if (query.startsWith('#') || query.startsWith('?')) {
195195
this.#partialUpdateLink({ queryString: query });
196+
this.#validationContext.messages.removeMessageByKey('UmbLinkPickerValueValidator');
196197
return;
197198
}
198199

@@ -202,6 +203,7 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement<UmbLinkPicker
202203
this.#partialUpdateLink({ queryString: `#${query}` });
203204
} else {
204205
this.#partialUpdateLink({ queryString: '' });
206+
this.#validationContext.messages.removeMessageByKey('UmbLinkPickerValueValidator');
205207
}
206208
}
207209

@@ -233,6 +235,7 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement<UmbLinkPicker
233235
type: 'external',
234236
url,
235237
});
238+
this.#validationContext.messages.removeMessageByKey('UmbLinkPickerValueValidator');
236239
}
237240

238241
async #onPickerSelection(event: UmbInputPickerEvent, type: 'document' | 'media') {

0 commit comments

Comments
 (0)