-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ExportPatternsModal): allow pattern export for snapshots
- Loading branch information
1 parent
fcd3253
commit 3a600e3
Showing
6 changed files
with
87 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// @flow | ||
|
||
import React from 'react' | ||
import { Modal, Button } from 'react-bootstrap' | ||
|
||
import {getComponentMessages} from '../../common/util/config' | ||
import * as versionActions from '../../manager/actions/versions' | ||
import type { Feed, Snapshot } from '../../types' | ||
import type { ItemProps } from '../../editor/components/EditorFeedSourcePanel' | ||
|
||
type Props = { | ||
createFeedVersionFromSnapshot: typeof versionActions.createFeedVersionFromSnapshot, | ||
feedSource: Feed, | ||
} | ||
|
||
type State = { | ||
showModal: boolean, | ||
snapshot: ?Snapshot | ||
} | ||
|
||
export default class ExportPatternsModal extends React.Component<Props, State> { | ||
messages = getComponentMessages('ExportPatternsModal') | ||
|
||
state = { | ||
showModal: false, | ||
snapshot: null | ||
} | ||
|
||
publish (publishProprietaryFiles: boolean) { | ||
const { createFeedVersionFromSnapshot, feedSource } = this.props | ||
this.state.snapshot && createFeedVersionFromSnapshot(feedSource, this.state.snapshot.id, publishProprietaryFiles) | ||
this.close() | ||
} | ||
|
||
close () { | ||
this.setState({showModal: false}) | ||
} | ||
|
||
// Open is called by the SnapshotItem class | ||
open (props: ItemProps) { | ||
this.setState({showModal: true, snapshot: props.snapshot}) | ||
} | ||
|
||
render () { | ||
const {Body, Title} = Modal | ||
const buttonStyle = {marginLeft: '10px', width: '50px'} | ||
|
||
return ( | ||
<Modal show={this.state.showModal} onHide={this.close}> | ||
<Body style={{display: 'flex'}}> | ||
<Title>{this.messages('exportPatterns')}</Title> | ||
<Button onClick={() => this.publish(true)} style={buttonStyle}> | ||
{this.messages('yes')} | ||
</Button> | ||
<Button onClick={() => this.publish(false)} style={buttonStyle}> | ||
{this.messages('no')} | ||
</Button> | ||
</Body> | ||
</Modal> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters