Select Git revision
-
millosolomillo authored
* [DJ1.11] Use a dict instead of django.template.Context * [Travis] update travis badge to match current branch * [Travis] Emit all warnings during tests * [DJ1.9] Remove warning of not declaring explicit app_label Example: RemovedInDjango19Warning: Model class helios.models.Voter doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9. (cherry picked from commit 693acef9e4c3b093d5bf2bc1655e6f53a6dd4007) * [DJ1.10] list of urlpatterns is a list of url() instead of a patterns() result * [DJ1.10] Support for string view arguments to url() will be removed * [DJ1.9] Add used django.contrib apps in installed apps * Remove traces of south (now unused) * Upgrade celery * [DJ1.9] Fix some imports for django 1.9 * A bit more homogeneous redirect creation * Improvements to tests * [DJ1.9] Pre-fix tests for Django 1.9 * Fixed election sorting in admin elections page * [DJ1.10] Redefine template settings * [Travis] Upgrade pip instead of fixing setuptools' version * [DJ1.9] Cannot import models from a django-app init (even as third-party import) * Use urlparse.parse_qs instead of cgi.parse_qs (deprecated) * Explicit some more imports removing almost all conflicting 'import *' * Restore functionality of extract-passwords-for-email * Upgrade Django to 1.9 * [DJ1.10] SubfieldBase has been deprecated. Use Field.from_db_value instead. * Silence urls.W002 warning. Slashes aren't deemed necessary at start of URL patterns, but the actual check author recognized the too-strict approach for his check: https://stackoverflow.com/a/41450355 * [DJ2] on_delete will be a required arg for ForeignKey, currently defaults to models.CASCADE. * [DJ1.10] Upgrade Celery to 4.2.1, Kombu to 4.2.0 Should probably integrate with django-celery-results and/or django-celery-beat * [DJ2] SelectDateWidget is moved out of extras * [tests] Extend setup_login capabilities * [tests] Add admin user fixture and test accessibility of stats * [DJ1.10] Update stats_urls to have names and be reversed by name * [DJ1.10] Update election_urls to have names and be reversed by name * [DJ1.10] reverse function is now in django.urls * [DJ1.10] Update helios.urls to have names and be reversed by name * Make stats_url_names and election_url_names visible from url_names * [DJ1.10] Update helios_auth.urls to have names and be reversed by name * [DJ1.10] Upgrade to Django 1.10 * [DJ1.11] Fix widgets * [DJ1.11] Upgrade to Django 1.11 * [Travis] Test to run travis on both Xenial and Trusty * [Travis] Postgres 9.3 isn't present in Xenial * Fix csrf_token on perms_why * [DJ2] Update HSTS Middleware to latest definition * Bump Django to 1.11.28 * [DJ1.8+] remove unneeded django-sslify and django-secure * [celery] Make celery backend configurable Also only use eager using testing, even if it is not recommended * [readme] revert travis badge to benadida/helios-server * add recent significant contributors Co-authored-by:
Marco Ciotola <848222@stud.unive.it> Co-authored-by:
Douglas Cerna (Soy Douglas) <douglascerna@yahoo.com> Co-authored-by:
Ben Adida <ben@adida.net>
millosolomillo authored* [DJ1.11] Use a dict instead of django.template.Context * [Travis] update travis badge to match current branch * [Travis] Emit all warnings during tests * [DJ1.9] Remove warning of not declaring explicit app_label Example: RemovedInDjango19Warning: Model class helios.models.Voter doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9. (cherry picked from commit 693acef9e4c3b093d5bf2bc1655e6f53a6dd4007) * [DJ1.10] list of urlpatterns is a list of url() instead of a patterns() result * [DJ1.10] Support for string view arguments to url() will be removed * [DJ1.9] Add used django.contrib apps in installed apps * Remove traces of south (now unused) * Upgrade celery * [DJ1.9] Fix some imports for django 1.9 * A bit more homogeneous redirect creation * Improvements to tests * [DJ1.9] Pre-fix tests for Django 1.9 * Fixed election sorting in admin elections page * [DJ1.10] Redefine template settings * [Travis] Upgrade pip instead of fixing setuptools' version * [DJ1.9] Cannot import models from a django-app init (even as third-party import) * Use urlparse.parse_qs instead of cgi.parse_qs (deprecated) * Explicit some more imports removing almost all conflicting 'import *' * Restore functionality of extract-passwords-for-email * Upgrade Django to 1.9 * [DJ1.10] SubfieldBase has been deprecated. Use Field.from_db_value instead. * Silence urls.W002 warning. Slashes aren't deemed necessary at start of URL patterns, but the actual check author recognized the too-strict approach for his check: https://stackoverflow.com/a/41450355 * [DJ2] on_delete will be a required arg for ForeignKey, currently defaults to models.CASCADE. * [DJ1.10] Upgrade Celery to 4.2.1, Kombu to 4.2.0 Should probably integrate with django-celery-results and/or django-celery-beat * [DJ2] SelectDateWidget is moved out of extras * [tests] Extend setup_login capabilities * [tests] Add admin user fixture and test accessibility of stats * [DJ1.10] Update stats_urls to have names and be reversed by name * [DJ1.10] Update election_urls to have names and be reversed by name * [DJ1.10] reverse function is now in django.urls * [DJ1.10] Update helios.urls to have names and be reversed by name * Make stats_url_names and election_url_names visible from url_names * [DJ1.10] Update helios_auth.urls to have names and be reversed by name * [DJ1.10] Upgrade to Django 1.10 * [DJ1.11] Fix widgets * [DJ1.11] Upgrade to Django 1.11 * [Travis] Test to run travis on both Xenial and Trusty * [Travis] Postgres 9.3 isn't present in Xenial * Fix csrf_token on perms_why * [DJ2] Update HSTS Middleware to latest definition * Bump Django to 1.11.28 * [DJ1.8+] remove unneeded django-sslify and django-secure * [celery] Make celery backend configurable Also only use eager using testing, even if it is not recommended * [readme] revert travis badge to benadida/helios-server * add recent significant contributors Co-authored-by:
Marco Ciotola <848222@stud.unive.it> Co-authored-by:
Douglas Cerna (Soy Douglas) <douglascerna@yahoo.com> Co-authored-by:
Ben Adida <ben@adida.net>
App.js 7.51 KiB
import React, { Suspense, useEffect, useState } from "react";
import { Helmet } from "react-helmet";
import ReactHintFactory from "react-hint";
import {
BrowserRouter as Router,
Link,
Route,
Switch,
useLocation,
} from "react-router-dom";
import { ReactKeycloakProvider as KeycloakProvider } from "@react-keycloak/web";
import { ExtraErrorData } from "@sentry/integrations/dist/extraerrordata";
import * as Sentry from "@sentry/react";
import { Integrations } from "@sentry/tracing";
import classNames from "classnames";
import MobileNav from "components/MobileNav";
import { basics } from "config";
import Transportation from "pages/Transportation";
import VNav from "./components/VNav";
import Accommodation from "./pages/Accommodation";
import Catering from "./pages/Catering";
import Home from "./pages/Home";
import LeaderElection from "./pages/LeaderElection";
import Map from "./pages/Map";
import Party from "./pages/Party";
import Program from "./pages/Program";
import Registration from "./pages/Registration";
import Team from "./pages/Team";
import Volunteers from "./pages/Volunteers";
import Workshops from "./pages/Workshops";
import Meeting from "./pages/Meeting";
import Disabled from "./pages/Disabled";
import KidsnFun from "./pages/KidsnFun";
import Payment from "./pages/Payment";
import cfLogo from "./cf2023_kormidlo_lod.svg";
import keycloak from "./keycloak";
import partyLogo from "./logo-full-black.svg";
import "./styles.css";
/**
* If configured, set up Sentry client that reports uncaught errors down to
* https://sentry.io.
*/
if (process.env.REACT_APP_SENTRY_DSN) {
Sentry.init({
dsn: process.env.REACT_APP_SENTRY_DSN,
tracesSampleRate: 0.1,
integrations: [new ExtraErrorData(), new Integrations.BrowserTracing()],
});
}
const ReactHint = ReactHintFactory(React);
function AppHeaderVenueInfo() {
const location = useLocation();
const isRoot = location.pathname === "/";
const [mobileNavOpen, setMobnileNavOpen] = useState(false);
// Close menu on navigation
useEffect(() => {
setMobnileNavOpen(false);
}, [location]);
return (
<>
<MobileNav
isOpen={mobileNavOpen}
onClose={() => setMobnileNavOpen(false)}
/>
<div className="flex justify-center space-x-4 md:space-x-0 md:block md:text-right md:ml-auto head-alt-xs md:head-alt-base">
<h2>{process.env.REACT_APP_CF_EVENT_DATE}</h2>
<h2>{process.env.REACT_APP_CF_EVENT_CITY}</h2>
<h2>{process.env.REACT_APP_CF_EVENT_VENUE}</h2>
</div>
{/* Mobile nav trigger */}
<div
className={classNames({
"mt-4 block md:hidden": !isRoot,
hidden: isRoot,
})}
>
<button
className="head-alt-base"
onClick={() => setMobnileNavOpen(true)}
>
Menu
</button>
</div>
</>
);
}
function PageBody() {
const location = useLocation();
const isRoot = location.pathname === "/";
return (
<div
className={classNames({
"flex flex-col md:flex-row md:space-x-8": !isRoot,
})}
>
<Switch>
<Route path="/registrace">
<Registration />
</Route>
<Route path="/stravovani">
<Catering />
</Route>
<Route path="/organizatori">
<Team />
</Route>
<Route path="/ubytovani">
<Accommodation />
</Route>
<Route path="/mapa">
<Map />
</Route>
<Route path="/program">
<Program />
</Route>
<Route path="/doprava">
<Transportation />
</Route>
<Route path="/pro-dobrovolniky">
<Volunteers />
</Route>
<Route path="/party">
<Party />
</Route>
<Route path="/volba-predsednictva">
<LeaderElection />
</Route>
<Route path="/workshopy">
<Workshops />
</Route>
<Route path="/zasedani">
<Meeting />
</Route>
<Route path="/hendikepovani">
<Disabled />
</Route>
<Route path="/deti-a-zabava">
<KidsnFun />
</Route>
<Route path="/platba/:id">
<Payment />
</Route>
<Route path="/">
<Home />
</Route>
</Switch>
{!isRoot && (
<VNav className="hidden md:block mt-8 md:mt-0 md:w-1/4 p-4 md:p-8" />
)}
</div>
);
}
function BaseApp() {
const year = new Date().getFullYear();
return (
<Router>
<Helmet>
<title>{basics.appTitle} | Pirátská strana</title>
<meta name="description" content={basics.appDesc} />
</Helmet>
<div className="container container--default my-4 md:my-16 space-y-8 md:space-y-16">
<header className="md:flex items-center text-center md:text-left">
<h1 className="head-alt-lg md:head-alt-xl cf-app-title">
<Link to="/" className="no-underline hover:no-underline">
{basics.appTitle}
</Link>
</h1>
<AppHeaderVenueInfo />
</header>
<PageBody />
<footer className="border-t border-grey-125 pt-4 flex flex-col md:flex-row items-center md:justify-between space-y-4 text-center md:text-left">
<img src={partyLogo} className="w-32" alt="Pirátská strana" />
<p>Piráti, {year}. Všechna práva vyhlazena.</p>
</footer>
</div>
<ReactHint
autoPosition
events
attribute="data-tip"
className="tooltip"
onRenderContent={(target, content) => (
<span className="block max-w-xs leading-tight">{content}</span>
)}
/>
</Router>
);
}
const LoadingComponent = (
<div className="h-screen w-screen flex justify-center items-center">
<div className="text-center">
<div className="flex flex-col md:flex-row items-center space-x-4 text-center mb-2">
<img
src={cfLogo}
alt="CF 2023"
className="hidden lg:block w-32 mr-16"
/>
</div>
</div>
</div>
);
const AuthenticatedApp = () => {
const keycloakInitConfig = {
onLoad: "check-sso",
// Necessary to prevent Keycloak cookie issues:
// @see: https://stackoverflow.com/a/63588334/303184
checkLoginIframe: false,
};
const onKeycloakEvent = async (event) => {
if (["onAuthRefreshSuccess", "onAuthSuccess"].includes(event)) {
Sentry.setUser(keycloak.tokenParsed);
}
};
return (
<>
<KeycloakProvider
authClient={keycloak}
initOptions={keycloakInitConfig}
LoadingComponent={LoadingComponent}
onEvent={onKeycloakEvent}
>
<Suspense fallback={LoadingComponent}>
<BaseApp />
</Suspense>
</KeycloakProvider>
</>
);
};
const ErrorBoundaryFallback = ({ error }) => {
return (
<div className="h-screen w-screen flex justify-center items-center">
<div className="text-center">
<h1 className="head-alt-xl text-red-600 mb-4">
V aplikaci došlo k chybě :(
</h1>
<p className="text-lg leading-normal">
Naši vývojáři o tom již byli informování a opraví to co nejdříve.
<br />
Omlouváme se za tuto nepříjemnost.
</p>
<a href="/" className="btn mt-8">
<div className="btn__body">Načíst znovu</div>
</a>
</div>
</div>
);
};
const App = Sentry.withProfiler(() => {
return (
<Sentry.ErrorBoundary fallback={ErrorBoundaryFallback} showDialog>
<AuthenticatedApp />
</Sentry.ErrorBoundary>
);
});
export default App;