Files
outline/app/components/InputSelectPermission.tsx
Tom Moor e3837f6ad5 feat: Adds permission selector in document/collection invite flow (#6948)
* stash

* fix: Permissions cleared on collection addition
fix: Cannot remove user from document
Allow choosing permission in invite flow
2024-05-26 09:45:53 -07:00

48 lines
1.1 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, InputSelectRef } from "./InputSelect";
function InputSelectPermission(
props: $Diff<
Props,
{
options: Array<Option>;
ariaLabel: string;
}
>,
ref: React.RefObject<InputSelectRef>
) {
const { value, onChange, ...rest } = props;
const { t } = useTranslation();
return (
<InputSelect
ref={ref}
label={t("Permission")}
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={onChange}
{...rest}
/>
);
}
export default React.forwardRef(InputSelectPermission);