picker-v2
parent
607d3bbbfd
commit
a89975dee2
|
@ -82,7 +82,7 @@
|
|||
}
|
||||
});
|
||||
action.validate = function (selection, sender) {
|
||||
return (selection.tasks.length === 1 && !selection.tasks[0].hasChildren);
|
||||
return selection.tasks.length === 1 && !selection.tasks[0].hasChildren;
|
||||
};
|
||||
return action;
|
||||
})();
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
(() => {
|
||||
var action = new PlugIn.Action(async (selection: Selection, sender: any) => {
|
||||
try {
|
||||
let originalTask = selection.tasks[0]
|
||||
let originalTask = selection.tasks[0];
|
||||
originalTask.flagged = false;
|
||||
|
||||
let isDoneAlert = new Alert("Is this task completely done?", originalTask.name);
|
||||
let isDoneAlert = new Alert(
|
||||
"Is this task completely done?",
|
||||
originalTask.name
|
||||
);
|
||||
isDoneAlert.addOption("Yep!");
|
||||
isDoneAlert.addOption("Not quite");
|
||||
isDoneAlert.addOption("Whoops, never mind!");
|
||||
|
@ -20,7 +23,10 @@
|
|||
let currentSibling = originalTask;
|
||||
|
||||
while (true) {
|
||||
let nextThingAlert = new Alert("Is there anything that has to happen next?", currentSibling.name);
|
||||
let nextThingAlert = new Alert(
|
||||
"Is there anything that has to happen next?",
|
||||
currentSibling.name
|
||||
);
|
||||
nextThingAlert.addOption("Yep!");
|
||||
nextThingAlert.addOption("No, we're all done");
|
||||
|
||||
|
@ -30,17 +36,21 @@
|
|||
}
|
||||
|
||||
let nextSiblingForm = new Form();
|
||||
nextSiblingForm.addField(new Form.Field.String("name", "What's Next?"));
|
||||
nextSiblingForm.addField(
|
||||
new Form.Field.String("name", "What's Next?")
|
||||
);
|
||||
nextSiblingForm.addField(new Form.Field.String("note", "Notes"));
|
||||
await nextSiblingForm.show(`What's the next thing that needs to happen after "${currentSibling.name}"?`, "Save");
|
||||
await nextSiblingForm.show(
|
||||
`What's the next thing that needs to happen after "${currentSibling.name}"?`,
|
||||
"Save"
|
||||
);
|
||||
|
||||
var values = nextSiblingForm.values as { name: string, note: string }
|
||||
var values = nextSiblingForm.values as { name: string; note: string };
|
||||
|
||||
currentSibling = new Task(values.name, currentSibling.after);
|
||||
currentSibling.note = values.note;
|
||||
currentSibling.addTags(originalTask.tags);
|
||||
}
|
||||
|
||||
} else if (isDoneAnswer == 1) {
|
||||
/////////////////////////////
|
||||
// No, it's not quite done //
|
||||
|
@ -48,16 +58,22 @@
|
|||
let nextThingForm = new Form();
|
||||
nextThingForm.addField(new Form.Field.String("name", "What's Next?"));
|
||||
nextThingForm.addField(new Form.Field.String("note", "Notes"));
|
||||
await nextThingForm.show(`What's the next thing that needs to happen to finish "${originalTask.name}"?`, "Save");
|
||||
await nextThingForm.show(
|
||||
`What's the next thing that needs to happen to finish "${originalTask.name}"?`,
|
||||
"Save"
|
||||
);
|
||||
|
||||
var values = nextThingForm.values as { name: string, note: string }
|
||||
var values = nextThingForm.values as { name: string; note: string };
|
||||
|
||||
let currentSibling = new Task(values.name, originalTask.beginning);
|
||||
currentSibling.note = values.note;
|
||||
currentSibling.addTags(originalTask.tags);
|
||||
|
||||
while (true) {
|
||||
let nextThingAlert = new Alert("Is there anything that'd have to happen after this is done?", currentSibling.name);
|
||||
let nextThingAlert = new Alert(
|
||||
"Is there anything that'd have to happen after this is done?",
|
||||
currentSibling.name
|
||||
);
|
||||
nextThingAlert.addOption("Yep!");
|
||||
nextThingAlert.addOption("No, not for now");
|
||||
|
||||
|
@ -67,28 +83,34 @@
|
|||
}
|
||||
|
||||
let nextSiblingForm = new Form();
|
||||
nextSiblingForm.addField(new Form.Field.String("name", "What's Next?"));
|
||||
nextSiblingForm.addField(
|
||||
new Form.Field.String("name", "What's Next?")
|
||||
);
|
||||
nextSiblingForm.addField(new Form.Field.String("note", "Notes"));
|
||||
await nextSiblingForm.show(`What's the next thing that needs to happen after "${currentSibling.name}"?`, "Save");
|
||||
await nextSiblingForm.show(
|
||||
`What's the next thing that needs to happen after "${currentSibling.name}"?`,
|
||||
"Save"
|
||||
);
|
||||
|
||||
values = nextSiblingForm.values as { name: string, note: string }
|
||||
values = nextSiblingForm.values as { name: string; note: string };
|
||||
|
||||
currentSibling = new Task(values.name, currentSibling.after);
|
||||
currentSibling.note = values.note;
|
||||
currentSibling.addTags(originalTask.tags);
|
||||
}
|
||||
|
||||
} else if (isDoneAnswer == 2) {
|
||||
///////////////////////////////////////
|
||||
// Whoops, didn't mean to click that //
|
||||
///////////////////////////////////////
|
||||
return;
|
||||
|
||||
} else {
|
||||
/////////////////////////////////////////
|
||||
// We forgot how many answers we added //
|
||||
/////////////////////////////////////////
|
||||
new Alert("Whoops!", `I got a value of '${isDoneAnswer}' from that alert, but I'm not sure what that means. This is a plugin bug!`)
|
||||
new Alert(
|
||||
"Whoops!",
|
||||
`I got a value of '${isDoneAnswer}' from that alert, but I'm not sure what that means. This is a plugin bug!`
|
||||
);
|
||||
return;
|
||||
}
|
||||
} catch (err) {
|
||||
|
@ -96,9 +118,9 @@
|
|||
}
|
||||
});
|
||||
|
||||
action.validate = function(selection: Selection, sender: any){
|
||||
return (selection.tasks.length === 1 && !selection.tasks[0].hasChildren)
|
||||
action.validate = function (selection: Selection, sender: any) {
|
||||
return selection.tasks.length === 1 && !selection.tasks[0].hasChildren;
|
||||
};
|
||||
|
||||
|
||||
return action;
|
||||
})();
|
||||
|
|
|
@ -33,14 +33,14 @@
|
|||
req.bodyString = `{"query":"{ search(type: ISSUE, query: \\"is:issue assignee:${login} state:open\\", last: 100) { nodes { ... on Issue { number title body url repository { name owner { login } } } } } }"}`;
|
||||
req.headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `bearer ${key}`,
|
||||
Authorization: `bearer ${key}`,
|
||||
};
|
||||
let resp = await (req.fetch().catch((err) => {
|
||||
let resp = await req.fetch().catch((err) => {
|
||||
console.error("Problem fetching issues:", err);
|
||||
let alert = new Alert("Problem fetching from GitHub", err);
|
||||
alert.show();
|
||||
throw err;
|
||||
}));
|
||||
});
|
||||
if (resp.bodyString === null) {
|
||||
throw "body string was null. Did the request succeed?";
|
||||
}
|
||||
|
@ -48,8 +48,10 @@
|
|||
let toFocus = [];
|
||||
for (let issue of body.data.search.nodes) {
|
||||
let gitHubTag = flattenedTags.byName("from GitHub") || new Tag("from GitHub");
|
||||
let orgTag = gitHubTag.tagNamed(issue.repository.owner.login) || new Tag(issue.repository.owner.login, gitHubTag);
|
||||
let repoTag = orgTag.tagNamed(issue.repository.name) || new Tag(issue.repository.name, orgTag);
|
||||
let orgTag = gitHubTag.tagNamed(issue.repository.owner.login) ||
|
||||
new Tag(issue.repository.owner.login, gitHubTag);
|
||||
let repoTag = orgTag.tagNamed(issue.repository.name) ||
|
||||
new Tag(issue.repository.name, orgTag);
|
||||
let repo = `${issue.repository.owner.login}/${issue.repository.name}`;
|
||||
let projectName = `${repo}#${issue.number}: ${issue.title}`;
|
||||
let project = flattenedProjects.byName(projectName) || new Project(projectName);
|
||||
|
|
|
@ -1,102 +1,116 @@
|
|||
(() => {
|
||||
let creds = new Credentials();
|
||||
let creds = new Credentials();
|
||||
|
||||
var action = new PlugIn.Action(async () => {
|
||||
try {
|
||||
let req = URL.FetchRequest.fromString("https://api.github.com/graphql");
|
||||
if (req === null || req.url === null || req.url.host === null) {
|
||||
throw "could not parse the URL for GitHub's GraphQL API"
|
||||
}
|
||||
var action = new PlugIn.Action(async () => {
|
||||
try {
|
||||
let req = URL.FetchRequest.fromString("https://api.github.com/graphql");
|
||||
if (req === null || req.url === null || req.url.host === null) {
|
||||
throw "could not parse the URL for GitHub's GraphQL API";
|
||||
}
|
||||
|
||||
/////////////////////////////////////
|
||||
// Step 1: make sure we have creds //
|
||||
/////////////////////////////////////
|
||||
let stored = creds.read(req.url.host);
|
||||
/////////////////////////////////////
|
||||
// Step 1: make sure we have creds //
|
||||
/////////////////////////////////////
|
||||
let stored = creds.read(req.url.host);
|
||||
|
||||
let login = null;
|
||||
let key = null;
|
||||
let login = null;
|
||||
let key = null;
|
||||
|
||||
if (stored === null || app.optionKeyDown) {
|
||||
let credsForm = new Form();
|
||||
credsForm.addField(new Form.Field.String("login", "Login"));
|
||||
credsForm.addField(new Form.Field.Password("key", "API Key"));
|
||||
if (stored === null || app.optionKeyDown) {
|
||||
let credsForm = new Form();
|
||||
credsForm.addField(new Form.Field.String("login", "Login"));
|
||||
credsForm.addField(new Form.Field.Password("key", "API Key"));
|
||||
|
||||
await credsForm.show("Let's set up: we need your GitHub username and an API key with the\n`repo` permission to pull issues from your assigned repos.\n\nCreate this at https://github.com/settings/tokens\n\nYou can get back here in the future to rotate tokens by holding\noption while activating the workflow.", "Save Key");
|
||||
login = (credsForm.values as { login: string }).login;
|
||||
key = (credsForm.values as { key: string }).key;
|
||||
await credsForm.show(
|
||||
"Let's set up: we need your GitHub username and an API key with the\n`repo` permission to pull issues from your assigned repos.\n\nCreate this at https://github.com/settings/tokens\n\nYou can get back here in the future to rotate tokens by holding\noption while activating the workflow.",
|
||||
"Save Key"
|
||||
);
|
||||
login = (credsForm.values as { login: string }).login;
|
||||
key = (credsForm.values as { key: string }).key;
|
||||
|
||||
creds.write(req.url.host, login, key);
|
||||
} else {
|
||||
login = stored.user;
|
||||
key = stored.password;
|
||||
}
|
||||
creds.write(req.url.host, login, key);
|
||||
} else {
|
||||
login = stored.user;
|
||||
key = stored.password;
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
// Step 2: get the issues //
|
||||
////////////////////////////
|
||||
req.method = "POST";
|
||||
req.bodyString = `{"query":"{ search(type: ISSUE, query: \\"is:issue assignee:${login} state:open\\", last: 100) { nodes { ... on Issue { number title body url repository { name owner { login } } } } } }"}`;
|
||||
req.headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `bearer ${key}`,
|
||||
};
|
||||
////////////////////////////
|
||||
// Step 2: get the issues //
|
||||
////////////////////////////
|
||||
req.method = "POST";
|
||||
req.bodyString = `{"query":"{ search(type: ISSUE, query: \\"is:issue assignee:${login} state:open\\", last: 100) { nodes { ... on Issue { number title body url repository { name owner { login } } } } } }"}`;
|
||||
req.headers = {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `bearer ${key}`,
|
||||
};
|
||||
|
||||
let resp = await (req.fetch().catch((err) => {
|
||||
console.error("Problem fetching issues:", err);
|
||||
let alert = new Alert("Problem fetching from GitHub", err);
|
||||
alert.show();
|
||||
throw err;
|
||||
}));
|
||||
let resp = await req.fetch().catch((err) => {
|
||||
console.error("Problem fetching issues:", err);
|
||||
let alert = new Alert("Problem fetching from GitHub", err);
|
||||
alert.show();
|
||||
throw err;
|
||||
});
|
||||
|
||||
if (resp.bodyString === null) {
|
||||
throw "body string was null. Did the request succeed?"
|
||||
}
|
||||
if (resp.bodyString === null) {
|
||||
throw "body string was null. Did the request succeed?";
|
||||
}
|
||||
|
||||
let body = JSON.parse(resp.bodyString);
|
||||
let body = JSON.parse(resp.bodyString);
|
||||
|
||||
//////////////////////////////////
|
||||
// Step 3: make the tasks in OF //
|
||||
//////////////////////////////////
|
||||
type Issue = {
|
||||
number: number,
|
||||
title: string,
|
||||
body: string,
|
||||
url: string,
|
||||
repository: {
|
||||
name: string,
|
||||
owner: {
|
||||
login: string,
|
||||
},
|
||||
},
|
||||
};
|
||||
//////////////////////////////////
|
||||
// Step 3: make the tasks in OF //
|
||||
//////////////////////////////////
|
||||
type Issue = {
|
||||
number: number;
|
||||
title: string;
|
||||
body: string;
|
||||
url: string;
|
||||
repository: {
|
||||
name: string;
|
||||
owner: {
|
||||
login: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
let toFocus: Array<Project> = [];
|
||||
for (let issue of body.data.search.nodes as Issue[]) {
|
||||
let gitHubTag = flattenedTags.byName("from GitHub") || new Tag("from GitHub");
|
||||
let orgTag = gitHubTag.tagNamed(issue.repository.owner.login) || new Tag(issue.repository.owner.login, gitHubTag);
|
||||
let repoTag = orgTag.tagNamed(issue.repository.name) || new Tag(issue.repository.name, orgTag);
|
||||
|
||||
let repo = `${issue.repository.owner.login}/${issue.repository.name}`;
|
||||
let projectName = `${repo}#${issue.number}: ${issue.title}`;
|
||||
let project = flattenedProjects.byName(projectName) || new Project(projectName);
|
||||
project.addTag(repoTag);
|
||||
project.note = `${issue.url}\n\n---\n\n${issue.body}`;
|
||||
toFocus.push(project);
|
||||
|
||||
if (project.tasks.length === 0) {
|
||||
new Task(`what needs to be done for ${repo}#${issue.number}?`, project);
|
||||
}
|
||||
}
|
||||
let toFocus: Array<Project> = [];
|
||||
for (let issue of body.data.search.nodes as Issue[]) {
|
||||
let gitHubTag =
|
||||
flattenedTags.byName("from GitHub") || new Tag("from GitHub");
|
||||
|
||||
if (app.platformName === "macOS") {
|
||||
document.windows[0].perspective = Perspective.BuiltIn.Projects;
|
||||
document.windows[0].focus = toFocus as SectionArray;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw err;
|
||||
let orgTag =
|
||||
gitHubTag.tagNamed(issue.repository.owner.login) ||
|
||||
new Tag(issue.repository.owner.login, gitHubTag);
|
||||
|
||||
let repoTag =
|
||||
orgTag.tagNamed(issue.repository.name) ||
|
||||
new Tag(issue.repository.name, orgTag);
|
||||
|
||||
let repo = `${issue.repository.owner.login}/${issue.repository.name}`;
|
||||
let projectName = `${repo}#${issue.number}: ${issue.title}`;
|
||||
let project =
|
||||
flattenedProjects.byName(projectName) || new Project(projectName);
|
||||
project.addTag(repoTag);
|
||||
project.note = `${issue.url}\n\n---\n\n${issue.body}`;
|
||||
toFocus.push(project);
|
||||
|
||||
if (project.tasks.length === 0) {
|
||||
new Task(
|
||||
`what needs to be done for ${repo}#${issue.number}?`,
|
||||
project
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return action;
|
||||
if (app.platformName === "macOS") {
|
||||
document.windows[0].perspective = Perspective.BuiltIn.Projects;
|
||||
document.windows[0].focus = toFocus as SectionArray;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
return action;
|
||||
})();
|
||||
|
|
|
@ -26,17 +26,18 @@
|
|||
// Step 2: get the tasks //
|
||||
///////////////////////////
|
||||
req.method = "POST";
|
||||
req.bodyString = '{"query":"{ viewer { assignedIssues(filter: {state: {type: {nin: [\\"completed\\",\\"canceled\\"]}}}) { nodes { identifier title url team { name } project { name url } } } } }"}';
|
||||
req.bodyString =
|
||||
'{"query":"{ viewer { assignedIssues(filter: {state: {type: {nin: [\\"completed\\",\\"canceled\\"]}}}) { nodes { identifier title url team { name } project { name url } } } } }"}';
|
||||
req.headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": key,
|
||||
Authorization: key,
|
||||
};
|
||||
let resp = await (req.fetch().catch((err) => {
|
||||
let resp = await req.fetch().catch((err) => {
|
||||
console.error("Problem fetching tasks:", err);
|
||||
let alert = new Alert("Problem fetching from Linear", err);
|
||||
alert.show();
|
||||
throw err;
|
||||
}));
|
||||
});
|
||||
if (resp.bodyString === null) {
|
||||
throw "body string was null. Did the request succeed?";
|
||||
}
|
||||
|
@ -47,7 +48,8 @@
|
|||
let toFocus = [];
|
||||
for (let linearTask of body.data.viewer.assignedIssues.nodes) {
|
||||
let teamsTag = flattenedTags.byName("teams") || new Tag("teams");
|
||||
let teamTag = teamsTag.tagNamed(linearTask.team.name) || new Tag(linearTask.team.name, teamsTag);
|
||||
let teamTag = teamsTag.tagNamed(linearTask.team.name) ||
|
||||
new Tag(linearTask.team.name, teamsTag);
|
||||
let linearTag = flattenedTags.byName("from Linear") || new Tag("from Linear");
|
||||
let projectName = `${linearTask.team.name} Non-Project Tasks`;
|
||||
if (linearTask.project !== null) {
|
||||
|
@ -59,7 +61,8 @@
|
|||
project.containsSingletonActions = true;
|
||||
project.status = Project.Status.Active;
|
||||
toFocus.push(project);
|
||||
if (linearTask.project && project.note.indexOf(linearTask.project.url) === -1) {
|
||||
if (linearTask.project &&
|
||||
project.note.indexOf(linearTask.project.url) === -1) {
|
||||
if (project.note !== "") {
|
||||
project.appendStringToNote(`\n\n${linearTask.project.url}`);
|
||||
}
|
||||
|
|
|
@ -1,104 +1,118 @@
|
|||
(() => {
|
||||
let creds = new Credentials();
|
||||
let creds = new Credentials();
|
||||
|
||||
var action = new PlugIn.Action(async () => {
|
||||
try {
|
||||
let req = URL.FetchRequest.fromString("https://api.linear.app/graphql");
|
||||
if (req === null || req.url === null || req.url.host === null) {
|
||||
throw "could not parse the URL for Linear's API"
|
||||
}
|
||||
var action = new PlugIn.Action(async () => {
|
||||
try {
|
||||
let req = URL.FetchRequest.fromString("https://api.linear.app/graphql");
|
||||
if (req === null || req.url === null || req.url.host === null) {
|
||||
throw "could not parse the URL for Linear's API";
|
||||
}
|
||||
|
||||
/////////////////////////////////////
|
||||
// Step 1: make sure we have creds //
|
||||
/////////////////////////////////////
|
||||
let stored = creds.read(req.url.host);
|
||||
/////////////////////////////////////
|
||||
// Step 1: make sure we have creds //
|
||||
/////////////////////////////////////
|
||||
let stored = creds.read(req.url.host);
|
||||
|
||||
let key = null;
|
||||
if (stored === null || app.optionKeyDown) {
|
||||
let credsForm = new Form();
|
||||
credsForm.addField(new Form.Field.Password("key", "API Key"));
|
||||
let key = null;
|
||||
if (stored === null || app.optionKeyDown) {
|
||||
let credsForm = new Form();
|
||||
credsForm.addField(new Form.Field.Password("key", "API Key"));
|
||||
|
||||
await credsForm.show("Please create a personal API key in the Linear settings and paste it here\n(hold option while activating this workflow in the future to reset this)", "Save Key");
|
||||
key = (credsForm.values as { key: string }).key;
|
||||
await credsForm.show(
|
||||
"Please create a personal API key in the Linear settings and paste it here\n(hold option while activating this workflow in the future to reset this)",
|
||||
"Save Key"
|
||||
);
|
||||
key = (credsForm.values as { key: string }).key;
|
||||
|
||||
creds.write(req.url.host, "-", key);
|
||||
} else {
|
||||
key = stored.password;
|
||||
}
|
||||
creds.write(req.url.host, "-", key);
|
||||
} else {
|
||||
key = stored.password;
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
// Step 2: get the tasks //
|
||||
///////////////////////////
|
||||
req.method = "POST";
|
||||
req.bodyString = '{"query":"{ viewer { assignedIssues(filter: {state: {type: {nin: [\\"completed\\",\\"canceled\\"]}}}) { nodes { identifier title url team { name } project { name url } } } } }"}';
|
||||
req.headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": key,
|
||||
};
|
||||
///////////////////////////
|
||||
// Step 2: get the tasks //
|
||||
///////////////////////////
|
||||
req.method = "POST";
|
||||
req.bodyString =
|
||||
'{"query":"{ viewer { assignedIssues(filter: {state: {type: {nin: [\\"completed\\",\\"canceled\\"]}}}) { nodes { identifier title url team { name } project { name url } } } } }"}';
|
||||
req.headers = {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: key,
|
||||
};
|
||||
|
||||
let resp = await (req.fetch().catch((err) => {
|
||||
console.error("Problem fetching tasks:", err);
|
||||
let alert = new Alert("Problem fetching from Linear", err);
|
||||
alert.show();
|
||||
throw err;
|
||||
}));
|
||||
let resp = await req.fetch().catch((err) => {
|
||||
console.error("Problem fetching tasks:", err);
|
||||
let alert = new Alert("Problem fetching from Linear", err);
|
||||
alert.show();
|
||||
throw err;
|
||||
});
|
||||
|
||||
if (resp.bodyString === null) {
|
||||
throw "body string was null. Did the request succeed?"
|
||||
}
|
||||
if (resp.bodyString === null) {
|
||||
throw "body string was null. Did the request succeed?";
|
||||
}
|
||||
|
||||
let body = JSON.parse(resp.bodyString);
|
||||
let body = JSON.parse(resp.bodyString);
|
||||
|
||||
//////////////////////////////////
|
||||
// Step 3: make the tasks in OF //
|
||||
//////////////////////////////////
|
||||
let toFocus: Array<Project> = [];
|
||||
for (let linearTask of body.data.viewer.assignedIssues.nodes) {
|
||||
let teamsTag = flattenedTags.byName("teams") || new Tag("teams");
|
||||
let teamTag = teamsTag.tagNamed(linearTask.team.name) || new Tag(linearTask.team.name, teamsTag);
|
||||
//////////////////////////////////
|
||||
// Step 3: make the tasks in OF //
|
||||
//////////////////////////////////
|
||||
let toFocus: Array<Project> = [];
|
||||
for (let linearTask of body.data.viewer.assignedIssues.nodes) {
|
||||
let teamsTag = flattenedTags.byName("teams") || new Tag("teams");
|
||||
let teamTag =
|
||||
teamsTag.tagNamed(linearTask.team.name) ||
|
||||
new Tag(linearTask.team.name, teamsTag);
|
||||
|
||||
let linearTag = flattenedTags.byName("from Linear") || new Tag("from Linear");
|
||||
let linearTag =
|
||||
flattenedTags.byName("from Linear") || new Tag("from Linear");
|
||||
|
||||
let projectName = `${linearTask.team.name} Non-Project Tasks`;
|
||||
if (linearTask.project !== null) {
|
||||
projectName = linearTask.project.name;
|
||||
}
|
||||
|
||||
let project = flattenedProjects.byName(projectName) || new Project(projectName);
|
||||
project.addTag(teamTag);
|
||||
project.addTag(linearTag);
|
||||
project.containsSingletonActions = true;
|
||||
toFocus.push(project);
|
||||
if (linearTask.project && project.note.indexOf(linearTask.project.url) === -1) {
|
||||
if (project.note !== "") {
|
||||
project.appendStringToNote(`\n\n${linearTask.project.url}`);
|
||||
} else {
|
||||
project.appendStringToNote(linearTask.project.url)
|
||||
}
|
||||
}
|
||||
|
||||
let taskName = `${linearTask.identifier}: ${linearTask.title}`;
|
||||
let task = project.taskNamed(taskName) || new Task(taskName, project);
|
||||
task.addTag(teamTag);
|
||||
task.addTag(linearTag);
|
||||
if (task.note.indexOf(linearTask.url) === -1) {
|
||||
if (task.note !== "") {
|
||||
task.appendStringToNote(`\n\n${linearTask.url}`);
|
||||
} else {
|
||||
task.appendStringToNote(linearTask.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (app.platformName === "macOS") {
|
||||
document.windows[0].perspective = Perspective.BuiltIn.Projects;
|
||||
document.windows[0].focus = toFocus as SectionArray;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw err;
|
||||
let projectName = `${linearTask.team.name} Non-Project Tasks`;
|
||||
if (linearTask.project !== null) {
|
||||
projectName = linearTask.project.name;
|
||||
}
|
||||
});
|
||||
|
||||
return action;
|
||||
let project =
|
||||
flattenedProjects.byName(projectName) || new Project(projectName);
|
||||
project.addTag(teamTag);
|
||||
project.addTag(linearTag);
|
||||
project.containsSingletonActions = true;
|
||||
project.status = Project.Status.Active;
|
||||
|
||||
toFocus.push(project);
|
||||
if (
|
||||
linearTask.project &&
|
||||
project.note.indexOf(linearTask.project.url) === -1
|
||||
) {
|
||||
if (project.note !== "") {
|
||||
project.appendStringToNote(`\n\n${linearTask.project.url}`);
|
||||
} else {
|
||||
project.appendStringToNote(linearTask.project.url);
|
||||
}
|
||||
}
|
||||
|
||||
let taskName = `${linearTask.identifier}: ${linearTask.title}`;
|
||||
let task = project.taskNamed(taskName) || new Task(taskName, project);
|
||||
task.addTag(teamTag);
|
||||
task.addTag(linearTag);
|
||||
task.markIncomplete();
|
||||
if (task.note.indexOf(linearTask.url) === -1) {
|
||||
if (task.note !== "") {
|
||||
task.appendStringToNote(`\n\n${linearTask.url}`);
|
||||
} else {
|
||||
task.appendStringToNote(linearTask.url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (app.platformName === "macOS") {
|
||||
document.windows[0].perspective = Perspective.BuiltIn.Projects;
|
||||
document.windows[0].focus = toFocus as SectionArray;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
return action;
|
||||
})();
|
||||
|
|
|
@ -8,21 +8,21 @@ don't! Modify the .ts file and run `tsc` instead!
|
|||
if (tag.name == "Wandering Toolmaker") {
|
||||
return tag.name;
|
||||
}
|
||||
else if (tag.name == "teams" || (tag.parent && tag.parent.name == "teams") || tag.name == "work" || (tag.parent && tag.parent.name == "work")) {
|
||||
else if (tag.name == "teams" ||
|
||||
(tag.parent && tag.parent.name == "teams") ||
|
||||
tag.name == "work" ||
|
||||
(tag.parent && tag.parent.name == "work")) {
|
||||
return "Team";
|
||||
}
|
||||
else if (tag.name == "personal" || (tag.parent && tag.parent.name == "personal")) {
|
||||
else if (tag.name == "personal" ||
|
||||
(tag.parent && tag.parent.name == "personal")) {
|
||||
return "Personal";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var action = new PlugIn.Action(async (selection, sender) => {
|
||||
try {
|
||||
let possibleCategories = [
|
||||
"Personal",
|
||||
"Team",
|
||||
"Wandering Toolmaker",
|
||||
];
|
||||
let possibleCategories = ["Personal", "Team", "Wandering Toolmaker"];
|
||||
let defaultCategory = possibleCategories[0];
|
||||
let defaultProject = null;
|
||||
let defaultMinutes = "25";
|
||||
|
@ -76,7 +76,9 @@ don't! Modify the .ts file and run `tsc` instead!
|
|||
}
|
||||
});
|
||||
action.validate = function (selection, sender) {
|
||||
return (selection.tasks.length === 1 || selection.tags.length === 1 || selection.projects.length === 1);
|
||||
return (selection.tasks.length === 1 ||
|
||||
selection.tags.length === 1 ||
|
||||
selection.projects.length === 1);
|
||||
};
|
||||
return action;
|
||||
})();
|
||||
|
|
|
@ -5,85 +5,100 @@ don't! Modify the .ts file and run `tsc` instead!
|
|||
(() => {
|
||||
function findCategory(tag: Tag): string | null {
|
||||
if (tag.name == "Wandering Toolmaker") {
|
||||
return tag.name
|
||||
|
||||
} else if (tag.name == "teams" || (tag.parent && tag.parent.name == "teams") || tag.name == "work" || (tag.parent && tag.parent.name == "work")) {
|
||||
return "Team"
|
||||
|
||||
} else if (tag.name == "personal" || (tag.parent && tag.parent.name == "personal")) {
|
||||
return "Personal"
|
||||
return tag.name;
|
||||
} else if (
|
||||
tag.name == "teams" ||
|
||||
(tag.parent && tag.parent.name == "teams") ||
|
||||
tag.name == "work" ||
|
||||
(tag.parent && tag.parent.name == "work")
|
||||
) {
|
||||
return "Team";
|
||||
} else if (
|
||||
tag.name == "personal" ||
|
||||
(tag.parent && tag.parent.name == "personal")
|
||||
) {
|
||||
return "Personal";
|
||||
}
|
||||
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
|
||||
var action = new PlugIn.Action(async (selection: Selection, sender: any) => {
|
||||
try {
|
||||
|
||||
let possibleCategories = [
|
||||
"Personal",
|
||||
"Team",
|
||||
"Wandering Toolmaker",
|
||||
];
|
||||
let possibleCategories = ["Personal", "Team", "Wandering Toolmaker"];
|
||||
let defaultCategory: string = possibleCategories[0];
|
||||
let defaultProject: string | null = null;
|
||||
let defaultMinutes: string = "25";
|
||||
|
||||
if (selection.tasks[0]) {
|
||||
let task = selection.tasks[0]
|
||||
let task = selection.tasks[0];
|
||||
|
||||
for (let tag of task.tags) {
|
||||
let category = findCategory(tag);
|
||||
if (category !== null) {
|
||||
defaultCategory = category
|
||||
break
|
||||
defaultCategory = category;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (task.containingProject) {
|
||||
defaultProject = task.containingProject.name;
|
||||
}
|
||||
|
||||
} else if (selection.tags[0]) {
|
||||
let tag = selection.tags[0]
|
||||
let tag = selection.tags[0];
|
||||
|
||||
defaultProject = tag.name
|
||||
defaultProject = tag.name;
|
||||
|
||||
let category = findCategory(tag)
|
||||
let category = findCategory(tag);
|
||||
if (category !== null) {
|
||||
defaultCategory = category
|
||||
defaultCategory = category;
|
||||
}
|
||||
|
||||
} else if (selection.projects[0]) {
|
||||
let project = selection.projects[0]
|
||||
let project = selection.projects[0];
|
||||
|
||||
defaultProject = project.name
|
||||
defaultProject = project.name;
|
||||
|
||||
for (let tag of project.tags) {
|
||||
let category = findCategory(tag);
|
||||
if (category !== null) {
|
||||
defaultCategory = category
|
||||
break
|
||||
defaultCategory = category;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let focusForm = new Form();
|
||||
focusForm.addField(new Form.Field.String("project", "Project", defaultProject));
|
||||
focusForm.addField(new Form.Field.Option("category", "Category", possibleCategories, possibleCategories, defaultCategory));
|
||||
focusForm.addField(new Form.Field.String("minutes", "Minutes", defaultMinutes));
|
||||
focusForm.addField(
|
||||
new Form.Field.String("project", "Project", defaultProject)
|
||||
);
|
||||
focusForm.addField(
|
||||
new Form.Field.Option(
|
||||
"category",
|
||||
"Category",
|
||||
possibleCategories,
|
||||
possibleCategories,
|
||||
defaultCategory
|
||||
)
|
||||
);
|
||||
focusForm.addField(
|
||||
new Form.Field.String("minutes", "Minutes", defaultMinutes)
|
||||
);
|
||||
|
||||
await focusForm.show("Focus on…", "Start");
|
||||
let values = focusForm.values as {
|
||||
project: string,
|
||||
category: string,
|
||||
minutes: string,
|
||||
project: string;
|
||||
category: string;
|
||||
minutes: string;
|
||||
};
|
||||
|
||||
let rawSessionUrl = `session:///start?intent=${encodeURIComponent(values.project)}&categoryName=${encodeURIComponent(values.category)}&duration=${encodeURIComponent(values.minutes)}`
|
||||
let sessionUrl = URL.fromString(rawSessionUrl)
|
||||
let rawSessionUrl = `session:///start?intent=${encodeURIComponent(
|
||||
values.project
|
||||
)}&categoryName=${encodeURIComponent(
|
||||
values.category
|
||||
)}&duration=${encodeURIComponent(values.minutes)}`;
|
||||
let sessionUrl = URL.fromString(rawSessionUrl);
|
||||
if (sessionUrl === null) {
|
||||
throw `failed to parse session string ("${rawSessionUrl}") into a URL`
|
||||
throw `failed to parse session string ("${rawSessionUrl}") into a URL`;
|
||||
}
|
||||
sessionUrl.open();
|
||||
} catch (err) {
|
||||
|
@ -91,8 +106,12 @@ don't! Modify the .ts file and run `tsc` instead!
|
|||
}
|
||||
});
|
||||
|
||||
action.validate = function(selection: Selection, sender: any){
|
||||
return (selection.tasks.length === 1 || selection.tags.length === 1 || selection.projects.length === 1)
|
||||
action.validate = function (selection: Selection, sender: any) {
|
||||
return (
|
||||
selection.tasks.length === 1 ||
|
||||
selection.tags.length === 1 ||
|
||||
selection.projects.length === 1
|
||||
);
|
||||
};
|
||||
|
||||
return action;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
declare const app: Application
|
||||
declare const app: Application;
|
||||
|
||||
declare const console: Console
|
||||
declare const console: Console;
|
||||
|
||||
declare const document: DatabaseDocument
|
||||
declare const document: DatabaseDocument;
|
||||
|
||||
declare const inbox: Inbox
|
||||
declare const inbox: Inbox;
|
||||
|
||||
declare const flattenedProjects : ProjectArray
|
||||
declare const flattenedProjects: ProjectArray;
|
||||
|
||||
declare const flattenedTags : TagArray
|
||||
declare const flattenedTags: TagArray;
|
||||
|
||||
declare const flattenedTasks : TaskArray
|
||||
declare const flattenedTasks: TaskArray;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue