Files
outline/app/components/InputSelectPermission.tsx
Apoorv Mishra 1490c3a14b Individual document sharing with permissions (#5814)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Tom Moor <tom@getoutline.com>
2024-01-30 17:48:22 -08:00

54 lines
1.2 KiB
TypeScript

import * as React from "react";
import { useTranslation } from "react-i18next";
import { $Diff } from "utility-types";
import { CollectionPermission } from "@shared/types";
import { EmptySelectValue } from "~/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 === EmptySelectValue) {
value = null;
}
onChange?.(value);
},
[onChange]
);
return (
<InputSelect
label={t("Default access")}
options={[
{
label: t("Can edit"),
value: CollectionPermission.ReadWrite,
},
{
label: t("View only"),
value: CollectionPermission.Read,
},
{
label: t("No access"),
value: EmptySelectValue,
},
]}
ariaLabel={t("Default access")}
value={value || EmptySelectValue}
onChange={handleChange}
{...rest}
/>
);
}