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

@ -25,6 +25,7 @@ import {Helmet} from "react-helmet";
import * as Conf from "./Conf";
import * as phoneNumber from "libphonenumber-js";
import moment from "moment";
import {DefaultOrganization} from "./Conf";
const {Option} = Select;
@ -1164,3 +1165,27 @@ export function inIframe() {
return true;
}
}
export function getOrganization() {
const organization = localStorage.getItem("organization");
return organization !== null ? organization : DefaultOrganization;
}
export function setOrganization(organization) {
localStorage.setItem("organization", organization);
window.dispatchEvent(new Event(Conf.StorageOrganizationChangedEvent));
}
export function getRequestOrganization(account) {
if (isAdminUser(account)) {
return getOrganization() === DefaultOrganization ? account.owner : getOrganization();
}
return account.owner;
}
export function isDefaultOrganizationSelected(account) {
if (isAdminUser(account)) {
return getOrganization() === DefaultOrganization;
}
return false;
}