Enable disabled app row to be clicked and nav to details (#3720)
This commit is contained in:
parent
2ce10652a5
commit
df6cb4979e
2 changed files with 26 additions and 9 deletions
|
@ -19,15 +19,25 @@ const Header: React.FC<HeaderProps> = ({
|
||||||
onAppDeactivateOpen,
|
onAppDeactivateOpen,
|
||||||
onAppDeleteOpen,
|
onAppDeleteOpen,
|
||||||
}) => {
|
}) => {
|
||||||
|
const getBackButtonUrl = () => {
|
||||||
/**
|
/**
|
||||||
* App is null with first render so fallback with HTML-safe fallback
|
* App is null with first render so fallback with HTML-safe fallback
|
||||||
*/
|
*/
|
||||||
const backButtonTarget = data?.id ? AppUrls.resolveAppUrl(data.id) : "#";
|
if (!data?.id) {
|
||||||
|
return "#";
|
||||||
|
}
|
||||||
|
|
||||||
|
const isAppActive = data.isActive;
|
||||||
|
|
||||||
|
return isAppActive
|
||||||
|
? AppUrls.resolveAppUrl(data.id)
|
||||||
|
: AppUrls.resolveAppListUrl();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TopNav
|
<TopNav
|
||||||
href={backButtonTarget}
|
href={getBackButtonUrl()}
|
||||||
title={
|
title={
|
||||||
<>
|
<>
|
||||||
{data?.name} {!data?.isActive && <DeactivatedText />}
|
{data?.name} {!data?.isActive && <DeactivatedText />}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { appsMessages } from "@dashboard/apps/messages";
|
import { appsMessages } from "@dashboard/apps/messages";
|
||||||
import { InstalledApp } from "@dashboard/apps/types";
|
import { InstalledApp } from "@dashboard/apps/types";
|
||||||
import { AppUrls } from "@dashboard/apps/urls";
|
import { AppPaths, AppUrls } from "@dashboard/apps/urls";
|
||||||
import { isAppInTunnel } from "@dashboard/apps/utils";
|
import { isAppInTunnel } from "@dashboard/apps/utils";
|
||||||
import Link from "@dashboard/components/Link";
|
import Link from "@dashboard/components/Link";
|
||||||
import { Box, Chip, List, sprinkles, Text } from "@saleor/macaw-ui/next";
|
import { Box, Chip, List, sprinkles, Text } from "@saleor/macaw-ui/next";
|
||||||
|
@ -19,13 +19,20 @@ export const InstalledAppListRow: React.FC<InstalledApp> = props => {
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Active app will redirect to app iframe, but disabled app is likely not going to work - so iframe is blocked.
|
||||||
|
* Link will point to app "manage" screen where app can be enabled or uninstalled
|
||||||
|
*/
|
||||||
|
const appUrl = app.isActive
|
||||||
|
? AppUrls.resolveAppUrl(app.id)
|
||||||
|
: AppPaths.resolveAppDetailsPath(app.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
href={AppUrls.resolveAppUrl(app.id)}
|
href={appUrl}
|
||||||
state={{ from: location.pathname }}
|
state={{ from: location.pathname }}
|
||||||
className={sprinkles({ display: "contents" })}
|
className={sprinkles({ display: "contents" })}
|
||||||
inline={false}
|
inline={false}
|
||||||
disabled={!app.isActive}
|
|
||||||
>
|
>
|
||||||
<List.Item
|
<List.Item
|
||||||
padding={4}
|
padding={4}
|
||||||
|
@ -40,7 +47,7 @@ export const InstalledAppListRow: React.FC<InstalledApp> = props => {
|
||||||
default: !app.isActive ? "surfaceNeutralSubdued" : undefined,
|
default: !app.isActive ? "surfaceNeutralSubdued" : undefined,
|
||||||
hover: "surfaceNeutralSubdued",
|
hover: "surfaceNeutralSubdued",
|
||||||
}}
|
}}
|
||||||
cursor={app.isActive ? "pointer" : "not-allowed"}
|
cursor={"pointer"}
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
gap={2}
|
gap={2}
|
||||||
|
|
Loading…
Reference in a new issue