diff --git a/site/src/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPageView.stories.tsx b/site/src/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPageView.stories.tsx index bd45ec90d1dfb..c6fb7283cf72d 100644 --- a/site/src/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPageView.stories.tsx +++ b/site/src/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPageView.stories.tsx @@ -6,7 +6,7 @@ const meta: Meta = { component: AppearanceSettingsPageView, args: { appearance: { - application_name: "", + application_name: "Foobar", logo_url: "https://github.com/coder.png", service_banner: { enabled: true, diff --git a/site/src/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPageView.tsx b/site/src/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPageView.tsx index 2aa975d27e180..c083a0cafabd6 100644 --- a/site/src/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPageView.tsx +++ b/site/src/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPageView.tsx @@ -42,6 +42,16 @@ export const AppearanceSettingsPageView = ({ const styles = useStyles(); const theme = useTheme(); + const applicationNameForm = useFormik<{ + application_name: string; + }>({ + initialValues: { + application_name: appearance.application_name, + }, + onSubmit: (values) => onSaveAppearance(values, false), + }); + const applicationNameFieldHelpers = getFormHelpers(applicationNameForm); + const logoForm = useFormik<{ logo_url: string; }>({ @@ -87,6 +97,22 @@ export const AppearanceSettingsPageView = ({ +
Submit} + > + +
+
{ const location = useLocation(); const [authState, authSend] = useAuth(); const redirectTo = retrieveRedirect(location.search); + const applicationName = getApplicationName(); if (authState.matches("signedIn")) { return ; @@ -18,7 +20,7 @@ export const LoginPage: FC = () => { return ( <> - Sign in to Coder + Sign in to {applicationName} = ({ // This allows messages to be displayed at the top of the sign in form. // Helpful for any redirects that want to inform the user of something. const info = new URLSearchParams(location.search).get("info") || undefined; + const applicationName = getApplicationName(); + const logoURL = getLogoURL(); + const applicationLogo = logoURL ? ( +
+ {applicationName} (e.currentTarget.style.display = "none")} + onLoad={(e) => (e.currentTarget.style.display = "inline")} + /> +
+ ) : ( + + ); return isLoading ? ( ) : (
- + {applicationLogo} > = ({ // Hide password auth by default if any OAuth method is enabled const [showPasswordAuth, setShowPasswordAuth] = useState(!oAuthEnabled); const styles = useStyles(); + const applicationName = getApplicationName(); return (

- Sign in to Coder + Sign in to {applicationName}

{Boolean(error) && ( diff --git a/site/src/utils/appearance.ts b/site/src/utils/appearance.ts new file mode 100644 index 0000000000000..3e9e3785f0064 --- /dev/null +++ b/site/src/utils/appearance.ts @@ -0,0 +1,16 @@ +export const getApplicationName = (): string => { + const c = document.head + .querySelector(`meta[name=application-name]`) + ?.getAttribute("content"); + // Fallback to "Coder" if the application name is not available for some reason. + // We need to check if the content does not look like {{ .ApplicationName}} + // as it means that Coder is running in development mode (port :8080). + return c && !c.startsWith("{{ .") ? c : "Coder"; +}; + +export const getLogoURL = (): string => { + const c = document.head + .querySelector(`meta[property=logo-url]`) + ?.getAttribute("content"); + return c && !c.startsWith("{{ .") ? c : ""; +};