chore: fix types

This commit is contained in:
Steven 2024-05-13 20:07:56 +08:00
parent b8763905ba
commit 31e07c083d
2 changed files with 16 additions and 20 deletions

View File

@ -28,11 +28,11 @@ const StorageSection = () => {
const origin = WorkspaceStorageSetting.fromPartial( const origin = WorkspaceStorageSetting.fromPartial(
workspaceSettingStore.getWorkspaceSettingByKey(WorkspaceSettingKey.STORAGE)?.storageSetting || {}, workspaceSettingStore.getWorkspaceSettingByKey(WorkspaceSettingKey.STORAGE)?.storageSetting || {},
); );
if (workspaceStorageSetting.storageType === WorkspaceStorageSetting_StorageType.STORAGE_TYPE_LOCAL) { if (workspaceStorageSetting.storageType === WorkspaceStorageSetting_StorageType.LOCAL) {
if (workspaceStorageSetting.filepathTemplate.length === 0) { if (workspaceStorageSetting.filepathTemplate.length === 0) {
return false; return false;
} }
} else if (workspaceStorageSetting.storageType === WorkspaceStorageSetting_StorageType.STORAGE_TYPE_S3) { } else if (workspaceStorageSetting.storageType === WorkspaceStorageSetting_StorageType.S3) {
if ( if (
workspaceStorageSetting.s3Config?.accessKeyId.length === 0 || workspaceStorageSetting.s3Config?.accessKeyId.length === 0 ||
workspaceStorageSetting.s3Config?.accessKeySecret.length === 0 || workspaceStorageSetting.s3Config?.accessKeySecret.length === 0 ||
@ -124,9 +124,9 @@ const StorageSection = () => {
handleStorageTypeChanged(event.target.value as WorkspaceStorageSetting_StorageType); handleStorageTypeChanged(event.target.value as WorkspaceStorageSetting_StorageType);
}} }}
> >
<Radio value={WorkspaceStorageSetting_StorageType.STORAGE_TYPE_DATABASE} label={t("setting.storage-section.type-database")} /> <Radio value={WorkspaceStorageSetting_StorageType.DATABASE} label={t("setting.storage-section.type-database")} />
<Radio value={WorkspaceStorageSetting_StorageType.STORAGE_TYPE_LOCAL} label={t("setting.storage-section.type-local")} /> <Radio value={WorkspaceStorageSetting_StorageType.LOCAL} label={t("setting.storage-section.type-local")} />
<Radio value={WorkspaceStorageSetting_StorageType.STORAGE_TYPE_S3} label={"S3"} /> <Radio value={WorkspaceStorageSetting_StorageType.S3} label={"S3"} />
</RadioGroup> </RadioGroup>
<div className="w-full flex flex-row justify-between items-center"> <div className="w-full flex flex-row justify-between items-center">
<div className="flex flex-row items-center"> <div className="flex flex-row items-center">
@ -140,49 +140,45 @@ const StorageSection = () => {
sx={{ sx={{
fontFamily: "monospace", fontFamily: "monospace",
}} }}
defaultValue={workspaceStorageSetting.uploadSizeLimitMb} value={workspaceStorageSetting.uploadSizeLimitMb}
onChange={handleMaxUploadSizeChanged} onChange={handleMaxUploadSizeChanged}
/> />
</div> </div>
{workspaceStorageSetting.storageType !== WorkspaceStorageSetting_StorageType.STORAGE_TYPE_DATABASE && ( {workspaceStorageSetting.storageType !== WorkspaceStorageSetting_StorageType.DATABASE && (
<div className="w-full flex flex-row justify-between items-center"> <div className="w-full flex flex-row justify-between items-center">
<span className="text-gray-700 dark:text-gray-500 mr-1">Filepath template</span> <span className="text-gray-700 dark:text-gray-500 mr-1">Filepath template</span>
<Input <Input
defaultValue={workspaceStorageSetting.filepathTemplate} value={workspaceStorageSetting.filepathTemplate}
placeholder="assets/{timestamp}_{filename}" placeholder="assets/{timestamp}_{filename}"
onChange={handleFilepathTemplateChanged} onChange={handleFilepathTemplateChanged}
/> />
</div> </div>
)} )}
{workspaceStorageSetting.storageType === WorkspaceStorageSetting_StorageType.STORAGE_TYPE_S3 && ( {workspaceStorageSetting.storageType === WorkspaceStorageSetting_StorageType.S3 && (
<> <>
<div className="w-full flex flex-row justify-between items-center"> <div className="w-full flex flex-row justify-between items-center">
<span className="text-gray-700 dark:text-gray-500 mr-1">Access key id</span> <span className="text-gray-700 dark:text-gray-500 mr-1">Access key id</span>
<Input <Input value={workspaceStorageSetting.s3Config?.accessKeyId} placeholder="" onChange={handleS3ConfigAccessKeyIdChanged} />
defaultValue={workspaceStorageSetting.s3Config?.accessKeyId}
placeholder=""
onChange={handleS3ConfigAccessKeyIdChanged}
/>
</div> </div>
<div className="w-full flex flex-row justify-between items-center"> <div className="w-full flex flex-row justify-between items-center">
<span className="text-gray-700 dark:text-gray-500 mr-1">Access key secret</span> <span className="text-gray-700 dark:text-gray-500 mr-1">Access key secret</span>
<Input <Input
defaultValue={workspaceStorageSetting.s3Config?.accessKeySecret} value={workspaceStorageSetting.s3Config?.accessKeySecret}
placeholder="" placeholder=""
onChange={handleS3ConfigAccessKeySecretChanged} onChange={handleS3ConfigAccessKeySecretChanged}
/> />
</div> </div>
<div className="w-full flex flex-row justify-between items-center"> <div className="w-full flex flex-row justify-between items-center">
<span className="text-gray-700 dark:text-gray-500 mr-1">Endpoint</span> <span className="text-gray-700 dark:text-gray-500 mr-1">Endpoint</span>
<Input defaultValue={workspaceStorageSetting.s3Config?.endpoint} placeholder="" onChange={handleS3ConfigEndpointChanged} /> <Input value={workspaceStorageSetting.s3Config?.endpoint} placeholder="" onChange={handleS3ConfigEndpointChanged} />
</div> </div>
<div className="w-full flex flex-row justify-between items-center"> <div className="w-full flex flex-row justify-between items-center">
<span className="text-gray-700 dark:text-gray-500 mr-1">Region</span> <span className="text-gray-700 dark:text-gray-500 mr-1">Region</span>
<Input defaultValue={workspaceStorageSetting.s3Config?.region} placeholder="" onChange={handleS3ConfigRegionChanged} /> <Input value={workspaceStorageSetting.s3Config?.region} placeholder="" onChange={handleS3ConfigRegionChanged} />
</div> </div>
<div className="w-full flex flex-row justify-between items-center"> <div className="w-full flex flex-row justify-between items-center">
<span className="text-gray-700 dark:text-gray-500 mr-1">Bucket</span> <span className="text-gray-700 dark:text-gray-500 mr-1">Bucket</span>
<Input defaultValue={workspaceStorageSetting.s3Config?.bucket} placeholder="" onChange={handleS3ConfigBucketChanged} /> <Input value={workspaceStorageSetting.s3Config?.bucket} placeholder="" onChange={handleS3ConfigBucketChanged} />
</div> </div>
</> </>
)} )}

View File

@ -42,9 +42,9 @@ const Inboxes = () => {
)} )}
<div className="flex flex-col justify-start items-start w-full mt-4 gap-4"> <div className="flex flex-col justify-start items-start w-full mt-4 gap-4">
{inboxes.map((inbox) => { {inboxes.map((inbox) => {
if (inbox.type === Inbox_Type.TYPE_MEMO_COMMENT) { if (inbox.type === Inbox_Type.MEMO_COMMENT) {
return <MemoCommentMessage key={`${inbox.name}-${inbox.status}`} inbox={inbox} />; return <MemoCommentMessage key={`${inbox.name}-${inbox.status}`} inbox={inbox} />;
} else if (inbox.type === Inbox_Type.TYPE_VERSION_UPDATE) { } else if (inbox.type === Inbox_Type.VERSION_UPDATE) {
return <VersionUpdateMessage key={`${inbox.name}-${inbox.status}`} inbox={inbox} />; return <VersionUpdateMessage key={`${inbox.name}-${inbox.status}`} inbox={inbox} />;
} }
return undefined; return undefined;