diff --git a/proto/api/v2/workspace_setting_service.proto b/proto/api/v2/workspace_setting_service.proto index 4ef295d4b..8d99dc5c2 100644 --- a/proto/api/v2/workspace_setting_service.proto +++ b/proto/api/v2/workspace_setting_service.proto @@ -93,9 +93,9 @@ message WorkspaceStorageSetting { StorageType storage_type = 1; // The id of actived external storage. optional int32 actived_external_storage_id = 2; - // The local storage path for STORAGE_TYPE_LOCAL. + // The template of local storage path. // e.g. assets/{timestamp}_{filename} - string local_storage_path = 3; + string local_storage_path_template = 3; // The max upload size in megabytes. int64 upload_size_limit_mb = 4; diff --git a/proto/gen/api/v2/README.md b/proto/gen/api/v2/README.md index bd7f87431..a78588f75 100644 --- a/proto/gen/api/v2/README.md +++ b/proto/gen/api/v2/README.md @@ -3084,7 +3084,7 @@ Used internally for obfuscating the page token. | ----- | ---- | ----- | ----------- | | storage_type | [WorkspaceStorageSetting.StorageType](#memos-api-v2-WorkspaceStorageSetting-StorageType) | | storage_type is the storage type. | | actived_external_storage_id | [int32](#int32) | optional | The id of actived external storage. | -| local_storage_path | [string](#string) | | The local storage path for STORAGE_TYPE_LOCAL. e.g. assets/{timestamp}_{filename} | +| local_storage_path_template | [string](#string) | | The template of local storage path. e.g. assets/{timestamp}_{filename} | | upload_size_limit_mb | [int64](#int64) | | The max upload size in megabytes. | diff --git a/proto/gen/api/v2/workspace_setting_service.pb.go b/proto/gen/api/v2/workspace_setting_service.pb.go index e5d8b36a9..37d5e6306 100644 --- a/proto/gen/api/v2/workspace_setting_service.pb.go +++ b/proto/gen/api/v2/workspace_setting_service.pb.go @@ -652,9 +652,9 @@ type WorkspaceStorageSetting struct { StorageType WorkspaceStorageSetting_StorageType `protobuf:"varint,1,opt,name=storage_type,json=storageType,proto3,enum=memos.api.v2.WorkspaceStorageSetting_StorageType" json:"storage_type,omitempty"` // The id of actived external storage. ActivedExternalStorageId *int32 `protobuf:"varint,2,opt,name=actived_external_storage_id,json=activedExternalStorageId,proto3,oneof" json:"actived_external_storage_id,omitempty"` - // The local storage path for STORAGE_TYPE_LOCAL. + // The template of local storage path. // e.g. assets/{timestamp}_{filename} - LocalStoragePath string `protobuf:"bytes,3,opt,name=local_storage_path,json=localStoragePath,proto3" json:"local_storage_path,omitempty"` + LocalStoragePathTemplate string `protobuf:"bytes,3,opt,name=local_storage_path_template,json=localStoragePathTemplate,proto3" json:"local_storage_path_template,omitempty"` // The max upload size in megabytes. UploadSizeLimitMb int64 `protobuf:"varint,4,opt,name=upload_size_limit_mb,json=uploadSizeLimitMb,proto3" json:"upload_size_limit_mb,omitempty"` } @@ -705,9 +705,9 @@ func (x *WorkspaceStorageSetting) GetActivedExternalStorageId() int32 { return 0 } -func (x *WorkspaceStorageSetting) GetLocalStoragePath() string { +func (x *WorkspaceStorageSetting) GetLocalStoragePathTemplate() string { if x != nil { - return x.LocalStoragePath + return x.LocalStoragePathTemplate } return "" } @@ -921,7 +921,7 @@ var file_api_v2_workspace_setting_service_proto_rawDesc = []byte{ 0x6f, 0x63, 0x61, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x70, 0x70, 0x65, 0x61, 0x72, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, 0x70, 0x65, 0x61, 0x72, 0x61, - 0x6e, 0x63, 0x65, 0x22, 0xad, 0x03, 0x0a, 0x17, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, + 0x6e, 0x63, 0x65, 0x22, 0xbe, 0x03, 0x0a, 0x17, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x54, 0x0a, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x31, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, @@ -932,80 +932,82 @@ var file_api_v2_workspace_setting_service_proto_rawDesc = []byte{ 0x5f, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x18, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x64, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x53, 0x74, 0x6f, - 0x72, 0x61, 0x67, 0x65, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, 0x2c, 0x0a, 0x12, 0x6c, 0x6f, 0x63, - 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x53, 0x74, 0x6f, 0x72, - 0x61, 0x67, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x2f, 0x0a, 0x14, 0x75, 0x70, 0x6c, 0x6f, 0x61, - 0x64, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x5f, 0x6d, 0x62, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x11, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, 0x7a, - 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x4d, 0x62, 0x22, 0x79, 0x0a, 0x0b, 0x53, 0x74, 0x6f, 0x72, - 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x18, 0x53, 0x54, 0x4f, 0x52, 0x41, - 0x47, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, - 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, - 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x44, 0x41, 0x54, 0x41, 0x42, 0x41, 0x53, 0x45, 0x10, 0x01, - 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, - 0x5f, 0x4c, 0x4f, 0x43, 0x41, 0x4c, 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, 0x53, 0x54, 0x4f, 0x52, - 0x41, 0x47, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x45, 0x58, 0x54, 0x45, 0x52, 0x4e, 0x41, - 0x4c, 0x10, 0x03, 0x42, 0x1e, 0x0a, 0x1c, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x64, 0x5f, - 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, - 0x5f, 0x69, 0x64, 0x22, 0x8e, 0x01, 0x0a, 0x1b, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x4d, 0x65, 0x6d, 0x6f, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x53, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x12, 0x36, 0x0a, 0x17, 0x64, 0x69, 0x73, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, - 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x64, 0x69, 0x73, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x50, 0x75, - 0x62, 0x6c, 0x69, 0x63, 0x56, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x37, 0x0a, 0x18, 0x64, - 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x75, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x64, - 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x57, 0x69, 0x74, 0x68, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x54, 0x69, 0x6d, 0x65, 0x22, 0x42, 0x0a, 0x23, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x54, 0x65, 0x6c, 0x65, 0x67, 0x72, 0x61, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x1b, 0x0a, 0x09, 0x62, - 0x6f, 0x74, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x62, 0x6f, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x32, 0x86, 0x04, 0x0a, 0x17, 0x57, 0x6f, 0x72, - 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x94, 0x01, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x6f, 0x72, - 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x2a, - 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, - 0x73, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, - 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x6d, 0x65, 0x6d, - 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x6f, - 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x12, - 0x1a, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x2f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x9e, 0x01, 0x0a, 0x13, - 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x12, 0x28, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, - 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, - 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, - 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x32, 0xda, 0x41, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x25, 0x12, 0x23, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, - 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, - 0x3d, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0xb2, 0x01, 0x0a, - 0x13, 0x53, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, + 0x72, 0x61, 0x67, 0x65, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, 0x3d, 0x0a, 0x1b, 0x6c, 0x6f, 0x63, + 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x5f, + 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x18, + 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x50, 0x61, 0x74, 0x68, + 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x2f, 0x0a, 0x14, 0x75, 0x70, 0x6c, 0x6f, + 0x61, 0x64, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x5f, 0x6d, 0x62, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x11, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, + 0x7a, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x4d, 0x62, 0x22, 0x79, 0x0a, 0x0b, 0x53, 0x74, 0x6f, + 0x72, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x18, 0x53, 0x54, 0x4f, 0x52, + 0x41, 0x47, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, + 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, + 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x44, 0x41, 0x54, 0x41, 0x42, 0x41, 0x53, 0x45, 0x10, + 0x01, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x4c, 0x4f, 0x43, 0x41, 0x4c, 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, 0x53, 0x54, 0x4f, + 0x52, 0x41, 0x47, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x45, 0x58, 0x54, 0x45, 0x52, 0x4e, + 0x41, 0x4c, 0x10, 0x03, 0x42, 0x1e, 0x0a, 0x1c, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x64, + 0x5f, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x5f, 0x69, 0x64, 0x22, 0x8e, 0x01, 0x0a, 0x1b, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x4d, 0x65, 0x6d, 0x6f, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x53, 0x65, 0x74, + 0x74, 0x69, 0x6e, 0x67, 0x12, 0x36, 0x0a, 0x17, 0x64, 0x69, 0x73, 0x61, 0x6c, 0x6c, 0x6f, 0x77, + 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x64, 0x69, 0x73, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x50, + 0x75, 0x62, 0x6c, 0x69, 0x63, 0x56, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x37, 0x0a, 0x18, + 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, + 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x57, 0x69, 0x74, 0x68, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x42, 0x0a, 0x23, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x54, 0x65, 0x6c, 0x65, 0x67, 0x72, 0x61, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x1b, 0x0a, 0x09, + 0x62, 0x6f, 0x74, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x62, 0x6f, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x32, 0x86, 0x04, 0x0a, 0x17, 0x57, 0x6f, + 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x94, 0x01, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x6f, + 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, + 0x2a, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x6d, 0x65, + 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x57, + 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, + 0x12, 0x1a, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x2f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x9e, 0x01, 0x0a, + 0x13, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x28, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, - 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x65, + 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, - 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x46, 0xda, 0x41, 0x07, 0x73, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x36, 0x3a, 0x07, 0x73, 0x65, 0x74, - 0x74, 0x69, 0x6e, 0x67, 0x32, 0x2b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x77, 0x6f, - 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x7b, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, - 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2f, 0x2a, - 0x7d, 0x42, 0xb4, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x42, 0x1c, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x65, 0x6d, 0x6f, - 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, - 0x76, 0x32, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x4d, 0x41, 0x58, 0xaa, 0x02, - 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0c, - 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x18, 0x4d, - 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x3a, - 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x32, 0xda, 0x41, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x25, 0x12, 0x23, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, + 0x32, 0x2f, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, + 0x65, 0x3d, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0xb2, 0x01, + 0x0a, 0x13, 0x53, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x28, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x29, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x53, + 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, + 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x46, 0xda, 0x41, 0x07, 0x73, + 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x36, 0x3a, 0x07, 0x73, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x32, 0x2b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x77, + 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x7b, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, + 0x67, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2f, + 0x2a, 0x7d, 0x42, 0xb4, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x42, 0x1c, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x65, 0x6d, + 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x76, 0x32, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x4d, 0x41, 0x58, 0xaa, + 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x32, 0xca, 0x02, + 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x18, + 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x4d, 0x65, 0x6d, 0x6f, 0x73, + 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/proto/gen/store/README.md b/proto/gen/store/README.md index 8e0342817..cf20b12be 100644 --- a/proto/gen/store/README.md +++ b/proto/gen/store/README.md @@ -636,7 +636,7 @@ | ----- | ---- | ----- | ----------- | | storage_type | [WorkspaceStorageSetting.StorageType](#memos-store-WorkspaceStorageSetting-StorageType) | | storage_type is the storage type. | | actived_external_storage_id | [int32](#int32) | optional | The id of actived external storage. | -| local_storage_path | [string](#string) | | The local storage path for STORAGE_TYPE_LOCAL. e.g. assets/{timestamp}_{filename} | +| local_storage_path_template | [string](#string) | | The template of local storage path. e.g. assets/{timestamp}_{filename} | | upload_size_limit_mb | [int64](#int64) | | The max upload size in megabytes. | diff --git a/proto/gen/store/workspace_setting.pb.go b/proto/gen/store/workspace_setting.pb.go index bb4c71700..c16c4a172 100644 --- a/proto/gen/store/workspace_setting.pb.go +++ b/proto/gen/store/workspace_setting.pb.go @@ -505,9 +505,9 @@ type WorkspaceStorageSetting struct { StorageType WorkspaceStorageSetting_StorageType `protobuf:"varint,1,opt,name=storage_type,json=storageType,proto3,enum=memos.store.WorkspaceStorageSetting_StorageType" json:"storage_type,omitempty"` // The id of actived external storage. ActivedExternalStorageId *int32 `protobuf:"varint,2,opt,name=actived_external_storage_id,json=activedExternalStorageId,proto3,oneof" json:"actived_external_storage_id,omitempty"` - // The local storage path for STORAGE_TYPE_LOCAL. + // The template of local storage path. // e.g. assets/{timestamp}_{filename} - LocalStoragePath string `protobuf:"bytes,3,opt,name=local_storage_path,json=localStoragePath,proto3" json:"local_storage_path,omitempty"` + LocalStoragePathTemplate string `protobuf:"bytes,3,opt,name=local_storage_path_template,json=localStoragePathTemplate,proto3" json:"local_storage_path_template,omitempty"` // The max upload size in megabytes. UploadSizeLimitMb int64 `protobuf:"varint,4,opt,name=upload_size_limit_mb,json=uploadSizeLimitMb,proto3" json:"upload_size_limit_mb,omitempty"` } @@ -558,9 +558,9 @@ func (x *WorkspaceStorageSetting) GetActivedExternalStorageId() int32 { return 0 } -func (x *WorkspaceStorageSetting) GetLocalStoragePath() string { +func (x *WorkspaceStorageSetting) GetLocalStoragePathTemplate() string { if x != nil { - return x.LocalStoragePath + return x.LocalStoragePathTemplate } return "" } @@ -751,7 +751,7 @@ var file_store_workspace_setting_proto_rawDesc = []byte{ 0x6f, 0x67, 0x6f, 0x55, 0x72, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x70, 0x70, 0x65, 0x61, 0x72, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, 0x70, 0x65, 0x61, 0x72, 0x61, 0x6e, 0x63, 0x65, 0x22, 0xac, + 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, 0x70, 0x65, 0x61, 0x72, 0x61, 0x6e, 0x63, 0x65, 0x22, 0xbd, 0x03, 0x0a, 0x17, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x53, 0x0a, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, @@ -763,61 +763,62 @@ var file_store_workspace_setting_proto_rawDesc = []byte{ 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x18, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x64, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x49, 0x64, - 0x88, 0x01, 0x01, 0x12, 0x2c, 0x0a, 0x12, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x6f, - 0x72, 0x61, 0x67, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x10, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x50, 0x61, 0x74, - 0x68, 0x12, 0x2f, 0x0a, 0x14, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x73, 0x69, 0x7a, 0x65, - 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x5f, 0x6d, 0x62, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x11, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, 0x7a, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, - 0x4d, 0x62, 0x22, 0x79, 0x0a, 0x0b, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x1c, 0x0a, 0x18, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x5f, 0x54, 0x59, 0x50, - 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, - 0x19, 0x0a, 0x15, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, - 0x44, 0x41, 0x54, 0x41, 0x42, 0x41, 0x53, 0x45, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, - 0x4f, 0x52, 0x41, 0x47, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4c, 0x4f, 0x43, 0x41, 0x4c, - 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x5f, 0x54, 0x59, - 0x50, 0x45, 0x5f, 0x45, 0x58, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x10, 0x03, 0x42, 0x1e, 0x0a, - 0x1c, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x64, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, - 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x64, 0x22, 0x8e, 0x01, - 0x0a, 0x1b, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4d, 0x65, 0x6d, 0x6f, 0x52, - 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x36, 0x0a, - 0x17, 0x64, 0x69, 0x73, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, - 0x5f, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, - 0x64, 0x69, 0x73, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x56, 0x69, - 0x73, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x37, 0x0a, 0x18, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, - 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, - 0x57, 0x69, 0x74, 0x68, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x42, - 0x0a, 0x23, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x65, 0x6c, 0x65, 0x67, - 0x72, 0x61, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x6f, 0x74, 0x5f, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x6f, 0x74, 0x54, 0x6f, 0x6b, - 0x65, 0x6e, 0x2a, 0xe7, 0x01, 0x0a, 0x13, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x21, 0x57, 0x4f, - 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x45, 0x54, 0x54, 0x49, 0x4e, 0x47, 0x5f, - 0x4b, 0x45, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, - 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x53, - 0x45, 0x54, 0x54, 0x49, 0x4e, 0x47, 0x5f, 0x42, 0x41, 0x53, 0x49, 0x43, 0x10, 0x01, 0x12, 0x1d, + 0x88, 0x01, 0x01, 0x12, 0x3d, 0x0a, 0x1b, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x6f, + 0x72, 0x61, 0x67, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x18, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x53, + 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x50, 0x61, 0x74, 0x68, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x12, 0x2f, 0x0a, 0x14, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x73, 0x69, 0x7a, + 0x65, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x5f, 0x6d, 0x62, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x11, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, 0x7a, 0x65, 0x4c, 0x69, 0x6d, 0x69, + 0x74, 0x4d, 0x62, 0x22, 0x79, 0x0a, 0x0b, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x18, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x5f, 0x54, 0x59, + 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, + 0x12, 0x19, 0x0a, 0x15, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, + 0x5f, 0x44, 0x41, 0x54, 0x41, 0x42, 0x41, 0x53, 0x45, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x53, + 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4c, 0x4f, 0x43, 0x41, + 0x4c, 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x5f, 0x54, + 0x59, 0x50, 0x45, 0x5f, 0x45, 0x58, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x10, 0x03, 0x42, 0x1e, + 0x0a, 0x1c, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x64, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x64, 0x22, 0x8e, + 0x01, 0x0a, 0x1b, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4d, 0x65, 0x6d, 0x6f, + 0x52, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x36, + 0x0a, 0x17, 0x64, 0x69, 0x73, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, + 0x63, 0x5f, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x15, 0x64, 0x69, 0x73, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x56, + 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x37, 0x0a, 0x18, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, + 0x79, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, + 0x79, 0x57, 0x69, 0x74, 0x68, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, + 0x42, 0x0a, 0x23, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x54, 0x65, 0x6c, 0x65, + 0x67, 0x72, 0x61, 0x6d, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, + 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x6f, 0x74, 0x5f, 0x74, 0x6f, + 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x6f, 0x74, 0x54, 0x6f, + 0x6b, 0x65, 0x6e, 0x2a, 0xe7, 0x01, 0x0a, 0x13, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x21, 0x57, + 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x45, 0x54, 0x54, 0x49, 0x4e, 0x47, + 0x5f, 0x4b, 0x45, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, + 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, + 0x53, 0x45, 0x54, 0x54, 0x49, 0x4e, 0x47, 0x5f, 0x42, 0x41, 0x53, 0x49, 0x43, 0x10, 0x01, 0x12, + 0x1d, 0x0a, 0x19, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x45, 0x54, + 0x54, 0x49, 0x4e, 0x47, 0x5f, 0x47, 0x45, 0x4e, 0x45, 0x52, 0x41, 0x4c, 0x10, 0x02, 0x12, 0x1d, 0x0a, 0x19, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x45, 0x54, 0x54, - 0x49, 0x4e, 0x47, 0x5f, 0x47, 0x45, 0x4e, 0x45, 0x52, 0x41, 0x4c, 0x10, 0x02, 0x12, 0x1d, 0x0a, - 0x19, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x45, 0x54, 0x54, 0x49, - 0x4e, 0x47, 0x5f, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x10, 0x03, 0x12, 0x22, 0x0a, 0x1e, - 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x45, 0x54, 0x54, 0x49, 0x4e, - 0x47, 0x5f, 0x4d, 0x45, 0x4d, 0x4f, 0x5f, 0x52, 0x45, 0x4c, 0x41, 0x54, 0x45, 0x44, 0x10, 0x04, - 0x12, 0x2a, 0x0a, 0x26, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x45, - 0x54, 0x54, 0x49, 0x4e, 0x47, 0x5f, 0x54, 0x45, 0x4c, 0x45, 0x47, 0x52, 0x41, 0x4d, 0x5f, 0x49, - 0x4e, 0x54, 0x45, 0x47, 0x52, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x05, 0x42, 0xa0, 0x01, 0x0a, - 0x0f, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, - 0x42, 0x15, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, - 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, - 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x73, - 0x74, 0x6f, 0x72, 0x65, 0xa2, 0x02, 0x03, 0x4d, 0x53, 0x58, 0xaa, 0x02, 0x0b, 0x4d, 0x65, 0x6d, - 0x6f, 0x73, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xca, 0x02, 0x0b, 0x4d, 0x65, 0x6d, 0x6f, 0x73, - 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xe2, 0x02, 0x17, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x53, - 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0xea, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x49, 0x4e, 0x47, 0x5f, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x10, 0x03, 0x12, 0x22, 0x0a, + 0x1e, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x53, 0x45, 0x54, 0x54, 0x49, + 0x4e, 0x47, 0x5f, 0x4d, 0x45, 0x4d, 0x4f, 0x5f, 0x52, 0x45, 0x4c, 0x41, 0x54, 0x45, 0x44, 0x10, + 0x04, 0x12, 0x2a, 0x0a, 0x26, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x50, 0x41, 0x43, 0x45, 0x5f, 0x53, + 0x45, 0x54, 0x54, 0x49, 0x4e, 0x47, 0x5f, 0x54, 0x45, 0x4c, 0x45, 0x47, 0x52, 0x41, 0x4d, 0x5f, + 0x49, 0x4e, 0x54, 0x45, 0x47, 0x52, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x05, 0x42, 0xa0, 0x01, + 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, + 0x65, 0x42, 0x15, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, + 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, + 0x73, 0x74, 0x6f, 0x72, 0x65, 0xa2, 0x02, 0x03, 0x4d, 0x53, 0x58, 0xaa, 0x02, 0x0b, 0x4d, 0x65, + 0x6d, 0x6f, 0x73, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xca, 0x02, 0x0b, 0x4d, 0x65, 0x6d, 0x6f, + 0x73, 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xe2, 0x02, 0x17, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, + 0x53, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0xea, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x53, 0x74, 0x6f, 0x72, 0x65, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/store/workspace_setting.proto b/proto/store/workspace_setting.proto index 73bb56a42..648408eeb 100644 --- a/proto/store/workspace_setting.proto +++ b/proto/store/workspace_setting.proto @@ -62,9 +62,9 @@ message WorkspaceStorageSetting { StorageType storage_type = 1; // The id of actived external storage. optional int32 actived_external_storage_id = 2; - // The local storage path for STORAGE_TYPE_LOCAL. + // The template of local storage path. // e.g. assets/{timestamp}_{filename} - string local_storage_path = 3; + string local_storage_path_template = 3; // The max upload size in megabytes. int64 upload_size_limit_mb = 4; diff --git a/server/route/api/v2/apidocs.swagger.yaml b/server/route/api/v2/apidocs.swagger.yaml index f0cfaf502..9ccfb522a 100644 --- a/server/route/api/v2/apidocs.swagger.yaml +++ b/server/route/api/v2/apidocs.swagger.yaml @@ -2069,10 +2069,10 @@ definitions: type: integer format: int32 description: The id of actived external storage. - localStoragePath: + localStoragePathTemplate: type: string title: |- - The local storage path for STORAGE_TYPE_LOCAL. + The template of local storage path. e.g. assets/{timestamp}_{filename} uploadSizeLimitMb: type: string diff --git a/server/route/api/v2/resource_service.go b/server/route/api/v2/resource_service.go index 24f86df1f..cbc131421 100644 --- a/server/route/api/v2/resource_service.go +++ b/server/route/api/v2/resource_service.go @@ -260,8 +260,8 @@ func SaveResourceBlob(ctx context.Context, s *store.Store, create *store.Resourc if workspaceStorageSetting.StorageType == storepb.WorkspaceStorageSetting_STORAGE_TYPE_LOCAL { localStoragePath := "assets/{timestamp}_{filename}" - if workspaceStorageSetting.LocalStoragePath != "" { - localStoragePath = workspaceStorageSetting.LocalStoragePath + if workspaceStorageSetting.LocalStoragePathTemplate != "" { + localStoragePath = workspaceStorageSetting.LocalStoragePathTemplate } internalPath := localStoragePath diff --git a/server/route/api/v2/workspace_setting_service.go b/server/route/api/v2/workspace_setting_service.go index 7dd76e1c6..a81555700 100644 --- a/server/route/api/v2/workspace_setting_service.go +++ b/server/route/api/v2/workspace_setting_service.go @@ -176,9 +176,10 @@ func convertWorkspaceStorageSettingFromStore(setting *storepb.WorkspaceStorageSe return nil } return &apiv2pb.WorkspaceStorageSetting{ - StorageType: apiv2pb.WorkspaceStorageSetting_StorageType(setting.StorageType), - LocalStoragePath: setting.LocalStoragePath, - UploadSizeLimitMb: setting.UploadSizeLimitMb, + StorageType: apiv2pb.WorkspaceStorageSetting_StorageType(setting.StorageType), + LocalStoragePathTemplate: setting.LocalStoragePathTemplate, + UploadSizeLimitMb: setting.UploadSizeLimitMb, + ActivedExternalStorageId: setting.ActivedExternalStorageId, } } @@ -187,9 +188,10 @@ func convertWorkspaceStorageSettingToStore(setting *apiv2pb.WorkspaceStorageSett return nil } return &storepb.WorkspaceStorageSetting{ - StorageType: storepb.WorkspaceStorageSetting_StorageType(setting.StorageType), - LocalStoragePath: setting.LocalStoragePath, - UploadSizeLimitMb: setting.UploadSizeLimitMb, + StorageType: storepb.WorkspaceStorageSetting_StorageType(setting.StorageType), + LocalStoragePathTemplate: setting.LocalStoragePathTemplate, + UploadSizeLimitMb: setting.UploadSizeLimitMb, + ActivedExternalStorageId: setting.ActivedExternalStorageId, } } diff --git a/store/common.go b/store/common.go index 79a63e843..f0b3c6e09 100644 --- a/store/common.go +++ b/store/common.go @@ -1,5 +1,14 @@ package store +import "google.golang.org/protobuf/encoding/protojson" + +var ( + protojsonUnmarshaler = protojson.UnmarshalOptions{ + AllowPartial: true, + DiscardUnknown: true, + } +) + // RowStatus is the status for a row. type RowStatus string diff --git a/store/db/mysql/user_setting.go b/store/db/mysql/user_setting.go index 8a2114de8..3a31002ac 100644 --- a/store/db/mysql/user_setting.go +++ b/store/db/mysql/user_setting.go @@ -5,42 +5,19 @@ import ( "database/sql" "strings" - "github.com/pkg/errors" - "google.golang.org/protobuf/encoding/protojson" - storepb "github.com/usememos/memos/proto/gen/store" "github.com/usememos/memos/store" ) -func (d *DB) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) (*storepb.UserSetting, error) { +func (d *DB) UpsertUserSetting(ctx context.Context, upsert *store.UserSetting) (*store.UserSetting, error) { stmt := "INSERT INTO `user_setting` (`user_id`, `key`, `value`) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = ?" - var valueString string - if upsert.Key == storepb.UserSettingKey_USER_SETTING_ACCESS_TOKENS { - valueBytes, err := protojson.Marshal(upsert.GetAccessTokens()) - if err != nil { - return nil, err - } - valueString = string(valueBytes) - } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_LOCALE { - valueString = upsert.GetLocale() - } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_APPEARANCE { - valueString = upsert.GetAppearance() - } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_MEMO_VISIBILITY { - valueString = upsert.GetMemoVisibility() - } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID { - valueString = upsert.GetTelegramUserId() - } else { - return nil, errors.Errorf("unknown user setting key: %s", upsert.Key.String()) - } - - if _, err := d.db.ExecContext(ctx, stmt, upsert.UserId, upsert.Key.String(), valueString, valueString); err != nil { + if _, err := d.db.ExecContext(ctx, stmt, upsert.UserID, upsert.Key.String(), upsert.Value, upsert.Value); err != nil { return nil, err } - return upsert, nil } -func (d *DB) ListUserSettings(ctx context.Context, find *store.FindUserSetting) ([]*storepb.UserSetting, error) { +func (d *DB) ListUserSettings(ctx context.Context, find *store.FindUserSetting) ([]*store.UserSetting, error) { where, args := []string{"1 = 1"}, []any{} if v := find.Key; v != storepb.UserSettingKey_USER_SETTING_KEY_UNSPECIFIED { @@ -57,46 +34,18 @@ func (d *DB) ListUserSettings(ctx context.Context, find *store.FindUserSetting) } defer rows.Close() - userSettingList := make([]*storepb.UserSetting, 0) + userSettingList := make([]*store.UserSetting, 0) for rows.Next() { - userSetting := &storepb.UserSetting{} - var keyString, valueString string + userSetting := &store.UserSetting{} + var keyString string if err := rows.Scan( - &userSetting.UserId, + &userSetting.UserID, &keyString, - &valueString, + &userSetting.Value, ); err != nil { return nil, err } userSetting.Key = storepb.UserSettingKey(storepb.UserSettingKey_value[keyString]) - if userSetting.Key == storepb.UserSettingKey_USER_SETTING_ACCESS_TOKENS { - accessTokensUserSetting := &storepb.AccessTokensUserSetting{} - if err := protojson.Unmarshal([]byte(valueString), accessTokensUserSetting); err != nil { - return nil, err - } - userSetting.Value = &storepb.UserSetting_AccessTokens{ - AccessTokens: accessTokensUserSetting, - } - } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_LOCALE { - userSetting.Value = &storepb.UserSetting_Locale{ - Locale: valueString, - } - } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_APPEARANCE { - userSetting.Value = &storepb.UserSetting_Appearance{ - Appearance: valueString, - } - } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_MEMO_VISIBILITY { - userSetting.Value = &storepb.UserSetting_MemoVisibility{ - MemoVisibility: valueString, - } - } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID { - userSetting.Value = &storepb.UserSetting_TelegramUserId{ - TelegramUserId: valueString, - } - } else { - // Skip unknown user setting key. - continue - } userSettingList = append(userSettingList, userSetting) } diff --git a/store/db/postgres/user_setting.go b/store/db/postgres/user_setting.go index 71c5fd3fa..e59bf5c97 100644 --- a/store/db/postgres/user_setting.go +++ b/store/db/postgres/user_setting.go @@ -5,14 +5,11 @@ import ( "database/sql" "strings" - "github.com/pkg/errors" - "google.golang.org/protobuf/encoding/protojson" - storepb "github.com/usememos/memos/proto/gen/store" "github.com/usememos/memos/store" ) -func (d *DB) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) (*storepb.UserSetting, error) { +func (d *DB) UpsertUserSetting(ctx context.Context, upsert *store.UserSetting) (*store.UserSetting, error) { stmt := ` INSERT INTO user_setting ( user_id, key, value @@ -21,33 +18,13 @@ func (d *DB) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) ON CONFLICT(user_id, key) DO UPDATE SET value = EXCLUDED.value ` - var valueString string - if upsert.Key == storepb.UserSettingKey_USER_SETTING_ACCESS_TOKENS { - valueBytes, err := protojson.Marshal(upsert.GetAccessTokens()) - if err != nil { - return nil, err - } - valueString = string(valueBytes) - } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_LOCALE { - valueString = upsert.GetLocale() - } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_APPEARANCE { - valueString = upsert.GetAppearance() - } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_MEMO_VISIBILITY { - valueString = upsert.GetMemoVisibility() - } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID { - valueString = upsert.GetTelegramUserId() - } else { - return nil, errors.Errorf("unknown user setting key: %s", upsert.Key.String()) - } - - if _, err := d.db.ExecContext(ctx, stmt, upsert.UserId, upsert.Key.String(), valueString); err != nil { + if _, err := d.db.ExecContext(ctx, stmt, upsert.UserID, upsert.Key.String(), upsert.Value); err != nil { return nil, err } - return upsert, nil } -func (d *DB) ListUserSettings(ctx context.Context, find *store.FindUserSetting) ([]*storepb.UserSetting, error) { +func (d *DB) ListUserSettings(ctx context.Context, find *store.FindUserSetting) ([]*store.UserSetting, error) { where, args := []string{"1 = 1"}, []any{} if v := find.Key; v != storepb.UserSettingKey_USER_SETTING_KEY_UNSPECIFIED { @@ -70,46 +47,18 @@ func (d *DB) ListUserSettings(ctx context.Context, find *store.FindUserSetting) } defer rows.Close() - userSettingList := make([]*storepb.UserSetting, 0) + userSettingList := make([]*store.UserSetting, 0) for rows.Next() { - userSetting := &storepb.UserSetting{} - var keyString, valueString string + userSetting := &store.UserSetting{} + var keyString string if err := rows.Scan( - &userSetting.UserId, + &userSetting.UserID, &keyString, - &valueString, + &userSetting.Value, ); err != nil { return nil, err } userSetting.Key = storepb.UserSettingKey(storepb.UserSettingKey_value[keyString]) - if userSetting.Key == storepb.UserSettingKey_USER_SETTING_ACCESS_TOKENS { - accessTokensUserSetting := &storepb.AccessTokensUserSetting{} - if err := protojson.Unmarshal([]byte(valueString), accessTokensUserSetting); err != nil { - return nil, err - } - userSetting.Value = &storepb.UserSetting_AccessTokens{ - AccessTokens: accessTokensUserSetting, - } - } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_LOCALE { - userSetting.Value = &storepb.UserSetting_Locale{ - Locale: valueString, - } - } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_APPEARANCE { - userSetting.Value = &storepb.UserSetting_Appearance{ - Appearance: valueString, - } - } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_MEMO_VISIBILITY { - userSetting.Value = &storepb.UserSetting_MemoVisibility{ - MemoVisibility: valueString, - } - } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID { - userSetting.Value = &storepb.UserSetting_TelegramUserId{ - TelegramUserId: valueString, - } - } else { - // Skip unknown user setting key. - continue - } userSettingList = append(userSettingList, userSetting) } diff --git a/store/db/sqlite/user_setting.go b/store/db/sqlite/user_setting.go index 95e065e89..4ef9577bf 100644 --- a/store/db/sqlite/user_setting.go +++ b/store/db/sqlite/user_setting.go @@ -5,14 +5,11 @@ import ( "database/sql" "strings" - "github.com/pkg/errors" - "google.golang.org/protobuf/encoding/protojson" - storepb "github.com/usememos/memos/proto/gen/store" "github.com/usememos/memos/store" ) -func (d *DB) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) (*storepb.UserSetting, error) { +func (d *DB) UpsertUserSetting(ctx context.Context, upsert *store.UserSetting) (*store.UserSetting, error) { stmt := ` INSERT INTO user_setting ( user_id, key, value @@ -21,33 +18,13 @@ func (d *DB) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) ON CONFLICT(user_id, key) DO UPDATE SET value = EXCLUDED.value ` - var valueString string - if upsert.Key == storepb.UserSettingKey_USER_SETTING_ACCESS_TOKENS { - valueBytes, err := protojson.Marshal(upsert.GetAccessTokens()) - if err != nil { - return nil, err - } - valueString = string(valueBytes) - } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_LOCALE { - valueString = upsert.GetLocale() - } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_APPEARANCE { - valueString = upsert.GetAppearance() - } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_MEMO_VISIBILITY { - valueString = upsert.GetMemoVisibility() - } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID { - valueString = upsert.GetTelegramUserId() - } else { - return nil, errors.Errorf("unknown user setting key: %s", upsert.Key.String()) - } - - if _, err := d.db.ExecContext(ctx, stmt, upsert.UserId, upsert.Key.String(), valueString); err != nil { + if _, err := d.db.ExecContext(ctx, stmt, upsert.UserID, upsert.Key.String(), upsert.Value); err != nil { return nil, err } - return upsert, nil } -func (d *DB) ListUserSettings(ctx context.Context, find *store.FindUserSetting) ([]*storepb.UserSetting, error) { +func (d *DB) ListUserSettings(ctx context.Context, find *store.FindUserSetting) ([]*store.UserSetting, error) { where, args := []string{"1 = 1"}, []any{} if v := find.Key; v != storepb.UserSettingKey_USER_SETTING_KEY_UNSPECIFIED { @@ -70,46 +47,18 @@ func (d *DB) ListUserSettings(ctx context.Context, find *store.FindUserSetting) } defer rows.Close() - userSettingList := make([]*storepb.UserSetting, 0) + userSettingList := make([]*store.UserSetting, 0) for rows.Next() { - userSetting := &storepb.UserSetting{} - var keyString, valueString string + userSetting := &store.UserSetting{} + var keyString string if err := rows.Scan( - &userSetting.UserId, + &userSetting.UserID, &keyString, - &valueString, + &userSetting.Value, ); err != nil { return nil, err } userSetting.Key = storepb.UserSettingKey(storepb.UserSettingKey_value[keyString]) - if userSetting.Key == storepb.UserSettingKey_USER_SETTING_ACCESS_TOKENS { - accessTokensUserSetting := &storepb.AccessTokensUserSetting{} - if err := protojson.Unmarshal([]byte(valueString), accessTokensUserSetting); err != nil { - return nil, err - } - userSetting.Value = &storepb.UserSetting_AccessTokens{ - AccessTokens: accessTokensUserSetting, - } - } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_LOCALE { - userSetting.Value = &storepb.UserSetting_Locale{ - Locale: valueString, - } - } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_APPEARANCE { - userSetting.Value = &storepb.UserSetting_Appearance{ - Appearance: valueString, - } - } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_MEMO_VISIBILITY { - userSetting.Value = &storepb.UserSetting_MemoVisibility{ - MemoVisibility: valueString, - } - } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID { - userSetting.Value = &storepb.UserSetting_TelegramUserId{ - TelegramUserId: valueString, - } - } else { - // Skip unknown user setting key. - continue - } userSettingList = append(userSettingList, userSetting) } if err := rows.Err(); err != nil { diff --git a/store/driver.go b/store/driver.go index 10c3d87cf..3fa08f4cc 100644 --- a/store/driver.go +++ b/store/driver.go @@ -61,8 +61,8 @@ type Driver interface { DeleteUser(ctx context.Context, delete *DeleteUser) error // UserSetting model related methods. - UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) (*storepb.UserSetting, error) - ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*storepb.UserSetting, error) + UpsertUserSetting(ctx context.Context, upsert *UserSetting) (*UserSetting, error) + ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*UserSetting, error) // IdentityProvider model related methods. CreateIdentityProvider(ctx context.Context, create *IdentityProvider) (*IdentityProvider, error) diff --git a/store/user_setting.go b/store/user_setting.go index d8e85bf50..7eed28aa6 100644 --- a/store/user_setting.go +++ b/store/user_setting.go @@ -3,34 +3,56 @@ package store import ( "context" + "github.com/pkg/errors" storepb "github.com/usememos/memos/proto/gen/store" + "google.golang.org/protobuf/encoding/protojson" ) +type UserSetting struct { + UserID int32 + Key storepb.UserSettingKey + Value string +} + type FindUserSetting struct { UserID *int32 Key storepb.UserSettingKey } func (s *Store) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting) (*storepb.UserSetting, error) { - userSettingMessage, err := s.driver.UpsertUserSetting(ctx, upsert) + userSettingRaw, err := convertUserSettingToRaw(upsert) + if err != nil { + return nil, err + } + userSettingRaw, err = s.driver.UpsertUserSetting(ctx, userSettingRaw) if err != nil { return nil, err } - s.userSettingCache.Store(getUserSettingV1CacheKey(userSettingMessage.UserId, userSettingMessage.Key.String()), userSettingMessage) - return userSettingMessage, nil + userSetting, err := convertUserSettingFromRaw(userSettingRaw) + if err != nil { + return nil, err + } + s.userSettingCache.Store(getUserSettingV1CacheKey(userSetting.UserId, userSetting.Key.String()), userSetting) + return userSetting, nil } func (s *Store) ListUserSettings(ctx context.Context, find *FindUserSetting) ([]*storepb.UserSetting, error) { - userSettingList, err := s.driver.ListUserSettings(ctx, find) + userSettingRawList, err := s.driver.ListUserSettings(ctx, find) if err != nil { return nil, err } - for _, userSetting := range userSettingList { + userSettings := []*storepb.UserSetting{} + for _, userSettingRaw := range userSettingRawList { + userSetting, err := convertUserSettingFromRaw(userSettingRaw) + if err != nil { + return nil, err + } s.userSettingCache.Store(getUserSettingV1CacheKey(userSetting.UserId, userSetting.Key.String()), userSetting) + userSettings = append(userSettings, userSetting) } - return userSettingList, nil + return userSettings, nil } func (s *Store) GetUserSetting(ctx context.Context, find *FindUserSetting) (*storepb.UserSetting, error) { @@ -44,10 +66,12 @@ func (s *Store) GetUserSetting(ctx context.Context, find *FindUserSetting) (*sto if err != nil { return nil, err } - if len(list) == 0 { return nil, nil } + if len(list) > 1 { + return nil, errors.Errorf("expected 1 user setting, but got %d", len(list)) + } userSetting := list[0] s.userSettingCache.Store(getUserSettingV1CacheKey(userSetting.UserId, userSetting.Key.String()), userSetting) @@ -97,3 +121,58 @@ func (s *Store) RemoveUserAccessToken(ctx context.Context, userID int32, token s return err } + +func convertUserSettingFromRaw(raw *UserSetting) (*storepb.UserSetting, error) { + userSetting := &storepb.UserSetting{ + UserId: raw.UserID, + Key: raw.Key, + } + + switch raw.Key { + case storepb.UserSettingKey_USER_SETTING_ACCESS_TOKENS: + accessTokensUserSetting := &storepb.AccessTokensUserSetting{} + if err := protojsonUnmarshaler.Unmarshal([]byte(raw.Value), accessTokensUserSetting); err != nil { + return nil, err + } + userSetting.Value = &storepb.UserSetting_AccessTokens{AccessTokens: accessTokensUserSetting} + case storepb.UserSettingKey_USER_SETTING_LOCALE: + userSetting.Value = &storepb.UserSetting_Locale{Locale: raw.Value} + case storepb.UserSettingKey_USER_SETTING_APPEARANCE: + userSetting.Value = &storepb.UserSetting_Appearance{Appearance: raw.Value} + case storepb.UserSettingKey_USER_SETTING_MEMO_VISIBILITY: + userSetting.Value = &storepb.UserSetting_MemoVisibility{MemoVisibility: raw.Value} + case storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID: + userSetting.Value = &storepb.UserSetting_TelegramUserId{TelegramUserId: raw.Value} + default: + return nil, errors.Errorf("unsupported user setting key: %v", raw.Key) + } + return userSetting, nil +} + +func convertUserSettingToRaw(userSetting *storepb.UserSetting) (*UserSetting, error) { + raw := &UserSetting{ + UserID: userSetting.UserId, + Key: userSetting.Key, + } + + switch userSetting.Key { + case storepb.UserSettingKey_USER_SETTING_ACCESS_TOKENS: + accessTokensUserSetting := userSetting.GetAccessTokens() + value, err := protojson.Marshal(accessTokensUserSetting) + if err != nil { + return nil, err + } + raw.Value = string(value) + case storepb.UserSettingKey_USER_SETTING_LOCALE: + raw.Value = userSetting.GetLocale() + case storepb.UserSettingKey_USER_SETTING_APPEARANCE: + raw.Value = userSetting.GetAppearance() + case storepb.UserSettingKey_USER_SETTING_MEMO_VISIBILITY: + raw.Value = userSetting.GetMemoVisibility() + case storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID: + raw.Value = userSetting.GetTelegramUserId() + default: + return nil, errors.Errorf("unsupported user setting key: %v", userSetting.Key) + } + return raw, nil +} diff --git a/store/workspace_setting.go b/store/workspace_setting.go index 7a4671f48..f4bf0f2da 100644 --- a/store/workspace_setting.go +++ b/store/workspace_setting.go @@ -186,6 +186,12 @@ func (s *Store) GetWorkspaceMemoRelatedSetting(ctx context.Context) (*storepb.Wo return workspaceMemoRelatedSetting, nil } +const ( + defaultWorkspaceStorageType = storepb.WorkspaceStorageSetting_STORAGE_TYPE_DATABASE + defaultWorkspaceUploadSizeLimitMb = 30 + defaultWorkspaceLocalStoragePathTemplate = "assets/{timestamp}_{filename}" +) + func (s *Store) GetWorkspaceStorageSetting(ctx context.Context) (*storepb.WorkspaceStorageSetting, error) { workspaceSetting, err := s.GetWorkspaceSettingV1(ctx, &FindWorkspaceSetting{ Name: storepb.WorkspaceSettingKey_WORKSPACE_SETTING_STORAGE.String(), @@ -198,6 +204,15 @@ func (s *Store) GetWorkspaceStorageSetting(ctx context.Context) (*storepb.Worksp if workspaceSetting != nil { workspaceStorageSetting = workspaceSetting.GetStorageSetting() } + if workspaceStorageSetting.StorageType == storepb.WorkspaceStorageSetting_STORAGE_TYPE_UNSPECIFIED { + workspaceStorageSetting.StorageType = defaultWorkspaceStorageType + } + if workspaceStorageSetting.UploadSizeLimitMb == 0 { + workspaceStorageSetting.UploadSizeLimitMb = defaultWorkspaceUploadSizeLimitMb + } + if workspaceStorageSetting.LocalStoragePathTemplate == "" { + workspaceStorageSetting.LocalStoragePathTemplate = defaultWorkspaceLocalStoragePathTemplate + } return workspaceStorageSetting, nil } @@ -208,31 +223,31 @@ func convertWorkspaceSettingFromRaw(workspaceSettingRaw *WorkspaceSetting) (*sto switch workspaceSettingRaw.Name { case storepb.WorkspaceSettingKey_WORKSPACE_SETTING_BASIC.String(): basicSetting := &storepb.WorkspaceBasicSetting{} - if err := protojson.Unmarshal([]byte(workspaceSettingRaw.Value), basicSetting); err != nil { + if err := protojsonUnmarshaler.Unmarshal([]byte(workspaceSettingRaw.Value), basicSetting); err != nil { return nil, err } workspaceSetting.Value = &storepb.WorkspaceSetting_BasicSetting{BasicSetting: basicSetting} case storepb.WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL.String(): generalSetting := &storepb.WorkspaceGeneralSetting{} - if err := protojson.Unmarshal([]byte(workspaceSettingRaw.Value), generalSetting); err != nil { + if err := protojsonUnmarshaler.Unmarshal([]byte(workspaceSettingRaw.Value), generalSetting); err != nil { return nil, err } workspaceSetting.Value = &storepb.WorkspaceSetting_GeneralSetting{GeneralSetting: generalSetting} case storepb.WorkspaceSettingKey_WORKSPACE_SETTING_STORAGE.String(): storageSetting := &storepb.WorkspaceStorageSetting{} - if err := protojson.Unmarshal([]byte(workspaceSettingRaw.Value), storageSetting); err != nil { + if err := protojsonUnmarshaler.Unmarshal([]byte(workspaceSettingRaw.Value), storageSetting); err != nil { return nil, err } workspaceSetting.Value = &storepb.WorkspaceSetting_StorageSetting{StorageSetting: storageSetting} case storepb.WorkspaceSettingKey_WORKSPACE_SETTING_MEMO_RELATED.String(): memoRelatedSetting := &storepb.WorkspaceMemoRelatedSetting{} - if err := protojson.Unmarshal([]byte(workspaceSettingRaw.Value), memoRelatedSetting); err != nil { + if err := protojsonUnmarshaler.Unmarshal([]byte(workspaceSettingRaw.Value), memoRelatedSetting); err != nil { return nil, err } workspaceSetting.Value = &storepb.WorkspaceSetting_MemoRelatedSetting{MemoRelatedSetting: memoRelatedSetting} case storepb.WorkspaceSettingKey_WORKSPACE_SETTING_TELEGRAM_INTEGRATION.String(): telegramIntegrationSetting := &storepb.WorkspaceTelegramIntegrationSetting{} - if err := protojson.Unmarshal([]byte(workspaceSettingRaw.Value), telegramIntegrationSetting); err != nil { + if err := protojsonUnmarshaler.Unmarshal([]byte(workspaceSettingRaw.Value), telegramIntegrationSetting); err != nil { return nil, err } workspaceSetting.Value = &storepb.WorkspaceSetting_TelegramIntegrationSetting{TelegramIntegrationSetting: telegramIntegrationSetting} diff --git a/web/src/components/Settings/StorageSection.tsx b/web/src/components/Settings/StorageSection.tsx index 82dbc48e7..19c800051 100644 --- a/web/src/components/Settings/StorageSection.tsx +++ b/web/src/components/Settings/StorageSection.tsx @@ -2,7 +2,6 @@ import { Button, Divider, Dropdown, - IconButton, Input, List, ListItem, @@ -11,9 +10,12 @@ import { MenuItem, Radio, RadioGroup, + Select, Tooltip, + Option, } from "@mui/joy"; -import { useEffect, useState } from "react"; +import { isEqual } from "lodash-es"; +import { useEffect, useMemo, useState } from "react"; import { toast } from "react-hot-toast"; import { Link } from "react-router-dom"; import * as api from "@/helpers/api"; @@ -25,7 +27,6 @@ import showCreateStorageServiceDialog from "../CreateStorageServiceDialog"; import { showCommonDialog } from "../Dialog/CommonDialog"; import Icon from "../Icon"; import LearnMore from "../LearnMore"; -import showUpdateLocalStorageDialog from "../UpdateLocalStorageDialog"; const StorageSection = () => { const t = useTranslate(); @@ -37,6 +38,26 @@ const StorageSection = () => { ), ); + const allowSaveStorageSetting = useMemo(() => { + if (workspaceStorageSetting.uploadSizeLimitMb <= 0) { + return false; + } + + const origin = WorkspaceStorageSetting.fromPartial( + workspaceSettingStore.getWorkspaceSettingByKey(WorkspaceSettingKey.WORKSPACE_SETTING_STORAGE)?.storageSetting || {}, + ); + if (workspaceStorageSetting.storageType === WorkspaceStorageSetting_StorageType.STORAGE_TYPE_LOCAL) { + if (workspaceStorageSetting.localStoragePathTemplate.length === 0) { + return false; + } + } else if (workspaceStorageSetting.storageType === WorkspaceStorageSetting_StorageType.STORAGE_TYPE_EXTERNAL) { + if (!workspaceStorageSetting.activedExternalStorageId || workspaceStorageSetting.activedExternalStorageId === 0) { + return false; + } + } + return !isEqual(origin, workspaceStorageSetting); + }, [workspaceStorageSetting, workspaceSettingStore.getState()]); + useEffect(() => { fetchStorageList(); }, []); @@ -56,10 +77,14 @@ const StorageSection = () => { uploadSizeLimitMb: num, }; setWorkspaceStorageSetting(update); - workspaceSettingStore.setWorkspaceSetting({ - name: `${WorkspaceSettingPrefix}${WorkspaceSettingKey.WORKSPACE_SETTING_STORAGE}`, - storageSetting: update, - }); + }; + + const handleLocalStoragePathTemplateChanged = async (event: React.FocusEvent) => { + const update: WorkspaceStorageSetting = { + ...workspaceStorageSetting, + localStoragePathTemplate: event.target.value, + }; + setWorkspaceStorageSetting(update); }; const handleStorageTypeChanged = async (storageType: WorkspaceStorageSetting_StorageType) => { @@ -68,10 +93,6 @@ const StorageSection = () => { storageType: storageType, }; setWorkspaceStorageSetting(update); - await workspaceSettingStore.setWorkspaceSetting({ - name: `${WorkspaceSettingPrefix}${WorkspaceSettingKey.WORKSPACE_SETTING_STORAGE}`, - storageSetting: update, - }); }; const handleActivedExternalStorageIdChanged = async (activedExternalStorageId: number) => { @@ -80,10 +101,14 @@ const StorageSection = () => { activedExternalStorageId: activedExternalStorageId, }; setWorkspaceStorageSetting(update); + }; + + const saveWorkspaceStorageSetting = async () => { await workspaceSettingStore.setWorkspaceSetting({ name: `${WorkspaceSettingPrefix}${WorkspaceSettingKey.WORKSPACE_SETTING_STORAGE}`, - storageSetting: update, + storageSetting: workspaceStorageSetting, }); + toast.success("Updated"); }; const handleDeleteStorage = (storage: ObjectStorage) => { @@ -106,10 +131,9 @@ const StorageSection = () => { return (
-
- {t("setting.storage-section.current-storage")} -
+
{t("setting.storage-section.current-storage")}
{ @@ -117,28 +141,12 @@ const StorageSection = () => { }} > -
- - showUpdateLocalStorageDialog()}> - - -
- -
- { - handleActivedExternalStorageIdChanged(Number(event.target.value)); - }} - > - {storageList.map((storage) => ( - - ))} + +
- {t("setting.system-section.max-upload-size")} + {t("setting.system-section.max-upload-size")} @@ -152,6 +160,36 @@ const StorageSection = () => { onChange={handleMaxUploadSizeChanged} />
+ {workspaceStorageSetting.storageType === WorkspaceStorageSetting_StorageType.STORAGE_TYPE_LOCAL && ( +
+ Local file path template + +
+ )} + {workspaceStorageSetting.storageType === WorkspaceStorageSetting_StorageType.STORAGE_TYPE_EXTERNAL && ( +
+ Actived storage + +
+ )} +
+ +
diff --git a/web/src/components/UpdateLocalStorageDialog.tsx b/web/src/components/UpdateLocalStorageDialog.tsx deleted file mode 100644 index 7fd8e9d96..000000000 --- a/web/src/components/UpdateLocalStorageDialog.tsx +++ /dev/null @@ -1,88 +0,0 @@ -import { Button, IconButton, Input } from "@mui/joy"; -import { useState } from "react"; -import { toast } from "react-hot-toast"; -import { WorkspaceSettingPrefix, useWorkspaceSettingStore } from "@/store/v1"; -import { WorkspaceSettingKey, WorkspaceStorageSetting } from "@/types/proto/store/workspace_setting"; -import { useTranslate } from "@/utils/i18n"; -import { generateDialog } from "./Dialog"; -import Icon from "./Icon"; -import LearnMore from "./LearnMore"; - -interface Props extends DialogProps { - confirmCallback?: () => void; -} - -const UpdateLocalStorageDialog: React.FC = (props: Props) => { - const t = useTranslate(); - const { destroy, confirmCallback } = props; - const workspaceSettingStore = useWorkspaceSettingStore(); - const [workspaceStorageSetting, setWorkspaceStorageSetting] = useState( - WorkspaceStorageSetting.fromPartial( - workspaceSettingStore.getWorkspaceSettingByKey(WorkspaceSettingKey.WORKSPACE_SETTING_STORAGE)?.storageSetting || {}, - ), - ); - - const handleCloseBtnClick = () => { - destroy(); - }; - - const handleConfirmBtnClick = async () => { - try { - await workspaceSettingStore.setWorkspaceSetting({ - name: `${WorkspaceSettingPrefix}${WorkspaceSettingKey.WORKSPACE_SETTING_STORAGE}`, - storageSetting: workspaceStorageSetting, - }); - } catch (error: any) { - console.error(error); - toast.error(error.details); - } - if (confirmCallback) { - confirmCallback(); - } - destroy(); - }; - - return ( - <> -
-

{t("setting.storage-section.update-local-path")}

- - - -
-
-

{t("setting.storage-section.update-local-path-description")}

-
- e.g. {"assets/{timestamp}_{filename}"} - -
- setWorkspaceStorageSetting({ ...workspaceStorageSetting, localStoragePath: e.target.value })} - /> -
- - -
-
- - ); -}; - -function showUpdateLocalStorageDialog(confirmCallback?: () => void) { - generateDialog( - { - className: "update-local-storage-dialog", - dialogName: "update-local-storage-dialog", - }, - UpdateLocalStorageDialog, - { confirmCallback }, - ); -} - -export default showUpdateLocalStorageDialog;