Skip to content

Add tooltip for "Upload File" button when user is not authenticated #3497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions client/modules/IDE/components/FileNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,20 @@ const FileNode = ({
{t('FileNode.AddFile')}
</button>
</li>
{authenticated && (
<li>
<button
aria-label={t('FileNode.UploadFileARIA')}
onClick={handleClickUploadFile}
>
{t('FileNode.UploadFile')}
</button>
</li>
)}
<li>
<button
disabled={!authenticated}
className={!authenticated ? 'tooltipped-login' : ''}
aria-label={
!authenticated
? t('FileNode.UploadFileRequiresLogin')
: t('FileNode.UploadFileARIA')
}
onClick={handleClickUploadFile}
>
{t('FileNode.UploadFile')}
</button>
</li>
</>
)}
<li>
Expand Down
30 changes: 17 additions & 13 deletions client/modules/IDE/components/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,23 @@ export default function SideBar() {
{t('Sidebar.AddFile')}
</button>
</li>
{isAuthenticated && (
<li>
<button
aria-label={t('Sidebar.UploadFileARIA')}
onClick={() => {
dispatch(openUploadFileModal(rootFile.id));
setTimeout(() => dispatch(closeProjectOptions()), 300);
}}
>
{t('Sidebar.UploadFile')}
</button>
</li>
)}
<li>
<button
disabled={!isAuthenticated}
className={!isAuthenticated ? 'tooltipped-login' : ''}
aria-label={
!isAuthenticated
? t('Sidebar.UploadFileRequiresLogin')
: t('Sidebar.UploadFileARIA')
}
onClick={() => {
dispatch(openUploadFileModal(rootFile.id));
setTimeout(() => dispatch(closeProjectOptions()), 300);
}}
>
{t('Sidebar.UploadFile')}
</button>
</li>
</ul>
)}
</div>
Expand Down
46 changes: 45 additions & 1 deletion client/styles/components/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@
.sidebar__file-item--closed .file-item__children {
display: none;
}

.sidebar__project-options {
@extend %dropdown-open-right;
display: none;
Expand All @@ -332,3 +331,48 @@
display: flex;
}
}

// Custom tooltip for upload file when login is required
.tooltipped-login {
position: relative;

&::before,
&::after {
position: absolute;
z-index: 1000000;
display: none;
pointer-events: none;
}

&::after {
padding: 5px 8px;
font-size: #{math.div(12, $base-font-size)}rem;
font-family: Montserrat, sans-serif;
content: attr(aria-label);
border-radius: 3px;
background-color: white !important;
color: black !important;
text-align: center;
white-space: pre;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

&::before {
display: none;
}

&:hover::after,
&:active::after,
&:focus::after {
display: inline-block;
text-decoration: none;
}

&::after {
bottom: -35px;
right: auto;
left: 5px;
transform: none;
}
}

4 changes: 3 additions & 1 deletion translations/locales/en-US/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@
"AddFile": "Create file",
"AddFileARIA": "add file",
"UploadFile": "Upload file",
"UploadFileARIA": "upload file"
"UploadFileARIA": "upload file",
"UploadFileRequiresLogin": "You must log in to upload files"
},
"FileNode": {
"OpenFolderARIA": "Open folder contents",
Expand All @@ -280,6 +281,7 @@
"AddFileARIA": "add file",
"UploadFile": "Upload file",
"UploadFileARIA": "upload file",
"UploadFileRequiresLogin": "You must log in to upload files",
"Rename": "Rename",
"Delete": "Delete"
},
Expand Down