Web: Client: Fixed header name on admins page, fixed value of admins on access-rights page, added filter to url on admins page
This commit is contained in:
parent
095b79dc31
commit
90973fa769
@ -143,7 +143,9 @@ class SectionHeaderContent extends React.Component {
|
||||
|
||||
const fullSettingsUrlLength = fullSettingsUrl.length;
|
||||
const resultPath = locationPathname.slice(fullSettingsUrlLength + 1);
|
||||
const arrayOfParams = resultPath.split("/");
|
||||
const arrayOfParams = resultPath.split("/").filter((param) => {
|
||||
return param !== "filter";
|
||||
});
|
||||
return arrayOfParams;
|
||||
};
|
||||
|
||||
|
@ -113,7 +113,7 @@ class AccessRights extends PureComponent {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { t, admins } = this.props;
|
||||
const { t, adminsTotal } = this.props;
|
||||
const { isLoading } = this.state;
|
||||
return isLoading ? (
|
||||
<MainContainer>
|
||||
@ -138,9 +138,9 @@ class AccessRights extends PureComponent {
|
||||
</Link>
|
||||
<StyledArrowRightIcon size="small" color="#333333" />
|
||||
</div>
|
||||
{admins.length > 0 && (
|
||||
{adminsTotal > 0 && (
|
||||
<Text className="category-item-subheader" truncate={true}>
|
||||
{admins.length} {t("Employees")}
|
||||
{adminsTotal} {t("Employees")}
|
||||
</Text>
|
||||
)}
|
||||
<Text className="category-item-description">
|
||||
@ -155,9 +155,10 @@ class AccessRights extends PureComponent {
|
||||
|
||||
export default inject(({ auth, setup }) => {
|
||||
const { updateListAdmins } = setup;
|
||||
const { admins } = setup.security.accessRight;
|
||||
const { admins, adminsTotal } = setup.security.accessRight;
|
||||
return {
|
||||
admins,
|
||||
adminsTotal,
|
||||
updateListAdmins,
|
||||
organizationName: auth.settingsStore.organizationName,
|
||||
owner: auth.settingsStore.owner,
|
||||
|
@ -4,6 +4,8 @@ import { withTranslation } from "react-i18next";
|
||||
import PropTypes from "prop-types";
|
||||
import styled from "styled-components";
|
||||
import HelpButton from "@appserver/components/help-button";
|
||||
import api from "@appserver/common/api";
|
||||
const { Filter } = api;
|
||||
|
||||
import ToggleButton from "@appserver/components/toggle-button";
|
||||
import ModalDialog from "@appserver/components/modal-dialog";
|
||||
@ -289,15 +291,25 @@ class PortalAdmins extends Component {
|
||||
setAddUsers,
|
||||
setRemoveAdmins,
|
||||
updateListAdmins,
|
||||
history,
|
||||
} = this.props;
|
||||
|
||||
const { location } = history;
|
||||
const { pathname } = location;
|
||||
let filter = Filter.getDefault();
|
||||
|
||||
if (pathname.indexOf("/admins/filter") > -1) {
|
||||
filter = Filter.getFilter(location);
|
||||
filter.page += 1;
|
||||
}
|
||||
|
||||
setAddUsers(this.addUsers);
|
||||
setRemoveAdmins(this.removeAdmins);
|
||||
|
||||
if (isEmpty(admins, true)) {
|
||||
this.setIsLoading(true);
|
||||
try {
|
||||
await updateListAdmins(null, true);
|
||||
await updateListAdmins(filter, true);
|
||||
this.setIsLoading(false);
|
||||
} catch (error) {
|
||||
toastr.error(error);
|
||||
|
@ -2,6 +2,9 @@ import api from "@appserver/common/api";
|
||||
import { makeAutoObservable } from "mobx";
|
||||
const { Filter } = api;
|
||||
import SelectionStore from "./SelectionStore";
|
||||
import { combineUrl } from "@appserver/common/utils";
|
||||
import { AppServerConfig } from "@appserver/common/constants";
|
||||
import config from "../../package.json";
|
||||
|
||||
class SettingsSetupStore {
|
||||
selectionStore = null;
|
||||
@ -18,6 +21,7 @@ class SettingsSetupStore {
|
||||
options: [],
|
||||
users: [],
|
||||
admins: [],
|
||||
adminsTotal: 0,
|
||||
owner: {},
|
||||
filter: Filter.getDefault(),
|
||||
selectorIsOpen: false,
|
||||
@ -56,6 +60,10 @@ class SettingsSetupStore {
|
||||
this.security.accessRight.admins = admins;
|
||||
};
|
||||
|
||||
setTotalAdmins = (total) => {
|
||||
this.security.accessRight.adminsTotal = total;
|
||||
};
|
||||
|
||||
setOwner = (owner) => {
|
||||
this.security.accessRight.owner = owner;
|
||||
};
|
||||
@ -98,6 +106,23 @@ class SettingsSetupStore {
|
||||
{};
|
||||
};
|
||||
|
||||
setFilterUrl = (filter) => {
|
||||
window.history.replaceState(
|
||||
"",
|
||||
"",
|
||||
combineUrl(
|
||||
AppServerConfig.proxyURL,
|
||||
`${config.homepage}/settings/security/access-rights/admins`,
|
||||
`/filter?page=${filter.page}`
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
setFilterParams = (data) => {
|
||||
this.setFilterUrl(data);
|
||||
this.setFilter(data);
|
||||
};
|
||||
|
||||
changeAdmins = async (userIds, productId, isAdmin) => {
|
||||
const requests = userIds.map((userId) =>
|
||||
api.people.changeProductAdmin(userId, productId, isAdmin)
|
||||
@ -148,8 +173,12 @@ class SettingsSetupStore {
|
||||
}
|
||||
|
||||
filterData.total = admins.total;
|
||||
if (filter) {
|
||||
this.setFilterParams(filterData);
|
||||
}
|
||||
|
||||
this.setAdmins(admins.items);
|
||||
this.setTotalAdmins(admins.total);
|
||||
this.setFilter(filterData);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user