1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 15:53:28 +00:00

add link choice (#3450)

This commit is contained in:
Michael An
2019-05-13 17:54:48 +08:00
committed by Daniel Pan
parent a9453d64dd
commit 31d39b6fa4
2 changed files with 71 additions and 1 deletions

View File

@@ -2,9 +2,10 @@ import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';
import { seafileAPI } from '../../utils/seafile-api';
import { siteRoot, gettext } from '../../utils/constants';
import { siteRoot, gettext, serviceURL } from '../../utils/constants';
import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
import MainPanelTopbar from './main-panel-topbar';
import ViewLinkDialog from '../../components/dialog/view-link-dialog';
class OrgLinks extends React.Component {
@@ -15,6 +16,8 @@ class OrgLinks extends React.Component {
page: 1,
pageNext: false,
isItemFreezed: false,
isShowLinkDialog: false,
currentLinkHref: '',
};
}
@@ -56,6 +59,21 @@ class OrgLinks extends React.Component {
});
}
openLinkDialog = (link) => {
let href;
if (link.name.indexOf('/') > -1) {
href = serviceURL + '/d/' + link.token + '/';
} else {
href = serviceURL + '/f/' + link.token + '/';
}
this.setState({ currentLinkHref: href });
this.toggleLinkDialog();
}
toggleLinkDialog = () => {
this.setState({isShowLinkDialog: !this.state.isShowLinkDialog});
}
componentDidMount() {
this.listOrgLinks(this.state.page);
}
@@ -91,6 +109,7 @@ class OrgLinks extends React.Component {
onFreezedItem={this.onFreezedItem}
onUnfreezedItem={this.onUnfreezedItem}
deleteOrgLink={this.deleteOrgLink}
openLinkDialog={this.openLinkDialog}
/>
</React.Fragment>
);
@@ -105,6 +124,9 @@ class OrgLinks extends React.Component {
</div>
</div>
</div>
{this.state.isShowLinkDialog &&
<ViewLinkDialog currentLinkHref={this.state.currentLinkHref} toggle={this.toggleLinkDialog}/>
}
</Fragment>
);
}
@@ -185,6 +207,7 @@ class RepoItem extends React.Component {
/>
<DropdownMenu>
<DropdownItem onClick={deleteOrgLink.bind(this, link.token)}>{gettext('Delete')}</DropdownItem>
<DropdownItem onClick={this.props.openLinkDialog.bind(this, link)}>{gettext('View Link')}</DropdownItem>
</DropdownMenu>
</Dropdown>
}