This repository has been archived by the owner on Oct 20, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete minimal version of file browser
- Loading branch information
1 parent
cdd039b
commit 79cd2dd
Showing
14 changed files
with
369 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const browserHelper = require('../ui/browser-helper'); | ||
|
||
/* eslint no-process-env: off */ | ||
|
||
const env = (browserHelper.isBrowser() ? window.env : process.env).ELMU_ENV || 'dev'; | ||
|
||
const commonSettings = {}; | ||
|
||
const overrides = { | ||
dev: { | ||
cdnRootURL: 'http://localhost:9000/dev-elmu-cdn/' | ||
}, | ||
test: { | ||
cdnRootURL: 'http://localhost:9000/test-elmu-cdn/' | ||
}, | ||
stag: { | ||
cdnRootURL: 'http://stag-cdn.elmu.online/' | ||
}, | ||
prod: { | ||
cdnRootURL: 'http://cdn.elmu.online/' | ||
} | ||
}; | ||
|
||
module.exports = Object.assign({}, commonSettings, overrides[env]); |
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,107 @@ | ||
const React = require('react'); | ||
const autoBind = require('auto-bind'); | ||
const PropTypes = require('prop-types'); | ||
const { Modal, Button } = require('antd'); | ||
const selection = require('../ui/selection'); | ||
const RepositoryBrowser = require('./repository-browser.jsx'); | ||
|
||
const localizedStrings = { | ||
MODAL_TITLE: 'Dateibrowser', | ||
BTN_LABEL_SELECT: 'Auswählen', | ||
BTN_LABEL_CANCEL: 'Abbrechen', | ||
BTN_LABEL_APPLY: 'Übernehmen' | ||
}; | ||
|
||
class CdnFilePicker extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
autoBind.react(this); | ||
|
||
this.state = { | ||
isModalVisible: false, | ||
currentSelectedFile: null | ||
}; | ||
} | ||
|
||
shouldComponentUpdate() { | ||
return true; | ||
} | ||
|
||
handleSelectButtonClick() { | ||
this.setState({ isModalVisible: true }); | ||
} | ||
|
||
handleApply() { | ||
const { onFileNameChanged } = this.props; | ||
const { currentSelectedFile } = this.state; | ||
|
||
this.setState({ isModalVisible: false }); | ||
onFileNameChanged(currentSelectedFile); | ||
} | ||
|
||
handleCancel() { | ||
this.setState({ isModalVisible: false }); | ||
} | ||
|
||
handleSelectionChanged(objects) { | ||
const newSelectedFile = objects.length ? objects[0].name : null; | ||
this.setState({ currentSelectedFile: newSelectedFile }); | ||
} | ||
|
||
render() { | ||
const { rootPrefix } = this.props; | ||
const { isModalVisible, currentSelectedFile } = this.state; | ||
|
||
return ( | ||
<div className="CdnFilePicker"> | ||
<Button | ||
type="primary" | ||
onClick={this.handleSelectButtonClick} | ||
> | ||
{localizedStrings.BTN_LABEL_SELECT} | ||
</Button> | ||
<Modal | ||
width="80%" | ||
visible={isModalVisible} | ||
title={localizedStrings.MODAL_TITLE} | ||
onOk={this.handleApply} | ||
onCancel={this.handleCancel} | ||
footer={[ | ||
<Button | ||
key="back" | ||
onClick={this.handleCancel} | ||
> | ||
{localizedStrings.BTN_LABEL_CANCEL} | ||
</Button>, | ||
<Button | ||
key="submit" | ||
type="primary" | ||
onClick={this.handleApply} | ||
disabled={!currentSelectedFile} | ||
> | ||
{localizedStrings.BTN_LABEL_APPLY} | ||
</Button> | ||
]} | ||
> | ||
<RepositoryBrowser | ||
rootPrefix={rootPrefix} | ||
selectionMode={selection.SINGLE} | ||
onSelectionChanged={this.handleSelectionChanged} | ||
/> | ||
</Modal> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
CdnFilePicker.propTypes = { | ||
onFileNameChanged: PropTypes.func, | ||
rootPrefix: PropTypes.string.isRequired | ||
}; | ||
|
||
CdnFilePicker.defaultProps = { | ||
onFileNameChanged: () => {} | ||
}; | ||
|
||
module.exports = CdnFilePicker; |
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
Oops, something went wrong.