mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 10:58:33 +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 = {
|
const propTypes = {
|
||||||
toggleCancel: PropTypes.func.isRequired,
|
toggleCancel: PropTypes.func.isRequired,
|
||||||
addWiki: PropTypes.func.isRequired,
|
addWiki: PropTypes.func.isRequired,
|
||||||
currentDeptID: PropTypes.string,
|
currentDeptEmail: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
class AddWikiDialog extends React.Component {
|
class AddWikiDialog extends React.Component {
|
||||||
@@ -36,12 +36,13 @@ class AddWikiDialog extends React.Component {
|
|||||||
let obj = {};
|
let obj = {};
|
||||||
obj.value = departments[i].name;
|
obj.value = departments[i].name;
|
||||||
obj.id = departments[i].id;
|
obj.id = departments[i].id;
|
||||||
|
obj.email = departments[i].email;
|
||||||
obj.label = departments[i].name;
|
obj.label = departments[i].name;
|
||||||
options.push(obj);
|
options.push(obj);
|
||||||
}
|
}
|
||||||
this.setState({ options });
|
this.setState({ options });
|
||||||
if (this.props.currentDeptID) {
|
if (this.props.currentDeptEmail) {
|
||||||
const selectedOption = options.find(op => op.id == this.props.currentDeptID);
|
const selectedOption = options.find(op => op.email == this.props.currentDeptEmail);
|
||||||
this.setState({ selectedOption });
|
this.setState({ selectedOption });
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
@@ -83,19 +83,19 @@ class WikiCardView extends Component {
|
|||||||
toggelAddWikiDialog={canPublishRepo ? toggelAddWikiDialog.bind(this, null) : null}
|
toggelAddWikiDialog={canPublishRepo ? toggelAddWikiDialog.bind(this, null) : null}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
for (let deptID in department2WikisMap) {
|
for (let deptEmail in department2WikisMap) {
|
||||||
wikiCardGroups.push(
|
wikiCardGroups.push(
|
||||||
<WikiCardGroup
|
<WikiCardGroup
|
||||||
key={'department-Wikis-' + deptID}
|
key={'department-Wikis-' + deptEmail}
|
||||||
deleteWiki={this.props.deleteWiki}
|
deleteWiki={this.props.deleteWiki}
|
||||||
renameWiki={this.props.renameWiki}
|
renameWiki={this.props.renameWiki}
|
||||||
sidePanelRate={sidePanelRate}
|
sidePanelRate={sidePanelRate}
|
||||||
isSidePanelFolded={isSidePanelFolded}
|
isSidePanelFolded={isSidePanelFolded}
|
||||||
wikis={department2WikisMap[deptID]}
|
wikis={department2WikisMap[deptEmail]}
|
||||||
title={department2WikisMap[deptID][0].owner_nickname}
|
title={department2WikisMap[deptEmail][0].owner_nickname}
|
||||||
isDepartment={true}
|
isDepartment={true}
|
||||||
isShowAvatar={false}
|
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 = {
|
this.state = {
|
||||||
loading: true,
|
loading: true,
|
||||||
errorMsg: '',
|
errorMsg: '',
|
||||||
currentDeptID: '',
|
currentDeptEmail: '',
|
||||||
wikis: [],
|
wikis: [],
|
||||||
isShowAddWikiMenu: false,
|
isShowAddWikiMenu: false,
|
||||||
isShowAddDialog: false,
|
isShowAddDialog: false,
|
||||||
@@ -72,16 +72,16 @@ class Wikis extends Component {
|
|||||||
this.setState({ isShowAddWikiMenu: !this.state.isShowAddWikiMenu });
|
this.setState({ isShowAddWikiMenu: !this.state.isShowAddWikiMenu });
|
||||||
};
|
};
|
||||||
|
|
||||||
toggelAddWikiDialog = (currentDeptID) => {
|
toggelAddWikiDialog = (currentDeptEmail) => {
|
||||||
if (this.state.isShowAddDialog) {
|
if (this.state.isShowAddDialog) {
|
||||||
this.setState({
|
this.setState({
|
||||||
isShowAddDialog: false,
|
isShowAddDialog: false,
|
||||||
currentDeptID: '',
|
currentDeptEmail: '',
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
isShowAddDialog: true,
|
isShowAddDialog: true,
|
||||||
currentDeptID
|
currentDeptEmail
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -94,7 +94,7 @@ class Wikis extends Component {
|
|||||||
wikis.push(new_wiki);
|
wikis.push(new_wiki);
|
||||||
this.setState({
|
this.setState({
|
||||||
wikis,
|
wikis,
|
||||||
currentDeptID: '',
|
currentDeptEmail: '',
|
||||||
});
|
});
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
@@ -108,7 +108,7 @@ class Wikis extends Component {
|
|||||||
if (wiki.version === 'v1') {
|
if (wiki.version === 'v1') {
|
||||||
wikiAPI.deleteWiki(wiki.id).then(() => {
|
wikiAPI.deleteWiki(wiki.id).then(() => {
|
||||||
let wikis = this.state.wikis.filter(item => {
|
let wikis = this.state.wikis.filter(item => {
|
||||||
return item.name !== wiki.name;
|
return item.id !== wiki.id;
|
||||||
});
|
});
|
||||||
this.setState({ wikis: wikis });
|
this.setState({ wikis: wikis });
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
@@ -120,7 +120,7 @@ class Wikis extends Component {
|
|||||||
} else {
|
} else {
|
||||||
wikiAPI.deleteWiki2(wiki.id).then(() => {
|
wikiAPI.deleteWiki2(wiki.id).then(() => {
|
||||||
let wikis = this.state.wikis.filter(item => {
|
let wikis = this.state.wikis.filter(item => {
|
||||||
return item.name !== wiki.name;
|
return item.id !== wiki.id;
|
||||||
});
|
});
|
||||||
this.setState({ wikis: wikis });
|
this.setState({ wikis: wikis });
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
@@ -181,7 +181,7 @@ class Wikis extends Component {
|
|||||||
<AddWikiDialog
|
<AddWikiDialog
|
||||||
toggleCancel={this.toggelAddWikiDialog}
|
toggleCancel={this.toggelAddWikiDialog}
|
||||||
addWiki={this.addWiki}
|
addWiki={this.addWiki}
|
||||||
currentDeptID={this.state.currentDeptID}
|
currentDeptEmail={this.state.currentDeptEmail}
|
||||||
/>
|
/>
|
||||||
</ModalPortal>
|
</ModalPortal>
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user