@@ -223,7 +246,7 @@ export function IndexerAddForm({ isOpen, toggle }: AddProps) {
diff --git a/web/src/forms/settings/IrcForms.tsx b/web/src/forms/settings/IrcForms.tsx
index 22badd0..7e17750 100644
--- a/web/src/forms/settings/IrcForms.tsx
+++ b/web/src/forms/settings/IrcForms.tsx
@@ -1,5 +1,4 @@
import { useMutation } from "react-query";
-import { Channel, Network } from "../../domain/interfaces";
import { XIcon } from "@heroicons/react/solid";
import { queryClient } from "../../App";
diff --git a/web/src/index.tsx b/web/src/index.tsx
index b3ed6fa..855d9ac 100644
--- a/web/src/index.tsx
+++ b/web/src/index.tsx
@@ -2,21 +2,22 @@ import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
-import {RecoilRoot} from 'recoil';
-import {APP} from "./domain/interfaces";
import App from "./App";
+import { InitializeGlobalContext } from "./utils/Context";
+
declare global {
interface Window { APP: APP; }
}
window.APP = window.APP || {};
+// Initializes auth and theme contexts
+InitializeGlobalContext();
+
ReactDOM.render(
-
-
-
+
,
- document.getElementById('root')
+ document.getElementById("root")
);
diff --git a/web/src/screens/Base.tsx b/web/src/screens/Base.tsx
index bb184ee..704453c 100644
--- a/web/src/screens/Base.tsx
+++ b/web/src/screens/Base.tsx
@@ -1,12 +1,16 @@
-import { Fragment } from 'react'
-import { Disclosure, Menu, Transition } from '@headlessui/react'
-import { ChevronDownIcon, MenuIcon, XIcon } from '@heroicons/react/outline'
+import { Fragment } from "react";
import { NavLink, Link, Route, Switch } from "react-router-dom";
+import { Disclosure, Menu, Transition } from "@headlessui/react";
+import { ChevronDownIcon, MenuIcon, XIcon } from "@heroicons/react/outline";
+
+import Logs from "./Logs";
import Settings from "./Settings";
+
+import { Releases } from "./Releases";
import { Dashboard } from "./Dashboard";
import { FilterDetails, Filters } from "./filters";
-import Logs from './Logs';
-import { Releases } from "./Releases";
+import { AuthContext } from '../utils/Context';
+
import logo from '../logo.png';
function classNames(...classes: string[]) {
@@ -14,10 +18,17 @@ function classNames(...classes: string[]) {
}
export default function Base() {
- const nav = [{ name: 'Dashboard', path: "/" }, { name: 'Filters', path: "/filters" }, { name: 'Releases', path: "/releases" }, { name: "Settings", path: "/settings" }, { name: "Logs", path: "/logs" }]
+ const authContext = AuthContext.useValue();
+ const nav = [
+ { name: 'Dashboard', path: "/" },
+ { name: 'Filters', path: "/filters" },
+ { name: 'Releases', path: "/releases" },
+ { name: "Settings", path: "/settings" },
+ { name: "Logs", path: "/logs" }
+ ];
return (
-
+
{({ open }) => (
<>
@@ -49,12 +60,6 @@ export default function Base() {
return true
}
- // if (item.path ==="/" && location.pathname ==="/") {
- // console.log("match base");
-
- // return true
- // }
-
if (!match) {
return false;
}
@@ -86,7 +91,7 @@ export default function Base() {
className="max-w-xs rounded-full flex items-center text-sm focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-800 focus:ring-white">
- Open user menu for User
+ Open user menu for {authContext.username}
{({ active }) => (
Settings
diff --git a/web/src/screens/Dashboard.tsx b/web/src/screens/Dashboard.tsx
index 34a0570..73fb3e7 100644
--- a/web/src/screens/Dashboard.tsx
+++ b/web/src/screens/Dashboard.tsx
@@ -4,7 +4,6 @@ import App from '../App'
import { useTable, useFilters, useGlobalFilter, useSortBy, usePagination } from 'react-table'
import APIClient from '../api/APIClient'
import { useQuery } from 'react-query'
-import { ReleaseFindResponse, ReleaseStats } from '../domain/interfaces'
import { EmptyListState } from '../components/emptystates'
import { ReleaseStatusCell } from './Releases'
diff --git a/web/src/screens/Releases.tsx b/web/src/screens/Releases.tsx
index a831206..fd8d404 100644
--- a/web/src/screens/Releases.tsx
+++ b/web/src/screens/Releases.tsx
@@ -7,7 +7,6 @@ import { useQuery } from "react-query"
import { useTable, useSortBy, usePagination } from "react-table"
import APIClient from "../api/APIClient"
import { EmptyListState } from "../components/emptystates"
-import { ReleaseActionStatus } from "../domain/interfaces"
import { classNames } from "../utils"
export function Releases() {
@@ -294,24 +293,22 @@ function Table() {
// Render the UI for your table
return (
<>
-
- {/*
*/}
- {/* {headerGroups.map((headerGroup: { headers: any[] }) =>
- headerGroup.headers.map((column) =>
- column.Filter ? (
-
- {column.render("Filter")}
-
- ) : null
- )
- )} */}
-
- {isSuccess ?
+ {isSuccess && data ? (
+ {/*
*/}
+ {/* {headerGroups.map((headerGroup: { headers: any[] }) =>
+ headerGroup.headers.map((column) =>
+ column.Filter ? (
+
+ {column.render("Filter")}
+
+ ) : null
+ )
+ )} */}
@@ -373,7 +370,6 @@ function Table() {
-
{/* Pagination */}
@@ -421,8 +417,7 @@ function Table() {
nextPage()}
- disabled={!canNextPage
- }>
+ disabled={!canNextPage}>
Next
@@ -438,13 +433,11 @@ function Table() {
-
-
- : }
+ ) : }
>
)
}
diff --git a/web/src/screens/Settings.tsx b/web/src/screens/Settings.tsx
index 73cfcda..284a0fc 100644
--- a/web/src/screens/Settings.tsx
+++ b/web/src/screens/Settings.tsx
@@ -1,17 +1,19 @@
import {CogIcon, DownloadIcon, KeyIcon} from '@heroicons/react/outline'
import {NavLink, Route, Switch as RouteSwitch, useLocation, useRouteMatch} from "react-router-dom";
+
import IndexerSettings from "./settings/Indexer";
import IrcSettings from "./settings/Irc";
import ApplicationSettings from "./settings/Application";
import DownloadClientSettings from "./settings/DownloadClient";
import {classNames} from "../utils";
-import ActionSettings from "./settings/Action";
+import { RegexPlayground } from './settings/RegexPlayground';
const subNavigation = [
{name: 'Application', href: '', icon: CogIcon, current: true},
{name: 'Indexers', href: 'indexers', icon: KeyIcon, current: false},
{name: 'IRC', href: 'irc', icon: KeyIcon, current: false},
{name: 'Clients', href: 'clients', icon: DownloadIcon, current: false},
+ // {name: 'Regex Playground', href: 'regex-playground', icon: CogIcon, current: false}
// {name: 'Actions', href: 'actions', icon: PlayIcon, current: false},
// {name: 'Rules', href: 'rules', icon: ClipboardCheckIcon, current: false},
// {name: 'Notifications', href: 'notifications', icon: BellIcon, current: false},
@@ -97,10 +99,13 @@ export default function Settings() {
-
+ {/*
-
+ */}
+
+
+
diff --git a/web/src/screens/auth/login.tsx b/web/src/screens/auth/login.tsx
index 69fc8cf..7d1eec9 100644
--- a/web/src/screens/auth/login.tsx
+++ b/web/src/screens/auth/login.tsx
@@ -1,40 +1,36 @@
-import { useMutation } from "react-query";
-import APIClient from "../../api/APIClient";
-import { Form, Formik } from "formik";
-import { useRecoilState } from "recoil";
-import { isLoggedIn } from "../../state/state";
import { useHistory } from "react-router-dom";
-import { useEffect } from "react";
-import logo from "../../logo.png"
+import { useMutation } from "react-query";
+import { Form, Formik } from "formik";
+
+import APIClient from "../../api/APIClient";
import { TextField, PasswordField } from "../../components/inputs";
-interface loginData {
+import logo from "../../logo.png";
+import { AuthContext } from "../../utils/Context";
+
+interface LoginData {
username: string;
password: string;
}
function Login() {
- const [loggedIn, setLoggedIn] = useRecoilState(isLoggedIn);
- let history = useHistory();
+ const history = useHistory();
+ const [, setAuthContext] = AuthContext.use();
- useEffect(() => {
- if (loggedIn) {
- // setLoading(false);
- history.push('/');
- } else {
- // setLoading(false);
+ const mutation = useMutation(
+ (data: LoginData) => APIClient.auth.login(data.username, data.password),
+ {
+ onSuccess: (_, variables: LoginData) => {
+ setAuthContext({
+ username: variables.username,
+ isLoggedIn: true
+ });
+ history.push("/");
+ },
}
- }, [loggedIn, history])
+ );
- const mutation = useMutation((data: loginData) => APIClient.auth.login(data.username, data.password), {
- onSuccess: () => {
- setLoggedIn(true);
- },
- })
-
- const handleSubmit = (data: any) => {
- mutation.mutate(data)
- }
+ const handleSubmit = (data: any) => mutation.mutate(data);
return (
@@ -45,27 +41,19 @@ function Login() {
alt="logo"
/>
-