mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-26 08:11:17 +02:00
add fork in header
This commit is contained in:
@@ -383,9 +383,11 @@ export default class App extends Component {
|
||||
}
|
||||
const fork = JSON.parse(JSON.stringify(sourceItem));
|
||||
delete fork.id;
|
||||
delete fork.createdBy;
|
||||
fork.title = '(Forked) ' + sourceItem.title;
|
||||
fork.updatedOn = Date.now();
|
||||
this.setCurrentItem(fork).then(() => this.refreshEditor());
|
||||
route('/create');
|
||||
alertsService.add(`"${sourceItem.title}" was forked`);
|
||||
trackEvent('fn', 'itemForked');
|
||||
}
|
||||
@@ -936,6 +938,15 @@ export default class App extends Component {
|
||||
var isNewItem = !this.state.currentItem.id;
|
||||
this.state.currentItem.id =
|
||||
this.state.currentItem.id || 'item-' + generateRandomId();
|
||||
if (
|
||||
this.state.currentItem.createdBy &&
|
||||
this.state.currentItem.createdBy !== this.state.user.uid
|
||||
) {
|
||||
alertsService.add(
|
||||
'You cannot save this item as it was created by someone else. Fork it to save it as your own.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.setState({
|
||||
isSaving: true
|
||||
});
|
||||
@@ -1697,6 +1708,9 @@ export default class App extends Component {
|
||||
isFileMode={
|
||||
this.state.currentItem && this.state.currentItem.files
|
||||
}
|
||||
onItemFork={() => {
|
||||
this.forkItem(this.state.currentItem);
|
||||
}}
|
||||
/>
|
||||
{this.state.currentItem && this.state.currentItem.files ? (
|
||||
<ContentWrapFiles
|
||||
|
Reference in New Issue
Block a user