-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI: Blacklist app crash fix and other changes (#666)
* fix: handle when no view blacklists auth * ui: blacklist preset time menu to buttons, minor fixes
- Loading branch information
Showing
7 changed files
with
105 additions
and
108 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
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,44 @@ | ||
import React from "react"; | ||
import { | ||
Button, | ||
ButtonGroup, | ||
} from "@material-ui/core"; | ||
import moment from "moment"; | ||
|
||
export const TimePickerButtons = ({ | ||
amount, | ||
unit, | ||
expirationTimestamp, | ||
setExpirationTimestamp, | ||
}) => { | ||
|
||
const adjustTimestamp = (amount, unit) => { | ||
const after = moment(expirationTimestamp).add(amount, unit); | ||
const now = moment(); | ||
|
||
if (after.isBefore(now)) { | ||
setExpirationTimestamp(now.format()) | ||
return; | ||
} | ||
|
||
setExpirationTimestamp(after.format()); | ||
}; | ||
|
||
const setTimestamp = (amount, unit) => { | ||
setExpirationTimestamp(moment().add(amount, unit).format()); | ||
}; | ||
|
||
return ( | ||
<ButtonGroup variant="outlined" size="small" style={{ display: "flex", marginBottom: 4 }}> | ||
<Button style={{ display: "block", width: "100%", maxWidth: "2rem" }} onClick={() => adjustTimestamp(-amount, unit)}> | ||
- | ||
</Button> | ||
<Button style={{ display: "block", width: "100%" }} onClick={() => setTimestamp(amount, unit)}> | ||
{amount} {unit} | ||
</Button> | ||
<Button style={{ display: "block", width: "100%", maxWidth: "2rem" }} onClick={() => adjustTimestamp(amount, unit)}> | ||
+ | ||
</Button> | ||
</ButtonGroup> | ||
); | ||
}; |