Skip to content

Commit

Permalink
fix(browser-extension): open preferences by default. closes #100
Browse files Browse the repository at this point in the history
  • Loading branch information
dennyabrain authored and duggalsu committed Oct 24, 2023
1 parent 6f4e950 commit 126a1ca
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 33 deletions.
8 changes: 7 additions & 1 deletion browser-extension/plugin/src/options.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import ReactDOM from 'react-dom';
import { BrowserRouter as Router } from 'react-router-dom';
import { App } from './ui-components/pages/App';

const app = document.getElementById('app');
ReactDOM.render(<App />, app);
ReactDOM.render(
<Router>
<App />
</Router>,
app
);
63 changes: 31 additions & 32 deletions browser-extension/plugin/src/ui-components/pages/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { Grommet, Box, Text, Button } from 'grommet';
import { useTranslation } from 'react-i18next';
import Theme from '../atoms/Theme';
import { Link, BrowserRouter, Routes, Route } from 'react-router-dom';
import { Link, Routes, Route, useNavigate } from 'react-router-dom';
import { Debug } from './Debug';
import { Preferences } from './Preferences';
import { Resources } from './Resources';
Expand All @@ -20,6 +20,7 @@ export function App() {
const { t, i18n } = useTranslation();
const { registerNewUser } = Api;
const { getUserData, setUserData } = repository;
let navigate = useNavigate();

function showNotification(notification) {
setNotification(notification);
Expand Down Expand Up @@ -52,6 +53,7 @@ export function App() {
const user = data.user;
await setUserData(user);
setUser(user);
navigate('/preferences');
}

return (
Expand Down Expand Up @@ -101,51 +103,48 @@ export function App() {
</Box>

{user ? (
<BrowserRouter>
<nav>
<Box direction="row" gap={'medium'}>
<Link id="app_nav_preference" to="/">
{t('navigation_preferences')}
</Link>
<Link
id="app_nav_archive"
to="/archive"
>
{t('navigation_archive')}
</Link>
<Link
id="app_nav_resources"
to="/resources"
>
{t('navigation_resources')}
</Link>
<Link to="/debug">
{t('navigation_debug')}
</Link>
</Box>
</nav>
<div>
<Box direction="row" gap={'medium'}>
<Link
id="app_nav_preference"
to="/preferences"
>
{t('navigation_preferences')}
</Link>
<Link id="app_nav_archive" to="/archive">
{t('navigation_archive')}
</Link>
<Link
id="app_nav_resources"
to="/resources"
>
{t('navigation_resources')}
</Link>
<Link to="/debug">
{t('navigation_debug')}
</Link>
</Box>

<Box height={'2.0em'} />

<Routes>
<Route></Route>
<Route
exact
path={`/`}
path="/preferences"
element={<Preferences />}
/>
<Route
path={`/archive`}
path="archive"
element={<Archive />}
/>
<Route
path={`/resources`}
path="resources"
element={<Resources />}
/>
<Route
path={`/debug`}
element={<Debug />}
/>
<Route path="debug" element={<Debug />} />
</Routes>
</BrowserRouter>
</div>
) : (
<Box>
<Button
Expand Down

0 comments on commit 126a1ca

Please sign in to comment.