forked from jitsi/jitsi-meet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(branding): Add ability to customize logo & background
- Loading branch information
Showing
14 changed files
with
279 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Action used to set custom user properties. | ||
*/ | ||
export const SET_DYNAMIC_BRANDING_DATA = 'SET_DYNAMIC_BRANDING_DATA'; | ||
|
||
/** | ||
* Action used to signal the branding elements are ready to be displayed | ||
*/ | ||
export const SET_DYNAMIC_BRANDING_READY = 'SET_DYNAMIC_BRANDING_READY'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// @flow | ||
|
||
import { getLogger } from 'jitsi-meet-logger'; | ||
|
||
import { doGetJSON } from '../base/util'; | ||
|
||
import { SET_DYNAMIC_BRANDING_DATA, SET_DYNAMIC_BRANDING_READY } from './actionTypes'; | ||
import { extractFqnFromPath } from './functions'; | ||
|
||
const logger = getLogger(__filename); | ||
|
||
/** | ||
* Fetches custom branding data. | ||
* If there is no data or the request fails, sets the `customizationReady` flag | ||
* so the defaults can be displayed. | ||
* | ||
* @returns {Function} | ||
*/ | ||
export function fetchCustomBrandingData() { | ||
return async function(dispatch: Function, getState: Function) { | ||
const state = getState(); | ||
const baseUrl = state['features/base/config'].brandingDataUrl; | ||
const { customizationReady } = state['features/dynamic-branding']; | ||
|
||
if (!customizationReady) { | ||
const fqn = extractFqnFromPath(state['features/base/connection'].locationURL.pathname); | ||
|
||
if (baseUrl && fqn) { | ||
try { | ||
const res = await doGetJSON(`${baseUrl}?conferenceFqn=${encodeURIComponent(fqn)}`); | ||
|
||
return dispatch(setDynamicBrandingData(res)); | ||
} catch (err) { | ||
logger.error('Error fetching branding data', err); | ||
} | ||
} | ||
|
||
dispatch(setDynamicBrandingReady()); | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* Action used to set the user customizations. | ||
* | ||
* @param {Object} value - The custom data to be set. | ||
* @returns {Object} | ||
*/ | ||
function setDynamicBrandingData(value) { | ||
return { | ||
type: SET_DYNAMIC_BRANDING_DATA, | ||
value | ||
}; | ||
} | ||
|
||
|
||
/** | ||
* Action used to signal the branding elements are ready to be displayed. | ||
* | ||
* @returns {Object} | ||
*/ | ||
function setDynamicBrandingReady() { | ||
return { | ||
type: SET_DYNAMIC_BRANDING_READY | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// @flow | ||
|
||
/** | ||
* Extracts the fqn part from a path, where fqn represents | ||
* tenant/roomName. | ||
* | ||
* @param {string} path - The URL path. | ||
* @returns {string} | ||
*/ | ||
export function extractFqnFromPath(path: string) { | ||
const parts = path.split('/'); | ||
const len = parts.length; | ||
|
||
return parts.length > 2 ? `${parts[len - 2]}/${parts[len - 1]}` : ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './actions'; | ||
export * from './functions'; | ||
|
||
import './reducer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// @flow | ||
|
||
import { ReducerRegistry } from '../base/redux'; | ||
|
||
import { SET_DYNAMIC_BRANDING_DATA, SET_DYNAMIC_BRANDING_READY } from './actionTypes'; | ||
|
||
/** | ||
* The name of the redux store/state property which is the root of the redux | ||
* state of the feature {@code dynamic-branding}. | ||
*/ | ||
const STORE_NAME = 'features/dynamic-branding'; | ||
|
||
const DEFAULT_STATE = { | ||
backgroundColor: '', | ||
backgroundImageUrl: '', | ||
customizationReady: false, | ||
logoClickUrl: '', | ||
logoImageUrl: '' | ||
}; | ||
|
||
/** | ||
* Reduces redux actions for the purposes of the feature {@code dynamic-branding}. | ||
*/ | ||
ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => { | ||
switch (action.type) { | ||
case SET_DYNAMIC_BRANDING_DATA: { | ||
const { backgroundColor, backgroundImageUrl, logoClickUrl, logoImageUrl } = action.value; | ||
|
||
return { | ||
backgroundColor, | ||
backgroundImageUrl, | ||
logoClickUrl, | ||
logoImageUrl, | ||
customizationReady: true | ||
}; | ||
} | ||
case SET_DYNAMIC_BRANDING_READY: | ||
return { | ||
...state, | ||
customizationReady: true | ||
}; | ||
|
||
} | ||
|
||
return state; | ||
}); |
Oops, something went wrong.