mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
666b3879b3
* refactor * refactor * design
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import * as React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import styled from "styled-components";
|
|
import { s } from "@shared/styles";
|
|
import type { Option } from "~/components/InputSelect";
|
|
import { InputSelect } from "~/components/InputSelect";
|
|
import type { Permission } from "~/types";
|
|
import { EmptySelectValue } from "~/types";
|
|
|
|
type Props = Pick<
|
|
React.ComponentProps<typeof InputSelect>,
|
|
"value" | "onChange" | "disabled" | "className"
|
|
>;
|
|
|
|
export default function InputMemberPermissionSelect(
|
|
props: Props & { permissions: Permission[] }
|
|
) {
|
|
const { value, onChange, ...rest } = props;
|
|
const { t } = useTranslation();
|
|
|
|
const options = React.useMemo<Option[]>(
|
|
() =>
|
|
props.permissions.reduce((acc, permission) => {
|
|
if (permission.divider) {
|
|
acc.push({ type: "separator" });
|
|
}
|
|
acc.push({
|
|
...permission,
|
|
type: "item",
|
|
});
|
|
return acc;
|
|
}, [] as Option[]),
|
|
[props.permissions]
|
|
);
|
|
|
|
return (
|
|
<Select
|
|
options={options}
|
|
value={value || EmptySelectValue}
|
|
onChange={onChange}
|
|
label={t("Permissions")}
|
|
labelHidden
|
|
nude
|
|
{...rest}
|
|
/>
|
|
);
|
|
}
|
|
|
|
const Select = styled(InputSelect)`
|
|
color: ${s("textSecondary")};
|
|
`;
|