Skip to content

Commit

Permalink
01 fix list can admin departments (#6132)
Browse files Browse the repository at this point in the history
02 fix no departments message

03 change wiki long name style
  • Loading branch information
Michael18811380328 authored May 30, 2024
1 parent 261c3a7 commit 2d66793
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
11 changes: 4 additions & 7 deletions frontend/src/components/dialog/add-wiki-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input, Label } from 'reactstrap';
import { gettext } from '../../utils/constants';
import { seafileAPI } from '../../utils/seafile-api';
import wikiAPI from '../../utils/wiki-api';
import { Utils } from '../../utils/utils';
import toaster from '../toast';
import { SeahubSelect } from '../common/select';
Expand All @@ -25,11 +25,7 @@ class AddWikiDialog extends React.Component {
}

componentDidMount() {
this.listDepartments();
}

listDepartments = () => {
seafileAPI.listDepartments().then(res => {
wikiAPI.listWikiDepartments().then(res => {
const departments = res.data.sort((a, b) => {
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
});
Expand All @@ -46,7 +42,7 @@ class AddWikiDialog extends React.Component {
let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
});
};
}

inputNewName = (e) => {
this.setState({
Expand Down Expand Up @@ -95,6 +91,7 @@ class AddWikiDialog extends React.Component {
components={{ NoOptionsMessage: (
<div style={{margin: '6px 10px', textAlign: 'center', color: 'hsl(0,0%,50%)'}}>{gettext('No department')}</div>
) }}
noOptionsMessage={() => {return gettext('No options available');}}
/>
</ModalBody>
<ModalFooter>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/wiki-card-view/wiki-card-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ class WikiCardItem extends Component {
let isOldVersion = wiki.version !== 'v2';
let publishedUrl = `${siteRoot}published/${encodeURIComponent(wiki.slug)}/`;
let editUrl = `${siteRoot}wikis/${wiki.id}/`;
let wikiName = isOldVersion ? <>{wiki.name} (old version)</> : <>{wiki.name}</>;
let wikiName = isOldVersion ? `${wiki.name} (old version)` : wiki.name;
return (
<>
<div className="wiki-card-item" onClick={this.clickWikiCard.bind(this, isOldVersion ? publishedUrl : editUrl )}>
<div className="wiki-card-item-top">
<div className="d-flex align-items-center">
<span className="sf3-font-wiki sf3-font" aria-hidden="true"></span>
<span className="wiki-card-item-name ml-2 text-truncate">{wikiName}</span>
<span className="wiki-card-item-name ml-2 text-truncate" title={wikiName} aria-label={wikiName}>{wikiName}</span>
</div>
<Dropdown isOpen={this.state.isItemMenuShow} toggle={this.toggleDropDownMenu} onClick={this.onClickDropdown}>
<DropdownToggle
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/components/wiki-card-view/wiki-card-view.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@
color: #666;
}

.wiki-card-item .wiki-card-item-top .dropdown {
display: flex;
align-items: center;
}

.wiki-card-item .wiki-card-item-top .sf3-font-wiki.sf3-font {
color: #FF8900;
font-size: 24px;
}

.wiki-card-item .wiki-card-item-top .wiki-card-item-name {
max-width: 250px;
max-width: 220px;
font-size: 16px;
}

Expand Down
6 changes: 6 additions & 0 deletions frontend/src/utils/wiki-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class WikiAPI {
}
}

listWikiDepartments() {
const url = this.server + '/api/v2.1/departments/';
const params = { can_admin: true };
return this.req.get(url, { params: params });
}

listWikiDir(wikiId, dirPath, withParents) {
const path = encodeURIComponent(dirPath);
let url = this.server + '/api/v2.1/wikis/' + wikiId + '/dir/?p=' + path;
Expand Down

0 comments on commit 2d66793

Please sign in to comment.