Skip to content

Commit

Permalink
Titan v1.0.0 Changelog
Browse files Browse the repository at this point in the history
- Rename props and functions to make it consistent with terminology i.e. fileViewGridRef becomes localChangesGridRef ✅
- Improve efficiency of SVN add, remove and revert operations by organising paths into batches ✅
- Persistently store the state of the isDebug flag for easier debugging process ✅
  • Loading branch information
ArrushC committed Jul 12, 2024
1 parent e3bfe6e commit c003d21
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 178 deletions.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="icon" type="image/png" href="/Titan.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Titan</title>
<script type="module" crossorigin src="/assets/index-D3U1y81_.js"></script>
<script type="module" crossorigin src="/assets/index-OJxXwibo.js"></script>
<link rel="modulepreload" crossorigin href="/assets/ag-grid-community-Cx90zoxL.js">
<link rel="modulepreload" crossorigin href="/assets/ag-grid-react-DXgOePOU.js">
<link rel="stylesheet" crossorigin href="/assets/index-Bc2YU8Yt.css">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "titan",
"private": true,
"proxy": "http://localhost:5173",
"version": "0.0.13",
"version": "1.0.0",
"type": "module",
"main": "main.js",
"description": "A desktop application for managing your workflow in VCS and RCS environments.",
Expand Down
195 changes: 120 additions & 75 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ async function sendConfig(socket) {
logger.info(`Updating config file with latest version - v${config.currentVersion || "-1"} -> v${latestVersion}`);
config.currentVersion = latestVersion;
await fs.writeFile(configFilePath, JSON.stringify(config, null, 4));
emitMessage(socket, "Config file updated with latest version", "success");
emitMessage(socket, `Updated Titan successfully to v${latestVersion}`, "success");
}
} catch (err) {
logger.error(err);
Expand Down Expand Up @@ -418,32 +418,65 @@ io.on("connection", (socket) => {
return;
}

let filesToProcess = data.filesToProcess;
for (const file of filesToProcess) {
const { "Branch Folder": branchFolder, "Branch Version": branchVersion, "Full Path": filePath, "Local Status": localStatus } = file;
let directoryPaths = [];
let files = [];

for (const file of data.filesToProcess) {
const isPathDirectory = await isDirectory(file["Full Path"]);
if (isPathDirectory) directoryPaths.push(file);
else files.push(file);
}

if (files.length > 0) {
const task = {
command: "revert",
args: [filePath],
postopCallback: (err, result) => {
options: {
params: [`--targets ${targetsFilePath}`],
},
preopCallback: async () => {
await writeTargetsFile(files.map((f) => f["Full Path"]));
},
postopCallback: async (err, result) => {
if (err) {
logger.error(`Failed to revert file ${filePath}:`, err);
emitMessage(socket, `Failed to revert ${branchString(branchFolder, branchVersion, filePath)}`, "error");
logger.error(`Failed to revert files:` + err);
emitMessage(socket, `Failed to revert files`, "error");
} else {
logger.info(`Successfully reverted file ${filePath}`);
emitMessage(socket, `Successfully reverted ${branchString(branchFolder, branchVersion, filePath)}`, "success");
if (localStatus == "unversioned") {
deleteFileOrDirectory(filePath);
logger.info(`Successfully reverted files`);
emitMessage(socket, `Successfully reverted files`, "success");
for (const file of files.filter((f) => f["Local Status"] == "unversioned")) {
await deleteFileOrDirectory(file["Full Path"]);
}
socket.emit("branch-refresh-unseen");
}
},
};
svnQueueSerial.push(task);
}

// If file path is directory then pass option of infinity depth
const isPathDirectory = await isDirectory(filePath);
if (isPathDirectory) task.options = { depth: "infinity" };

if (directoryPaths.length > 0) {
const task = {
command: "revert",
options: {
depth: "infinity",
params: [`--targets ${targetsFilePath}`],
},
preopCallback: async () => {
await writeTargetsFile(directoryPaths.map((d) => d["Full Path"]));
},
postopCallback: async (err, result) => {
if (err) {
logger.error(`Failed to revert directories:` + err);
emitMessage(socket, `Failed to revert directories`, "error");
} else {
logger.info(`Successfully reverted directories`);
emitMessage(socket, `Successfully reverted directories`, "success");
for (const dir of directoryPaths.filter((d) => d["Local Status"] == "unversioned")) {
await deleteFileOrDirectory(dir["Full Path"]);
}
socket.emit("branch-refresh-unseen");
}
},
};
svnQueueSerial.push(task);
}

Expand All @@ -454,71 +487,84 @@ io.on("connection", (socket) => {
debugTask("svn-files-add-remove", data, false);

if (!data.filesToProcess || data.filesToProcess.length === 0) {
emitMessage(socket, "No files to undo", "error");
emitMessage(socket, "No files to add or remove", "error");
return;
}

for (const file of data.filesToProcess) {
const { "Branch Folder": branchFolder, "Branch Version": branchVersion, "Full Path": filePath, "Local Status": localStatus } = file;
const isPathDirectory = await isDirectory(filePath);

let task = {};
if (localStatus == "unversioned") {
task = {
command: "add",
args: [filePath],
postopCallback: (err, result) => {
if (err) {
logger.error(`Failed to add file ${filePath}:`, err);
emitMessage(socket, `Failed to add ${branchString(branchFolder, branchVersion, filePath)}`, "error");
} else {
logger.info(`Successfully added file ${filePath}`);
emitMessage(socket, `Successfully added ${branchString(branchFolder, branchVersion, filePath)}`, "success");
if (isPathDirectory) socket.emit("branch-refresh-unseen");
}
},
};
} else if (task == "missing") {
task = {
command: "del",
args: [filePath],
postopCallback: (err, result) => {
if (err) {
logger.error(`Failed to add file ${filePath}:`, err);
emitMessage(socket, `Failed to add ${branchString(branchFolder, branchVersion, filePath)}`, "error");
} else {
logger.info(`Successfully added file ${filePath}`);
emitMessage(socket, `Successfully added ${branchString(branchFolder, branchVersion, filePath)}`, "success");
socket.emit("branch-refresh-unseen");
}
},
};
} else {
emitMessage(socket, `Invalid local status for file ${branchString(branchFolder, branchVersion, filePath)}. Please contact the developer!`, "error");
logger.error(`Invalid local status for file ${filePath}: ${localStatus}`);
return;
const unversionedPaths = data.filesToProcess.filter((file) => file["Local Status"] == "unversioned");
const missingPaths = data.filesToProcess.filter((file) => file["Local Status"] == "missing");

if (unversionedPaths.length > 0) {
let allPaths = unversionedPaths.map((file) => file["Full Path"]);
let files = [];

for (const path of allPaths) {
const isPathDirectory = await isDirectory(path);
if (!isPathDirectory) files.push(path);
}

let task = {
command: "add",
options: {
params: [`--targets ${targetsFilePath}`],
},
preopCallback: async () => {
await writeTargetsFile(allPaths);
},
postopCallback: (err, result) => {
if (err) {
logger.error(`Failed to add all unversioned paths:` + err);
emitMessage(socket, `Failed to add all unversioned paths`, "error");
} else {
logger.info(`Successfully added all unversioned paths`);
emitMessage(socket, `Successfully added all unversioned paths`, "success");
if (files.length < 1) socket.emit("branch-refresh-unseen");
}
},
};
svnQueueSerial.push(task);

if (localStatus == "unversioned" && !isPathDirectory) {
let propTask = {
command: "propset",
args: ["svn:keywords", '"Id Author Date Revision HeadURL"', filePath],
postopCallback: (err, result) => {
if (err) {
logger.error(`Failed to set SVN properties for file ${filePath}:`, err);
emitMessage(socket, `Failed to set SVN properties for ${branchString(branchFolder, branchVersion, filePath)}`, "error");
} else {
logger.info(`Successfully set SVN properties for file ${filePath}`);
emitMessage(socket, `SVN properties for ${branchString(branchFolder, branchVersion, filePath)} has been set. Please check that you have added SVN comments to ensure that your SVN client can automatically update them`, "warning", 10_000);
socket.emit("branch-refresh-unseen");
}
},
};
let propTask = {
command: "propset",
args: ["svn:keywords", '"Id Author Date Revision HeadURL"', `--targets ${targetsFilePath}`],
preopCallback: async () => {
await writeTargetsFile(files);
},
postopCallback: (err, result) => {
if (err) {
logger.error(`Failed to set SVN properties for all unversioned files:` + err);
emitMessage(socket, `Failed to set SVN properties for all unversioned files`, "error");
} else {
logger.info(`Successfully set SVN properties for all unversioned files`);
emitMessage(socket, `SVN properties for all unversioned files have been set. Please check that you have added SVN comments to ensure that your SVN client can automatically update them`, "warning", 10_000);
socket.emit("branch-refresh-unseen");
}
},
};
svnQueueSerial.push(propTask);
}

svnQueueSerial.push(propTask);
}
if (missingPaths.length > 0) {
let task = {
command: "del",
options: {
params: [`--targets ${targetsFilePath}`],
},
preopCallback: async () => {
await writeTargetsFile(missingPaths.map((file) => file["Full Path"]));
},
postopCallback: (err, result) => {
if (err) {
logger.error(`Failed to remove all missing files:` + err);
emitMessage(socket, `Failed to remove all missing files`, "error");
} else {
logger.info(`Successfully removed all missing files`);
emitMessage(socket, `Successfully removed all missing files`, "success");
socket.emit("branch-refresh-unseen");
}
},
};
svnQueueSerial.push(task);
}

debugTask("svn-files-add-remove", data, true);
Expand Down Expand Up @@ -564,7 +610,7 @@ io.on("connection", (socket) => {
command: "commit",
options: {
msg: prefixedCommitMessage,
params: [`--targets ${targetsFilePath}`]
params: [`--targets ${targetsFilePath}`],
},
preopCallback: async () => {
await writeTargetsFile(files);
Expand Down Expand Up @@ -635,7 +681,6 @@ io.on("connection", (socket) => {
});
});


/************************************
* Catch-all Route To Serve React App
************************************/
Expand Down
4 changes: 2 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useApp } from "./AppContext";
import { RaiseClientNotificaiton } from "./utils/ChakraUI";

function App() {
const { toast, isCommitMode, selectedRows, configurableRowData, config } = useApp();
const { toast, isCommitMode, selectedBranches, configurableRowData, config } = useApp();

useEffect(() => {
window.electron.onAppClosing((event) => {
Expand Down Expand Up @@ -42,7 +42,7 @@ function App() {
) : (
<Box id="commitRegion">
<Heading as={"h2"} size={"lg"} noOfLines={1} mb={4} className="pulse-animation">
Committing {selectedRows.length == configurableRowData.length ? "All" : `${selectedRows.length}/${configurableRowData.length}`} Branch{selectedRows.length == 1 ? "" : "es"}
Committing {selectedBranches.length == configurableRowData.length ? "All" : `${selectedBranches.length}/${configurableRowData.length}`} Branch{selectedBranches.length == 1 ? "" : "es"}
</Heading>
<CommitRegion />
</Box>
Expand Down
48 changes: 26 additions & 22 deletions src/AppContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ const AppContext = createContext({
branchInfos: {},
setBranchInfos: (_) => {},
branchTableGridRef: null,
selectedRows: [],
setSelectedRows: (_) => {},
selectedBranches: [],
setSelectedBranches: (_) => {},
isCommitMode: false,
setIsCommitMode: (_) => {},
branchStatusRows: [],
setBranchStatusRows: (_) => {},
fileViewGridRef: null,
unseenFilesGridRef: null,
showFilesView: false,
setShowFilesView: (_) => {},
selectedBranchStatuses: [],
setSelectedBranchStatuses: (_) => {},
localChangesGridRef: null,
untrackedChangesGridRef: null,
showCommitView: false,
setShowCommitView: (_) => {},
});

export const useApp = () => {
Expand All @@ -36,7 +36,7 @@ export const AppProvider = ({ children }) => {
const [config, setConfig] = useState(null);
const [socket, setSocket] = useState(null);
const toast = useToast();
const [isDebug, setIsDebug] = useState(true);
const [isDebug, setIsDebug] = useState(localStorage.getItem("isDebug") === "true");

useEffect(() => {
const socket = socketIOClient(ENDPOINT_URL);
Expand Down Expand Up @@ -71,6 +71,10 @@ export const AppProvider = ({ children }) => {
};
}, []);

useEffect(() => {
localStorage.setItem("isDebug", String(isDebug));
}, [isDebug]);

const saveConfig = useCallback(
(configToSave) => {
if (configToSave === null || configToSave === undefined) return;
Expand All @@ -95,14 +99,14 @@ export const AppProvider = ({ children }) => {
const [configurableRowData, setConfigurableRowData] = useState([]);
const [branchInfos, setBranchInfos] = useState({});
const branchTableGridRef = useRef(null);
const [selectedRows, setSelectedRows] = useState([]);
const [selectedBranches, setSelectedBranches] = useState([]);

// Props used in CommitRegion
const [isCommitMode, setIsCommitMode] = useState(false);
const [branchStatusRows, setBranchStatusRows] = useState([]);
const fileViewGridRef = useRef(null);
const unseenFilesGridRef = useRef(null);
const [showFilesView, setShowFilesView] = useState(false);
const [selectedBranchStatuses, setSelectedBranchStatuses] = useState([]);
const localChangesGridRef = useRef(null);
const untrackedChangesGridRef = useRef(null);
const [showCommitView, setShowCommitView] = useState(false);

return (
<AppContext.Provider
Expand All @@ -118,16 +122,16 @@ export const AppProvider = ({ children }) => {
branchInfos,
setBranchInfos,
branchTableGridRef,
selectedRows,
setSelectedRows,
selectedBranches,
setSelectedBranches,
isCommitMode,
setIsCommitMode,
branchStatusRows,
setBranchStatusRows,
fileViewGridRef,
unseenFilesGridRef,
showFilesView,
setShowFilesView,
selectedBranchStatuses,
setSelectedBranchStatuses,
localChangesGridRef,
untrackedChangesGridRef,
showCommitView,
setShowCommitView,
}}>
{children}
</AppContext.Provider>
Expand Down
Loading

0 comments on commit c003d21

Please sign in to comment.