Skip to content

Commit

Permalink
feat: hide ssl config when ssl auto disabled (closes #210)
Browse files Browse the repository at this point in the history
  • Loading branch information
gempain committed Mar 24, 2021
1 parent 236401c commit 772eee9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions server/src/system/handlers/system-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import { env } from '../../env/env';
export function systemEnv(req: Request, res: Response) {
res.json({
MELI_URL: env.MELI_URL,
MELI_HTTPS_AUTO: env.MELI_HTTPS_AUTO,
});
}
18 changes: 11 additions & 7 deletions ui/src/components/sites/settings/DomainForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import styles from './DomainForm.module.scss';
import { maxLength, required } from '../../../commons/components/forms/form-constants';
import { InputError } from '../../../commons/components/forms/InputError';
import { Hint } from '../../../commons/components/Hint';
import { useEnv } from '../../../providers/EnvProvider';

type SslConfigurationType = SiteDomain['sslConfiguration']['type'];

Expand All @@ -15,7 +16,7 @@ function Config({
}: { sslType: SslConfigurationType; input: string; item: SiteDomain }) {
switch (sslType) {
case 'manual':
return <ManualConfig input={input} item={item} />;
return <ManualConfig input={input} item={item}/>;
default:
return <></>;
}
Expand All @@ -39,7 +40,7 @@ export function ManualConfig({ input, item }: { input: string; item: SiteDomain
defaultValue={(item.sslConfiguration as ManualSslConfiguration)?.fullchain}
className="form-control"
/>
<InputError error={errors} path={sslFullchain} />
<InputError error={errors} path={sslFullchain}/>
</div>
</div>
<div className="form-row d-flex align-items-center">
Expand All @@ -52,10 +53,10 @@ export function ManualConfig({ input, item }: { input: string; item: SiteDomain
defaultValue={(item.sslConfiguration as ManualSslConfiguration)?.privateKey}
className="form-control"
/>
<InputError error={errors} path={sslPrivateKey} />
<InputError error={errors} path={sslPrivateKey}/>
</div>
</div>
<hr />
<hr/>
</>
);
}
Expand All @@ -70,6 +71,7 @@ export function DomainForm({
const {
register, errors, getValues, control, watch,
} = useFormContext();
const env = useEnv();

const input = `domains[${index}]`;
const nameInput = `${input}.name`;
Expand Down Expand Up @@ -99,7 +101,7 @@ export function DomainForm({
placeholder="docs.domain.com"
defaultValue={item.name}
/>
<InputError error={errors} path={nameInput} />
<InputError error={errors} path={nameInput}/>
</div>
<div className="form-group col flex-grow-0">
<button type="button" className="btn btn-danger" onClick={() => remove()}>
Expand All @@ -121,7 +123,9 @@ export function DomainForm({
defaultValue={item?.exposeBranches}
/>
</div>
<div className="form-group">
<div className={classNames('form-group', {
'd-none': !env.MELI_HTTPS_AUTO,
})}>
<Controller
control={control}
name={sslTypeToggle}
Expand All @@ -133,7 +137,7 @@ export function DomainForm({
defaultValue={item?.sslConfiguration?.type ?? 'acme'}
/>
<div className="mt-3">
<Config sslType={sslType} input={input} item={item} />
<Config sslType={sslType} input={input} item={item}/>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions ui/src/providers/EnvProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { AlertError } from '../commons/components/AlertError';

export interface Env {
MELI_URL: string;
MELI_HTTPS_AUTO: string;
}

const Context = createContext<Env>(undefined as any);
Expand Down

0 comments on commit 772eee9

Please sign in to comment.