mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-05 05:50:19 +08:00
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:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user