mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-19 18:29:23 +00:00
Fix create wiki with department owner name (#6400)
* 01 fix add wiki department id change to email * 02 fix wiki with same name
This commit is contained in:
@@ -10,7 +10,7 @@ import { SeahubSelect } from '../common/select';
|
||||
const propTypes = {
|
||||
toggleCancel: PropTypes.func.isRequired,
|
||||
addWiki: PropTypes.func.isRequired,
|
||||
currentDeptID: PropTypes.string,
|
||||
currentDeptEmail: PropTypes.string,
|
||||
};
|
||||
|
||||
class AddWikiDialog extends React.Component {
|
||||
@@ -36,12 +36,13 @@ class AddWikiDialog extends React.Component {
|
||||
let obj = {};
|
||||
obj.value = departments[i].name;
|
||||
obj.id = departments[i].id;
|
||||
obj.email = departments[i].email;
|
||||
obj.label = departments[i].name;
|
||||
options.push(obj);
|
||||
}
|
||||
this.setState({ options });
|
||||
if (this.props.currentDeptID) {
|
||||
const selectedOption = options.find(op => op.id == this.props.currentDeptID);
|
||||
if (this.props.currentDeptEmail) {
|
||||
const selectedOption = options.find(op => op.email == this.props.currentDeptEmail);
|
||||
this.setState({ selectedOption });
|
||||
}
|
||||
}).catch(error => {
|
||||
|
@@ -83,19 +83,19 @@ class WikiCardView extends Component {
|
||||
toggelAddWikiDialog={canPublishRepo ? toggelAddWikiDialog.bind(this, null) : null}
|
||||
/>
|
||||
);
|
||||
for (let deptID in department2WikisMap) {
|
||||
for (let deptEmail in department2WikisMap) {
|
||||
wikiCardGroups.push(
|
||||
<WikiCardGroup
|
||||
key={'department-Wikis-' + deptID}
|
||||
key={'department-Wikis-' + deptEmail}
|
||||
deleteWiki={this.props.deleteWiki}
|
||||
renameWiki={this.props.renameWiki}
|
||||
sidePanelRate={sidePanelRate}
|
||||
isSidePanelFolded={isSidePanelFolded}
|
||||
wikis={department2WikisMap[deptID]}
|
||||
title={department2WikisMap[deptID][0].owner_nickname}
|
||||
wikis={department2WikisMap[deptEmail]}
|
||||
title={department2WikisMap[deptEmail][0].owner_nickname}
|
||||
isDepartment={true}
|
||||
isShowAvatar={false}
|
||||
toggelAddWikiDialog={(canPublishRepo && this.state.departmentMap[deptID]) ? toggelAddWikiDialog.bind(this, deptID) : null}
|
||||
toggelAddWikiDialog={(canPublishRepo && this.state.departmentMap[deptEmail]) ? toggelAddWikiDialog.bind(this, deptEmail) : null}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ class Wikis extends Component {
|
||||
this.state = {
|
||||
loading: true,
|
||||
errorMsg: '',
|
||||
currentDeptID: '',
|
||||
currentDeptEmail: '',
|
||||
wikis: [],
|
||||
isShowAddWikiMenu: false,
|
||||
isShowAddDialog: false,
|
||||
@@ -72,16 +72,16 @@ class Wikis extends Component {
|
||||
this.setState({ isShowAddWikiMenu: !this.state.isShowAddWikiMenu });
|
||||
};
|
||||
|
||||
toggelAddWikiDialog = (currentDeptID) => {
|
||||
toggelAddWikiDialog = (currentDeptEmail) => {
|
||||
if (this.state.isShowAddDialog) {
|
||||
this.setState({
|
||||
isShowAddDialog: false,
|
||||
currentDeptID: '',
|
||||
currentDeptEmail: '',
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
isShowAddDialog: true,
|
||||
currentDeptID
|
||||
currentDeptEmail
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -94,7 +94,7 @@ class Wikis extends Component {
|
||||
wikis.push(new_wiki);
|
||||
this.setState({
|
||||
wikis,
|
||||
currentDeptID: '',
|
||||
currentDeptEmail: '',
|
||||
});
|
||||
}).catch((error) => {
|
||||
if (error.response) {
|
||||
@@ -108,7 +108,7 @@ class Wikis extends Component {
|
||||
if (wiki.version === 'v1') {
|
||||
wikiAPI.deleteWiki(wiki.id).then(() => {
|
||||
let wikis = this.state.wikis.filter(item => {
|
||||
return item.name !== wiki.name;
|
||||
return item.id !== wiki.id;
|
||||
});
|
||||
this.setState({ wikis: wikis });
|
||||
}).catch((error) => {
|
||||
@@ -120,7 +120,7 @@ class Wikis extends Component {
|
||||
} else {
|
||||
wikiAPI.deleteWiki2(wiki.id).then(() => {
|
||||
let wikis = this.state.wikis.filter(item => {
|
||||
return item.name !== wiki.name;
|
||||
return item.id !== wiki.id;
|
||||
});
|
||||
this.setState({ wikis: wikis });
|
||||
}).catch((error) => {
|
||||
@@ -181,7 +181,7 @@ class Wikis extends Component {
|
||||
<AddWikiDialog
|
||||
toggleCancel={this.toggelAddWikiDialog}
|
||||
addWiki={this.addWiki}
|
||||
currentDeptID={this.state.currentDeptID}
|
||||
currentDeptEmail={this.state.currentDeptEmail}
|
||||
/>
|
||||
</ModalPortal>
|
||||
}
|
||||
|
Reference in New Issue
Block a user