-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathAppsmithLink.tsx
More file actions
60 lines (54 loc) · 1.63 KB
/
Copy pathAppsmithLink.tsx
File metadata and controls
60 lines (54 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React, { useCallback } from "react";
import { Link, Tooltip } from "@appsmith/ads";
import styled from "styled-components";
import { LOGO_TOOLTIP, createMessage } from "ee/constants/messages";
import { APPLICATIONS_URL } from "constants/routes";
import AppsmithLogo from "assets/images/appsmith_logo_square.png";
import history from "utils/history";
import { useSelector } from "react-redux";
import { getOrganizationConfig } from "ee/selectors/organizationSelectors";
export const StyledLink = styled((props) => {
// we are removing non input related props before passing them in the components
// eslint-disable @typescript-eslint/no-unused-vars
return <Link {...props} />;
})`
height: 24px;
min-width: 24px;
width: 24px;
display: inline-block;
img {
min-width: 24px;
width: 24px;
height: 24px;
object-fit: contain;
}
`;
export const AppsmithLink = () => {
const organizationConfig = useSelector(getOrganizationConfig);
const handleOnClick = useCallback(
(e: React.MouseEvent<HTMLAnchorElement>) => {
e.stopPropagation();
if (e.ctrlKey || e.metaKey) {
window.open(APPLICATIONS_URL, "_blank");
} else {
history.push(APPLICATIONS_URL);
}
},
[],
);
return (
<Tooltip content={createMessage(LOGO_TOOLTIP)} placement="bottomLeft">
<StyledLink onClick={handleOnClick}>
<img
alt="Appsmith logo"
className="t--appsmith-logo"
src={
organizationConfig.brandLogoUrl
? organizationConfig.brandLogoUrl
: AppsmithLogo
}
/>
</StyledLink>
</Tooltip>
);
};