mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 23:44:22 +00:00
Merge pull request #18 from LordMathis/feat/show-hidden-setting
Implement show hidden files setting
This commit is contained in:
@@ -59,6 +59,9 @@ var migrations = []Migration{
|
|||||||
FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
|
FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Add show_hidden_files field to workspaces
|
||||||
|
ALTER TABLE workspaces ADD COLUMN show_hidden_files BOOLEAN NOT NULL DEFAULT 0;
|
||||||
|
|
||||||
-- Add indexes for performance
|
-- Add indexes for performance
|
||||||
CREATE INDEX idx_sessions_user_id ON sessions(user_id);
|
CREATE INDEX idx_sessions_user_id ON sessions(user_id);
|
||||||
CREATE INDEX idx_sessions_expires_at ON sessions(expires_at);
|
CREATE INDEX idx_sessions_expires_at ON sessions(expires_at);
|
||||||
|
|||||||
@@ -66,12 +66,12 @@ func (db *DB) createWorkspaceTx(tx *sql.Tx, workspace *models.Workspace) error {
|
|||||||
result, err := tx.Exec(`
|
result, err := tx.Exec(`
|
||||||
INSERT INTO workspaces (
|
INSERT INTO workspaces (
|
||||||
user_id, name,
|
user_id, name,
|
||||||
theme, auto_save,
|
theme, auto_save, show_hidden_files,
|
||||||
git_enabled, git_url, git_user, git_token,
|
git_enabled, git_url, git_user, git_token,
|
||||||
git_auto_commit, git_commit_msg_template
|
git_auto_commit, git_commit_msg_template
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||||
workspace.UserID, workspace.Name,
|
workspace.UserID, workspace.Name,
|
||||||
workspace.Theme, workspace.AutoSave,
|
workspace.Theme, workspace.AutoSave, workspace.ShowHiddenFiles,
|
||||||
workspace.GitEnabled, workspace.GitURL, workspace.GitUser, workspace.GitToken,
|
workspace.GitEnabled, workspace.GitURL, workspace.GitUser, workspace.GitToken,
|
||||||
workspace.GitAutoCommit, workspace.GitCommitMsgTemplate,
|
workspace.GitAutoCommit, workspace.GitCommitMsgTemplate,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ func (db *DB) CreateWorkspace(workspace *models.Workspace) error {
|
|||||||
|
|
||||||
result, err := db.Exec(`
|
result, err := db.Exec(`
|
||||||
INSERT INTO workspaces (
|
INSERT INTO workspaces (
|
||||||
user_id, name, theme, auto_save,
|
user_id, name, theme, auto_save, show_hidden_files,
|
||||||
git_enabled, git_url, git_user, git_token,
|
git_enabled, git_url, git_user, git_token,
|
||||||
git_auto_commit, git_commit_msg_template
|
git_auto_commit, git_commit_msg_template
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||||
workspace.UserID, workspace.Name, workspace.Theme, workspace.AutoSave,
|
workspace.UserID, workspace.Name, workspace.Theme, workspace.AutoSave, workspace.ShowHiddenFiles,
|
||||||
workspace.GitEnabled, workspace.GitURL, workspace.GitUser, encryptedToken,
|
workspace.GitEnabled, workspace.GitURL, workspace.GitUser, encryptedToken,
|
||||||
workspace.GitAutoCommit, workspace.GitCommitMsgTemplate,
|
workspace.GitAutoCommit, workspace.GitCommitMsgTemplate,
|
||||||
)
|
)
|
||||||
@@ -49,7 +49,7 @@ func (db *DB) GetWorkspaceByID(id int) (*models.Workspace, error) {
|
|||||||
err := db.QueryRow(`
|
err := db.QueryRow(`
|
||||||
SELECT
|
SELECT
|
||||||
id, user_id, name, created_at,
|
id, user_id, name, created_at,
|
||||||
theme, auto_save,
|
theme, auto_save, show_hidden_files,
|
||||||
git_enabled, git_url, git_user, git_token,
|
git_enabled, git_url, git_user, git_token,
|
||||||
git_auto_commit, git_commit_msg_template
|
git_auto_commit, git_commit_msg_template
|
||||||
FROM workspaces
|
FROM workspaces
|
||||||
@@ -57,7 +57,7 @@ func (db *DB) GetWorkspaceByID(id int) (*models.Workspace, error) {
|
|||||||
id,
|
id,
|
||||||
).Scan(
|
).Scan(
|
||||||
&workspace.ID, &workspace.UserID, &workspace.Name, &workspace.CreatedAt,
|
&workspace.ID, &workspace.UserID, &workspace.Name, &workspace.CreatedAt,
|
||||||
&workspace.Theme, &workspace.AutoSave,
|
&workspace.Theme, &workspace.AutoSave, &workspace.ShowHiddenFiles,
|
||||||
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
||||||
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate,
|
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate,
|
||||||
)
|
)
|
||||||
@@ -82,7 +82,7 @@ func (db *DB) GetWorkspaceByName(userID int, workspaceName string) (*models.Work
|
|||||||
err := db.QueryRow(`
|
err := db.QueryRow(`
|
||||||
SELECT
|
SELECT
|
||||||
id, user_id, name, created_at,
|
id, user_id, name, created_at,
|
||||||
theme, auto_save,
|
theme, auto_save, show_hidden_files,
|
||||||
git_enabled, git_url, git_user, git_token,
|
git_enabled, git_url, git_user, git_token,
|
||||||
git_auto_commit, git_commit_msg_template
|
git_auto_commit, git_commit_msg_template
|
||||||
FROM workspaces
|
FROM workspaces
|
||||||
@@ -90,7 +90,7 @@ func (db *DB) GetWorkspaceByName(userID int, workspaceName string) (*models.Work
|
|||||||
userID, workspaceName,
|
userID, workspaceName,
|
||||||
).Scan(
|
).Scan(
|
||||||
&workspace.ID, &workspace.UserID, &workspace.Name, &workspace.CreatedAt,
|
&workspace.ID, &workspace.UserID, &workspace.Name, &workspace.CreatedAt,
|
||||||
&workspace.Theme, &workspace.AutoSave,
|
&workspace.Theme, &workspace.AutoSave, &workspace.ShowHiddenFiles,
|
||||||
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
||||||
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate,
|
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate,
|
||||||
)
|
)
|
||||||
@@ -121,6 +121,7 @@ func (db *DB) UpdateWorkspace(workspace *models.Workspace) error {
|
|||||||
name = ?,
|
name = ?,
|
||||||
theme = ?,
|
theme = ?,
|
||||||
auto_save = ?,
|
auto_save = ?,
|
||||||
|
show_hidden_files = ?,
|
||||||
git_enabled = ?,
|
git_enabled = ?,
|
||||||
git_url = ?,
|
git_url = ?,
|
||||||
git_user = ?,
|
git_user = ?,
|
||||||
@@ -131,6 +132,7 @@ func (db *DB) UpdateWorkspace(workspace *models.Workspace) error {
|
|||||||
workspace.Name,
|
workspace.Name,
|
||||||
workspace.Theme,
|
workspace.Theme,
|
||||||
workspace.AutoSave,
|
workspace.AutoSave,
|
||||||
|
workspace.ShowHiddenFiles,
|
||||||
workspace.GitEnabled,
|
workspace.GitEnabled,
|
||||||
workspace.GitURL,
|
workspace.GitURL,
|
||||||
workspace.GitUser,
|
workspace.GitUser,
|
||||||
@@ -148,7 +150,7 @@ func (db *DB) GetWorkspacesByUserID(userID int) ([]*models.Workspace, error) {
|
|||||||
rows, err := db.Query(`
|
rows, err := db.Query(`
|
||||||
SELECT
|
SELECT
|
||||||
id, user_id, name, created_at,
|
id, user_id, name, created_at,
|
||||||
theme, auto_save,
|
theme, auto_save, show_hidden_files,
|
||||||
git_enabled, git_url, git_user, git_token,
|
git_enabled, git_url, git_user, git_token,
|
||||||
git_auto_commit, git_commit_msg_template
|
git_auto_commit, git_commit_msg_template
|
||||||
FROM workspaces
|
FROM workspaces
|
||||||
@@ -166,7 +168,7 @@ func (db *DB) GetWorkspacesByUserID(userID int) ([]*models.Workspace, error) {
|
|||||||
var encryptedToken string
|
var encryptedToken string
|
||||||
err := rows.Scan(
|
err := rows.Scan(
|
||||||
&workspace.ID, &workspace.UserID, &workspace.Name, &workspace.CreatedAt,
|
&workspace.ID, &workspace.UserID, &workspace.Name, &workspace.CreatedAt,
|
||||||
&workspace.Theme, &workspace.AutoSave,
|
&workspace.Theme, &workspace.AutoSave, &workspace.ShowHiddenFiles,
|
||||||
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
||||||
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate,
|
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate,
|
||||||
)
|
)
|
||||||
@@ -193,6 +195,7 @@ func (db *DB) UpdateWorkspaceSettings(workspace *models.Workspace) error {
|
|||||||
SET
|
SET
|
||||||
theme = ?,
|
theme = ?,
|
||||||
auto_save = ?,
|
auto_save = ?,
|
||||||
|
show_hidden_files = ?,
|
||||||
git_enabled = ?,
|
git_enabled = ?,
|
||||||
git_url = ?,
|
git_url = ?,
|
||||||
git_user = ?,
|
git_user = ?,
|
||||||
@@ -202,6 +205,7 @@ func (db *DB) UpdateWorkspaceSettings(workspace *models.Workspace) error {
|
|||||||
WHERE id = ?`,
|
WHERE id = ?`,
|
||||||
workspace.Theme,
|
workspace.Theme,
|
||||||
workspace.AutoSave,
|
workspace.AutoSave,
|
||||||
|
workspace.ShowHiddenFiles,
|
||||||
workspace.GitEnabled,
|
workspace.GitEnabled,
|
||||||
workspace.GitURL,
|
workspace.GitURL,
|
||||||
workspace.GitUser,
|
workspace.GitUser,
|
||||||
@@ -255,7 +259,7 @@ func (db *DB) GetAllWorkspaces() ([]*models.Workspace, error) {
|
|||||||
rows, err := db.Query(`
|
rows, err := db.Query(`
|
||||||
SELECT
|
SELECT
|
||||||
id, user_id, name, created_at,
|
id, user_id, name, created_at,
|
||||||
theme, auto_save,
|
theme, auto_save, show_hidden_files,
|
||||||
git_enabled, git_url, git_user, git_token,
|
git_enabled, git_url, git_user, git_token,
|
||||||
git_auto_commit, git_commit_msg_template
|
git_auto_commit, git_commit_msg_template
|
||||||
FROM workspaces`,
|
FROM workspaces`,
|
||||||
@@ -271,7 +275,7 @@ func (db *DB) GetAllWorkspaces() ([]*models.Workspace, error) {
|
|||||||
var encryptedToken string
|
var encryptedToken string
|
||||||
err := rows.Scan(
|
err := rows.Scan(
|
||||||
&workspace.ID, &workspace.UserID, &workspace.Name, &workspace.CreatedAt,
|
&workspace.ID, &workspace.UserID, &workspace.Name, &workspace.CreatedAt,
|
||||||
&workspace.Theme, &workspace.AutoSave,
|
&workspace.Theme, &workspace.AutoSave, &workspace.ShowHiddenFiles,
|
||||||
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
&workspace.GitEnabled, &workspace.GitURL, &workspace.GitUser, &encryptedToken,
|
||||||
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate,
|
&workspace.GitAutoCommit, &workspace.GitCommitMsgTemplate,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ type Workspace struct {
|
|||||||
// Integrated settings
|
// Integrated settings
|
||||||
Theme string `json:"theme" validate:"oneof=light dark"`
|
Theme string `json:"theme" validate:"oneof=light dark"`
|
||||||
AutoSave bool `json:"autoSave"`
|
AutoSave bool `json:"autoSave"`
|
||||||
|
ShowHiddenFiles bool `json:"showHiddenFiles"`
|
||||||
GitEnabled bool `json:"gitEnabled"`
|
GitEnabled bool `json:"gitEnabled"`
|
||||||
GitURL string `json:"gitUrl" validate:"required_if=GitEnabled true"`
|
GitURL string `json:"gitUrl" validate:"required_if=GitEnabled true"`
|
||||||
GitUser string `json:"gitUser" validate:"required_if=GitEnabled true"`
|
GitUser string `json:"gitUser" validate:"required_if=GitEnabled true"`
|
||||||
@@ -29,6 +30,7 @@ func (w *Workspace) Validate() error {
|
|||||||
func (w *Workspace) GetDefaultSettings() {
|
func (w *Workspace) GetDefaultSettings() {
|
||||||
w.Theme = "light"
|
w.Theme = "light"
|
||||||
w.AutoSave = false
|
w.AutoSave = false
|
||||||
|
w.ShowHiddenFiles = false
|
||||||
w.GitEnabled = false
|
w.GitEnabled = false
|
||||||
w.GitURL = ""
|
w.GitURL = ""
|
||||||
w.GitUser = ""
|
w.GitUser = ""
|
||||||
|
|||||||
@@ -65,10 +65,17 @@ const Node = ({ node, style, dragHandle }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const FileTree = ({ files, handleFileSelect }) => {
|
const FileTree = ({ files, handleFileSelect, showHiddenFiles }) => {
|
||||||
const target = useRef(null);
|
const target = useRef(null);
|
||||||
const size = useSize(target);
|
const size = useSize(target);
|
||||||
|
|
||||||
|
files = files.filter((file) => {
|
||||||
|
if (file.name.startsWith('.') && !showHiddenFiles) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={target}
|
ref={target}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const Sidebar = ({ selectedFile, handleFileSelect, files, loadFileList }) => {
|
|||||||
<FileTree
|
<FileTree
|
||||||
files={files}
|
files={files}
|
||||||
handleFileSelect={handleFileSelect}
|
handleFileSelect={handleFileSelect}
|
||||||
selectedFile={selectedFile}
|
showHiddenFiles={settings.showHiddenFiles}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Text, Switch, Tooltip, Group, Box, Title } from '@mantine/core';
|
import { Text, Switch, Tooltip, Group, Box } from '@mantine/core';
|
||||||
|
|
||||||
const EditorSettings = ({ autoSave, onAutoSaveChange }) => {
|
const EditorSettings = ({
|
||||||
|
autoSave,
|
||||||
|
showHiddenFiles,
|
||||||
|
onAutoSaveChange,
|
||||||
|
onShowHiddenFilesChange,
|
||||||
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Box mb="md">
|
<Box mb="md">
|
||||||
<Tooltip label="Auto Save feature is coming soon!" position="left">
|
<Tooltip label="Auto Save feature is coming soon!" position="left">
|
||||||
<Group justify="space-between" align="center">
|
<Group justify="space-between" align="center" mb="sm">
|
||||||
<Text size="sm">Auto Save</Text>
|
<Text size="sm">Auto Save</Text>
|
||||||
<Switch
|
<Switch
|
||||||
checked={autoSave}
|
checked={autoSave}
|
||||||
@@ -14,6 +19,16 @@ const EditorSettings = ({ autoSave, onAutoSaveChange }) => {
|
|||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
|
<Group justify="space-between" align="center">
|
||||||
|
<Text size="sm">Show Hidden Files</Text>
|
||||||
|
<Switch
|
||||||
|
checked={showHiddenFiles}
|
||||||
|
onChange={(event) =>
|
||||||
|
onShowHiddenFilesChange(event.currentTarget.checked)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ const WorkspaceSettings = () => {
|
|||||||
name: currentWorkspace.name,
|
name: currentWorkspace.name,
|
||||||
theme: currentWorkspace.theme,
|
theme: currentWorkspace.theme,
|
||||||
autoSave: currentWorkspace.autoSave,
|
autoSave: currentWorkspace.autoSave,
|
||||||
|
showHiddenFiles: currentWorkspace.showHiddenFiles,
|
||||||
gitEnabled: currentWorkspace.gitEnabled,
|
gitEnabled: currentWorkspace.gitEnabled,
|
||||||
gitUrl: currentWorkspace.gitUrl,
|
gitUrl: currentWorkspace.gitUrl,
|
||||||
gitUser: currentWorkspace.gitUser,
|
gitUser: currentWorkspace.gitUser,
|
||||||
@@ -185,6 +186,10 @@ const WorkspaceSettings = () => {
|
|||||||
onAutoSaveChange={(value) =>
|
onAutoSaveChange={(value) =>
|
||||||
handleInputChange('autoSave', value)
|
handleInputChange('autoSave', value)
|
||||||
}
|
}
|
||||||
|
showHiddenFiles={state.localSettings.showHiddenFiles}
|
||||||
|
onShowHiddenFilesChange={(value) =>
|
||||||
|
handleInputChange('showHiddenFiles', value)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</Accordion.Panel>
|
</Accordion.Panel>
|
||||||
</Accordion.Item>
|
</Accordion.Item>
|
||||||
|
|||||||
Reference in New Issue
Block a user