Commit 3f56ce47 authored by johnnyjoy's avatar johnnyjoy

chore: update definition of workspace setting

parent 53d39785
......@@ -65,108 +65,114 @@ message WorkspaceSetting {
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
oneof value {
WorkspaceGeneralSetting general_setting = 2;
WorkspaceStorageSetting storage_setting = 3;
WorkspaceMemoRelatedSetting memo_related_setting = 4;
GeneralSetting general_setting = 2;
StorageSetting storage_setting = 3;
MemoRelatedSetting memo_related_setting = 4;
}
// Enumeration of workspace setting keys.
enum Key {
KEY_UNSPECIFIED = 0;
// BASIC is the key for basic settings.
BASIC = 1;
// GENERAL is the key for general settings.
GENERAL = 2;
GENERAL = 1;
// STORAGE is the key for storage settings.
STORAGE = 3;
STORAGE = 2;
// MEMO_RELATED is the key for memo related settings.
MEMO_RELATED = 4;
MEMO_RELATED = 3;
}
}
message WorkspaceGeneralSetting {
// theme is the name of the selected theme.
// This references a CSS file in the web/public/themes/ directory.
string theme = 1;
// disallow_user_registration disallows user registration.
bool disallow_user_registration = 2;
// disallow_password_auth disallows password authentication.
bool disallow_password_auth = 3;
// additional_script is the additional script.
string additional_script = 4;
// additional_style is the additional style.
string additional_style = 5;
// custom_profile is the custom profile.
WorkspaceCustomProfile custom_profile = 6;
// week_start_day_offset is the week start day offset from Sunday.
// 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday
// Default is Sunday.
int32 week_start_day_offset = 7;
// disallow_change_username disallows changing username.
bool disallow_change_username = 8;
// disallow_change_nickname disallows changing nickname.
bool disallow_change_nickname = 9;
}
message WorkspaceCustomProfile {
string title = 1;
string description = 2;
string logo_url = 3;
string locale = 4;
string appearance = 5;
}
message WorkspaceStorageSetting {
enum StorageType {
STORAGE_TYPE_UNSPECIFIED = 0;
// DATABASE is the database storage type.
DATABASE = 1;
// LOCAL is the local storage type.
LOCAL = 2;
// S3 is the S3 storage type.
S3 = 3;
// General workspace settings configuration.
message GeneralSetting {
// theme is the name of the selected theme.
// This references a CSS file in the web/public/themes/ directory.
string theme = 1;
// disallow_user_registration disallows user registration.
bool disallow_user_registration = 2;
// disallow_password_auth disallows password authentication.
bool disallow_password_auth = 3;
// additional_script is the additional script.
string additional_script = 4;
// additional_style is the additional style.
string additional_style = 5;
// custom_profile is the custom profile.
CustomProfile custom_profile = 6;
// week_start_day_offset is the week start day offset from Sunday.
// 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday
// Default is Sunday.
int32 week_start_day_offset = 7;
// disallow_change_username disallows changing username.
bool disallow_change_username = 8;
// disallow_change_nickname disallows changing nickname.
bool disallow_change_nickname = 9;
// Custom profile configuration for workspace branding.
message CustomProfile {
string title = 1;
string description = 2;
string logo_url = 3;
string locale = 4;
string appearance = 5;
}
}
// storage_type is the storage type.
StorageType storage_type = 1;
// The template of file path.
// e.g. assets/{timestamp}_{filename}
string filepath_template = 2;
// The max upload size in megabytes.
int64 upload_size_limit_mb = 3;
// Reference: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-go/
message S3Config {
string access_key_id = 1;
string access_key_secret = 2;
string endpoint = 3;
string region = 4;
string bucket = 5;
bool use_path_style = 6;
// Storage configuration settings for workspace attachments.
message StorageSetting {
// Storage type enumeration for different storage backends.
enum StorageType {
STORAGE_TYPE_UNSPECIFIED = 0;
// DATABASE is the database storage type.
DATABASE = 1;
// LOCAL is the local storage type.
LOCAL = 2;
// S3 is the S3 storage type.
S3 = 3;
}
// storage_type is the storage type.
StorageType storage_type = 1;
// The template of file path.
// e.g. assets/{timestamp}_{filename}
string filepath_template = 2;
// The max upload size in megabytes.
int64 upload_size_limit_mb = 3;
// S3 configuration for cloud storage backend.
// Reference: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-go/
message S3Config {
string access_key_id = 1;
string access_key_secret = 2;
string endpoint = 3;
string region = 4;
string bucket = 5;
bool use_path_style = 6;
}
// The S3 config.
S3Config s3_config = 4;
}
// The S3 config.
S3Config s3_config = 4;
}
message WorkspaceMemoRelatedSetting {
// disallow_public_visibility disallows set memo as public visibility.
bool disallow_public_visibility = 1;
// display_with_update_time orders and displays memo with update time.
bool display_with_update_time = 2;
// content_length_limit is the limit of content length. Unit is byte.
int32 content_length_limit = 3;
// enable_double_click_edit enables editing on double click.
bool enable_double_click_edit = 4;
// enable_link_preview enables links preview.
bool enable_link_preview = 5;
// enable_comment enables comment.
bool enable_comment = 6;
// reactions is the list of reactions.
repeated string reactions = 7;
// disable_markdown_shortcuts disallow the registration of markdown shortcuts.
bool disable_markdown_shortcuts = 8;
// enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW).
bool enable_blur_nsfw_content = 9;
// nsfw_tags is the list of tags that mark content as NSFW for blurring.
repeated string nsfw_tags = 10;
// Memo-related workspace settings and policies.
message MemoRelatedSetting {
// disallow_public_visibility disallows set memo as public visibility.
bool disallow_public_visibility = 1;
// display_with_update_time orders and displays memo with update time.
bool display_with_update_time = 2;
// content_length_limit is the limit of content length. Unit is byte.
int32 content_length_limit = 3;
// enable_double_click_edit enables editing on double click.
bool enable_double_click_edit = 4;
// enable_link_preview enables links preview.
bool enable_link_preview = 5;
// enable_comment enables comment.
bool enable_comment = 6;
// reactions is the list of reactions.
repeated string reactions = 7;
// disable_markdown_shortcuts disallow the registration of markdown shortcuts.
bool disable_markdown_shortcuts = 8;
// enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW).
bool enable_blur_nsfw_content = 9;
// nsfw_tags is the list of tags that mark content as NSFW for blurring.
repeated string nsfw_tags = 10;
}
}
// Request message for GetWorkspaceSetting method.
......
This diff is collapsed.
This diff is collapsed.
......@@ -105,15 +105,15 @@ func convertWorkspaceSettingFromStore(setting *storepb.WorkspaceSetting) *v1pb.W
}
switch setting.Value.(type) {
case *storepb.WorkspaceSetting_GeneralSetting:
workspaceSetting.Value = &v1pb.WorkspaceSetting_GeneralSetting{
workspaceSetting.Value = &v1pb.WorkspaceSetting_GeneralSetting_{
GeneralSetting: convertWorkspaceGeneralSettingFromStore(setting.GetGeneralSetting()),
}
case *storepb.WorkspaceSetting_StorageSetting:
workspaceSetting.Value = &v1pb.WorkspaceSetting_StorageSetting{
workspaceSetting.Value = &v1pb.WorkspaceSetting_StorageSetting_{
StorageSetting: convertWorkspaceStorageSettingFromStore(setting.GetStorageSetting()),
}
case *storepb.WorkspaceSetting_MemoRelatedSetting:
workspaceSetting.Value = &v1pb.WorkspaceSetting_MemoRelatedSetting{
workspaceSetting.Value = &v1pb.WorkspaceSetting_MemoRelatedSetting_{
MemoRelatedSetting: convertWorkspaceMemoRelatedSettingFromStore(setting.GetMemoRelatedSetting()),
}
}
......@@ -145,7 +145,7 @@ func convertWorkspaceSettingToStore(setting *v1pb.WorkspaceSetting) *storepb.Wor
return workspaceSetting
}
func convertWorkspaceGeneralSettingFromStore(setting *storepb.WorkspaceGeneralSetting) *v1pb.WorkspaceGeneralSetting {
func convertWorkspaceGeneralSettingFromStore(setting *storepb.WorkspaceGeneralSetting) *v1pb.WorkspaceSetting_GeneralSetting {
if setting == nil {
return nil
}
......@@ -155,7 +155,7 @@ func convertWorkspaceGeneralSettingFromStore(setting *storepb.WorkspaceGeneralSe
theme = "default"
}
generalSetting := &v1pb.WorkspaceGeneralSetting{
generalSetting := &v1pb.WorkspaceSetting_GeneralSetting{
Theme: theme,
DisallowUserRegistration: setting.DisallowUserRegistration,
DisallowPasswordAuth: setting.DisallowPasswordAuth,
......@@ -166,7 +166,7 @@ func convertWorkspaceGeneralSettingFromStore(setting *storepb.WorkspaceGeneralSe
DisallowChangeNickname: setting.DisallowChangeNickname,
}
if setting.CustomProfile != nil {
generalSetting.CustomProfile = &v1pb.WorkspaceCustomProfile{
generalSetting.CustomProfile = &v1pb.WorkspaceSetting_GeneralSetting_CustomProfile{
Title: setting.CustomProfile.Title,
Description: setting.CustomProfile.Description,
LogoUrl: setting.CustomProfile.LogoUrl,
......@@ -177,7 +177,7 @@ func convertWorkspaceGeneralSettingFromStore(setting *storepb.WorkspaceGeneralSe
return generalSetting
}
func convertWorkspaceGeneralSettingToStore(setting *v1pb.WorkspaceGeneralSetting) *storepb.WorkspaceGeneralSetting {
func convertWorkspaceGeneralSettingToStore(setting *v1pb.WorkspaceSetting_GeneralSetting) *storepb.WorkspaceGeneralSetting {
if setting == nil {
return nil
}
......@@ -203,17 +203,17 @@ func convertWorkspaceGeneralSettingToStore(setting *v1pb.WorkspaceGeneralSetting
return generalSetting
}
func convertWorkspaceStorageSettingFromStore(settingpb *storepb.WorkspaceStorageSetting) *v1pb.WorkspaceStorageSetting {
func convertWorkspaceStorageSettingFromStore(settingpb *storepb.WorkspaceStorageSetting) *v1pb.WorkspaceSetting_StorageSetting {
if settingpb == nil {
return nil
}
setting := &v1pb.WorkspaceStorageSetting{
StorageType: v1pb.WorkspaceStorageSetting_StorageType(settingpb.StorageType),
setting := &v1pb.WorkspaceSetting_StorageSetting{
StorageType: v1pb.WorkspaceSetting_StorageSetting_StorageType(settingpb.StorageType),
FilepathTemplate: settingpb.FilepathTemplate,
UploadSizeLimitMb: settingpb.UploadSizeLimitMb,
}
if settingpb.S3Config != nil {
setting.S3Config = &v1pb.WorkspaceStorageSetting_S3Config{
setting.S3Config = &v1pb.WorkspaceSetting_StorageSetting_S3Config{
AccessKeyId: settingpb.S3Config.AccessKeyId,
AccessKeySecret: settingpb.S3Config.AccessKeySecret,
Endpoint: settingpb.S3Config.Endpoint,
......@@ -225,7 +225,7 @@ func convertWorkspaceStorageSettingFromStore(settingpb *storepb.WorkspaceStorage
return setting
}
func convertWorkspaceStorageSettingToStore(setting *v1pb.WorkspaceStorageSetting) *storepb.WorkspaceStorageSetting {
func convertWorkspaceStorageSettingToStore(setting *v1pb.WorkspaceSetting_StorageSetting) *storepb.WorkspaceStorageSetting {
if setting == nil {
return nil
}
......@@ -247,11 +247,11 @@ func convertWorkspaceStorageSettingToStore(setting *v1pb.WorkspaceStorageSetting
return settingpb
}
func convertWorkspaceMemoRelatedSettingFromStore(setting *storepb.WorkspaceMemoRelatedSetting) *v1pb.WorkspaceMemoRelatedSetting {
func convertWorkspaceMemoRelatedSettingFromStore(setting *storepb.WorkspaceMemoRelatedSetting) *v1pb.WorkspaceSetting_MemoRelatedSetting {
if setting == nil {
return nil
}
return &v1pb.WorkspaceMemoRelatedSetting{
return &v1pb.WorkspaceSetting_MemoRelatedSetting{
DisallowPublicVisibility: setting.DisallowPublicVisibility,
DisplayWithUpdateTime: setting.DisplayWithUpdateTime,
ContentLengthLimit: setting.ContentLengthLimit,
......@@ -265,7 +265,7 @@ func convertWorkspaceMemoRelatedSettingFromStore(setting *storepb.WorkspaceMemoR
}
}
func convertWorkspaceMemoRelatedSettingToStore(setting *v1pb.WorkspaceMemoRelatedSetting) *storepb.WorkspaceMemoRelatedSetting {
func convertWorkspaceMemoRelatedSettingToStore(setting *v1pb.WorkspaceSetting_MemoRelatedSetting) *storepb.WorkspaceMemoRelatedSetting {
if setting == nil {
return nil
}
......
......@@ -9,18 +9,18 @@ import { Input } from "@/components/ui/input";
import { Switch } from "@/components/ui/switch";
import { workspaceStore } from "@/store";
import { workspaceSettingNamePrefix } from "@/store/common";
import { WorkspaceMemoRelatedSetting, WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service";
import { WorkspaceSetting_MemoRelatedSetting, WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service";
import { useTranslate } from "@/utils/i18n";
const MemoRelatedSettings = observer(() => {
const t = useTranslate();
const [originalSetting, setOriginalSetting] = useState<WorkspaceMemoRelatedSetting>(workspaceStore.state.memoRelatedSetting);
const [memoRelatedSetting, setMemoRelatedSetting] = useState<WorkspaceMemoRelatedSetting>(originalSetting);
const [originalSetting, setOriginalSetting] = useState<WorkspaceSetting_MemoRelatedSetting>(workspaceStore.state.memoRelatedSetting);
const [memoRelatedSetting, setMemoRelatedSetting] = useState<WorkspaceSetting_MemoRelatedSetting>(originalSetting);
const [editingReaction, setEditingReaction] = useState<string>("");
const [editingNsfwTag, setEditingNsfwTag] = useState<string>("");
const updatePartialSetting = (partial: Partial<WorkspaceMemoRelatedSetting>) => {
const newWorkspaceMemoRelatedSetting = WorkspaceMemoRelatedSetting.fromPartial({
const updatePartialSetting = (partial: Partial<WorkspaceSetting_MemoRelatedSetting>) => {
const newWorkspaceMemoRelatedSetting = WorkspaceSetting_MemoRelatedSetting.fromPartial({
...memoRelatedSetting,
...partial,
});
......
......@@ -15,21 +15,25 @@ import { workspaceStore } from "@/store";
import { workspaceSettingNamePrefix } from "@/store/common";
import {
WorkspaceSetting_Key,
WorkspaceStorageSetting,
WorkspaceStorageSetting_S3Config,
WorkspaceStorageSetting_StorageType,
WorkspaceSetting_StorageSetting,
WorkspaceSetting_StorageSetting_S3Config,
WorkspaceSetting_StorageSetting_StorageType,
} from "@/types/proto/api/v1/workspace_service";
import { useTranslate } from "@/utils/i18n";
const StorageSection = observer(() => {
const t = useTranslate();
const [workspaceStorageSetting, setWorkspaceStorageSetting] = useState<WorkspaceStorageSetting>(
WorkspaceStorageSetting.fromPartial(workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.STORAGE)?.storageSetting || {}),
const [workspaceStorageSetting, setWorkspaceStorageSetting] = useState<WorkspaceSetting_StorageSetting>(
WorkspaceSetting_StorageSetting.fromPartial(
workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.STORAGE)?.storageSetting || {},
),
);
useEffect(() => {
setWorkspaceStorageSetting(
WorkspaceStorageSetting.fromPartial(workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.STORAGE)?.storageSetting || {}),
WorkspaceSetting_StorageSetting.fromPartial(
workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.STORAGE)?.storageSetting || {},
),
);
}, [workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.STORAGE)]);
......@@ -38,14 +42,14 @@ const StorageSection = observer(() => {
return false;
}
const origin = WorkspaceStorageSetting.fromPartial(
const origin = WorkspaceSetting_StorageSetting.fromPartial(
workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.STORAGE)?.storageSetting || {},
);
if (workspaceStorageSetting.storageType === WorkspaceStorageSetting_StorageType.LOCAL) {
if (workspaceStorageSetting.storageType === WorkspaceSetting_StorageSetting_StorageType.LOCAL) {
if (workspaceStorageSetting.filepathTemplate.length === 0) {
return false;
}
} else if (workspaceStorageSetting.storageType === WorkspaceStorageSetting_StorageType.S3) {
} else if (workspaceStorageSetting.storageType === WorkspaceSetting_StorageSetting_StorageType.S3) {
if (
workspaceStorageSetting.s3Config?.accessKeyId.length === 0 ||
workspaceStorageSetting.s3Config?.accessKeySecret.length === 0 ||
......@@ -64,7 +68,7 @@ const StorageSection = observer(() => {
if (Number.isNaN(num)) {
num = 0;
}
const update: WorkspaceStorageSetting = {
const update: WorkspaceSetting_StorageSetting = {
...workspaceStorageSetting,
uploadSizeLimitMb: num,
};
......@@ -72,17 +76,17 @@ const StorageSection = observer(() => {
};
const handleFilepathTemplateChanged = async (event: React.FocusEvent<HTMLInputElement>) => {
const update: WorkspaceStorageSetting = {
const update: WorkspaceSetting_StorageSetting = {
...workspaceStorageSetting,
filepathTemplate: event.target.value,
};
setWorkspaceStorageSetting(update);
};
const handlePartialS3ConfigChanged = async (s3Config: Partial<WorkspaceStorageSetting_S3Config>) => {
const update: WorkspaceStorageSetting = {
const handlePartialS3ConfigChanged = async (s3Config: Partial<WorkspaceSetting_StorageSetting_S3Config>) => {
const update: WorkspaceSetting_StorageSetting = {
...workspaceStorageSetting,
s3Config: WorkspaceStorageSetting_S3Config.fromPartial({
s3Config: WorkspaceSetting_StorageSetting_S3Config.fromPartial({
...workspaceStorageSetting.s3Config,
...s3Config,
}),
......@@ -116,8 +120,8 @@ const StorageSection = observer(() => {
});
};
const handleStorageTypeChanged = async (storageType: WorkspaceStorageSetting_StorageType) => {
const update: WorkspaceStorageSetting = {
const handleStorageTypeChanged = async (storageType: WorkspaceSetting_StorageSetting_StorageType) => {
const update: WorkspaceSetting_StorageSetting = {
...workspaceStorageSetting,
storageType: storageType,
};
......@@ -138,20 +142,20 @@ const StorageSection = observer(() => {
<RadioGroup
value={workspaceStorageSetting.storageType}
onValueChange={(value) => {
handleStorageTypeChanged(value as WorkspaceStorageSetting_StorageType);
handleStorageTypeChanged(value as WorkspaceSetting_StorageSetting_StorageType);
}}
className="flex flex-row gap-4"
>
<div className="flex items-center space-x-2">
<RadioGroupItem value={WorkspaceStorageSetting_StorageType.DATABASE} id="database" />
<RadioGroupItem value={WorkspaceSetting_StorageSetting_StorageType.DATABASE} id="database" />
<Label htmlFor="database">{t("setting.storage-section.type-database")}</Label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value={WorkspaceStorageSetting_StorageType.LOCAL} id="local" />
<RadioGroupItem value={WorkspaceSetting_StorageSetting_StorageType.LOCAL} id="local" />
<Label htmlFor="local">{t("setting.storage-section.type-local")}</Label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value={WorkspaceStorageSetting_StorageType.S3} id="s3" />
<RadioGroupItem value={WorkspaceSetting_StorageSetting_StorageType.S3} id="s3" />
<Label htmlFor="s3">S3</Label>
</div>
</RadioGroup>
......@@ -171,7 +175,7 @@ const StorageSection = observer(() => {
</div>
<Input className="w-16 font-mono" value={workspaceStorageSetting.uploadSizeLimitMb} onChange={handleMaxUploadSizeChanged} />
</div>
{workspaceStorageSetting.storageType !== WorkspaceStorageSetting_StorageType.DATABASE && (
{workspaceStorageSetting.storageType !== WorkspaceSetting_StorageSetting_StorageType.DATABASE && (
<div className="w-full flex flex-row justify-between items-center">
<span className="text-muted-foreground mr-1">{t("setting.storage-section.filepath-template")}</span>
<Input
......@@ -182,7 +186,7 @@ const StorageSection = observer(() => {
/>
</div>
)}
{workspaceStorageSetting.storageType === WorkspaceStorageSetting_StorageType.S3 && (
{workspaceStorageSetting.storageType === WorkspaceSetting_StorageSetting_StorageType.S3 && (
<>
<div className="w-full flex flex-row justify-between items-center">
<span className="text-muted-foreground mr-1">Access key id</span>
......
......@@ -14,7 +14,7 @@ import useDialog from "@/hooks/useDialog";
import { workspaceStore } from "@/store";
import { workspaceSettingNamePrefix } from "@/store/common";
import { IdentityProvider } from "@/types/proto/api/v1/idp_service";
import { WorkspaceGeneralSetting, WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service";
import { WorkspaceSetting_GeneralSetting, WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service";
import { useTranslate } from "@/utils/i18n";
import ThemeSelector from "../ThemeSelector";
import UpdateCustomizedProfileDialog from "../UpdateCustomizedProfileDialog";
......@@ -22,10 +22,10 @@ import UpdateCustomizedProfileDialog from "../UpdateCustomizedProfileDialog";
const WorkspaceSection = observer(() => {
const t = useTranslate();
const customizeDialog = useDialog();
const originalSetting = WorkspaceGeneralSetting.fromPartial(
const originalSetting = WorkspaceSetting_GeneralSetting.fromPartial(
workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.GENERAL)?.generalSetting || {},
);
const [workspaceGeneralSetting, setWorkspaceGeneralSetting] = useState<WorkspaceGeneralSetting>(originalSetting);
const [workspaceGeneralSetting, setWorkspaceGeneralSetting] = useState<WorkspaceSetting_GeneralSetting>(originalSetting);
const [identityProviderList, setIdentityProviderList] = useState<IdentityProvider[]>([]);
useEffect(() => {
......@@ -36,9 +36,9 @@ const WorkspaceSection = observer(() => {
customizeDialog.open();
};
const updatePartialSetting = (partial: Partial<WorkspaceGeneralSetting>) => {
const updatePartialSetting = (partial: Partial<WorkspaceSetting_GeneralSetting>) => {
setWorkspaceGeneralSetting(
WorkspaceGeneralSetting.fromPartial({
WorkspaceSetting_GeneralSetting.fromPartial({
...workspaceGeneralSetting,
...partial,
}),
......
......@@ -7,7 +7,7 @@ import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
import { workspaceStore } from "@/store";
import { workspaceSettingNamePrefix } from "@/store/common";
import { WorkspaceCustomProfile, WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service";
import { WorkspaceSetting_GeneralSetting_CustomProfile, WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service";
import { useTranslate } from "@/utils/i18n";
import AppearanceSelect from "./AppearanceSelect";
import LocaleSelect from "./LocaleSelect";
......@@ -21,13 +21,13 @@ interface Props {
function UpdateCustomizedProfileDialog({ open, onOpenChange, onSuccess }: Props) {
const t = useTranslate();
const workspaceGeneralSetting = workspaceStore.state.generalSetting;
const [customProfile, setCustomProfile] = useState<WorkspaceCustomProfile>(
WorkspaceCustomProfile.fromPartial(workspaceGeneralSetting.customProfile || {}),
const [customProfile, setCustomProfile] = useState<WorkspaceSetting_GeneralSetting_CustomProfile>(
WorkspaceSetting_GeneralSetting_CustomProfile.fromPartial(workspaceGeneralSetting.customProfile || {}),
);
const [isLoading, setIsLoading] = useState(false);
const setPartialState = (partialState: Partial<WorkspaceCustomProfile>) => {
const setPartialState = (partialState: Partial<WorkspaceSetting_GeneralSetting_CustomProfile>) => {
setCustomProfile((state) => ({
...state,
...partialState,
......
......@@ -2,7 +2,11 @@ import { uniqBy } from "lodash-es";
import { makeAutoObservable } from "mobx";
import { workspaceServiceClient } from "@/grpcweb";
import { WorkspaceProfile, WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service";
import { WorkspaceGeneralSetting, WorkspaceMemoRelatedSetting, WorkspaceSetting } from "@/types/proto/api/v1/workspace_service";
import {
WorkspaceSetting_GeneralSetting,
WorkspaceSetting_MemoRelatedSetting,
WorkspaceSetting,
} from "@/types/proto/api/v1/workspace_service";
import { isValidateLocale } from "@/utils/i18n";
import { workspaceSettingNamePrefix } from "./common";
......@@ -15,14 +19,14 @@ class LocalState {
get generalSetting() {
return (
this.settings.find((setting) => setting.name === `${workspaceSettingNamePrefix}${WorkspaceSetting_Key.GENERAL}`)?.generalSetting ||
WorkspaceGeneralSetting.fromPartial({})
WorkspaceSetting_GeneralSetting.fromPartial({})
);
}
get memoRelatedSetting() {
return (
this.settings.find((setting) => setting.name === `${workspaceSettingNamePrefix}${WorkspaceSetting_Key.MEMO_RELATED}`)
?.memoRelatedSetting || WorkspaceMemoRelatedSetting.fromPartial({})
?.memoRelatedSetting || WorkspaceSetting_MemoRelatedSetting.fromPartial({})
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment