Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Made link button on homepage configurable. #7226

Merged
merged 1 commit into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/client-core/i18n/en/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,10 @@
"startPath": "PWA Start Path",
"shortTitleTooltip": "The displayed title of a PWA-installed copy of this app if 'title' is too long; recommended max 12 characters",
"startPathTooltip": "The path that a PWA-installed copy of this app will direct to",
"authSettingsRefreshNotification": "Updating authentication settings requires restarting the API pods. This should be complete within a few minutes. Changes you just made may not be reflected until then."
"authSettingsRefreshNotification": "Updating authentication settings requires restarting the API pods. This should be complete within a few minutes. Changes you just made may not be reflected until then.",
"homepageLinkButtonEnabled": "Show link button on homepage",
"homepageLinkButtonRedirect": "URL of homepage link button",
"homepageLinkButtonText": "Text of homepage link button"
},
"avatar": {
"source": "Source",
Expand Down
44 changes: 43 additions & 1 deletion packages/client-core/src/admin/components/Setting/Client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Box, Button, Grid, IconButton, Typography } from '@mui/material'
import Tooltip from '@mui/material/Tooltip'

import { useAuthState } from '../../../user/services/AuthService'
import InputSwitch from '../../common/InputSwitch'
import InputText from '../../common/InputText'
import { ClientSettingService, useClientSettingState } from '../../services/Setting/ClientSettingService'
import styles from '../../styles/settings.module.scss'
Expand Down Expand Up @@ -36,6 +37,13 @@ const Client = () => {
const [favicon32px, setFavicon32px] = useState(clientSetting?.favicon32px)
const [key8thWall, setKey8thWall] = useState(clientSetting?.key8thWall)
const [siteDescription, setSiteDescription] = useState(clientSetting?.siteDescription)
const [homepageLinkButtonEnabled, setHomepageLinkButtonEnabled] = useState(
clientSetting?.homepageLinkButtonEnabled as boolean
)
const [homepageLinkButtonRedirect, setHomepageLinkButtonRedirect] = useState(
clientSetting?.homepageLinkButtonRedirect
)
const [homepageLinkButtonText, setHomepageLinkButtonText] = useState(clientSetting?.homepageLinkButtonText)

useEffect(() => {
if (user?.id?.value != null && clientSettingState?.updateNeeded?.value === true) {
Expand All @@ -60,6 +68,9 @@ const Client = () => {
setFavicon32px(clientSetting?.favicon32px)
setSiteDescription(clientSetting?.siteDescription)
setKey8thWall(clientSetting?.key8thWall)
setHomepageLinkButtonEnabled(clientSetting?.homepageLinkButtonEnabled)
setHomepageLinkButtonRedirect(clientSetting?.homepageLinkButtonRedirect)
setHomepageLinkButtonText(clientSetting?.homepageLinkButtonText)
}
}, [clientSettingState?.updateNeeded?.value])

Expand Down Expand Up @@ -108,7 +119,10 @@ const Client = () => {
appSocialLinks: JSON.stringify(appSocialLinks),
themeSettings: JSON.stringify(clientSetting?.themeSettings),
themeModes: JSON.stringify(clientSetting?.themeModes),
key8thWall: key8thWall
key8thWall: key8thWall,
homepageLinkButtonEnabled: homepageLinkButtonEnabled,
homepageLinkButtonRedirect: homepageLinkButtonRedirect,
homepageLinkButtonText: homepageLinkButtonText
},
id
)
Expand All @@ -128,6 +142,9 @@ const Client = () => {
setFavicon32px(clientSetting?.favicon32px)
setSiteDescription(clientSetting?.siteDescription)
setKey8thWall(clientSetting?.key8thWall)
setHomepageLinkButtonEnabled(clientSetting?.homepageLinkButtonEnabled)
setHomepageLinkButtonRedirect(clientSetting?.homepageLinkButtonRedirect)
setHomepageLinkButtonText(clientSetting?.homepageLinkButtonText)
}

return (
Expand Down Expand Up @@ -165,6 +182,31 @@ const Client = () => {
onChange={(e) => setAppBackground(e.target.value)}
/>

<InputSwitch
name="homepageLinkButtonEnabled"
label={t('admin:components.setting.homepageLinkButtonEnabled')}
checked={homepageLinkButtonEnabled}
onChange={(e) => setHomepageLinkButtonEnabled(e.target.checked)}
/>

{homepageLinkButtonEnabled && (
<InputText
name="description"
label={t('admin:components.setting.homepageLinkButtonRedirect')}
value={homepageLinkButtonRedirect || ''}
onChange={(e) => setHomepageLinkButtonRedirect(e.target.value)}
/>
)}

{homepageLinkButtonEnabled && (
<InputText
name="description"
label={t('admin:components.setting.homepageLinkButtonText')}
value={homepageLinkButtonText || ''}
onChange={(e) => setHomepageLinkButtonText(e.target.value)}
/>
)}

<Typography className={styles.settingsSubHeading}>{t('admin:components.setting.appSocialLinks')}</Typography>

{appSocialLinks?.length > 0 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ const ClientTheme = () => {
appSocialLinks: JSON.stringify(clientSetting?.appSocialLinks),
themeSettings: JSON.stringify(newThemeSettings),
themeModes: JSON.stringify(newThemeModes),
key8thWall: clientSetting?.key8thWall
key8thWall: clientSetting?.key8thWall,
homepageLinkButtonEnabled: clientSetting?.homepageLinkButtonEnabled,
homepageLinkButtonRedirect: clientSetting?.homepageLinkButtonRedirect,
homepageLinkButtonText: clientSetting?.homepageLinkButtonText
},
id
)
Expand Down
16 changes: 9 additions & 7 deletions packages/client/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ export const HomePage = (): any => {
<span>{clientSetting.appDescription}</span>
</Trans>
)}
<Button
className={styles.gradientButton + ' ' + styles.forceVaporwave}
autoFocus
onClick={() => (window.location.href = 'https://etherealengine.com/explore')}
>
{t('common:exploreRedirect')}
</Button>
{clientSetting.homepageLinkButtonEnabled && (
<Button
className={styles.gradientButton + ' ' + styles.forceVaporwave}
autoFocus
onClick={() => (window.location.href = clientSetting.homepageLinkButtonRedirect)}
>
{clientSetting.homepageLinkButtonText}
</Button>
)}
</div>
<div className="form-container">
<style>
Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/dbmodels/ClientSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ export interface ClientSettingInterface {
themeSettings: string
themeModes: string
key8thWall: string
homepageLinkButtonEnabled: boolean
homepageLinkButtonRedirect: string
homepageLinkButtonText: string
}
6 changes: 6 additions & 0 deletions packages/common/src/interfaces/ClientSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export interface ClientSetting {
themeSettings: ThemeSetting
themeModes: ThemeMode
key8thWall: string
homepageLinkButtonEnabled: boolean
homepageLinkButtonRedirect: string
homepageLinkButtonText: string
}

interface SocialLink {
Expand Down Expand Up @@ -94,4 +97,7 @@ export interface PatchClientSetting {
themeSettings: string
themeModes: string
key8thWall: string
homepageLinkButtonEnabled: boolean
homepageLinkButtonRedirect: string
homepageLinkButtonText: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export class ClientSetting<T = ClientSettingDataType> extends Service<T> {
...el,
appSocialLinks: appSocialLinks,
themeSettings: themeSettings,
themeModes: themeModes
themeModes: themeModes,
homepageLinkButtonEnabled: el.homepageLinkButtonEnabled === 1
}
})

Expand All @@ -62,7 +63,8 @@ export class ClientSetting<T = ClientSettingDataType> extends Service<T> {
...clientSettings,
appSocialLinks: appSocialLinks,
themeSettings: themeSettings,
themeModes: themeModes
themeModes: themeModes,
homepageLinkButtonEnabled: clientSettings.homepageLinkButtonEnabled === 1
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ export default (app: Application) => {
key8thWall: {
type: DataTypes.STRING,
allowNull: true
},
homepageLinkButtonEnabled: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
homepageLinkButtonRedirect: {
type: DataTypes.STRING
},
homepageLinkButtonText: {
type: DataTypes.STRING
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export const clientSeed = {
]),
themeSettings: JSON.stringify(defaultThemeSettings),
themeModes: JSON.stringify(defaultThemeModes),
key8thWall: process.env.VITE_8TH_WALL
key8thWall: process.env.VITE_8TH_WALL,
homepageLinkButtonEnabled: false,
homepageLinkButtonRedirect: '',
homepageLinkButtonText: ''
}
]
}