Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
steverydz committed Aug 2, 2023
1 parent 6fe0791 commit 2e1b870
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ import type { SigningKey } from "../../types/shared";

type Props = {
setShowNotification: Function;
setShowErrorNotification: Function;
setErrorMessage: Function;
refetch: Function;
};

function CreateSigningKeyForm({
setShowNotification,
setShowErrorNotification,
setErrorMessage,
refetch,
}: Props) {
Expand All @@ -42,7 +40,6 @@ function CreateSigningKeyForm({
navigate(`/admin/${id}/signing-keys`);
setNewSigningKey({ name: "" });
setTimeout(() => {
setShowErrorNotification(false);
setErrorMessage("");
}, 5000);
};
Expand Down Expand Up @@ -81,7 +78,6 @@ function CreateSigningKeyForm({
const signingKeysData = await response.json();

if (!signingKeysData.success) {
setShowErrorNotification(true);
setErrorMessage(signingKeysData.message);
throw new Error(signingKeysData.message);
}
Expand Down Expand Up @@ -149,7 +145,6 @@ function CreateSigningKeyForm({
onClick={() => {
navigate(`/admin/${id}/signing-keys`);
setNewSigningKey({ name: "" });
setShowErrorNotification(false);
setErrorMessage("");
}}
>
Expand Down
14 changes: 3 additions & 11 deletions static/js/brand-store/components/SigningKeys/SigningKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import {
} from "react-router-dom";
import { Row, Col, Notification } from "@canonical/react-components";

import { sortByDateDescending } from "../../utils";

import { useSigningKeys, useModels } from "../../hooks";

import {
signingKeysListState,
signingKeysListFilterState,
Expand All @@ -25,7 +22,7 @@ import SigningKeysFilter from "./SigningKeysFilter";
import SigningKeysTable from "./SigningKeysTable";
import CreateSigningKeyForm from "./CreateSigningKeyForm";

import { isClosedPanel, setPageTitle } from "../../utils";
import { isClosedPanel, setPageTitle, sortByDateDescending } from "../../utils";

import type { SigningKey, Model, Policy } from "../../types/shared";

Expand Down Expand Up @@ -68,9 +65,6 @@ function SigningKeys() {
const brandStore = useRecoilValue(brandStoreState(id));
const [searchParams] = useSearchParams();
const [showNotification, setShowNotification] = useState<boolean>(false);
const [showErrorNotification, setShowErrorNotification] = useState<boolean>(
false
);
const [errorMessage, setErrorMessage] = useState<string>("");
const [
showDisableSuccessNotification,
Expand Down Expand Up @@ -116,12 +110,11 @@ function SigningKeys() {
</Notification>
</div>
)}
{showErrorNotification && errorMessage && (
{errorMessage && (
<div className="u-fixed-width">
<Notification
severity="negative"
onDismiss={() => {
setShowErrorNotification(false);
setErrorMessage("");
}}
>
Expand Down Expand Up @@ -176,7 +169,7 @@ function SigningKeys() {
}`}
onClick={() => {
navigate(`/admin/${id}/signing-keys`);
setShowErrorNotification(false);
setErrorMessage("");
}}
></div>
<aside
Expand All @@ -187,7 +180,6 @@ function SigningKeys() {
{!isClosedPanel(location.pathname, "create") && (
<CreateSigningKeyForm
setShowNotification={setShowNotification}
setShowErrorNotification={setShowErrorNotification}
setErrorMessage={setErrorMessage}
refetch={refetch}
/>
Expand Down

0 comments on commit 2e1b870

Please sign in to comment.