1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-04-28 03:10:45 +00:00

fix share dialog link expire time (#6924)

This commit is contained in:
Michael An 2024-10-21 14:24:02 +08:00 committed by GitHub
parent e3480b2a3c
commit e04c3f367b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';
import dayjs from 'dayjs';
import localeData from 'dayjs/plugin/localeData';
import utc from 'dayjs/plugin/utc';
import weekOfYear from 'dayjs/plugin/weekOfYear';
import Calendar from '@seafile/seafile-calendar';
import DatePicker from '@seafile/seafile-calendar/lib/Picker';
import { translateCalendar } from '../utils/date-format-utils';
@ -8,19 +11,26 @@ import { translateCalendar } from '../utils/date-format-utils';
import '@seafile/seafile-calendar/assets/index.css';
import '../css/date-and-time-picker.css';
dayjs.extend(utc);
dayjs.extend(localeData);
dayjs.extend(weekOfYear);
class Picker extends React.Component {
constructor(props) {
super(props);
this.defaultCalendarValue = null;
this.calendarContainerRef = React.createRef();
this.inputRef = React.createRef();
}
componentDidMount() {
let now = dayjs();
let lang = window.app.config.lang;
this.defaultCalendarValue = dayjs().locale(lang).clone();
const isZhcn = lang === 'zh-cn';
if (isZhcn) {
now = now.locale('zh-cn');
} else {
now = now.locale('en-gb');
}
this.defaultCalendarValue = now.clone();
}
getCalendarContainer = () => {
@ -33,20 +43,21 @@ class Picker extends React.Component {
showHourAndMinute = this.props.showHourAndMinute;
}
const FORMAT = showHourAndMinute ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
const format = showHourAndMinute ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
const calendar = (<Calendar
defaultValue={this.defaultCalendarValue}
disabledDate={this.props.disabledDate}
format={FORMAT}
locale={translateCalendar()}
showHourAndMinute={showHourAndMinute}
/>);
return (
<DatePicker
disabled={this.props.disabled}
getCalendarContainer={this.getCalendarContainer}
calendar={calendar}
calendar={
<Calendar
defaultValue={this.defaultCalendarValue}
disabledDate={this.props.disabledDate}
format={format}
locale={translateCalendar()}
showHourAndMinute={showHourAndMinute}
/>
}
value={this.props.value}
onChange={this.props.onChange}
>
@ -55,12 +66,12 @@ class Picker extends React.Component {
return (
<div>
<input
placeholder={FORMAT}
placeholder={format}
style={{ width: this.props.inputWidth || 250 }}
tabIndex="-1"
disabled={this.props.disabled}
readOnly={true}
value={value && value.format(FORMAT) || ''}
value={value && value.format(format) || ''}
className="form-control"
ref={this.inputRef}
/>