import * as React from 'react';
import { Popper } from '@mui/base/Popper';
import { ClickAwayListener } from '@mui/base/ClickAwayListener';
import Autocomplete from '@mui/joy/Autocomplete';
import AutocompleteListbox from '@mui/joy/AutocompleteListbox';
import AutocompleteOption from '@mui/joy/AutocompleteOption';
import Box from '@mui/joy/Box';
import Link from '@mui/joy/Link';
import List from '@mui/joy/List';
import ListItem from '@mui/joy/ListItem';
import Typography from '@mui/joy/Typography';
import Sheet from '@mui/joy/Sheet';
import SettingsIcon from '@mui/icons-material/Settings';
import CloseIcon from '@mui/icons-material/Close';
import DoneIcon from '@mui/icons-material/Done';
import colors from '@mui/joy/colors';
const Listbox = React.forwardRef((props, ref) => (
));
export default function GitHubLabel() {
const [anchorEl, setAnchorEl] = React.useState(null);
const [value, setValue] = React.useState([labels[1], labels[11]]);
const [pendingValue, setPendingValue] = React.useState([]);
const handleClick = (event) => {
setPendingValue(value);
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setValue(pendingValue);
if (anchorEl) {
anchorEl.focus();
}
setAnchorEl(null);
};
const open = Boolean(anchorEl);
const id = open ? 'github-label' : undefined;
return (
Labels
{value.map((label) => (
{label.name}
))}
({
width: 300,
boxShadow: 'md',
borderRadius: '6px',
overflow: 'hidden',
'--joy-palette-neutral-plainBg': '#fff',
'--joy-palette-background-surface': '#fff',
[theme.getColorSchemeSelector('dark')]: {
'--joy-palette-neutral-plainBg': '#000',
'--joy-palette-background-surface': '#000',
},
})}
>
Apply labels to this pull request
{
if (reason === 'escape') {
handleClose();
}
}}
value={pendingValue}
onChange={(event, newValue, reason) => {
if (
event.type === 'keydown' &&
(event.key === 'Backspace' || event.key === 'Delete') &&
reason === 'removeOption'
) {
return;
}
setPendingValue(newValue);
}}
disableClearable
disableCloseOnSelect
forcePopupIcon={false}
renderTags={() => null}
noOptionsText="No labels"
renderOption={(props, option, { selected }) => (
({
alignItems: 'flex-start',
border: 'none',
borderBottom: '1px solid',
borderColor: 'divider',
'--joy-palette-neutral-plainHoverBg': 'rgba(0, 0, 0, 0.03)',
'--joy-palette-neutral-plainActiveBg': 'rgba(0, 0, 0, 0.03)',
[theme.getColorSchemeSelector('dark')]: {
'--joy-palette-neutral-plainHoverBg': colors.grey[800],
'--joy-palette-neutral-plainActiveBg': colors.grey[800],
},
'&[aria-selected="true"]': {
fontWeight: 'normal',
},
'&:first-of-type': {
borderTop: '1px solid',
borderColor: 'divider',
},
})}
>
{option.name}
{option.description}
)}
options={[...labels].sort((a, b) => {
// Display the selected labels first.
let ai = value.indexOf(a);
ai = ai === -1 ? value.length + labels.indexOf(a) : ai;
let bi = value.indexOf(b);
bi = bi === -1 ? value.length + labels.indexOf(b) : bi;
return ai - bi;
})}
getOptionLabel={(option) => option.name}
sx={{
p: '4px 2px',
borderTop: '1px solid',
borderBottom: '1px solid',
borderColor: 'divider',
'--Input-radius': '4px',
m: '0.75rem 0.5rem',
}}
/>
);
}
// From https://github.com/abdonrd/github-labels
const labels = [
{
name: 'good first issue',
color: '#7057ff',
description: 'Good for newcomers',
},
{
name: 'help wanted',
color: '#008672',
description: 'Extra attention is needed',
},
{
name: 'priority: critical',
color: '#b60205',
description: '',
},
{
name: 'priority: high',
color: '#d93f0b',
description: '',
},
{
name: 'priority: low',
color: '#0e8a16',
description: '',
},
{
name: 'priority: medium',
color: '#fbca04',
description: '',
},
{
name: "status: can't reproduce",
color: '#fec1c1',
description: '',
},
{
name: 'status: confirmed',
color: '#215cea',
description: '',
},
{
name: 'status: duplicate',
color: '#cfd3d7',
description: 'This issue or pull request already exists',
},
{
name: 'status: needs information',
color: '#fef2c0',
description: '',
},
{
name: 'status: wont do/fix',
color: '#eeeeee',
description: 'This will not be worked on',
},
{
name: 'type: bug',
color: '#d73a4a',
description: "Something isn't working",
},
{
name: 'type: discussion',
color: '#d4c5f9',
description: '',
},
{
name: 'type: documentation',
color: '#006b75',
description: '',
},
{
name: 'type: enhancement',
color: '#84b6eb',
description: '',
},
{
name: 'type: epic',
color: '#3e4b9e',
description: 'A theme of work that contain sub-tasks',
},
{
name: 'type: feature request',
color: '#fbca04',
description: 'New feature or request',
},
{
name: 'type: question',
color: '#d876e3',
description: 'Further information is requested',
},
];