MCPcopy Create free account
hub / github.com/microsoft/SandDance / _DataExportPicker

Function _DataExportPicker

docs/app/js/sanddance-app.js:11626–11750  ·  view source on GitHub ↗
(props1)

Source from the content-addressed store, hash-verified

11624 ]
11625];
11626function _DataExportPicker(props1) {
11627 class __DataExportPicker extends (0, _base.base).react.Component {
11628 constructor(props){
11629 super(props);
11630 this.state = this.getInitialState(this.props);
11631 }
11632 getInitialState(props) {
11633 const initialState = {
11634 initializer: props.initializer,
11635 dialogHidden: true,
11636 exportType: exportTypes[0][0],
11637 fileName: props.initializer.fileName,
11638 fileNameError: "",
11639 working: false
11640 };
11641 return initialState;
11642 }
11643 componentDidUpdate() {
11644 if (!(0, _sanddanceReact.util).deepCompare(this.props.initializer, this.state.initializer)) this.setState(this.getInitialState(this.props));
11645 }
11646 // Converts to dataExport type and calls dataExportHandler to deal with data
11647 createExport(exportType, displayName) {
11648 const final = (data)=>{
11649 this.props.dataExportHandler(data, exportType, displayName);
11650 this.close();
11651 };
11652 const json = JSON.stringify(this.props.data, columnReplacer);
11653 switch(exportType){
11654 case "json":
11655 final(json);
11656 break;
11657 case "csv":
11658 final((0, _exportDelimited.convertToDelimited)(JSON.parse(json), ","));
11659 break;
11660 case "tsv":
11661 final((0, _exportDelimited.convertToDelimited)(JSON.parse(json), " "));
11662 break;
11663 case "html":
11664 {
11665 const csv = (0, _exportDelimited.convertToDelimited)(JSON.parse(json), ",");
11666 const html = (0, _dataExporterHtml.embedHtml)(`${(0, _language.strings).appName} - ${escape(displayName)}`, embedScript(csv, displayName));
11667 final(html);
11668 }
11669 }
11670 }
11671 close() {
11672 this.setState({
11673 dialogHidden: true,
11674 working: false
11675 });
11676 }
11677 render() {
11678 const closeDialog = ()=>this.close();
11679 if (this.state.delayAction) requestAnimationFrame(()=>{
11680 //allow render to complete
11681 if (this.state.delayAction) {
11682 this.state.delayAction();
11683 this.setState({

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected