index.tsx 962 B

12345678910111213141516171819202122232425262728293031323334
  1. import LinkButton from "@ente/shared/components/LinkButton";
  2. import ElectronAPIs from "@ente/shared/electron";
  3. import { logError } from "@ente/shared/sentry";
  4. import { Tooltip } from "@mui/material";
  5. import { styled } from "@mui/material/styles";
  6. const DirectoryPathContainer = styled(LinkButton)(
  7. ({ width }) => `
  8. width: ${width}px;
  9. white-space: nowrap;
  10. overflow: hidden;
  11. text-overflow: ellipsis;
  12. /* Beginning of string */
  13. direction: rtl;
  14. text-align: left;
  15. `,
  16. );
  17. export const DirectoryPath = ({ width, path }) => {
  18. const handleClick = async () => {
  19. try {
  20. await ElectronAPIs.openDirectory(path);
  21. } catch (e) {
  22. logError(e, "openDirectory failed");
  23. }
  24. };
  25. return (
  26. <DirectoryPathContainer width={width} onClick={handleClick}>
  27. <Tooltip title={path}>
  28. <span>{path}</span>
  29. </Tooltip>
  30. </DirectoryPathContainer>
  31. );
  32. };