This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
8,870 additions
and
8,558 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
53 changes: 53 additions & 0 deletions
53
src/components/molecules/Settings/Project/BasicAuthSection/index.tsx
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,53 @@ | ||
import { styled } from "@reearth/theme"; | ||
import React from "react"; | ||
import { useIntl } from "react-intl"; | ||
import Section from "../../Section"; | ||
import EditableItem from "../EditableItem"; | ||
import ToggleItem from "../ToggleItem"; | ||
|
||
export type Props = { | ||
onSave: (active?: boolean, basicAuthUsername?: string, basicAuthPassword?: string) => void; | ||
isBasicAuthActive?: boolean; | ||
basicAuthUsername?: string; | ||
basicAuthPassword?: string; | ||
}; | ||
|
||
const BasicAuthSection: React.FC<Props> = ({ | ||
onSave, | ||
isBasicAuthActive, | ||
basicAuthUsername, | ||
basicAuthPassword, | ||
}) => { | ||
const intl = useIntl(); | ||
return ( | ||
<Wrapper> | ||
<Section title={intl.formatMessage({ defaultMessage: "Basic Authorization" })}> | ||
<ToggleItem | ||
title={intl.formatMessage({ defaultMessage: "Enable basic authorization" })} | ||
checked={!!isBasicAuthActive} | ||
onChange={() => onSave(!isBasicAuthActive, basicAuthUsername, basicAuthPassword)} | ||
/> | ||
<EditableItem | ||
title={intl.formatMessage({ defaultMessage: "Username" })} | ||
body={basicAuthUsername} | ||
multilineTextBox={false} | ||
onSubmit={username => onSave(isBasicAuthActive, username, basicAuthPassword)} | ||
/> | ||
<EditableItem | ||
title={intl.formatMessage({ defaultMessage: "Password" })} | ||
body={basicAuthPassword} | ||
multilineTextBox={false} | ||
onSubmit={password => onSave(isBasicAuthActive, basicAuthUsername, password)} | ||
/> | ||
</Section> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
const Wrapper = styled.div` | ||
width: 100%; | ||
background-color: ${({ theme }) => theme.colors.bg[3]}; | ||
margin-bottom: 64px; | ||
`; | ||
|
||
export default BasicAuthSection; |
15 changes: 15 additions & 0 deletions
15
src/components/molecules/Settings/Project/ToggleItem/index.tsx
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,15 @@ | ||
import ToggleButton from "@reearth/components/atoms/ToggleButton"; | ||
import React from "react"; | ||
import Field from "../../Field"; | ||
|
||
export type Props = { | ||
checked: boolean; | ||
title: string; | ||
onChange?: () => void; | ||
}; | ||
|
||
const ToggleItem: React.FC<Props> = ({ title, onChange, checked }) => { | ||
return <Field header={title} body={<ToggleButton checked={checked} onChange={onChange} />} />; | ||
}; | ||
|
||
export default ToggleItem; |
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
Oops, something went wrong.