fix: workspace setting keys

pull/4908/head
Steven 3 months ago
parent c133f5528a
commit ac386c218d

@ -69,6 +69,18 @@ message WorkspaceSetting {
WorkspaceStorageSetting storage_setting = 3;
WorkspaceMemoRelatedSetting memo_related_setting = 4;
}
enum Key {
KEY_UNSPECIFIED = 0;
// BASIC is the key for basic settings.
BASIC = 1;
// GENERAL is the key for general settings.
GENERAL = 2;
// STORAGE is the key for storage settings.
STORAGE = 3;
// MEMO_RELATED is the key for memo related settings.
MEMO_RELATED = 4;
}
}
message WorkspaceGeneralSetting {

@ -23,6 +23,65 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type WorkspaceSetting_Key int32
const (
WorkspaceSetting_KEY_UNSPECIFIED WorkspaceSetting_Key = 0
// BASIC is the key for basic settings.
WorkspaceSetting_BASIC WorkspaceSetting_Key = 1
// GENERAL is the key for general settings.
WorkspaceSetting_GENERAL WorkspaceSetting_Key = 2
// STORAGE is the key for storage settings.
WorkspaceSetting_STORAGE WorkspaceSetting_Key = 3
// MEMO_RELATED is the key for memo related settings.
WorkspaceSetting_MEMO_RELATED WorkspaceSetting_Key = 4
)
// Enum value maps for WorkspaceSetting_Key.
var (
WorkspaceSetting_Key_name = map[int32]string{
0: "KEY_UNSPECIFIED",
1: "BASIC",
2: "GENERAL",
3: "STORAGE",
4: "MEMO_RELATED",
}
WorkspaceSetting_Key_value = map[string]int32{
"KEY_UNSPECIFIED": 0,
"BASIC": 1,
"GENERAL": 2,
"STORAGE": 3,
"MEMO_RELATED": 4,
}
)
func (x WorkspaceSetting_Key) Enum() *WorkspaceSetting_Key {
p := new(WorkspaceSetting_Key)
*p = x
return p
}
func (x WorkspaceSetting_Key) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (WorkspaceSetting_Key) Descriptor() protoreflect.EnumDescriptor {
return file_api_v1_workspace_service_proto_enumTypes[0].Descriptor()
}
func (WorkspaceSetting_Key) Type() protoreflect.EnumType {
return &file_api_v1_workspace_service_proto_enumTypes[0]
}
func (x WorkspaceSetting_Key) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use WorkspaceSetting_Key.Descriptor instead.
func (WorkspaceSetting_Key) EnumDescriptor() ([]byte, []int) {
return file_api_v1_workspace_service_proto_rawDescGZIP(), []int{2, 0}
}
type WorkspaceStorageSetting_StorageType int32
const (
@ -62,11 +121,11 @@ func (x WorkspaceStorageSetting_StorageType) String() string {
}
func (WorkspaceStorageSetting_StorageType) Descriptor() protoreflect.EnumDescriptor {
return file_api_v1_workspace_service_proto_enumTypes[0].Descriptor()
return file_api_v1_workspace_service_proto_enumTypes[1].Descriptor()
}
func (WorkspaceStorageSetting_StorageType) Type() protoreflect.EnumType {
return &file_api_v1_workspace_service_proto_enumTypes[0]
return &file_api_v1_workspace_service_proto_enumTypes[1]
}
func (x WorkspaceStorageSetting_StorageType) Number() protoreflect.EnumNumber {
@ -890,12 +949,18 @@ const file_api_v1_workspace_service_proto_rawDesc = "" +
"\aversion\x18\x02 \x01(\tR\aversion\x12\x12\n" +
"\x04mode\x18\x03 \x01(\tR\x04mode\x12!\n" +
"\finstance_url\x18\x06 \x01(\tR\vinstanceUrl\"\x1c\n" +
"\x1aGetWorkspaceProfileRequest\"\x9f\x03\n" +
"\x1aGetWorkspaceProfileRequest\"\xf2\x03\n" +
"\x10WorkspaceSetting\x12\x17\n" +
"\x04name\x18\x01 \x01(\tB\x03\xe0A\bR\x04name\x12P\n" +
"\x0fgeneral_setting\x18\x02 \x01(\v2%.memos.api.v1.WorkspaceGeneralSettingH\x00R\x0egeneralSetting\x12P\n" +
"\x0fstorage_setting\x18\x03 \x01(\v2%.memos.api.v1.WorkspaceStorageSettingH\x00R\x0estorageSetting\x12]\n" +
"\x14memo_related_setting\x18\x04 \x01(\v2).memos.api.v1.WorkspaceMemoRelatedSettingH\x00R\x12memoRelatedSetting:f\xeaAc\n" +
"\x14memo_related_setting\x18\x04 \x01(\v2).memos.api.v1.WorkspaceMemoRelatedSettingH\x00R\x12memoRelatedSetting\"Q\n" +
"\x03Key\x12\x13\n" +
"\x0fKEY_UNSPECIFIED\x10\x00\x12\t\n" +
"\x05BASIC\x10\x01\x12\v\n" +
"\aGENERAL\x10\x02\x12\v\n" +
"\aSTORAGE\x10\x03\x12\x10\n" +
"\fMEMO_RELATED\x10\x04:f\xeaAc\n" +
"\x1eapi.memos.dev/WorkspaceSetting\x12\x1cworkspace/settings/{setting}*\x11workspaceSettings2\x10workspaceSettingB\a\n" +
"\x05value\"\xef\x03\n" +
"\x17WorkspaceGeneralSetting\x12\x14\n" +
@ -970,37 +1035,38 @@ func file_api_v1_workspace_service_proto_rawDescGZIP() []byte {
return file_api_v1_workspace_service_proto_rawDescData
}
var file_api_v1_workspace_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_api_v1_workspace_service_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
var file_api_v1_workspace_service_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_api_v1_workspace_service_proto_goTypes = []any{
(WorkspaceStorageSetting_StorageType)(0), // 0: memos.api.v1.WorkspaceStorageSetting.StorageType
(*WorkspaceProfile)(nil), // 1: memos.api.v1.WorkspaceProfile
(*GetWorkspaceProfileRequest)(nil), // 2: memos.api.v1.GetWorkspaceProfileRequest
(*WorkspaceSetting)(nil), // 3: memos.api.v1.WorkspaceSetting
(*WorkspaceGeneralSetting)(nil), // 4: memos.api.v1.WorkspaceGeneralSetting
(*WorkspaceCustomProfile)(nil), // 5: memos.api.v1.WorkspaceCustomProfile
(*WorkspaceStorageSetting)(nil), // 6: memos.api.v1.WorkspaceStorageSetting
(*WorkspaceMemoRelatedSetting)(nil), // 7: memos.api.v1.WorkspaceMemoRelatedSetting
(*GetWorkspaceSettingRequest)(nil), // 8: memos.api.v1.GetWorkspaceSettingRequest
(*UpdateWorkspaceSettingRequest)(nil), // 9: memos.api.v1.UpdateWorkspaceSettingRequest
(*WorkspaceStorageSetting_S3Config)(nil), // 10: memos.api.v1.WorkspaceStorageSetting.S3Config
(*fieldmaskpb.FieldMask)(nil), // 11: google.protobuf.FieldMask
(WorkspaceSetting_Key)(0), // 0: memos.api.v1.WorkspaceSetting.Key
(WorkspaceStorageSetting_StorageType)(0), // 1: memos.api.v1.WorkspaceStorageSetting.StorageType
(*WorkspaceProfile)(nil), // 2: memos.api.v1.WorkspaceProfile
(*GetWorkspaceProfileRequest)(nil), // 3: memos.api.v1.GetWorkspaceProfileRequest
(*WorkspaceSetting)(nil), // 4: memos.api.v1.WorkspaceSetting
(*WorkspaceGeneralSetting)(nil), // 5: memos.api.v1.WorkspaceGeneralSetting
(*WorkspaceCustomProfile)(nil), // 6: memos.api.v1.WorkspaceCustomProfile
(*WorkspaceStorageSetting)(nil), // 7: memos.api.v1.WorkspaceStorageSetting
(*WorkspaceMemoRelatedSetting)(nil), // 8: memos.api.v1.WorkspaceMemoRelatedSetting
(*GetWorkspaceSettingRequest)(nil), // 9: memos.api.v1.GetWorkspaceSettingRequest
(*UpdateWorkspaceSettingRequest)(nil), // 10: memos.api.v1.UpdateWorkspaceSettingRequest
(*WorkspaceStorageSetting_S3Config)(nil), // 11: memos.api.v1.WorkspaceStorageSetting.S3Config
(*fieldmaskpb.FieldMask)(nil), // 12: google.protobuf.FieldMask
}
var file_api_v1_workspace_service_proto_depIdxs = []int32{
4, // 0: memos.api.v1.WorkspaceSetting.general_setting:type_name -> memos.api.v1.WorkspaceGeneralSetting
6, // 1: memos.api.v1.WorkspaceSetting.storage_setting:type_name -> memos.api.v1.WorkspaceStorageSetting
7, // 2: memos.api.v1.WorkspaceSetting.memo_related_setting:type_name -> memos.api.v1.WorkspaceMemoRelatedSetting
5, // 3: memos.api.v1.WorkspaceGeneralSetting.custom_profile:type_name -> memos.api.v1.WorkspaceCustomProfile
0, // 4: memos.api.v1.WorkspaceStorageSetting.storage_type:type_name -> memos.api.v1.WorkspaceStorageSetting.StorageType
10, // 5: memos.api.v1.WorkspaceStorageSetting.s3_config:type_name -> memos.api.v1.WorkspaceStorageSetting.S3Config
3, // 6: memos.api.v1.UpdateWorkspaceSettingRequest.setting:type_name -> memos.api.v1.WorkspaceSetting
11, // 7: memos.api.v1.UpdateWorkspaceSettingRequest.update_mask:type_name -> google.protobuf.FieldMask
2, // 8: memos.api.v1.WorkspaceService.GetWorkspaceProfile:input_type -> memos.api.v1.GetWorkspaceProfileRequest
8, // 9: memos.api.v1.WorkspaceService.GetWorkspaceSetting:input_type -> memos.api.v1.GetWorkspaceSettingRequest
9, // 10: memos.api.v1.WorkspaceService.UpdateWorkspaceSetting:input_type -> memos.api.v1.UpdateWorkspaceSettingRequest
1, // 11: memos.api.v1.WorkspaceService.GetWorkspaceProfile:output_type -> memos.api.v1.WorkspaceProfile
3, // 12: memos.api.v1.WorkspaceService.GetWorkspaceSetting:output_type -> memos.api.v1.WorkspaceSetting
3, // 13: memos.api.v1.WorkspaceService.UpdateWorkspaceSetting:output_type -> memos.api.v1.WorkspaceSetting
5, // 0: memos.api.v1.WorkspaceSetting.general_setting:type_name -> memos.api.v1.WorkspaceGeneralSetting
7, // 1: memos.api.v1.WorkspaceSetting.storage_setting:type_name -> memos.api.v1.WorkspaceStorageSetting
8, // 2: memos.api.v1.WorkspaceSetting.memo_related_setting:type_name -> memos.api.v1.WorkspaceMemoRelatedSetting
6, // 3: memos.api.v1.WorkspaceGeneralSetting.custom_profile:type_name -> memos.api.v1.WorkspaceCustomProfile
1, // 4: memos.api.v1.WorkspaceStorageSetting.storage_type:type_name -> memos.api.v1.WorkspaceStorageSetting.StorageType
11, // 5: memos.api.v1.WorkspaceStorageSetting.s3_config:type_name -> memos.api.v1.WorkspaceStorageSetting.S3Config
4, // 6: memos.api.v1.UpdateWorkspaceSettingRequest.setting:type_name -> memos.api.v1.WorkspaceSetting
12, // 7: memos.api.v1.UpdateWorkspaceSettingRequest.update_mask:type_name -> google.protobuf.FieldMask
3, // 8: memos.api.v1.WorkspaceService.GetWorkspaceProfile:input_type -> memos.api.v1.GetWorkspaceProfileRequest
9, // 9: memos.api.v1.WorkspaceService.GetWorkspaceSetting:input_type -> memos.api.v1.GetWorkspaceSettingRequest
10, // 10: memos.api.v1.WorkspaceService.UpdateWorkspaceSetting:input_type -> memos.api.v1.UpdateWorkspaceSettingRequest
2, // 11: memos.api.v1.WorkspaceService.GetWorkspaceProfile:output_type -> memos.api.v1.WorkspaceProfile
4, // 12: memos.api.v1.WorkspaceService.GetWorkspaceSetting:output_type -> memos.api.v1.WorkspaceSetting
4, // 13: memos.api.v1.WorkspaceService.UpdateWorkspaceSetting:output_type -> memos.api.v1.WorkspaceSetting
11, // [11:14] is the sub-list for method output_type
8, // [8:11] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
@ -1023,7 +1089,7 @@ func file_api_v1_workspace_service_proto_init() {
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_v1_workspace_service_proto_rawDesc), len(file_api_v1_workspace_service_proto_rawDesc)),
NumEnums: 1,
NumEnums: 2,
NumMessages: 10,
NumExtensions: 0,
NumServices: 1,

@ -9,8 +9,7 @@ import { Input } from "@/components/ui/input";
import { Switch } from "@/components/ui/switch";
import { workspaceStore } from "@/store";
import { workspaceSettingNamePrefix } from "@/store/common";
import { WorkspaceMemoRelatedSetting } from "@/types/proto/api/v1/workspace_service";
import { WorkspaceSettingKey } from "@/types/proto/store/workspace_setting";
import { WorkspaceMemoRelatedSetting, WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service";
import { useTranslate } from "@/utils/i18n";
const MemoRelatedSettings = observer(() => {
@ -54,7 +53,7 @@ const MemoRelatedSettings = observer(() => {
try {
await workspaceStore.upsertWorkspaceSetting({
name: `${workspaceSettingNamePrefix}${WorkspaceSettingKey.MEMO_RELATED}`,
name: `${workspaceSettingNamePrefix}${WorkspaceSetting_Key.MEMO_RELATED}`,
memoRelatedSetting,
});
setOriginalSetting(memoRelatedSetting);

@ -14,24 +14,24 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/comp
import { workspaceStore } from "@/store";
import { workspaceSettingNamePrefix } from "@/store/common";
import {
WorkspaceSetting_Key,
WorkspaceStorageSetting,
WorkspaceStorageSetting_S3Config,
WorkspaceStorageSetting_StorageType,
} from "@/types/proto/api/v1/workspace_service";
import { WorkspaceSettingKey } from "@/types/proto/store/workspace_setting";
import { useTranslate } from "@/utils/i18n";
const StorageSection = observer(() => {
const t = useTranslate();
const [workspaceStorageSetting, setWorkspaceStorageSetting] = useState<WorkspaceStorageSetting>(
WorkspaceStorageSetting.fromPartial(workspaceStore.getWorkspaceSettingByKey(WorkspaceSettingKey.STORAGE)?.storageSetting || {}),
WorkspaceStorageSetting.fromPartial(workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.STORAGE)?.storageSetting || {}),
);
useEffect(() => {
setWorkspaceStorageSetting(
WorkspaceStorageSetting.fromPartial(workspaceStore.getWorkspaceSettingByKey(WorkspaceSettingKey.STORAGE)?.storageSetting || {}),
WorkspaceStorageSetting.fromPartial(workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.STORAGE)?.storageSetting || {}),
);
}, [workspaceStore.getWorkspaceSettingByKey(WorkspaceSettingKey.STORAGE)]);
}, [workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.STORAGE)]);
const allowSaveStorageSetting = useMemo(() => {
if (workspaceStorageSetting.uploadSizeLimitMb <= 0) {
@ -39,7 +39,7 @@ const StorageSection = observer(() => {
}
const origin = WorkspaceStorageSetting.fromPartial(
workspaceStore.getWorkspaceSettingByKey(WorkspaceSettingKey.STORAGE)?.storageSetting || {},
workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.STORAGE)?.storageSetting || {},
);
if (workspaceStorageSetting.storageType === WorkspaceStorageSetting_StorageType.LOCAL) {
if (workspaceStorageSetting.filepathTemplate.length === 0) {
@ -126,7 +126,7 @@ const StorageSection = observer(() => {
const saveWorkspaceStorageSetting = async () => {
await workspaceStore.upsertWorkspaceSetting({
name: `${workspaceSettingNamePrefix}${WorkspaceSettingKey.STORAGE}`,
name: `${workspaceSettingNamePrefix}${WorkspaceSetting_Key.STORAGE}`,
storageSetting: workspaceStorageSetting,
});
toast.success("Updated");

@ -14,8 +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 } from "@/types/proto/api/v1/workspace_service";
import { WorkspaceSettingKey } from "@/types/proto/store/workspace_setting";
import { WorkspaceGeneralSetting, WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service";
import { useTranslate } from "@/utils/i18n";
import ThemeSelector from "../ThemeSelector";
import UpdateCustomizedProfileDialog from "../UpdateCustomizedProfileDialog";
@ -24,14 +23,14 @@ const WorkspaceSection = observer(() => {
const t = useTranslate();
const customizeDialog = useDialog();
const originalSetting = WorkspaceGeneralSetting.fromPartial(
workspaceStore.getWorkspaceSettingByKey(WorkspaceSettingKey.GENERAL)?.generalSetting || {},
workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.GENERAL)?.generalSetting || {},
);
const [workspaceGeneralSetting, setWorkspaceGeneralSetting] = useState<WorkspaceGeneralSetting>(originalSetting);
const [identityProviderList, setIdentityProviderList] = useState<IdentityProvider[]>([]);
useEffect(() => {
setWorkspaceGeneralSetting({ ...workspaceGeneralSetting, customProfile: originalSetting.customProfile });
}, [workspaceStore.getWorkspaceSettingByKey(WorkspaceSettingKey.GENERAL)]);
}, [workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.GENERAL)]);
const handleUpdateCustomizedProfileButtonClick = () => {
customizeDialog.open();
@ -49,7 +48,7 @@ const WorkspaceSection = observer(() => {
const handleSaveGeneralSetting = async () => {
try {
await workspaceStore.upsertWorkspaceSetting({
name: `${workspaceSettingNamePrefix}${WorkspaceSettingKey.GENERAL}`,
name: `${workspaceSettingNamePrefix}${WorkspaceSetting_Key.GENERAL}`,
generalSetting: workspaceGeneralSetting,
});
} catch (error: any) {

@ -7,8 +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 } from "@/types/proto/api/v1/workspace_service";
import { WorkspaceSettingKey } from "@/types/proto/store/workspace_setting";
import { WorkspaceCustomProfile, WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service";
import { useTranslate } from "@/utils/i18n";
import AppearanceSelect from "./AppearanceSelect";
import LocaleSelect from "./LocaleSelect";
@ -88,7 +87,7 @@ function UpdateCustomizedProfileDialog({ open, onOpenChange, onSuccess }: Props)
setIsLoading(true);
try {
await workspaceStore.upsertWorkspaceSetting({
name: `${workspaceSettingNamePrefix}${WorkspaceSettingKey.GENERAL}`,
name: `${workspaceSettingNamePrefix}${WorkspaceSetting_Key.GENERAL}`,
generalSetting: {
...workspaceGeneralSetting,
customProfile: customProfile,

@ -8,7 +8,7 @@ import { viewStore, userStore, workspaceStore } from "@/store";
import memoFilterStore from "@/store/memoFilter";
import { State } from "@/types/proto/api/v1/common";
import { Memo } from "@/types/proto/api/v1/memo_service";
import { WorkspaceSettingKey } from "@/types/proto/store/workspace_setting";
import { WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service";
// Helper function to extract shortcut ID from resource name
// Format: users/{user}/shortcuts/{shortcut}
@ -40,7 +40,7 @@ const Home = observer(() => {
} else if (filter.factor === "property.hasCode") {
conditions.push(`has_code`);
} else if (filter.factor === "displayTime") {
const displayWithUpdateTime = workspaceStore.getWorkspaceSettingByKey(WorkspaceSettingKey.MEMO_RELATED).memoRelatedSetting
const displayWithUpdateTime = workspaceStore.getWorkspaceSettingByKey(WorkspaceSetting_Key.MEMO_RELATED).memoRelatedSetting
?.displayWithUpdateTime;
const factor = displayWithUpdateTime ? "updated_ts" : "created_ts";
const filterDate = new Date(filter.value);

@ -16,7 +16,7 @@ import useCurrentUser from "@/hooks/useCurrentUser";
import useResponsiveWidth from "@/hooks/useResponsiveWidth";
import { workspaceStore } from "@/store";
import { User_Role } from "@/types/proto/api/v1/user_service";
import { WorkspaceSettingKey } from "@/types/proto/store/workspace_setting";
import { WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service";
import { useTranslate } from "@/utils/i18n";
type SettingSection = "my-account" | "preference" | "member" | "system" | "memo-related" | "storage" | "sso";
@ -73,7 +73,7 @@ const Setting = observer(() => {
// Initial fetch for workspace settings.
(async () => {
[WorkspaceSettingKey.MEMO_RELATED, WorkspaceSettingKey.STORAGE].forEach(async (key) => {
[WorkspaceSetting_Key.MEMO_RELATED, WorkspaceSetting_Key.STORAGE].forEach(async (key) => {
await workspaceStore.fetchWorkspaceSetting(key);
});
})();

@ -1,9 +1,8 @@
import { uniqBy } from "lodash-es";
import { makeAutoObservable } from "mobx";
import { workspaceServiceClient } from "@/grpcweb";
import { WorkspaceProfile } from "@/types/proto/api/v1/workspace_service";
import { WorkspaceProfile, WorkspaceSetting_Key } from "@/types/proto/api/v1/workspace_service";
import { WorkspaceGeneralSetting, WorkspaceMemoRelatedSetting, WorkspaceSetting } from "@/types/proto/api/v1/workspace_service";
import { WorkspaceSettingKey } from "@/types/proto/store/workspace_setting";
import { isValidateLocale } from "@/utils/i18n";
import { workspaceSettingNamePrefix } from "./common";
@ -15,14 +14,14 @@ class LocalState {
get generalSetting() {
return (
this.settings.find((setting) => setting.name === `${workspaceSettingNamePrefix}${WorkspaceSettingKey.GENERAL}`)?.generalSetting ||
this.settings.find((setting) => setting.name === `${workspaceSettingNamePrefix}${WorkspaceSetting_Key.GENERAL}`)?.generalSetting ||
WorkspaceGeneralSetting.fromPartial({})
);
}
get memoRelatedSetting() {
return (
this.settings.find((setting) => setting.name === `${workspaceSettingNamePrefix}${WorkspaceSettingKey.MEMO_RELATED}`)
this.settings.find((setting) => setting.name === `${workspaceSettingNamePrefix}${WorkspaceSetting_Key.MEMO_RELATED}`)
?.memoRelatedSetting || WorkspaceMemoRelatedSetting.fromPartial({})
);
}
@ -49,7 +48,7 @@ class LocalState {
const workspaceStore = (() => {
const state = new LocalState();
const fetchWorkspaceSetting = async (settingKey: WorkspaceSettingKey) => {
const fetchWorkspaceSetting = async (settingKey: WorkspaceSetting_Key) => {
const setting = await workspaceServiceClient.getWorkspaceSetting({ name: `${workspaceSettingNamePrefix}${settingKey}` });
state.setPartial({
settings: uniqBy([setting, ...state.settings], "name"),
@ -63,7 +62,7 @@ const workspaceStore = (() => {
});
};
const getWorkspaceSettingByKey = (settingKey: WorkspaceSettingKey) => {
const getWorkspaceSettingByKey = (settingKey: WorkspaceSetting_Key) => {
return (
state.settings.find((setting) => setting.name === `${workspaceSettingNamePrefix}${settingKey}`) || WorkspaceSetting.fromPartial({})
);
@ -80,7 +79,7 @@ const workspaceStore = (() => {
export const initialWorkspaceStore = async () => {
const workspaceProfile = await workspaceServiceClient.getWorkspaceProfile({});
// Prepare workspace settings.
for (const key of [WorkspaceSettingKey.GENERAL, WorkspaceSettingKey.MEMO_RELATED]) {
for (const key of [WorkspaceSetting_Key.GENERAL, WorkspaceSetting_Key.MEMO_RELATED]) {
await workspaceStore.fetchWorkspaceSetting(key);
}

@ -41,6 +41,61 @@ export interface WorkspaceSetting {
memoRelatedSetting?: WorkspaceMemoRelatedSetting | undefined;
}
export enum WorkspaceSetting_Key {
KEY_UNSPECIFIED = "KEY_UNSPECIFIED",
/** BASIC - BASIC is the key for basic settings. */
BASIC = "BASIC",
/** GENERAL - GENERAL is the key for general settings. */
GENERAL = "GENERAL",
/** STORAGE - STORAGE is the key for storage settings. */
STORAGE = "STORAGE",
/** MEMO_RELATED - MEMO_RELATED is the key for memo related settings. */
MEMO_RELATED = "MEMO_RELATED",
UNRECOGNIZED = "UNRECOGNIZED",
}
export function workspaceSetting_KeyFromJSON(object: any): WorkspaceSetting_Key {
switch (object) {
case 0:
case "KEY_UNSPECIFIED":
return WorkspaceSetting_Key.KEY_UNSPECIFIED;
case 1:
case "BASIC":
return WorkspaceSetting_Key.BASIC;
case 2:
case "GENERAL":
return WorkspaceSetting_Key.GENERAL;
case 3:
case "STORAGE":
return WorkspaceSetting_Key.STORAGE;
case 4:
case "MEMO_RELATED":
return WorkspaceSetting_Key.MEMO_RELATED;
case -1:
case "UNRECOGNIZED":
default:
return WorkspaceSetting_Key.UNRECOGNIZED;
}
}
export function workspaceSetting_KeyToNumber(object: WorkspaceSetting_Key): number {
switch (object) {
case WorkspaceSetting_Key.KEY_UNSPECIFIED:
return 0;
case WorkspaceSetting_Key.BASIC:
return 1;
case WorkspaceSetting_Key.GENERAL:
return 2;
case WorkspaceSetting_Key.STORAGE:
return 3;
case WorkspaceSetting_Key.MEMO_RELATED:
return 4;
case WorkspaceSetting_Key.UNRECOGNIZED:
default:
return -1;
}
}
export interface WorkspaceGeneralSetting {
/**
* theme is the name of the selected theme.

@ -35,7 +35,7 @@ export enum Edition {
EDITION_2024 = "EDITION_2024",
/**
* EDITION_1_TEST_ONLY - Placeholder editions for testing feature resolution. These should not be
* used or relyed on outside of tests.
* used or relied on outside of tests.
*/
EDITION_1_TEST_ONLY = "EDITION_1_TEST_ONLY",
EDITION_2_TEST_ONLY = "EDITION_2_TEST_ONLY",
@ -177,11 +177,19 @@ export interface FileDescriptorProto {
* The supported values are "proto2", "proto3", and "editions".
*
* If `edition` is present, this value must be "editions".
* WARNING: This field should only be used by protobuf plugins or special
* cases like the proto compiler. Other uses are discouraged and
* developers should rely on the protoreflect APIs for their client language.
*/
syntax?:
| string
| undefined;
/** The edition of the proto file. */
/**
* The edition of the proto file.
* WARNING: This field should only be used by protobuf plugins or special
* cases like the proto compiler. Other uses are discouraged and
* developers should rely on the protoreflect APIs for their client language.
*/
edition?: Edition | undefined;
}
@ -828,7 +836,12 @@ export interface FileOptions {
rubyPackage?:
| string
| undefined;
/** Any features defined in the specific edition. */
/**
* Any features defined in the specific edition.
* WARNING: This field should only be used by protobuf plugins or special
* cases like the proto compiler. Other uses are discouraged and
* developers should rely on the protoreflect APIs for their client language.
*/
features?:
| FeatureSet
| undefined;
@ -966,7 +979,12 @@ export interface MessageOptions {
deprecatedLegacyJsonFieldConflicts?:
| boolean
| undefined;
/** Any features defined in the specific edition. */
/**
* Any features defined in the specific edition.
* WARNING: This field should only be used by protobuf plugins or special
* cases like the proto compiler. Other uses are discouraged and
* developers should rely on the protoreflect APIs for their client language.
*/
features?:
| FeatureSet
| undefined;
@ -976,12 +994,13 @@ export interface MessageOptions {
export interface FieldOptions {
/**
* NOTE: ctype is deprecated. Use `features.(pb.cpp).string_type` instead.
* The ctype option instructs the C++ code generator to use a different
* representation of the field than it normally would. See the specific
* options below. This option is only implemented to support use of
* [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of
* type "bytes" in the open source release -- sorry, we'll try to include
* other types in a future version!
* type "bytes" in the open source release.
* TODO: make ctype actually deprecated.
*/
ctype?:
| FieldOptions_CType
@ -1070,7 +1089,12 @@ export interface FieldOptions {
retention?: FieldOptions_OptionRetention | undefined;
targets: FieldOptions_OptionTargetType[];
editionDefaults: FieldOptions_EditionDefault[];
/** Any features defined in the specific edition. */
/**
* Any features defined in the specific edition.
* WARNING: This field should only be used by protobuf plugins or special
* cases like the proto compiler. Other uses are discouraged and
* developers should rely on the protoreflect APIs for their client language.
*/
features?: FeatureSet | undefined;
featureSupport?:
| FieldOptions_FeatureSupport
@ -1169,11 +1193,7 @@ export function fieldOptions_JSTypeToNumber(object: FieldOptions_JSType): number
}
}
/**
* If set to RETENTION_SOURCE, the option will be omitted from the binary.
* Note: as of January 2023, support for this is in progress and does not yet
* have an effect (b/264593489).
*/
/** If set to RETENTION_SOURCE, the option will be omitted from the binary. */
export enum FieldOptions_OptionRetention {
RETENTION_UNKNOWN = "RETENTION_UNKNOWN",
RETENTION_RUNTIME = "RETENTION_RUNTIME",
@ -1216,8 +1236,7 @@ export function fieldOptions_OptionRetentionToNumber(object: FieldOptions_Option
/**
* This indicates the types of entities that the field may apply to when used
* as an option. If it is unset, then the field may be freely used as an
* option on any kind of entity. Note: as of January 2023, support for this is
* in progress and does not yet have an effect (b/264593489).
* option on any kind of entity.
*/
export enum FieldOptions_OptionTargetType {
TARGET_TYPE_UNKNOWN = "TARGET_TYPE_UNKNOWN",
@ -1341,7 +1360,12 @@ export interface FieldOptions_FeatureSupport {
}
export interface OneofOptions {
/** Any features defined in the specific edition. */
/**
* Any features defined in the specific edition.
* WARNING: This field should only be used by protobuf plugins or special
* cases like the proto compiler. Other uses are discouraged and
* developers should rely on the protoreflect APIs for their client language.
*/
features?:
| FeatureSet
| undefined;
@ -1379,7 +1403,12 @@ export interface EnumOptions {
deprecatedLegacyJsonFieldConflicts?:
| boolean
| undefined;
/** Any features defined in the specific edition. */
/**
* Any features defined in the specific edition.
* WARNING: This field should only be used by protobuf plugins or special
* cases like the proto compiler. Other uses are discouraged and
* developers should rely on the protoreflect APIs for their client language.
*/
features?:
| FeatureSet
| undefined;
@ -1397,7 +1426,12 @@ export interface EnumValueOptions {
deprecated?:
| boolean
| undefined;
/** Any features defined in the specific edition. */
/**
* Any features defined in the specific edition.
* WARNING: This field should only be used by protobuf plugins or special
* cases like the proto compiler. Other uses are discouraged and
* developers should rely on the protoreflect APIs for their client language.
*/
features?:
| FeatureSet
| undefined;
@ -1418,7 +1452,12 @@ export interface EnumValueOptions {
}
export interface ServiceOptions {
/** Any features defined in the specific edition. */
/**
* Any features defined in the specific edition.
* WARNING: This field should only be used by protobuf plugins or special
* cases like the proto compiler. Other uses are discouraged and
* developers should rely on the protoreflect APIs for their client language.
*/
features?:
| FeatureSet
| undefined;
@ -1446,7 +1485,12 @@ export interface MethodOptions {
idempotencyLevel?:
| MethodOptions_IdempotencyLevel
| undefined;
/** Any features defined in the specific edition. */
/**
* Any features defined in the specific edition.
* WARNING: This field should only be used by protobuf plugins or special
* cases like the proto compiler. Other uses are discouraged and
* developers should rely on the protoreflect APIs for their client language.
*/
features?:
| FeatureSet
| undefined;
@ -1549,6 +1593,7 @@ export interface FeatureSet {
utf8Validation?: FeatureSet_Utf8Validation | undefined;
messageEncoding?: FeatureSet_MessageEncoding | undefined;
jsonFormat?: FeatureSet_JsonFormat | undefined;
enforceNamingStyle?: FeatureSet_EnforceNamingStyle | undefined;
}
export enum FeatureSet_FieldPresence {
@ -1791,6 +1836,45 @@ export function featureSet_JsonFormatToNumber(object: FeatureSet_JsonFormat): nu
}
}
export enum FeatureSet_EnforceNamingStyle {
ENFORCE_NAMING_STYLE_UNKNOWN = "ENFORCE_NAMING_STYLE_UNKNOWN",
STYLE2024 = "STYLE2024",
STYLE_LEGACY = "STYLE_LEGACY",
UNRECOGNIZED = "UNRECOGNIZED",
}
export function featureSet_EnforceNamingStyleFromJSON(object: any): FeatureSet_EnforceNamingStyle {
switch (object) {
case 0:
case "ENFORCE_NAMING_STYLE_UNKNOWN":
return FeatureSet_EnforceNamingStyle.ENFORCE_NAMING_STYLE_UNKNOWN;
case 1:
case "STYLE2024":
return FeatureSet_EnforceNamingStyle.STYLE2024;
case 2:
case "STYLE_LEGACY":
return FeatureSet_EnforceNamingStyle.STYLE_LEGACY;
case -1:
case "UNRECOGNIZED":
default:
return FeatureSet_EnforceNamingStyle.UNRECOGNIZED;
}
}
export function featureSet_EnforceNamingStyleToNumber(object: FeatureSet_EnforceNamingStyle): number {
switch (object) {
case FeatureSet_EnforceNamingStyle.ENFORCE_NAMING_STYLE_UNKNOWN:
return 0;
case FeatureSet_EnforceNamingStyle.STYLE2024:
return 1;
case FeatureSet_EnforceNamingStyle.STYLE_LEGACY:
return 2;
case FeatureSet_EnforceNamingStyle.UNRECOGNIZED:
default:
return -1;
}
}
/**
* A compiled specification for the defaults of a set of features. These
* messages are generated from FeatureSet extensions and can be used to seed
@ -4914,6 +4998,7 @@ function createBaseFeatureSet(): FeatureSet {
utf8Validation: FeatureSet_Utf8Validation.UTF8_VALIDATION_UNKNOWN,
messageEncoding: FeatureSet_MessageEncoding.MESSAGE_ENCODING_UNKNOWN,
jsonFormat: FeatureSet_JsonFormat.JSON_FORMAT_UNKNOWN,
enforceNamingStyle: FeatureSet_EnforceNamingStyle.ENFORCE_NAMING_STYLE_UNKNOWN,
};
}
@ -4948,6 +5033,12 @@ export const FeatureSet: MessageFns<FeatureSet> = {
if (message.jsonFormat !== undefined && message.jsonFormat !== FeatureSet_JsonFormat.JSON_FORMAT_UNKNOWN) {
writer.uint32(48).int32(featureSet_JsonFormatToNumber(message.jsonFormat));
}
if (
message.enforceNamingStyle !== undefined &&
message.enforceNamingStyle !== FeatureSet_EnforceNamingStyle.ENFORCE_NAMING_STYLE_UNKNOWN
) {
writer.uint32(56).int32(featureSet_EnforceNamingStyleToNumber(message.enforceNamingStyle));
}
return writer;
},
@ -5006,6 +5097,14 @@ export const FeatureSet: MessageFns<FeatureSet> = {
message.jsonFormat = featureSet_JsonFormatFromJSON(reader.int32());
continue;
}
case 7: {
if (tag !== 56) {
break;
}
message.enforceNamingStyle = featureSet_EnforceNamingStyleFromJSON(reader.int32());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
@ -5027,6 +5126,8 @@ export const FeatureSet: MessageFns<FeatureSet> = {
message.utf8Validation = object.utf8Validation ?? FeatureSet_Utf8Validation.UTF8_VALIDATION_UNKNOWN;
message.messageEncoding = object.messageEncoding ?? FeatureSet_MessageEncoding.MESSAGE_ENCODING_UNKNOWN;
message.jsonFormat = object.jsonFormat ?? FeatureSet_JsonFormat.JSON_FORMAT_UNKNOWN;
message.enforceNamingStyle = object.enforceNamingStyle ??
FeatureSet_EnforceNamingStyle.ENFORCE_NAMING_STYLE_UNKNOWN;
return message;
},
};

Loading…
Cancel
Save