• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

alkem-io / client-web / #9315

12 Nov 2024 04:27PM UTC coverage: 5.912%. First build
#9315

Pull #7168

travis-ci

Pull Request #7168: Make avatar clickable to allow more intuitive upload

204 of 10492 branches covered (1.94%)

Branch coverage included in aggregate %.

0 of 19 new or added lines in 4 files covered. (0.0%)

1487 of 18112 relevant lines covered (8.21%)

0.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/core/ui/button/UploadButton.tsx
1
import Button from '@mui/material/Button';
2
import IconButton from '@mui/material/IconButton';
3
import React from 'react';
4
import { useTranslation } from 'react-i18next';
5
import FileUploadWrapper from '../upload/FileUploadWrapper';
6

7
/**
8
 * @param onFileSelected Callback fired when a file is selected
9
 * @param allowedTypes Array of MIME types that are allowed for upload (e.g. ['image/jpeg', 'image/png'])
10
 * @param icon Optional icon element to render an IconButton instead of a regular Button
11
 * @param text Optional button text (used when icon is not provided)
12
 * @param disabled Optional flag to disable the button
13
 */
14
type UploadButtonProps = {
15
  onFileSelected: (file: File) => void;
16
  allowedTypes: string[];
17
  icon?: React.ReactElement;
18
  text?: string;
19
  disabled?: boolean;
20
};
21

NEW
22
const UploadButton = ({ onFileSelected, allowedTypes, icon, text, disabled }: UploadButtonProps) => {
×
23
  const { t } = useTranslation();
×
24
  const label = text ?? t('components.file-upload.uploadFile');
25

×
26
  return (
27
    <FileUploadWrapper onFileSelected={onFileSelected} allowedTypes={allowedTypes}>
×
28
      {icon ? (
29
        <IconButton aria-label={label} disabled={disabled}>
30
          {icon}
31
        </IconButton>
32
      ) : (
33
        <Button aria-label={label} disabled={disabled}>
34
          {label}
35
        </Button>
36
      )}
37
    </FileUploadWrapper>
38
  );
39
};
40

41
export default UploadButton;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc