Skip to content

Commit

Permalink
Remove default exports
Browse files Browse the repository at this point in the history
Better improves intellisense support
  • Loading branch information
punmechanic committed Aug 28, 2023
1 parent d8a4fd7 commit 69f1b4b
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 47 deletions.
2 changes: 1 addition & 1 deletion frontend/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import { App } from "./App";

it("renders without crashing", () => {
const div = document.createElement("div");
Expand Down
20 changes: 9 additions & 11 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from "react";
import React, { useEffect } from "react";
import { Grid } from "semantic-ui-react";
import Header from "./components/Header";
import History from "./components/History";
import KeyCard from "./components/KeyCard";
import KeyRequestForm from "./components/KeyRequestForm";
import LoginForm from "./components/LoginForm";
import TroubleshootingCard from "./components/TroubleshootingCard";
import { Header } from "./components/Header";
import { History } from "./components/History";
import { KeyCard } from "./components/KeyCard";
import { KeyRequestForm } from "./components/KeyRequestForm";
import { LoginForm } from "./components/LoginForm";
import { TroubleshootingCard } from "./components/TroubleshootingCard";
import { updateUserInfo } from "./actions";

const App = () => {
React.useEffect(() => {
export const App = () => {
useEffect(() => {
// We used to support OneLogin as a provider; this ensures it isn't kept around.
if (localStorage.getItem("provider") !== "okta") {
updateUserInfo({ username: "", password: "" });
Expand Down Expand Up @@ -39,5 +39,3 @@ const App = () => {
</div>
);
};

export default App;
2 changes: 1 addition & 1 deletion frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { Menu } from "semantic-ui-react";

export default function Header() {
export const Header = () => {
return (
<Menu fixed="top" fluid color="grey">
<Menu.Item header>Key Conjurer</Menu.Item>
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/components/History.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import keyConjurerLogo from "./../images/KeyConjurer.png";

const binaryName = process.env.REACT_APP_BINARY_NAME;

const History = () => (
export const History = () => (
<Card fluid>
<Image src={keyConjurerLogo} />
<Card.Content>
Expand Down Expand Up @@ -45,5 +45,3 @@ const History = () => (
</Card.Content>
</Card>
);

export default History;
2 changes: 0 additions & 2 deletions frontend/src/components/KeyCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,3 @@ export AWS_SECURITY_TOKEN=$AWS_SESSION_TOKEN`;
</Card>
);
}

export default KeyCard;
2 changes: 1 addition & 1 deletion frontend/src/components/KeyRequestForm.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import KeyRequestForm from "./KeyRequestForm";
import { KeyRequestForm } from "./KeyRequestForm";
import { cleanup, render } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { update, resetAllStores } from "../stores";
Expand Down
26 changes: 12 additions & 14 deletions frontend/src/components/KeyRequestForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from "react";
import React, { Component, type ChangeEvent } from "react";
import { Message, Form, Card } from "semantic-ui-react";
import { requestKeys } from "../actions";
import { subscribe } from "../stores";
Expand All @@ -7,7 +7,7 @@ const documentationURL = process.env.REACT_APP_DOCUMENTATION_URL;
const timeouts = [1, 2, 3, 4, 5, 6, 7, 8];

interface RoleInputProps {
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
value: string;
}

Expand Down Expand Up @@ -52,7 +52,7 @@ interface State {
requestSent: boolean;
}

class KeyRequestForm extends Component<{}, State> {
export class KeyRequestForm extends Component<{}, State> {
state: State = {
accounts: [],
keyRequest: false,
Expand All @@ -71,17 +71,17 @@ class KeyRequestForm extends Component<{}, State> {

handleChange =
<K extends keyof State>(name: K) =>
(event: React.ChangeEvent<HTMLSelectElement | HTMLInputElement>) => {
if (name === "timeout") {
localStorage.setItem("timeout", event.currentTarget.value);
}
(event: ChangeEvent<HTMLSelectElement | HTMLInputElement>) => {
if (name === "timeout") {
localStorage.setItem("timeout", event.currentTarget.value);
}

this.setState((prevState) => {
return { ...prevState, [name]: event.currentTarget.value };
});
};
this.setState((prevState) => {
return { ...prevState, [name]: event.currentTarget.value };
});
};

setAccount = (event: React.ChangeEvent<HTMLSelectElement>) => {
setAccount = (event: ChangeEvent<HTMLSelectElement>) => {
this.setState({ selectedAccount: event.currentTarget.value });
};

Expand Down Expand Up @@ -259,5 +259,3 @@ class KeyRequestForm extends Component<{}, State> {
);
}
}

export default KeyRequestForm;
18 changes: 8 additions & 10 deletions frontend/src/components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface State {
errorMessage?: string;
}

class LoginForm extends Component<{}, State> {
export class LoginForm extends Component<{}, State> {
state = {
username: "",
password: "",
Expand Down Expand Up @@ -68,13 +68,13 @@ class LoginForm extends Component<{}, State> {

const handleTextChange =
(property: "username" | "password") =>
(_event: unknown, data: { value: string }) => {
const { username, password } = this.state;
updateUserInfo({
username: "username" === property ? data.value : username,
password: "password" === property ? data.value : password,
});
};
(_event: unknown, data: { value: string }) => {
const { username, password } = this.state;
updateUserInfo({
username: "username" === property ? data.value : username,
password: "password" === property ? data.value : password,
});
};

const handleSubmit = () => {
const { username, password } = this.state;
Expand Down Expand Up @@ -125,5 +125,3 @@ class LoginForm extends Component<{}, State> {
);
}
}

export default LoginForm;
4 changes: 1 addition & 3 deletions frontend/src/components/TroubleshootingCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { Card } from "semantic-ui-react";

const TroubleshootingCard = () => {
export const TroubleshootingCard = () => {
return (
<Card fluid>
<Card.Content>
Expand All @@ -14,5 +14,3 @@ const TroubleshootingCard = () => {
</Card>
);
};

export default TroubleshootingCard;
2 changes: 1 addition & 1 deletion frontend/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import { App } from "./App";
import "./index.css";
import "semantic-ui-css/semantic.min.css";

Expand Down

0 comments on commit 69f1b4b

Please sign in to comment.