-
Notifications
You must be signed in to change notification settings - Fork 97
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
feat: save and restore workspaces, add menu bar #79
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1a65a4f
feat: save and restore models with indexedDB
j4k0xb fa1933e
fix: debounce model save
j4k0xb a85a56d
feat: sleeker full width progress bar
j4k0xb d3b1112
feat: menu bar, open recent
j4k0xb 9c190fe
feat: preview session content
j4k0xb 5f8835e
fix: sync sessions state
j4k0xb b9ad0db
fix: don't alert on beforeunload for empty models
j4k0xb 3002f97
refactor: settings
j4k0xb b03e9b6
refactor: rename sessions to workspaces
j4k0xb a6d715a
feat: save file
j4k0xb 667e951
refactor: remove console logs
j4k0xb 12fb255
Merge branch 'master' into indexeddb
j4k0xb 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 |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import { For } from 'solid-js'; | ||
import { setSettings, settings, type Settings } from '../hooks/useSettings'; | ||
import { useWorkspaces, type Workspace } from '../indexeddb'; | ||
|
||
interface Props { | ||
onFileOpen?: (content: string) => void; | ||
onSave?: () => void; | ||
onRestore?: (workspace: Workspace) => void; | ||
} | ||
|
||
export default function Menu(props: Props) { | ||
const { workspaces } = useWorkspaces(); | ||
|
||
function openFile() { | ||
const input = document.createElement('input'); | ||
input.type = 'file'; | ||
input.onchange = async (event) => { | ||
const file = (event.target as HTMLInputElement).files?.[0]; | ||
if (!file) return; | ||
const content = await file.text(); | ||
props.onFileOpen?.(content); | ||
}; | ||
input.click(); | ||
} | ||
|
||
return ( | ||
<ul class="menu menu-sm menu-horizontal bg-base-200 w-full"> | ||
<li> | ||
<details> | ||
<summary>File</summary> | ||
<ul class="min-w-52 z-10 !px-0"> | ||
<li> | ||
<a onClick={openFile}>Open File…</a> | ||
</li> | ||
<li> | ||
<div class="dropdown dropdown-right dropdown-hover transform-none"> | ||
<div tabindex="0" role="button"> | ||
Open Recent | ||
</div> | ||
<ul | ||
tabindex="0" | ||
class="dropdown-content z-10 menu ml-0 p-2 shadow bg-base-100 rounded-box" | ||
> | ||
<For each={workspaces()} fallback={<li>No recent files</li>}> | ||
{(workspace) => ( | ||
<li> | ||
<a | ||
onClick={() => props.onRestore?.(workspace)} | ||
class="truncate" | ||
> | ||
{new Date(workspace.timestamp).toLocaleString()} - | ||
<code>{workspace.models[0].value.slice(0, 20)}…</code> | ||
</a> | ||
</li> | ||
)} | ||
</For> | ||
</ul> | ||
</div> | ||
</li> | ||
<li> | ||
<a onClick={props.onSave}>Save</a> | ||
</li> | ||
</ul> | ||
</details> | ||
</li> | ||
<li> | ||
<details> | ||
<summary>Settings</summary> | ||
<ul class="min-w-52 z-10"> | ||
<li> | ||
<label class="h-10 flex items-center"> | ||
Theme | ||
<select | ||
class="select select-sm ml-auto" | ||
value={settings.theme} | ||
onChange={(e) => | ||
setSettings( | ||
'theme', | ||
e.currentTarget.value as Settings['theme'], | ||
) | ||
} | ||
> | ||
<option value="dark">Dark</option> | ||
<option value="light">Light</option> | ||
<option value="system">System</option> | ||
</select> | ||
</label> | ||
</li> | ||
<li> | ||
<label class="h-10 flex items-center"> | ||
Confirm on Leave | ||
<input | ||
type="checkbox" | ||
class="checkbox checkbox-sm ml-auto" | ||
checked={settings.confirmOnLeave} | ||
onChange={(e) => | ||
setSettings('confirmOnLeave', e.currentTarget.checked) | ||
} | ||
/> | ||
</label> | ||
</li> | ||
<li> | ||
<label class="h-10 flex items-center"> | ||
Workspace History | ||
<input | ||
type="checkbox" | ||
class="checkbox checkbox-sm ml-auto" | ||
checked={settings.workspaceHistory} | ||
onChange={(e) => | ||
setSettings('workspaceHistory', e.currentTarget.checked) | ||
} | ||
/> | ||
</label> | ||
</li> | ||
</ul> | ||
</details> | ||
</li> | ||
<li> | ||
<a href="https://github.com/j4k0xb/webcrack" target="_blank"> | ||
GitHub | ||
</a> | ||
</li> | ||
<li> | ||
<a href="/docs" target="_blank"> | ||
Documentation | ||
</a> | ||
</li> | ||
</ul> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Show, createEffect, createSignal } from 'solid-js'; | ||
import { useDeobfuscateContext } from '../context/DeobfuscateContext'; | ||
|
||
export default function ProgressBar() { | ||
const { deobfuscating, progress } = useDeobfuscateContext(); | ||
const [progressShown, setProgressShown] = createSignal(false); | ||
|
||
createEffect(() => { | ||
if (deobfuscating()) setProgressShown(true); | ||
else if (progress() === 100) setTimeout(() => setProgressShown(false), 500); | ||
else setProgressShown(false); | ||
}); | ||
|
||
return ( | ||
<Show when={progressShown()}> | ||
<style> | ||
{` | ||
.progress::-webkit-progress-value { | ||
transition: width 300ms ease; | ||
} | ||
`} | ||
</style> | ||
<progress | ||
class="progress progress-info absolute top-0 h-0.5 w-full z-10 pointer-events-none bg-transparent" | ||
value={progress() / 100} | ||
/> | ||
</Show> | ||
); | ||
} |
Oops, something went wrong.
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.
Does this clear any currently open tabs? If so, I wonder if that might be unexpected for users sometimes?
Realistically (at least with the current 5sec countdown on the restore dialog) it's probably rare (but not impossible) that you would get in a state of having open work that gets lost via this.
I wonder if making it so it only closes if it's the default/empty 'new tab' might be safer?
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.
Yes, they can't be kept because each model needs to have an unique URI (path)
A possibility would be saving them before or showing a confirm dialog