Merge pull request #1772 from LalitDeore/branding
Fix the branding issue for partners
This commit is contained in:
@@ -1069,6 +1069,72 @@ func handleInfo(resp http.ResponseWriter, request *http.Request) {
|
|||||||
activatedAppIds = append(activatedAppIds, app.ID)
|
activatedAppIds = append(activatedAppIds, app.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parsedStatus := []string{}
|
||||||
|
if len(org.ManagerOrgs) > 0 || userInfo.ActiveOrg.CreatorOrg != "" {
|
||||||
|
parsedStatus = append(parsedStatus, "sub_org")
|
||||||
|
|
||||||
|
parentOrgId := userInfo.ActiveOrg.CreatorOrg
|
||||||
|
if len(userInfo.ActiveOrg.CreatorOrg) == 0 {
|
||||||
|
parentOrgId = org.ManagerOrgs[0].Id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for licensing/branding of parent and override
|
||||||
|
parentOrg, err := shuffle.GetOrg(ctx, parentOrgId)
|
||||||
|
if err == nil {
|
||||||
|
if parentOrg.LeadInfo.IntegrationPartner {
|
||||||
|
parsedStatus = append(parsedStatus, "integration_partner")
|
||||||
|
|
||||||
|
// except theme take from parent org
|
||||||
|
org.Branding.EnableChat = parentOrg.Branding.EnableChat
|
||||||
|
org.Branding.HomeUrl = parentOrg.Branding.HomeUrl
|
||||||
|
org.Branding.DocumentationLink = parentOrg.Defaults.DocumentationReference
|
||||||
|
org.Branding.SupportEmail = parentOrg.Branding.SupportEmail
|
||||||
|
org.Branding.LogoutUrl = parentOrg.Branding.LogoutUrl
|
||||||
|
org.Branding.BrandColor = parentOrg.Branding.BrandColor
|
||||||
|
org.Branding.BrandName = parentOrg.Branding.BrandName
|
||||||
|
org.Branding.GlobalUser = parentOrg.Branding.GlobalUser
|
||||||
|
|
||||||
|
if len(org.Branding.Theme) == 0 {
|
||||||
|
org.Branding.Theme = parentOrg.Branding.Theme
|
||||||
|
}
|
||||||
|
|
||||||
|
userInfo.ActiveOrg.Branding = parentOrg.Branding
|
||||||
|
userInfo.ActiveOrg.Image = parentOrg.Image
|
||||||
|
userInfo.ActiveOrg.Branding.DocumentationLink = parentOrg.Defaults.DocumentationReference
|
||||||
|
userInfo.ActiveOrg.Branding.BrandColor = parentOrg.Branding.BrandColor
|
||||||
|
userInfo.ActiveOrg.Branding.SupportEmail = org.Branding.SupportEmail
|
||||||
|
userInfo.ActiveOrg.Branding.LogoutUrl = org.Branding.LogoutUrl
|
||||||
|
userInfo.ActiveOrg.Branding.BrandName = parentOrg.Branding.BrandName
|
||||||
|
|
||||||
|
if len(org.Branding.Theme) == 0 {
|
||||||
|
userInfo.ActiveOrg.Branding.Theme = parentOrg.Branding.Theme
|
||||||
|
} else {
|
||||||
|
userInfo.ActiveOrg.Branding.Theme = org.Branding.Theme
|
||||||
|
}
|
||||||
|
|
||||||
|
// check whether current is global user or not? means is user part of parent org or not
|
||||||
|
for _, user := range parentOrg.Users {
|
||||||
|
if user.Id == userInfo.Id && user.Role == "admin" {
|
||||||
|
userInfo.ActiveOrg.Branding.GlobalUser = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// for parent org branding
|
||||||
|
if org.LeadInfo.IntegrationPartner {
|
||||||
|
userInfo.ActiveOrg.Branding.Theme = org.Branding.Theme
|
||||||
|
userInfo.ActiveOrg.Branding.DocumentationLink = org.Defaults.DocumentationReference
|
||||||
|
userInfo.ActiveOrg.Branding.SupportEmail = org.Branding.SupportEmail
|
||||||
|
userInfo.ActiveOrg.Branding.LogoutUrl = org.Branding.LogoutUrl
|
||||||
|
userInfo.ActiveOrg.Branding.BrandColor = org.Branding.BrandColor
|
||||||
|
userInfo.ActiveOrg.Branding.BrandName = org.Branding.BrandName
|
||||||
|
|
||||||
|
parsedStatus = append(parsedStatus, "integration_partner")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
returnValue := shuffle.HandleInfo{
|
returnValue := shuffle.HandleInfo{
|
||||||
Success: true,
|
Success: true,
|
||||||
Username: userInfo.Username,
|
Username: userInfo.Username,
|
||||||
@@ -1092,6 +1158,7 @@ func handleInfo(resp http.ResponseWriter, request *http.Request) {
|
|||||||
Licensed: licensed,
|
Licensed: licensed,
|
||||||
ActiveApps: activatedAppIds,
|
ActiveApps: activatedAppIds,
|
||||||
Theme: userInfo.Theme,
|
Theme: userInfo.Theme,
|
||||||
|
OrgStatus: parsedStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
returnData, err := json.Marshal(returnValue)
|
returnData, err := json.Marshal(returnValue)
|
||||||
|
|||||||
+36
-3
@@ -92,7 +92,7 @@ const App = (message, props) => {
|
|||||||
const [dataset, setDataset] = useState(false)
|
const [dataset, setDataset] = useState(false)
|
||||||
const [isLoaded, setIsLoaded] = useState(false)
|
const [isLoaded, setIsLoaded] = useState(false)
|
||||||
const [curpath, setCurpath] = useState(typeof window === "undefined" || window.location === undefined ? "" : window.location.pathname)
|
const [curpath, setCurpath] = useState(typeof window === "undefined" || window.location === undefined ? "" : window.location.pathname)
|
||||||
const { themeMode, handleThemeChange, setBrandColor, brandColor,setThemeMode} = useContext(Context);
|
const { themeMode, handleThemeChange, setBrandColor, brandColor,setThemeMode, setSupportEmail, setLogoutUrl, setBrandName} = useContext(Context);
|
||||||
const currentTheme = getTheme(themeMode, brandColor);
|
const currentTheme = getTheme(themeMode, brandColor);
|
||||||
const mainColor = currentTheme?.palette?.backgroundColor
|
const mainColor = currentTheme?.palette?.backgroundColor
|
||||||
const [isPreviousThemeLight, setIsPreviousThemeLight] = useState(false)
|
const [isPreviousThemeLight, setIsPreviousThemeLight] = useState(false)
|
||||||
@@ -192,11 +192,44 @@ const App = (message, props) => {
|
|||||||
{ path: "/" }
|
{ path: "/" }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (responseJson?.theme?.length > 0) {
|
if (responseJson?.org_status?.includes("integration_partner")) {
|
||||||
handleThemeChange(responseJson.theme)
|
if (responseJson?.active_org?.branding?.enable_chat !== true) {
|
||||||
|
|
||||||
|
// Find the drift chatbox and remove it
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseJson?.active_org?.branding?.theme?.length > 0 ) {
|
||||||
|
handleThemeChange(responseJson?.active_org?.branding?.theme)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseJson?.active_org?.branding?.brand_color?.length > 0 ) {
|
||||||
|
setBrandColor(responseJson?.active_org?.branding?.brand_color)
|
||||||
|
localStorage.setItem("brandColor", responseJson?.active_org?.branding?.brand_color)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseJson?.active_org?.branding?.brand_name?.length > 0 ) {
|
||||||
|
setBrandName(responseJson?.active_org?.branding?.brand_name)
|
||||||
|
localStorage.setItem("brandName", responseJson?.active_org?.branding?.brand_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseJson?.active_org?.branding?.support_email?.length > 0 ) {
|
||||||
|
setSupportEmail(responseJson?.active_org?.branding?.support_email)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseJson?.active_org?.branding?.logout_url?.length > 0 ) {
|
||||||
|
setLogoutUrl(responseJson?.active_org?.branding?.logout_url)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem("brandColor")
|
||||||
|
setBrandColor("#ff8544")
|
||||||
|
setBrandName("Shuffle")
|
||||||
|
localStorage.removeItem("brandName")
|
||||||
|
if(responseJson?.theme?.length > 0){
|
||||||
|
handleThemeChange(responseJson?.theme)
|
||||||
}else{
|
}else{
|
||||||
handleThemeChange("dark")
|
handleThemeChange("dark")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
handleThemeChange("dark")
|
handleThemeChange("dark")
|
||||||
setThemeMode("dark")
|
setThemeMode("dark")
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
import React, { useState, useEffect, useContext, memo, useMemo } from 'react'
|
||||||
|
import {getTheme} from '../theme.jsx';
|
||||||
|
import { Context } from '../context/ContextApi.jsx';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Typography,
|
||||||
|
} from '@mui/material';
|
||||||
|
|
||||||
|
import {
|
||||||
|
BarChart,
|
||||||
|
BarSeries,
|
||||||
|
Bar,
|
||||||
|
BarLabel,
|
||||||
|
|
||||||
|
GridlineSeries,
|
||||||
|
Gridline,
|
||||||
|
TooltipArea,
|
||||||
|
ChartTooltip,
|
||||||
|
TooltipTemplate,
|
||||||
|
} from 'reaviz';
|
||||||
|
|
||||||
|
const LineChartWrapper = (props) => {
|
||||||
|
const {keys, inputname, height, width, border} = props
|
||||||
|
|
||||||
|
const [hovered, setHovered] = useState("");
|
||||||
|
const {themeMode} = useContext(Context)
|
||||||
|
const theme = getTheme(themeMode)
|
||||||
|
|
||||||
|
var inputdata = keys.data === undefined ? keys : keys.data
|
||||||
|
|
||||||
|
var newname = inputname === undefined || inputname === null ? "" : inputname.trim().replaceAll("_", " ")
|
||||||
|
newname = newname.charAt(0).toUpperCase() + newname.slice(1)
|
||||||
|
|
||||||
|
if (inputdata?.key !== undefined && inputdata?.key !== null && inputdata?.key !== "" && inputdata?.datasets !== undefined && inputdata?.datasets !== null && inputdata?.datasets.length > 0 && inputdata?.labels !== undefined && inputdata?.labels !== null && inputdata?.labels.length > 0) {
|
||||||
|
|
||||||
|
var tmpdata = inputdata?.datasets[0]
|
||||||
|
if (tmpdata?.data !== undefined && tmpdata?.data !== null && tmpdata?.data.length > 0 && inputdata?.labels?.length === tmpdata?.data?.length) {
|
||||||
|
console.log("Fix it!")
|
||||||
|
var newarray = []
|
||||||
|
for (var key in tmpdata.data) {
|
||||||
|
var entry = {
|
||||||
|
"key": inputdata.labels[key] !== undefined ? inputdata.labels[key] : key,
|
||||||
|
"data": tmpdata.data[key],
|
||||||
|
}
|
||||||
|
|
||||||
|
newarray.push(entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
inputdata = newarray
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputdata === undefined || inputdata === null) {
|
||||||
|
return (
|
||||||
|
<Typography>
|
||||||
|
Invalid linegraph data format
|
||||||
|
</Typography>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
var defaultStyle = {
|
||||||
|
color: "white",
|
||||||
|
padding: 30,
|
||||||
|
marginTop: 15,
|
||||||
|
overflow: "hidden",
|
||||||
|
|
||||||
|
border: "1px solid rgba(255,255,255,0.3)",
|
||||||
|
borderRadius: theme.palette?.borderRadius,
|
||||||
|
backgroundColor: theme.palette.platformColor,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (border === false) {
|
||||||
|
defaultStyle.border = "none"
|
||||||
|
defaultStyle.borderRadius = 0
|
||||||
|
defaultStyle.backgroundColor = "transparent"
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={defaultStyle}>
|
||||||
|
<Typography variant="h6" style={{marginBotton: 30, }}>
|
||||||
|
{newname}
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<BarChart
|
||||||
|
style={{marginTop: 100, }}
|
||||||
|
width={"100%"}
|
||||||
|
height={height}
|
||||||
|
data={inputdata}
|
||||||
|
|
||||||
|
series={
|
||||||
|
<BarSeries
|
||||||
|
bar={
|
||||||
|
<Bar />
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
gridlines={
|
||||||
|
<GridlineSeries line={<Gridline direction="all" />} />
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LineChartWrapper;
|
||||||
Reference in New Issue
Block a user