feat: migrate orgconfig model across the app

This commit is contained in:
swve 2024-08-10 16:53:59 +02:00
parent 6485b6e1bb
commit 28a2456d69
12 changed files with 467 additions and 363 deletions

View file

@ -10,21 +10,9 @@ function useGetAIFeatures(props: UseGetAIFeatures) {
const [isEnabled, setisEnabled] = React.useState(false)
function checkAvailableAIFeaturesOnOrg(feature: string) {
const config = org?.config?.config?.AIConfig
const config = org?.config?.config?.features.ai.enabled
if (!config) {
return false
}
if (!config.enabled) {
return false
}
if (!config.features[feature]) {
return false
}
return true
return config
}
React.useEffect(() => {

View file

@ -26,7 +26,7 @@ export function OrgProvider({ children, orgslug }: { children: React.ReactNode,
)
const isOrgActive = useMemo(() => org?.config?.config?.GeneralConfig?.active !== false, [org])
const isOrgActive = useMemo(() => org?.config?.config?.general?.enabled !== false, [org])
const isUserPartOfTheOrg = useMemo(() => orgs?.some((userOrg: any) => userOrg.id === org?.id), [orgs, org?.id])
if (orgError || orgsError) return <ErrorUI message='An error occurred while fetching data' />

View file

@ -33,7 +33,7 @@ function OrgAccess() {
async function getOrgJoinMethod() {
if (org) {
if (org.config.config.GeneralConfig.users.signup_mechanism == 'open') {
if (org.config.config.features.members.signup_mode == 'open') {
setJoinMethod('open')
} else {
setJoinMethod('inviteOnly')

View file

@ -17,7 +17,7 @@ function ActiveAvatars(props: ActiveAvatarsProps) {
/* Collaboration Features */
const collab = getCollaborationServerUrl()
const isCollabEnabledOnThisOrg = org?.config.config.GeneralConfig.collaboration && collab
const isCollabEnabledOnThisOrg = org?.config.config.features.collaboration.enabled && collab
// Get users from the mouseMovements object
useEffect(() => {

View file

@ -35,7 +35,7 @@ function EditorWrapper(props: EditorWrapperProps): JSX.Element {
/* Collaboration Features */
const collab = getCollaborationServerUrl()
const isCollabEnabledOnThisOrg = props.org.config.config.GeneralConfig.collaboration && collab
const isCollabEnabledOnThisOrg = props.org.config.config.features.collaboration.enabled && collab
const doc = new Y.Doc()
// mouse movement
const [mouseMovements, setMouseMovements] = useState({} as any);

View file

@ -27,7 +27,7 @@ function MouseMovements({ movements, onlinePageInstanceID, org }: MouseMovements
/* Collaboration config */
const collab = getCollaborationServerUrl()
const isCollabEnabledOnThisOrg = org?.config.config.GeneralConfig.collaboration && collab
const isCollabEnabledOnThisOrg = org?.config.config.features.collaboration.enabled && collab
useEffect(() => {