Skip to content

Commit

Permalink
(fix) style fix on alerts tab, remove unresolve, fix placeholder logi…
Browse files Browse the repository at this point in the history
…c, fix pagination counting logic
  • Loading branch information
NikhilShahi committed Sep 3, 2022
1 parent 06e07c8 commit 41785f4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 32 deletions.
15 changes: 1 addition & 14 deletions frontend/src/components/Alert/AlertComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const AlertComponent: React.FC<AlertComponentProps> = ({
</ModalBody>
{alert.status !== Status.IGNORED && (
<ModalFooter>
{alert.status !== Status.RESOLVED ? (
{alert.status !== Status.RESOLVED && (
<Button
isLoading={updating}
leftIcon={<FiCheckCircle />}
Expand All @@ -164,19 +164,6 @@ export const AlertComponent: React.FC<AlertComponentProps> = ({
>
Resolve
</Button>
) : (
<Button
isLoading={updating}
leftIcon={<AiOutlineExclamationCircle fontSize="20px" />}
colorScheme="red"
onClick={() =>
handleUpdateAlert(alert.uuid, {
updateType: UpdateAlertType.UNRESOLVE,
})
}
>
Unresolve
</Button>
)}
</ModalFooter>
)}
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/Alert/AlertDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,9 @@ export const AlertDetail: React.FC<AlertDetailProps> = ({
}}
value={resolutionMessage || ""}
placeholder={
alert.status !== Status.RESOLVED &&
"Provide reason for resolving..."
alert.status !== Status.RESOLVED
? "Provide reason for resolving..."
: ""
}
onChange={e => setResolutionMessage(e.target.value)}
/>
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/Alert/AlertList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,9 @@ export const AlertList: React.FC<AlertListProps> = ({
{totalCount && (
<HStack alignSelf="flex-end" p="3" pr="70px">
<Text>
{(page - 1) * params.offset + 1}-
{(page - 1) * params.offset + alerts.length} of {totalCount} alerts
{(page - 1) * ALERT_PAGE_LIMIT + 1}-
{(page - 1) * ALERT_PAGE_LIMIT + alerts.length} of {totalCount}{" "}
alerts
</Text>
<PaginationComponent
pageSize={ALERT_PAGE_LIMIT}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Endpoint/AlertTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const AlertTab: React.FC<AlertTabProps> = ({ apiEndpointUuid }) => {
}

return (
<Box pt="4" px="8" h="full">
<Box py="4" px="8" h="full">
<AlertList
alerts={alerts}
handleUpdateAlert={handleUpdateAlert}
Expand Down
23 changes: 10 additions & 13 deletions frontend/src/hooks/use-debounce.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { useState, useEffect } from "react"

export const useDebounce = (value: string, delay: number) => {
const [debouncedValue, setDebouncedValue] = useState(value);
useEffect(
() => {
const handler = setTimeout(() => {
setDebouncedValue(value);
}, delay);
return () => {
clearTimeout(handler);
};
},
[value, delay]
);
return debouncedValue;
const [debouncedValue, setDebouncedValue] = useState(value)
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedValue(value)
}, delay)
return () => {
clearTimeout(handler)
}
}, [value, delay])
return debouncedValue
}

0 comments on commit 41785f4

Please sign in to comment.