mirror of
https://github.com/outline/outline.git
synced 2025-12-20 10:09:43 -06:00
This PR moves the entire project to Typescript. Due to the ~1000 ignores this will lead to a messy codebase for a while, but the churn is worth it – all of those ignore comments are places that were never type-safe previously. closes #1282
52 lines
1.0 KiB
TypeScript
52 lines
1.0 KiB
TypeScript
import * as React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { $Diff } from "utility-types";
|
|
import InputSelect, { Props, Option } from "./InputSelect";
|
|
|
|
export default function InputSelectPermission(
|
|
props: $Diff<
|
|
Props,
|
|
{
|
|
options: Array<Option>;
|
|
ariaLabel: string;
|
|
}
|
|
>
|
|
) {
|
|
const { value, onChange, ...rest } = props;
|
|
const { t } = useTranslation();
|
|
const handleChange = React.useCallback(
|
|
(value) => {
|
|
if (value === "no_access") {
|
|
value = "";
|
|
}
|
|
|
|
onChange(value);
|
|
},
|
|
[onChange]
|
|
);
|
|
|
|
return (
|
|
<InputSelect
|
|
label={t("Default access")}
|
|
options={[
|
|
{
|
|
label: t("View and edit"),
|
|
value: "read_write",
|
|
},
|
|
{
|
|
label: t("View only"),
|
|
value: "read",
|
|
},
|
|
{
|
|
label: t("No access"),
|
|
value: "no_access",
|
|
},
|
|
]}
|
|
ariaLabel={t("Default access")}
|
|
value={value || "no_access"}
|
|
onChange={handleChange}
|
|
{...rest}
|
|
/>
|
|
);
|
|
}
|