-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4147 from weaveworks/AddCommentToSuspendAction
Add comment to suspend action
- Loading branch information
Showing
5 changed files
with
193 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React, { Dispatch, SetStateAction } from "react"; | ||
import { UseMutationResult } from "react-query/react"; | ||
import styled from "styled-components"; | ||
import { ToggleSuspendResourceResponse } from "../../lib/api/core/core.pb"; | ||
import Button from "../Button"; | ||
import Flex from "../Flex"; | ||
import Modal from "../Modal"; | ||
|
||
export type Props = { | ||
onCloseModal: Dispatch<SetStateAction<boolean>>; | ||
open: boolean; | ||
setSuspendMessage: Dispatch<SetStateAction<string>>; | ||
suspend: UseMutationResult<ToggleSuspendResourceResponse>; | ||
suspendMessage: string; | ||
className?: string; | ||
}; | ||
|
||
const MessageTextarea = styled.textarea` | ||
width: 100%; | ||
box-sizing: border-box; | ||
font-family: inherit; | ||
font-size: 100%; | ||
border-radius: ${(props) => props.theme.spacing.xxs}; | ||
resize: none; | ||
margin-bottom: ${(props) => props.theme.spacing.base}; | ||
padding: ${(props) => props.theme.spacing.xs}; | ||
&:focus { | ||
outline: ${(props) => props.theme.colors.primary} solid 2px; | ||
} | ||
`; | ||
|
||
function SuspendMessageModal({ | ||
className, | ||
onCloseModal, | ||
open, | ||
setSuspendMessage, | ||
suspend, | ||
suspendMessage, | ||
}: Props) { | ||
const closeHandler = () => { | ||
setSuspendMessage(""); | ||
onCloseModal(false); | ||
}; | ||
const suspendHandler = () => { | ||
setSuspendMessage(suspendMessage); | ||
suspend.mutateAsync({}); | ||
setSuspendMessage(""); | ||
onCloseModal(false); | ||
}; | ||
|
||
const onClose = () => closeHandler(); | ||
|
||
const content = ( | ||
<> | ||
<MessageTextarea | ||
rows={5} | ||
value={suspendMessage} | ||
onChange={(ev) => setSuspendMessage(ev.target.value)} | ||
></MessageTextarea> | ||
<Flex wide end> | ||
<Button onClick={suspendHandler} color="inherit" variant="text"> | ||
Suspend | ||
</Button> | ||
</Flex> | ||
</> | ||
); | ||
|
||
return ( | ||
<Modal | ||
open={open} | ||
onClose={onClose} | ||
title="Suspend Reason" | ||
description="Add reason for suspending" | ||
children={content} | ||
className={className} | ||
/> | ||
); | ||
} | ||
|
||
export default SuspendMessageModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters