fix: userName in workspace is not editable

This commit is contained in:
林一二 2021-06-25 22:16:05 +08:00
parent 6b6bdf3cdd
commit 87f8f5ff64
7 changed files with 33 additions and 21 deletions

View file

@ -105,7 +105,9 @@
"GitEmailDescription": "Email used for Git commit, and is used to count daily activities on Github and other online git services",
"GitUserNameDescription": "The account name used to log in to Git. Not the nickname",
"LogoutToGetStorageServiceToken": "Log in to the online storage service to obtain latest credentials",
"AddWorkspace": "Add Workspace"
"AddWorkspace": "Add Workspace",
"WorkspaceUserName": "Workspace User Name",
"WorkspaceUserNameDetail": "The editor name used in the Wiki will be fill in the creator field when the Tiddler is created or edited. The editor name set in the workspace will override the global default editor name assigned in the preferences. This allows you to create Tiddlers with different identities in the same Wiki, with multiple workspace configed with different user name."
},
"EditWorkspace": {
"Path": "Wiki Path",

View file

@ -131,6 +131,8 @@
"WorkspaceUpdated": "工作区更新完毕正在启动Wiki",
"StartLinkingSubWikiToMainWiki": "开始链接子Wiki到父Wiki",
"AddFileSystemPath": "正在为子Wiki添加FileSystemPaths",
"WorkspaceUserName": "工作区编辑者名",
"WorkspaceUserNameDetail": "在 Wiki 中使用的编辑者名,将在创建或编辑 Tiddler 时填入 creator 字段。工作区内设置的编辑者名,将覆盖设置里配的全局的默认编辑者名。这方便你通过创建多个配了不同编辑者名的工作区,在同一个 Wiki 里用不同的身份创建 Tiddler。",
"TagName": "标签名",
"TagNameHelp": "加上此标签的笔记将会自动被放入这个子知识库内(可先不填,之后右键点击这个工作区的图标选择编辑工作区修改)",
"NoGitInfoAlert": "你未选择在线Git仓库地址或未成功登录在线Git存储服务账号可能被墙。点击创建按钮将创建一个不会自动同步到Github的本地仓库请注意。"
@ -305,7 +307,9 @@
"DoubleWikiInstanceError": "重复启动维基错误",
"DoubleWikiInstanceErrorDescription": "E-4 你启动了同一个Wiki两次这可能是程序bug导致的。",
"InsertMenuAfterSubMenuIndexError": "插入目录模板到现有目录后错误",
"InsertMenuAfterSubMenuIndexErrorDescription": "E-5 你尝试插入目录,且 afterSubMenu \"{afterSubMenu}\" 在目录 menuID \"{menuID}\" 内,但我们无法在目录 \"{menu}\" 里找到它,请用正确的 menuID 指定一个目录。"
"InsertMenuAfterSubMenuIndexErrorDescription": "E-5 你尝试插入目录,且 afterSubMenu \"{afterSubMenu}\" 在目录 menuID \"{menuID}\" 内,但我们无法在目录 \"{menu}\" 里找到它,请用正确的 menuID 指定一个目录。",
"InitWikiGitSyncedWikiNoGitUserInfoError": "笔记仓库初始化失败因为没有提供Git信息错误",
"InitWikiGitSyncedWikiNoGitUserInfoErrorDescription": "E-3 初始化同步到云端的笔记仓库需要你选择一个云端的 git 仓库地址,还有提供相应云服务的认证凭证,然而目前没有获得这些信息。"
},
"Loading": "加载中",
"Yes": "是的",

View file

@ -45,16 +45,6 @@ export function useWikiWorkspaceForm(options?: { fromExisted: boolean }) {
const [storageProvider, storageProviderSetter] = useState<SupportedStorageServices>(SupportedStorageServices.local);
const gitUserInfo = useStorageServiceUserInfoObservable(storageProvider);
/**
* Update tiddlywiki's editor user name when first time creating new workspace
*/
const [userName, userNameSetter] = usePromiseValueAndSetter(
async () => await window.service.auth.get('userName'),
async (newUserName) => {
if (newUserName !== undefined) await window.service.auth.set('userName', newUserName);
},
);
/**
* For sub-wiki, we need to link it to a main wiki's folder, so all wiki contents can be loaded together.
*/
@ -123,8 +113,6 @@ export function useWikiWorkspaceForm(options?: { fromExisted: boolean }) {
storageProviderSetter,
wikiPort,
wikiPortSetter,
userName,
userNameSetter,
mainWikiToLink,
mainWikiToLinkSetter,
tagName,

View file

@ -139,6 +139,8 @@ export default function EditWorkspace(): JSX.Element {
isSubWiki,
name,
port,
order,
userName,
tagName,
transparentBackground,
picturePath,
@ -146,7 +148,7 @@ export default function EditWorkspace(): JSX.Element {
disableAudio,
disableNotifications,
homeUrl,
} = ((workspace ?? {}) as unknown) as IWorkspace;
} = (workspace ?? {}) as unknown as IWorkspace;
const fileSystemPaths = usePromiseValue<ISubWikiPluginContent[]>(
async () => (mainWikiToLink ? await window.service.wiki.getSubWikiPluginContent(mainWikiToLink) : []),
[],
@ -163,7 +165,7 @@ export default function EditWorkspace(): JSX.Element {
<div id="test" data-usage="For spectron automating testing" />
<Helmet>
<title>
{t('WorkspaceSelector.EditWorkspace')} {String(workspace.order ?? 1)} {workspace.name}
{t('WorkspaceSelector.EditWorkspace')} {String(order ?? 1)} {name}
</title>
</Helmet>
<FlexGrow>
@ -175,6 +177,13 @@ export default function EditWorkspace(): JSX.Element {
value={name}
onChange={(event) => workspaceSetter({ ...workspace, name: event.target.value })}
/>
<TextField
helperText={t('AddWorkspace.WorkspaceUserNameDetail')}
fullWidth
onChange={(event) => workspaceSetter({ ...workspace, userName: event.target.value })}
label={t('AddWorkspace.WorkspaceUserName')}
value={userName}
/>
{!isSubWiki && (
<TextField
id="outlined-full-width"

View file

@ -9,7 +9,7 @@ import { BehaviorSubject } from 'rxjs';
import { IGitUserInfos } from '@services/git/interface';
const defaultUserInfos = {
userName: 'TiddlyGit User',
userName: 'TiddlyGitUser',
authing: undefined as IAuthingUserInfo | undefined,
};

View file

@ -1,3 +1,4 @@
import { IGitUserInfos } from '@services/git/interface';
import i18n from '@services/libs/i18n';
export class InitWikiGitError extends Error {
@ -15,3 +16,13 @@ export class InitWikiGitRevertError extends Error {
this.message = `${i18n.t('Error.InitWikiGitRevertErrorDescription')} ${extraMessage ?? ''}`;
}
}
export class InitWikiGitSyncedWikiNoGitUserInfoError extends Error {
constructor(gitUrl?: string | null, userInfo?: IGitUserInfos | null) {
super();
this.name = i18n.t('Error.InitWikiGitSyncedWikiNoGitUserInfoError');
this.message = `${i18n.t('Error.InitWikiGitSyncedWikiNoGitUserInfoErrorDescription')} gitUrl: ${gitUrl ?? 'undefined'} , userInfo: ${
userInfo === undefined ? JSON.stringify(userInfo) : 'undefined'
}`;
}
}

View file

@ -16,7 +16,7 @@ import { logger } from '@services/libs/log';
import i18n from '@services/libs/i18n';
import { IWikiGitWorkspaceService } from './interface';
import { IMenuService } from '@services/menu/interface';
import { InitWikiGitError, InitWikiGitRevertError } from './error';
import { InitWikiGitError, InitWikiGitRevertError, InitWikiGitSyncedWikiNoGitUserInfoError } from './error';
import { SupportedStorageServices } from '@services/types';
import { hasGit } from 'git-sync-js';
@ -42,9 +42,7 @@ export class WikiGitWorkspace implements IWikiGitWorkspaceService {
if (typeof gitUrl === 'string' && userInfo !== undefined) {
await this.gitService.initWikiGit(wikiFolderLocation, isSyncedWiki, gitUrl, userInfo);
} else {
throw new Error(
`E-1-1 SyncedWiki gitUrl is ${gitUrl ?? 'undefined'} , userInfo is ${userInfo === undefined ? JSON.stringify(userInfo) : 'undefined'}`,
);
throw new InitWikiGitSyncedWikiNoGitUserInfoError(gitUrl, userInfo);
}
} else {
await this.gitService.initWikiGit(wikiFolderLocation, false);