feat: add organization context select box for admin (#2013)

* feat: organization as context

* feat: organization as context with backend filtration

* Update app.conf

* update app.conf and hide organization select for mobile.

---------

Co-authored-by: dplynsky <dplynsky@ptsecurity.com>
Co-authored-by: hsluoyz <hsluoyz@qq.com>
This commit is contained in:
Denis Plynskiy
2023-06-29 20:32:34 +03:00
committed by GitHub
parent 91cb5f393a
commit eee9b8b9fe
46 changed files with 207 additions and 76 deletions

View File

@ -17,6 +17,9 @@ import {Button, Input, Result, Space} from "antd";
import {SearchOutlined} from "@ant-design/icons";
import Highlighter from "react-highlight-words";
import i18next from "i18next";
import * as Setting from "./Setting";
import * as Conf from "./Conf";
import {DefaultOrganization} from "./Conf";
class BaseListPage extends React.Component {
constructor(props) {
@ -35,6 +38,22 @@ class BaseListPage extends React.Component {
};
}
handleOrganizationChange = () => {
const {pagination} = this.state;
this.fetch({pagination});
};
componentDidMount() {
window.addEventListener(Conf.StorageOrganizationChangedEvent, this.handleOrganizationChange);
if (!Setting.isAdminUser(this.props.account)) {
Setting.setOrganization(DefaultOrganization);
}
}
componentWillUnmount() {
window.removeEventListener(Conf.StorageOrganizationChangedEvent, this.handleOrganizationChange);
}
UNSAFE_componentWillMount() {
const {pagination} = this.state;
this.fetch({pagination});