mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-03 16:10:26 +00:00
[share dialog] bugfix for 'Add auto expiration' in Share Link (#3824)
* [share dialog] bugfix for 'Add auto expiration' in Share Link * [share dialog] modified 'Share Link'
This commit is contained in:
@@ -21,14 +21,17 @@ class GenerateShareLink extends React.Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
|
this.isExpireDaysNoLimit = (parseInt(shareLinkExpireDaysMin) === 0 && parseInt(shareLinkExpireDaysMax) === 0 && shareLinkExpireDaysDefault == 0);
|
||||||
|
this.defaultExpireDays = this.isExpireDaysNoLimit ? '' : shareLinkExpireDaysDefault;
|
||||||
this.state = {
|
this.state = {
|
||||||
isValidate: false,
|
isValidate: false,
|
||||||
isShowPasswordInput: false,
|
isShowPasswordInput: false,
|
||||||
isPasswordVisible: false,
|
isPasswordVisible: false,
|
||||||
isExpireChecked: false,
|
isExpireChecked: !this.isExpireDaysNoLimit,
|
||||||
password: '',
|
password: '',
|
||||||
passwdnew: '',
|
passwdnew: '',
|
||||||
expireDays: shareLinkExpireDaysDefault,
|
expireDays: this.defaultExpireDays,
|
||||||
errorInfo: '',
|
errorInfo: '',
|
||||||
sharedLinkInfo: null,
|
sharedLinkInfo: null,
|
||||||
isNoticeMessageShow: false,
|
isNoticeMessageShow: false,
|
||||||
@@ -40,7 +43,6 @@ class GenerateShareLink extends React.Component {
|
|||||||
'can_edit': false,
|
'can_edit': false,
|
||||||
'can_download': true
|
'can_download': true
|
||||||
};
|
};
|
||||||
this.isExpireDaysNoLimit = (parseInt(shareLinkExpireDaysMin) === 0 && parseInt(shareLinkExpireDaysMax) === 0);
|
|
||||||
this.isOfficeFile = Utils.isOfficeFile(this.props.itemPath);
|
this.isOfficeFile = Utils.isOfficeFile(this.props.itemPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,10 +126,11 @@ class GenerateShareLink extends React.Component {
|
|||||||
if (isValid) {
|
if (isValid) {
|
||||||
this.setState({errorInfo: ''});
|
this.setState({errorInfo: ''});
|
||||||
let { itemPath, repoID } = this.props;
|
let { itemPath, repoID } = this.props;
|
||||||
let { password, expireDays } = this.state;
|
let { password, isExpireChecked, expireDays } = this.state;
|
||||||
let permissions = this.permissions;
|
let permissions = this.permissions;
|
||||||
permissions = JSON.stringify(permissions);
|
permissions = JSON.stringify(permissions);
|
||||||
seafileAPI.createShareLink(repoID, itemPath, password, expireDays, permissions).then((res) => {
|
const expireDaysSent = isExpireChecked ? expireDays : '';
|
||||||
|
seafileAPI.createShareLink(repoID, itemPath, password, expireDaysSent, permissions).then((res) => {
|
||||||
let sharedLinkInfo = new SharedLinkInfo(res.data);
|
let sharedLinkInfo = new SharedLinkInfo(res.data);
|
||||||
this.setState({sharedLinkInfo: sharedLinkInfo});
|
this.setState({sharedLinkInfo: sharedLinkInfo});
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
@@ -157,8 +160,8 @@ class GenerateShareLink extends React.Component {
|
|||||||
password: '',
|
password: '',
|
||||||
passwordnew: '',
|
passwordnew: '',
|
||||||
isShowPasswordInput: false,
|
isShowPasswordInput: false,
|
||||||
expireDays: shareLinkExpireDaysDefault,
|
expireDays: this.defaultExpireDays,
|
||||||
isExpireChecked: false,
|
isExpireChecked: !this.isExpireDaysNoLimit,
|
||||||
errorInfo: '',
|
errorInfo: '',
|
||||||
sharedLinkInfo: null,
|
sharedLinkInfo: null,
|
||||||
isNoticeMessageShow: false,
|
isNoticeMessageShow: false,
|
||||||
@@ -354,13 +357,13 @@ class GenerateShareLink extends React.Component {
|
|||||||
<Fragment>
|
<Fragment>
|
||||||
<FormGroup check>
|
<FormGroup check>
|
||||||
<Label check>
|
<Label check>
|
||||||
<Input className="expire-checkbox" type="checkbox" onChange={this.onExpireChecked}/>{' '}{gettext('Add auto expiration')}
|
<Input className="expire-checkbox" type="checkbox" onChange={this.onExpireChecked} />{' '}{gettext('Add auto expiration')}
|
||||||
</Label>
|
</Label>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
{this.state.isExpireChecked &&
|
{this.state.isExpireChecked &&
|
||||||
<FormGroup check>
|
<FormGroup check>
|
||||||
<Label check>
|
<Label check>
|
||||||
<Input className="expire-input expire-input-border" type="text" value={this.state.expireDays} onChange={this.onExpireDaysChanged} readOnly={!this.state.isExpireChecked}/><span className="expir-span">{gettext('days')}</span>
|
<Input className="expire-input expire-input-border" type="text" value={this.state.expireDays} onChange={this.onExpireDaysChanged} readOnly={!this.state.isExpireChecked} /><span className="expir-span">{gettext('days')}</span>
|
||||||
</Label>
|
</Label>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user