-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factor out some "save edit" footer code
This pulls the code into a component to limit duplication. The component can be used when "cancel" and "save" buttons are needed in modal tabs that allow editing things like access policies. This makes it easier to reuse and limits duplicated code.
- Loading branch information
Showing
5 changed files
with
53 additions
and
52 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,38 @@ | ||
import { useTranslation } from "react-i18next" | ||
|
||
type SaveEditFooterProps = { | ||
active: boolean; | ||
reset: () => void; | ||
submit: () => void; | ||
isValid?: boolean; | ||
} | ||
|
||
export const SaveEditFooter: React.FC<SaveEditFooterProps> = ({ | ||
active, | ||
reset, | ||
submit, | ||
isValid, | ||
}) => { | ||
const { t } = useTranslation(); | ||
|
||
return <footer style={{ padding: "0 15px" }}> | ||
{active && isValid && ( | ||
<div className="pull-left"> | ||
<button | ||
type="reset" | ||
onClick={reset} | ||
className="cancel" | ||
>{t("CANCEL")}</button> | ||
</div> | ||
)} | ||
<div className="pull-right"> | ||
<button | ||
onClick={submit} | ||
disabled={!isValid || !active} | ||
className={`save green ${ | ||
!isValid || !active ? "disabled" : "" | ||
}`} | ||
>{t("SAVE")}</button> | ||
</div> | ||
</footer>; | ||
} |
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