Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion pkg/app/web/src/components/application-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SyncIcon from "@material-ui/icons/Cached";
import OpenInNewIcon from "@material-ui/icons/OpenInNew";
import Skeleton from "@material-ui/lab/Skeleton/Skeleton";
import { SerializedError } from "@reduxjs/toolkit";
import clsx from "clsx";
import dayjs from "dayjs";
import React, { FC, memo } from "react";
import { useDispatch, useSelector } from "react-redux";
Expand Down Expand Up @@ -51,6 +52,9 @@ const useStyles = makeStyles((theme) => ({
position: "relative",
flexDirection: "column",
},
disabled: {
opacity: 0.6,
},
content: {
flex: 1,
},
Expand Down Expand Up @@ -211,7 +215,13 @@ export const ApplicationDetail: FC<Props> = memo(function ApplicationDetail({
}

return (
<Paper square elevation={1} className={classes.root}>
<Paper
square
elevation={1}
className={clsx(classes.root, {
[classes.disabled]: app?.disabled,
})}
>
<Box flex={1}>
<Box display="flex" alignItems="baseline">
<Typography variant="h5">
Expand Down Expand Up @@ -305,6 +315,7 @@ export const ApplicationDetail: FC<Props> = memo(function ApplicationDetail({
label="select sync strategy"
color="primary"
loading={isSyncing}
disabled={isSyncing || Boolean(app?.disabled)}
onClick={handleSync}
options={syncOptions}
startIcon={<SyncIcon />}
Expand Down
9 changes: 8 additions & 1 deletion pkg/app/web/src/components/application-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { APPLICATION_KIND_TEXT } from "../constants/application-kind";
import { setUpdateTargetId } from "../modules/update-application";
import { DeleteApplicationDialog } from "./delete-application-dialog";
import { setDeletingAppId } from "../modules/delete-application";
import clsx from "clsx";

const useStyles = makeStyles((theme) => ({
root: {
Expand All @@ -56,6 +57,9 @@ const useStyles = makeStyles((theme) => ({
statusText: {
marginLeft: theme.spacing(1),
},
disabledRow: {
background: theme.palette.grey[200],
},
}));

const NOT_AVAILABLE_TEXT = "N/A";
Expand Down Expand Up @@ -184,7 +188,10 @@ export const ApplicationList: FC = memo(function ApplicationList() {
).map((app) => {
const recentlyDeployment = app.mostRecentlySuccessfulDeployment;
return (
<TableRow key={`app-${app.id}`}>
<TableRow
key={`app-${app.id}`}
className={clsx({ [classes.disabledRow]: app.disabled })}
>
<TableCell>
<div className={classes.statusCell}>
{app.syncState ? (
Expand Down
25 changes: 23 additions & 2 deletions pkg/app/web/src/components/application-state-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import React, { FC, memo } from "react";
import { useDispatch, useSelector } from "react-redux";
import { UI_TEXT_REFRESH } from "../constants/ui-text";
import { AppState } from "../modules";
import {
Application,
selectById as selectAppById,
} from "../modules/applications";
import {
ApplicationLiveState,
fetchApplicationStateById,
Expand All @@ -23,6 +27,7 @@ interface Props {
}

const ERROR_MESSAGE = "It was unable to fetch the latest state of application.";
const DISABLED_APPLICATION_MESSAGE = "This application is disabled.";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This application is currently disabled. You can enable it from the application list page."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the message.
Thank you!

image


const useStyles = makeStyles(() => ({
container: {
Expand All @@ -37,14 +42,30 @@ export const ApplicationStateView: FC<Props> = memo(
function ApplicationStateView({ applicationId }) {
const classes = useStyles();
const dispatch = useDispatch();
const [hasError, liveState] = useSelector<
const [hasError, liveState, app] = useSelector<
AppState,
[boolean, ApplicationLiveState | undefined]
[boolean, ApplicationLiveState | undefined, Application | undefined]
>((state) => [
selectHasError(state.applicationLiveState, applicationId),
selectLiveStateById(state.applicationLiveState, applicationId),
selectAppById(state.applications, applicationId),
]);

if (app?.disabled) {
return (
<Box
display="flex"
justifyContent="center"
alignItems="center"
flex={1}
>
<Typography variant="h6" component="span">
{DISABLED_APPLICATION_MESSAGE}
</Typography>
</Box>
);
}

if (hasError) {
return (
<Box className={classes.container} flexDirection="column">
Expand Down
1 change: 1 addition & 0 deletions pkg/app/web/src/components/deployment-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export const DeploymentDetail: FC<Props> = memo(function DeploymentDetail({
}}
startIcon={<CancelIcon />}
loading={isCanceling}
disabled={isCanceling}
/>
)}
</Box>
Expand Down
2 changes: 2 additions & 0 deletions pkg/app/web/src/components/split-button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const overview: React.FC = () => (
startIcon={<CancelIcon />}
options={["Cancel", "Cancel Without Rollback"]}
onClick={action("onClick")}
disabled={false}
loading={false}
/>
);
Expand All @@ -25,5 +26,6 @@ export const loading: React.FC = () => (
options={["Cancel", "Cancel Without Rollback"]}
onClick={action("onClick")}
loading
disabled
/>
);
3 changes: 2 additions & 1 deletion pkg/app/web/src/components/split-button.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import userEvent from "@testing-library/user-event";
import React from "react";
import { render, screen, act } from "../../test-utils";
import { act, render, screen } from "../../test-utils";
import { SplitButton } from "./split-button";

it("calls onClick handler with option's index if clicked", () => {
Expand All @@ -9,6 +9,7 @@ it("calls onClick handler with option's index if clicked", () => {
<SplitButton
label="select option"
loading={false}
disabled={false}
onClick={onClick}
options={["option1", "option2"]}
/>,
Expand Down
6 changes: 4 additions & 2 deletions pkg/app/web/src/components/split-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface Props {
label: string;
onClick: (index: number) => void;
startIcon?: React.ReactNode;
disabled: boolean;
loading: boolean;
color?: PropTypes.Color;
className?: string;
Expand All @@ -38,6 +39,7 @@ interface Props {
export const SplitButton: FC<Props> = ({
onClick,
options,
disabled,
loading,
startIcon,
className,
Expand All @@ -55,12 +57,12 @@ export const SplitButton: FC<Props> = ({
variant="outlined"
color={color || "inherit"}
ref={anchorRef}
disabled={loading}
disabled={disabled}
>
<Button
startIcon={startIcon}
onClick={() => onClick(selectedCancelOption)}
disabled={loading}
disabled={disabled}
>
{options[selectedCancelOption]}
{loading && (
Expand Down