refactor(ui): new standard and accessible UI font (#1777)
This commit is contained in:
@@ -36,6 +36,7 @@ public class BookLoreUserTransformer {
|
||||
bookLoreUser.setTheme(userEntity.getTheme());
|
||||
bookLoreUser.setThemeAccent(userEntity.getThemeAccent());
|
||||
bookLoreUser.setThemeSyncEnabled(userEntity.isThemeSyncEnabled());
|
||||
bookLoreUser.setUiFont(userEntity.getUiFont());
|
||||
bookLoreUser.setDefaultPassword(userEntity.isDefaultPassword());
|
||||
bookLoreUser.setPermissions(permissions);
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ public class BookLoreUser {
|
||||
private String theme;
|
||||
private String themeAccent;
|
||||
private boolean themeSyncEnabled;
|
||||
private String uiFont;
|
||||
private ProvisioningMethod provisioningMethod;
|
||||
private List<Library> assignedLibraries;
|
||||
private UserPermissions permissions;
|
||||
|
||||
@@ -10,4 +10,5 @@ public class UserProfileUpdateRequest {
|
||||
private String theme;
|
||||
private String themeAccent;
|
||||
private Boolean themeSyncEnabled;
|
||||
private String uiFont;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,10 @@ public class BookLoreUserEntity {
|
||||
@Column(name = "theme_sync_enabled", nullable = false)
|
||||
private boolean themeSyncEnabled = true;
|
||||
|
||||
@Builder.Default
|
||||
@Column(name = "ui_font", nullable = false, length = 32)
|
||||
private String uiFont = "default";
|
||||
|
||||
@Column(name = "provisioning_method")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private ProvisioningMethod provisioningMethod;
|
||||
|
||||
@@ -43,6 +43,7 @@ public class UserService {
|
||||
"red", "orange", "amber", "yellow", "lime", "green", "emerald", "teal",
|
||||
"cyan", "sky", "blue", "indigo", "violet", "purple", "fuchsia", "pink", "rose"
|
||||
);
|
||||
private static final Set<String> SUPPORTED_UI_FONTS = Set.of("default", "atkinson");
|
||||
|
||||
private final UserRepository userRepository;
|
||||
private final LibraryRepository libraryRepository;
|
||||
@@ -124,6 +125,11 @@ public class UserService {
|
||||
user.setThemeSyncEnabled(updateRequest.getThemeSyncEnabled());
|
||||
}
|
||||
|
||||
if (updateRequest.getUiFont() != null) {
|
||||
validateUiFont(updateRequest.getUiFont());
|
||||
user.setUiFont(updateRequest.getUiFont());
|
||||
}
|
||||
|
||||
userRepository.save(user);
|
||||
auditService.log(AuditAction.USER_UPDATED, "User", id, "Updated user profile: " + user.getUsername());
|
||||
return bookLoreUserTransformer.toDTO(user);
|
||||
@@ -282,4 +288,10 @@ public class UserService {
|
||||
throw ApiError.INVALID_INPUT.createException("Unsupported theme accent: " + themeAccent);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateUiFont(String uiFont) {
|
||||
if (!SUPPORTED_UI_FONTS.contains(uiFont)) {
|
||||
throw ApiError.INVALID_INPUT.createException("Unsupported UI font: " + uiFont);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user