Skip to content

Commit

Permalink
Fix opening panels in production. (#1466)
Browse files Browse the repository at this point in the history
  • Loading branch information
huwshimi authored May 3, 2023
1 parent d7297fc commit 2d1b212
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/components/ModelTableList/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ export function generateAccessButton(
) {
return (
<button
onClick={() => {
onClick={(event) => {
event.stopPropagation();
setPanelQs(
{
model: modelName,
Expand Down
7 changes: 4 additions & 3 deletions src/pages/ControllersIndex/ControllersIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ function Details() {
<div className="controllers--register">
<button
className="p-button--positive"
onClick={() =>
setPanelQs({ panel: "register-controller" }, { replace: true })
}
onClick={(event) => {
event.stopPropagation();
setPanelQs({ panel: "register-controller" }, { replace: true });
}}
>
Register a controller
</button>
Expand Down
9 changes: 7 additions & 2 deletions src/pages/EntityDetails/App/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Button, MainTable, Icon } from "@canonical/react-components";
import { Field, Formik } from "formik";
import type { MouseEvent } from "react";
import { useMemo, useRef, useState } from "react";
import { useSelector } from "react-redux";
import { Link, useParams } from "react-router-dom";
Expand Down Expand Up @@ -173,7 +174,8 @@ export default function App(): JSX.Element {
});

const application = entity ? applications?.[entity] : null;
const showConfig = () => {
const showConfig = (event: MouseEvent) => {
event.stopPropagation();
setQuery(
{ panel: "config", entity, charm: application?.["charm-url"], modelUUID },
{ replace: true }
Expand Down Expand Up @@ -310,7 +312,10 @@ export default function App(): JSX.Element {
appearance="base"
className="entity-details__action-button"
hasIcon={true}
onClick={showActions}
onClick={(event: MouseEvent) => {
event.stopPropagation();
showActions();
}}
disabled={!enableActionButtonRow}
data-testid={TestId.RUN_ACTION_BUTTON}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Button, MainTable, Icon } from "@canonical/react-components";
import { Button, Icon, MainTable } from "@canonical/react-components";
import type { MainTableRow } from "@canonical/react-components/dist/components/MainTable/MainTable";
import classnames from "classnames";
import Fuse from "fuse.js";
import type { MouseEvent } from "react";
import { useEffect, useMemo, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useParams } from "react-router-dom";

import ChipGroup from "components/ChipGroup/ChipGroup";
import type { Chip } from "components/ChipGroup/ChipGroup";
import ChipGroup from "components/ChipGroup/ChipGroup";
import ContentReveal from "components/ContentReveal/ContentReveal";
import type { EntityDetailsRoute } from "components/Routes/Routes";
import useAnalytics from "hooks/useAnalytics";
Expand Down Expand Up @@ -72,7 +73,8 @@ function SearchResultsActionsRow() {
panel: null,
});

const handleRunAction = async () => {
const handleRunAction = async (event: MouseEvent) => {
event.stopPropagation();
sendAnalytics({
category: "ApplicationSearch",
action: "Run action (button)",
Expand Down
7 changes: 4 additions & 3 deletions src/pages/EntityDetails/Model/Model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ const Model = () => {
) && (
<button
className="entity-details__action-button"
onClick={() =>
setQuery({ panel: "share-model" }, { replace: true })
}
onClick={(event) => {
event.stopPropagation();
setQuery({ panel: "share-model" }, { replace: true });
}}
>
<i className="p-icon--share"></i>
{Label.ACCESS_BUTTON}
Expand Down
7 changes: 4 additions & 3 deletions src/panels/ActionsPanel/CharmActionsPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { Button } from "@canonical/react-components";
import type { MutableRefObject } from "react";
import type { MouseEvent, MutableRefObject } from "react";
import { useCallback, useMemo, useRef, useState } from "react";
import reactHotToast from "react-hot-toast";
import { useSelector } from "react-redux";
Expand Down Expand Up @@ -165,7 +165,8 @@ export default function CharmActionsPanel(): JSX.Element {
return SubmitConfirmation(
selectedAction,
selectedApplications,
() => {
(event) => {
event.stopPropagation();
setConfirmType("");
executeAction();
setQueryParams({ panel: null }, { replace: true });
Expand Down Expand Up @@ -243,7 +244,7 @@ function onValuesChange(
function SubmitConfirmation(
actionName: string,
applications: ApplicationInfo[],
confirmFunction: () => void,
confirmFunction: (event: MouseEvent) => void,
cancelFunction: () => void
): JSX.Element {
const applicationCount = applications.length;
Expand Down

0 comments on commit 2d1b212

Please sign in to comment.