Skip to content

Commit bab708c

Browse files
fix(workspace): hide league reset settings when leagues are disabled
1 parent 8b66435 commit bab708c

29 files changed

+257
-106
lines changed

server/application-server/openapi.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4885,6 +4885,9 @@ components:
48854885
leaderboardEnabled:
48864886
type: boolean
48874887
description: Enable the leaderboard ranking page
4888+
leaguesEnabled:
4889+
type: boolean
4890+
description: Enable league tiers and rankings
48884891
practicesEnabled:
48894892
type: boolean
48904893
description: Enable the practice review feature
@@ -5122,6 +5125,9 @@ components:
51225125
type: string
51235126
description: Time for leaderboard notifications in HH:mm format
51245127
example: 09:00
5128+
leaguesEnabled:
5129+
type: boolean
5130+
description: Whether league tiers and rankings are enabled
51255131
practicesEnabled:
51265132
type: boolean
51275133
description: Whether the practice review feature is enabled
@@ -5163,6 +5169,7 @@ components:
51635169
- id
51645170
- isPubliclyViewable
51655171
- leaderboardEnabled
5172+
- leaguesEnabled
51665173
- practicesEnabled
51675174
- progressionEnabled
51685175
- providerType
@@ -5193,6 +5200,9 @@ components:
51935200
leaderboardEnabled:
51945201
type: boolean
51955202
description: Whether the leaderboard is enabled
5203+
leaguesEnabled:
5204+
type: boolean
5205+
description: Whether league tiers and rankings are enabled
51965206
practicesEnabled:
51975207
type: boolean
51985208
description: Whether the practice review feature is enabled
@@ -5220,6 +5230,7 @@ components:
52205230
- displayName
52215231
- id
52225232
- leaderboardEnabled
5233+
- leaguesEnabled
52235234
- practicesEnabled
52245235
- progressionEnabled
52255236
- providerType

server/application-server/src/main/java/de/tum/in/www1/hephaestus/workspace/WorkspaceFeatures.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public class WorkspaceFeatures {
4949
@NotNull(message = "Progression enabled flag is required")
5050
private Boolean progressionEnabled = false;
5151

52+
/** Whether the league tiers and rankings are enabled */
53+
@Column(name = "leagues_enabled", nullable = false)
54+
@NotNull(message = "Leagues enabled flag is required")
55+
private Boolean leaguesEnabled = false;
56+
5257
/**
5358
* Applies a partial update from the request DTO (PATCH semantics).
5459
* Null fields in the request are ignored; non-null fields overwrite the current value.
@@ -66,5 +71,8 @@ public void applyPatch(UpdateWorkspaceFeaturesRequestDTO request) {
6671
if (request.progressionEnabled() != null) {
6772
this.progressionEnabled = request.progressionEnabled();
6873
}
74+
if (request.leaguesEnabled() != null) {
75+
this.leaguesEnabled = request.leaguesEnabled();
76+
}
6977
}
7078
}

server/application-server/src/main/java/de/tum/in/www1/hephaestus/workspace/WorkspaceSettingsService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,13 @@ public Workspace updateFeatures(Long workspaceId, UpdateWorkspaceFeaturesRequest
151151
workspace.getFeatures().applyPatch(request);
152152

153153
log.info(
154-
"Updated workspace features: workspaceId={}, practices={}, achievements={}, leaderboard={}, progression={}",
154+
"Updated workspace features: workspaceId={}, practices={}, achievements={}, leaderboard={}, progression={}, leagues={}",
155155
workspaceId,
156156
request.practicesEnabled(),
157157
request.achievementsEnabled(),
158158
request.leaderboardEnabled(),
159-
request.progressionEnabled()
159+
request.progressionEnabled(),
160+
request.leaguesEnabled()
160161
);
161162
return workspaceRepository.save(workspace);
162163
}

server/application-server/src/main/java/de/tum/in/www1/hephaestus/workspace/dto/UpdateWorkspaceFeaturesRequestDTO.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ public record UpdateWorkspaceFeaturesRequestDTO(
1111
@Schema(description = "Enable the practice review feature") Boolean practicesEnabled,
1212
@Schema(description = "Enable the achievements system") Boolean achievementsEnabled,
1313
@Schema(description = "Enable the leaderboard ranking page") Boolean leaderboardEnabled,
14-
@Schema(description = "Enable the league/progression system") Boolean progressionEnabled
14+
@Schema(description = "Enable the league/progression system") Boolean progressionEnabled,
15+
@Schema(description = "Enable league tiers and rankings") Boolean leaguesEnabled
1516
) {}

server/application-server/src/main/java/de/tum/in/www1/hephaestus/workspace/dto/WorkspaceDTO.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public record WorkspaceDTO(
4545
@NonNull @Schema(description = "Whether the practice review feature is enabled") Boolean practicesEnabled,
4646
@NonNull @Schema(description = "Whether the achievements system is enabled") Boolean achievementsEnabled,
4747
@NonNull @Schema(description = "Whether the leaderboard is enabled") Boolean leaderboardEnabled,
48-
@NonNull @Schema(description = "Whether the league/progression system is enabled") Boolean progressionEnabled
48+
@NonNull @Schema(description = "Whether the league/progression system is enabled") Boolean progressionEnabled,
49+
@NonNull @Schema(description = "Whether league tiers and rankings are enabled") Boolean leaguesEnabled
4950
) {
5051
public static WorkspaceDTO from(Workspace workspace) {
5152
return new WorkspaceDTO(
@@ -74,7 +75,8 @@ public static WorkspaceDTO from(Workspace workspace) {
7475
workspace.getFeatures().getPracticesEnabled(),
7576
workspace.getFeatures().getAchievementsEnabled(),
7677
workspace.getFeatures().getLeaderboardEnabled(),
77-
workspace.getFeatures().getProgressionEnabled()
78+
workspace.getFeatures().getProgressionEnabled(),
79+
workspace.getFeatures().getLeaguesEnabled()
7880
);
7981
}
8082
}

server/application-server/src/main/java/de/tum/in/www1/hephaestus/workspace/dto/WorkspaceListItemDTO.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public record WorkspaceListItemDTO(
2222
@NonNull @Schema(description = "Whether the practice review feature is enabled") Boolean practicesEnabled,
2323
@NonNull @Schema(description = "Whether the achievements system is enabled") Boolean achievementsEnabled,
2424
@NonNull @Schema(description = "Whether the leaderboard is enabled") Boolean leaderboardEnabled,
25-
@NonNull @Schema(description = "Whether the league/progression system is enabled") Boolean progressionEnabled
25+
@NonNull @Schema(description = "Whether the league/progression system is enabled") Boolean progressionEnabled,
26+
@NonNull @Schema(description = "Whether league tiers and rankings are enabled") Boolean leaguesEnabled
2627
) {
2728
public static WorkspaceListItemDTO from(Workspace workspace) {
2829
return new WorkspaceListItemDTO(
@@ -36,7 +37,8 @@ public static WorkspaceListItemDTO from(Workspace workspace) {
3637
workspace.getFeatures().getPracticesEnabled(),
3738
workspace.getFeatures().getAchievementsEnabled(),
3839
workspace.getFeatures().getLeaderboardEnabled(),
39-
workspace.getFeatures().getProgressionEnabled()
40+
workspace.getFeatures().getProgressionEnabled(),
41+
workspace.getFeatures().getLeaguesEnabled()
4042
);
4143
}
4244
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
5+
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
6+
7+
<changeSet id="1775000000000-1" author="hephaestus">
8+
<comment>Add leagues_enabled feature flag column to workspace table</comment>
9+
<addColumn tableName="workspace">
10+
<column name="leagues_enabled" type="BOOLEAN" defaultValueBoolean="false">
11+
<constraints nullable="false"/>
12+
</column>
13+
</addColumn>
14+
</changeSet>
15+
16+
</databaseChangeLog>

server/application-server/src/main/resources/db/master.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@
6767
<include file="./changelog/1774785360089_changelog.xml" relativeToChangelogFile="true"/>
6868
<include file="./changelog/1774800000000_changelog.xml" relativeToChangelogFile="true"/>
6969
<include file="./changelog/1774900000000_changelog.xml" relativeToChangelogFile="true"/>
70+
<include file="./changelog/1775000000000_changelog.xml" relativeToChangelogFile="true"/>
7071
</databaseChangeLog>

webapp/src/api/types.gen.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ export type WorkspaceListItem = {
140140
* Whether the leaderboard is enabled
141141
*/
142142
leaderboardEnabled: boolean;
143+
/**
144+
* Whether league tiers and rankings are enabled
145+
*/
146+
leaguesEnabled: boolean;
143147
/**
144148
* Whether the practice review feature is enabled
145149
*/
@@ -242,6 +246,10 @@ export type Workspace = {
242246
* Time for leaderboard notifications in HH:mm format
243247
*/
244248
leaderboardScheduleTime?: string;
249+
/**
250+
* Whether league tiers and rankings are enabled
251+
*/
252+
leaguesEnabled: boolean;
245253
/**
246254
* Whether the practice review feature is enabled
247255
*/
@@ -460,6 +468,10 @@ export type UpdateWorkspaceFeaturesRequest = {
460468
* Enable the leaderboard ranking page
461469
*/
462470
leaderboardEnabled?: boolean;
471+
/**
472+
* Enable league tiers and rankings
473+
*/
474+
leaguesEnabled?: boolean;
463475
/**
464476
* Enable the practice review feature
465477
*/

webapp/src/components/admin/AdminFeaturesSettings.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const meta = {
3737
achievementsEnabled: false,
3838
leaderboardEnabled: false,
3939
progressionEnabled: false,
40+
leaguesEnabled: false,
4041
isSaving: false,
4142
onToggle: fn(),
4243
},

0 commit comments

Comments
 (0)