Skip to content

Commit

Permalink
ULT-1 added project search, fixed master branch fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel.terletzkiy committed Feb 14, 2023
1 parent 9c7f2c8 commit e8e7071
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
7 changes: 4 additions & 3 deletions electron/controller/ProjectScraper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ module.exports = class ProjectScraper {
return projectBranches;
}

static open(path: Project["path"], issue: Task["key"], event?: any) {
static async open(path: Project["path"], issue: Task["key"], event?: any) {
try {
const shell = require("shelljs");
shell.config.execPath = shell.which("node").stdout;
shell.cd(path);

const masterBranch = GitShell.getMasterBranch(path);
shell.exec(`git fetch && git pull origin ${masterBranch}`, { windowsHide: true }); //update master
const masterBranch = (await GitShell.getMasterBranch(path)).replace('/',' ');
console.log("change project: ", masterBranch, issue, path, !!event);
shell.exec(`git fetch && git pull ${masterBranch}`, { windowsHide: true }); //update master
shell.exec(`git stash`, { windowsHide: true }); //sash current uncommitted files
if (
shell.exec(`git checkout ${issue}`, { windowsHide: true }).code !== 0
Expand Down
4 changes: 2 additions & 2 deletions electron/router/ProjectRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const ProjectScraper = require("../controller/ProjectScraper");

ipcMain.on(
"open/project",
(event: any, arg: { path: string; issue: Task["key"] }) => {
async (event: any, arg: { path: string; issue: Task["key"] }) => {
event.sender.send(
"result/open/project",
ProjectScraper.open(arg.path, arg.issue, event)
await ProjectScraper.open(arg.path, arg.issue, event)
);
}
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ultira",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"description": "ultimate jira tool",
"author": {
Expand Down
31 changes: 25 additions & 6 deletions src/components/JiraProjectList.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<template>
<d-card v-if="projects.length > 0" block elevation="4" class="ma-3">
<d-textfield v-model="search" class="search sticky" filled solo placeholder="Search..." full-width>
<template v-slot:prefix>
<d-icon name="search" />
</template>
</d-textfield>
<d-column
v-for="list in lists"
:key="list.title"
Expand All @@ -8,7 +13,7 @@
v-show="list.projects.length > 0"
>
<d-card-subtitle color="primary" class="font-weight-bold px-4 sticky" glow
>{{ list.title }}
>{{ list.title }}
</d-card-subtitle>
<d-accordion
v-for="(project, p) in list.projects"
Expand Down Expand Up @@ -82,7 +87,7 @@
import { projects, currentIssueKey } from "../store/jira.store";
import JiraProjectButton from "./JiraProjectButton.vue";
import JiraController from "../controller/JiraController";
import { computed } from "vue";
import { computed, ref } from "vue";
import ProjectController from "../controller/ProjectController";
import { Project } from "../../types/Jira";
Expand All @@ -98,22 +103,30 @@ function issueExists(branch: string): boolean {
);
}
const search = ref("");
const lists = computed<Array<{ title: string; projects: Array<Project> }>>(
() => {
console.log(recommendedProjects.value);
return [
{
title: "Recommended",
projects: recommendedProjects.value,
projects: recommendedProjects.value
},
{
title: "All",
projects: projects.value,
},
projects: !search ?
projects.value :
projects.value.filter((project) =>
project.project.toLowerCase().includes(search.value.toLowerCase()) ||
project.branch.toLowerCase().includes(search.value.toLowerCase()) ||
project.path.toLowerCase().includes(search.value.toLowerCase())
)
}
];
}
);
const recommendedProjects = computed<Array<Project>>(() => {
return projects.value.filter(
(project) =>
Expand Down Expand Up @@ -147,6 +160,12 @@ function onFileClick(project: Project, file: string) {
backdrop-filter: blur(10px);
}
.search {
top: 35px;
z-index: 2;
}
::v-deep(.d-accordion .d-title) {
padding: 0 !important;
}
Expand Down

0 comments on commit e8e7071

Please sign in to comment.