Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Add optional frontpage summary to news items.
-- When populated, this text is shown on the frontpage instead of the full body when the item is highlighted.

ALTER TABLE "NewsItem"
ADD COLUMN "FrontpageSummary" TEXT;
8 changes: 4 additions & 4 deletions db/seed/NewsItem.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Id;Title;Body;DueDate;IsHighlighted;CreatedBy;CreatedAt;ModifiedAt
A1000000-0000-0000-0000-000000000001;Welcome to the new Self Service Portal;We have launched a completely redesigned Self Service Portal with improved navigation, faster load times, and a new dark mode. Check it out and let us know what you think in the #cloud-engineering Slack channel.;2026-06-30T23:59:59;true;seedscript;2026-04-22T08:00:00;
A1000000-0000-0000-0000-000000000002;Kubernetes 1.32 upgrade scheduled for May;We will be upgrading all clusters to Kubernetes 1.32 on May 12th. There will be a brief rolling restart of workloads. No action is required from capability teams, but please review the changelog for any deprecations that may affect you.;2026-05-12T23:59:59;false;seedscript;2026-04-15T09:00:00;
A1000000-0000-0000-0000-000000000003;New ECR lifecycle policies in effect;Automatic cleanup policies have been applied to all ECR repositories. Images older than 90 days that are not tagged as 'latest' or with a semantic version will be pruned. Reach out to Cloud Engineering if you have questions.;2026-05-31T23:59:59;false;seedscript;2026-04-10T11:00:00;
Id;Title;Body;DueDate;IsHighlighted;CreatedBy;CreatedAt;ModifiedAt;FrontpageSummary
A1000000-0000-0000-0000-000000000001;Welcome to the new Self Service Portal;We have launched a completely redesigned Self Service Portal with improved navigation, faster load times, and a new dark mode. Check it out and let us know what you think in the #cloud-engineering Slack channel.;2026-06-30T23:59:59;true;seedscript;2026-04-22T08:00:00;;
A1000000-0000-0000-0000-000000000002;Kubernetes 1.32 upgrade scheduled for May;We will be upgrading all clusters to Kubernetes 1.32 on May 12th. There will be a brief rolling restart of workloads. No action is required from capability teams, but please review the changelog for any deprecations that may affect you.;2026-05-12T23:59:59;false;seedscript;2026-04-15T09:00:00;;
A1000000-0000-0000-0000-000000000003;New ECR lifecycle policies in effect;Automatic cleanup policies have been applied to all ECR repositories. Images older than 90 days that are not tagged as 'latest' or with a semantic version will be pruned. Reach out to Cloud Engineering if you have questions.;2026-05-31T23:59:59;false;seedscript;2026-04-10T11:00:00;;
15 changes: 13 additions & 2 deletions src/SelfService/Domain/Models/NewsItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class NewsItem : Entity<NewsItemId>
{
public string Title { get; private set; }
public string Body { get; private set; }
public string? FrontpageSummary { get; private set; }
public DateTime DueDate { get; private set; }
public bool IsHighlighted { get; private set; }
public string CreatedBy { get; private set; }
Expand All @@ -17,19 +18,27 @@ public NewsItem(
DateTime dueDate,
bool isHighlighted,
string createdBy,
DateTime createdAt
DateTime createdAt,
string? frontpageSummary = null
)
: base(id)
{
Title = title;
Body = body;
FrontpageSummary = frontpageSummary;
DueDate = dueDate;
IsHighlighted = isHighlighted;
CreatedBy = createdBy;
CreatedAt = createdAt;
}

public void Update(string? title, string? body, DateTime? dueDate, DateTime modifiedAt)
public void Update(
string? title,
string? body,
DateTime? dueDate,
DateTime modifiedAt,
string? frontpageSummary = null
)
{
if (!string.IsNullOrWhiteSpace(title))
{
Expand All @@ -46,6 +55,8 @@ public void Update(string? title, string? body, DateTime? dueDate, DateTime modi
DueDate = dueDate.Value;
}

FrontpageSummary = frontpageSummary;

ModifiedAt = modifiedAt;
}

Expand Down
8 changes: 7 additions & 1 deletion src/SelfService/Domain/Services/NewsItemService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ public async Task UpdateNewsItem(NewsItemId id, NewsItemUpdateRequest updateRequ
await _newsItemRepository.FindById(id)
?? throw new KeyNotFoundException($"News item with id '{id}' not found.");

newsItem.Update(updateRequest.Title, updateRequest.Body, updateRequest.DueDate, DateTime.UtcNow);
newsItem.Update(
updateRequest.Title,
updateRequest.Body,
updateRequest.DueDate,
DateTime.UtcNow,
updateRequest.FrontpageSummary
);
}

[TransactionalBoundary]
Expand Down
1 change: 1 addition & 0 deletions src/SelfService/Infrastructure/Api/ApiResourceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,7 @@ public NewsItemApiResource Convert(NewsItem newsItem)
id: newsItem.Id,
title: newsItem.Title,
body: newsItem.Body,
frontpageSummary: newsItem.FrontpageSummary,
dueDate: newsItem.DueDate,
isHighlighted: newsItem.IsHighlighted,
isRelevant: newsItem.IsRelevant(),
Expand Down
3 changes: 2 additions & 1 deletion src/SelfService/Infrastructure/Api/News/NewsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public async Task<IActionResult> CreateNewsItem([FromBody] NewsItemCreateRequest
dueDate: request.DueDate,
isHighlighted: false,
createdBy: userId,
createdAt: DateTime.UtcNow
createdAt: DateTime.UtcNow,
frontpageSummary: request.FrontpageSummary
);

var created = await _newsItemService.CreateNewsItem(newsItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class NewsItemApiResource
public NewsItemId Id { get; private set; }
public string Title { get; private set; }
public string Body { get; private set; }
public string? FrontpageSummary { get; private set; }
public DateTime DueDate { get; private set; }
public bool IsHighlighted { get; private set; }
public bool IsRelevant { get; private set; }
Expand All @@ -33,6 +34,7 @@ public NewsItemApiResource(
NewsItemId id,
string title,
string body,
string? frontpageSummary,
DateTime dueDate,
bool isHighlighted,
bool isRelevant,
Expand All @@ -45,6 +47,7 @@ NewsItemLinks links
Id = id;
Title = title;
Body = body;
FrontpageSummary = frontpageSummary;
DueDate = dueDate;
IsHighlighted = isHighlighted;
IsRelevant = isRelevant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class NewsItemCreateRequest
[Required]
public string? Body { get; set; }

public string? FrontpageSummary { get; set; }

[Required]
public DateTime DueDate { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ public class NewsItemUpdateRequest
{
public string? Title { get; set; }
public string? Body { get; set; }
public string? FrontpageSummary { get; set; }
public DateTime? DueDate { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
cfg.Property(x => x.Id).ValueGeneratedNever();
cfg.Property(x => x.Title);
cfg.Property(x => x.Body);
cfg.Property(x => x.FrontpageSummary);
cfg.Property(x => x.DueDate);
cfg.Property(x => x.IsHighlighted);
cfg.Property(x => x.CreatedBy);
Expand Down
Loading