Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for disabling few website features #1597

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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: 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

- `YOPASS_DISABLE_FEATURES_CARDS=1` - Allows disabling Features cards
- `YOPASS_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.YOPASS_DISABLE_FEATURES_CARDS !== '1';
return (
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
<HashRouter>
<Header />
<Container maxWidth={'lg'}>
<Routing />
<Features />
{features && <Features />}
<Attribution />
</Container>
</HashRouter>
Expand Down
5 changes: 4 additions & 1 deletion website/src/Routing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import DisplaySecret from './displaySecret/DisplaySecret';
import Upload from './createSecret/Upload';

export const Routing = () => {
const oneClickLink = process.env.YOPASS_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.YOPASS_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
4 changes: 4 additions & 0 deletions website/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export default defineConfig(() => {
REACT_APP_FALLBACK_LANGUAGE: process.env.REACT_APP_FALLBACK_LANGUAGE,
START_SERVER_AND_TEST_INSECURE:
process.env.START_SERVER_AND_TEST_INSECURE,
YOPASS_DISABLE_FEATURES_CARDS:
process.env.YOPASS_DISABLE_FEATURES_CARDS,
YOPASS_DISABLE_ONE_CLICK_LINK:
process.env.YOPASS_DISABLE_ONE_CLICK_LINK,
},
},
server: {
Expand Down