Skip to content

Commit

Permalink
Add support for disabling few website features
Browse files Browse the repository at this point in the history
- Toggle for Features cards
- Toggle for "One-click link"
  • Loading branch information
Neverous committed Feb 15, 2023
1 parent 461243e commit ec36235
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ After adding your LOCALE.json file(s) in `./public/locales/`, build the website
```bash
PUBLIC_URL='https://my-domain.com' REACT_APP_BACKEND_URL='http://api.my-domain.com' REACT_APP_FALLBACK_LANGUAGE=en yarn build
```

## Additional options

- `REACT_APP_DISABLE_FEATURES_CARDS=1` - Allows disabling Features cards
- `REACT_APP_DISABLE_ONE_CLICK_LINK=1` - Allows disabling "One-click link" support
3 changes: 2 additions & 1 deletion website/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ const App = () => {
});
}

const features = process.env.REACT_APP_DISABLE_FEATURES_CARDS !== '1';
return (
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
<HashRouter>
<Header />
<Container maxWidth={'lg'}>
<Routing />
<Features />
{features && <Features />}
<Attribution />
</Container>
</HashRouter>
Expand Down
3 changes: 2 additions & 1 deletion website/src/Routing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import DisplaySecret from './displaySecret/DisplaySecret';
import Upload from './createSecret/Upload';

export const Routing = () => {
const oneClickLink = process.env.REACT_APP_DISABLE_ONE_CLICK_LINK !== '1';
return (
<Routes>
<Route path="/" element={<CreateSecret />} />
<Route path="/upload" element={<Upload />} />
<Route path="/:format/:key/:password" element={<DisplaySecret />} />
{oneClickLink && <Route path="/:format/:key/:password" element={<DisplaySecret />} />}
<Route path="/:format/:key" element={<DisplaySecret />} />
</Routes>
);
Expand Down
3 changes: 2 additions & 1 deletion website/src/displaySecret/Result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const Result = ({ uuid, password, prefix, customPassword }: ResultProps) => {
`${window.location.protocol}//${window.location.host}`) + `/#/${prefix}`;
const short = `${base}/${uuid}`;
const full = `${short}/${password}`;
const oneClickLink = process.env.REACT_APP_DISABLE_ONE_CLICK_LINK !== '1';
const { t } = useTranslation();

return (
Expand All @@ -39,7 +40,7 @@ const Result = ({ uuid, password, prefix, customPassword }: ResultProps) => {
<TableContainer>
<Table>
<TableBody>
{!customPassword && (
{oneClickLink && !customPassword && (
<Row label={t('result.rowLabelOneClick')} value={full} />
)}
<Row label={t('result.rowLabelShortLink')} value={short} />
Expand Down

0 comments on commit ec36235

Please sign in to comment.