-
Notifications
You must be signed in to change notification settings - Fork 326
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
Add "About app" modal #9833
Merged
Merged
Add "About app" modal #9833
Changes from 9 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
0b5f077
WIP: Version page
somebody1234 e5d374b
Auto-generate version in development mode
somebody1234 20c1507
Also show Electron version
somebody1234 747c9b7
Switch to use actual versions
somebody1234 391c457
Merge branch 'develop' into wip/sb/about-app
somebody1234 f60a2cc
Also show user agent
somebody1234 9c6e95b
Add copy-paste support
somebody1234 0118cd3
Adjust styles
somebody1234 5a4d655
Fix lint errors
somebody1234 9401e6b
Switch to dialog components
somebody1234 5cf728c
Generate UI and string from array instead of generating string from UI
somebody1234 9eb4189
WIP: Fix "about" modal interactions
somebody1234 b3c61c4
Fix closing "about" modal
somebody1234 aa173e0
WIP: Menu entry for opening "about" modal
somebody1234 31c38db
Fix "about" button in system menu
somebody1234 c017e16
WIP: Refactor `TheModal` out of dashboard
somebody1234 7edd217
Add top right menu to authentication pages
somebody1234 960cf56
Fix modal not being closeable on auth pages
somebody1234 d3625e5
Fix lint errors
somebody1234 aa49c77
Fix E2E tests
somebody1234 4dc92b4
Fix logging out
somebody1234 49ae1b2
Merge branch 'develop' into wip/sb/about-app
somebody1234 beecc9e
Prettier
somebody1234 f67ba44
Merge branch 'develop' into wip/sb/about-app
somebody1234 1d0ae10
Prettier
somebody1234 0da91d4
Hide menu bar (was enabled for debugging purposes)
somebody1234 1340cfd
Address code review
somebody1234 034517e
Merge branch 'develop' into wip/sb/about-app
somebody1234 013a769
Use `useLayoutEffect`
somebody1234 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ | |
"checkJs": false, | ||
"skipLibCheck": false | ||
}, | ||
"include": ["./src/"] | ||
"include": ["./src/", "../types/"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
app/ide-desktop/lib/dashboard/src/modals/AboutModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/** @file Modal for confirming delete of any type of asset. */ | ||
import * as React from 'react' | ||
|
||
import LogoIcon from 'enso-assets/enso_logo.svg' | ||
|
||
import * as textProvider from '#/providers/TextProvider' | ||
|
||
import * as aria from '#/components/aria' | ||
import Modal from '#/components/Modal' | ||
import ButtonRow from '#/components/styled/ButtonRow' | ||
import SvgMask from '#/components/SvgMask' | ||
import UnstyledButton from '#/components/UnstyledButton' | ||
|
||
// ================= | ||
// === Constants === | ||
// ================= | ||
|
||
/** The duration of time for which the "copy" button indicates that the text has | ||
* successfully been copied. */ | ||
const CLEAR_COPIED_STATE_TIMEOUT_MS = 2_500 | ||
|
||
// ================== | ||
// === AboutModal === | ||
// ================== | ||
|
||
/** Props for a {@link AboutModal}. */ | ||
export interface AboutModalProps { | ||
readonly supportsLocalBackend: boolean | ||
} | ||
|
||
/** A modal for confirming the deletion of an asset. */ | ||
export default function AboutModal(props: AboutModalProps) { | ||
const { supportsLocalBackend } = props | ||
const { getText } = textProvider.useText() | ||
const [isCopied, setIsCopied] = React.useState(false) | ||
const textContainerRef = React.useRef<HTMLTableSectionElement | null>(null) | ||
|
||
const doCopy = () => { | ||
const textContainer = textContainerRef.current | ||
if (textContainer == null) { | ||
MrFlashAccount marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return | ||
} else { | ||
const firstChild = textContainer.children[0] | ||
const lastChild = textContainer.children[textContainer.children.length - 1] | ||
if (firstChild != null && lastChild != null) { | ||
getSelection()?.setBaseAndExtent(firstChild, 0, lastChild, 2) | ||
} | ||
const texts = Array.from( | ||
textContainer.children, | ||
element => `${element.children[0]?.textContent} ${element.children[1]?.textContent}` | ||
) | ||
void navigator.clipboard.writeText(texts.join('\n')) | ||
if (!isCopied) { | ||
setIsCopied(true) | ||
setTimeout(() => { | ||
setIsCopied(false) | ||
}, CLEAR_COPIED_STATE_TIMEOUT_MS) | ||
} | ||
return | ||
} | ||
} | ||
|
||
return ( | ||
<Modal centered className="bg-dim"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please stop copypasting between components. We have Dialog component, use it instead |
||
<div | ||
data-testid="about-modal" | ||
className="pointer-events-auto relative flex w-[30rem] select-text flex-col gap-modal rounded-default p-modal-wide before:absolute before:inset before:h-full before:w-full before:rounded-default before:bg-selected-frame before:backdrop-blur-default" | ||
onClick={event => { | ||
event.stopPropagation() | ||
}} | ||
> | ||
<div className="relative flex items-center gap-4"> | ||
<SvgMask src={LogoIcon} className="size-16 shrink-0" /> | ||
<div className="flex flex-col gap-3"> | ||
<div className="text-base font-semibold"> | ||
{supportsLocalBackend | ||
? getText('appNameDesktopEdition') | ||
: getText('appNameCloudEdition')} | ||
</div> | ||
<table> | ||
<tbody ref={textContainerRef}> | ||
{window.versionInfo != null ? ( | ||
<> | ||
<tr> | ||
<td className="whitespace-nowrap pr-cell-x">{getText('version')}</td> | ||
<td>{window.versionInfo.version}</td> | ||
</tr> | ||
<tr> | ||
<td className="whitespace-nowrap pr-cell-x">{getText('build')}</td> | ||
<td>{window.versionInfo.build}</td> | ||
</tr> | ||
<tr> | ||
<td className="whitespace-nowrap pr-cell-x">{getText('electronVersion')}</td> | ||
<td>{window.versionInfo.electron}</td> | ||
</tr> | ||
<tr> | ||
<td className="whitespace-nowrap pr-cell-x">{getText('chromeVersion')}</td> | ||
<td>{window.versionInfo.chrome}</td> | ||
</tr> | ||
</> | ||
) : ( | ||
<> | ||
{process.env.ENSO_CLOUD_DASHBOARD_VERSION != null && ( | ||
<tr> | ||
<td className="whitespace-nowrap pr-cell-x">{getText('version')}</td> | ||
<td>{process.env.ENSO_CLOUD_DASHBOARD_VERSION}</td> | ||
</tr> | ||
)} | ||
{process.env.ENSO_CLOUD_DASHBOARD_COMMIT_HASH != null && ( | ||
<tr> | ||
<td className="whitespace-nowrap pr-cell-x">{getText('build')}</td> | ||
<td>{process.env.ENSO_CLOUD_DASHBOARD_COMMIT_HASH}</td> | ||
</tr> | ||
)} | ||
</> | ||
)} | ||
<tr> | ||
<td className="whitespace-nowrap pr-cell-x">{getText('userAgent')}</td> | ||
<td>{navigator.userAgent}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<ButtonRow> | ||
<UnstyledButton | ||
className="button relative bg-invite text-inversed active" | ||
onPress={doCopy} | ||
> | ||
<aria.Text className="text"> | ||
{isCopied ? getText('copied') : getText('copy')} | ||
</aria.Text> | ||
</UnstyledButton> | ||
</ButtonRow> | ||
</div> | ||
</div> | ||
</div> | ||
</Modal> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be easier to understand if we build a string from existing variables(window.versionInfo and so forth), instead of trying to extract the information from html.