Skip to content

Commit

Permalink
fix: add first todoist version
Browse files Browse the repository at this point in the history
  • Loading branch information
dubisdev committed Mar 5, 2024
1 parent 59359cc commit e99cf76
Show file tree
Hide file tree
Showing 27 changed files with 727 additions and 0 deletions.
58 changes: 58 additions & 0 deletions extensions/todoist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<img width="300" align="right" alt="rokii-todoist logo" src="https://user-images.githubusercontent.com/77246331/174854937-535dccc9-6d27-4bf8-927f-f4e664ca0a0f.png"/>

# cerebro-todoist &nbsp; ![npm](https://img.shields.io/npm/v/cerebro-cerebro-todoist?color=green) ![download number](https://img.shields.io/npm/dt/cerebro-cerebro-todoist)

> [Rokii](https://rokii.app) plugin to create and manage Todoist tasks.
⚠️ Rokii-Todoist is an extension that IS NOT created by, affiliated with,
or supported by @Doist

## Installation

- Type `plugins todoist` into Rokii
- Click `install`
- Set your Todoist API token in the plugin
settings --> `plugins todoist` - Select `settings` - `token`

<p align="center">
<img width="600" src="https://user-images.githubusercontent.com/77246331/169042136-e94d61a0-9bac-4992-80f3-0c62396a616d.png"

## Usage

### Available commands

- `tds new` ➡️ Creates a new task (natural language syntax supported)
- `tds today` ➡️ Returns a list with tasks for today and overdue tasks
- Navigate between them to see details
- `tds view` + filter ➡️ Returns tasks matching the filter
(ex: 18/05, tomorrow, today, search: buy, ...).
For more information about this filters see [Todoist Documentation](https://todoist.com/help/articles/introduction-to-filters)

😎 You can search between tasks just by typing ➡️ `tds today milk` - Filters
the tasks and returns the ones that have "milk" in their name
(same with `tds view 12/10 & search:milk`)

⚡ Due to performance issues and API restrictions,
project names will only appear if the number of matching tasks is less than 10

💡 You can configure the command names in the plugin
settings page ➡️ `plugins todoist settings`

## Need Support?

You can [open an issue](https://github.com/rokiiapp/extensions/issues/new) in
this repository or [contact me by email](mailto:[email protected])

## Related

- [RokiiApp](http://github.com/rokiiapp/app) – main repo for Rokii

## Privacy Policy

No user data is collected. Once you install the plugin it makes requests
directly to the Todoist API and the responses are sent directly to your computer.
Just simple, fast and private.

## License

MIT © [David Jiménez](https://dubis.dev)
Binary file added extensions/todoist/assets/logo-gimp.xcf
Binary file not shown.
Binary file added extensions/todoist/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/todoist/assets/published/add task.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/todoist/assets/published/today.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/todoist/assets/social.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions extensions/todoist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@rokii-plugins/todoist",
"version": "0.1.0",
"type": "module",
"description": "Manage your Todoist tasks from Rokii",
"author": "David Jiménez <[email protected]> (https://dubis.dev)",
"license": "MIT",
"repository": "rokiiapp/extensions",
"files": [
"dist"
],
"dependencies": {
"@rokii/api": "0.4.1",
"@cerebroapp/cerebro-ui": "2.0.0-alpha.5",
"@doist/todoist-api-typescript": "3.0.1",
"cerebro-command-router": "2.0.0",
"p-debounce": "4.0.0",
"semver": "7.5.4"
},
"devDependencies": {
"@rokii/build": "2.0.13",
"@types/react": "*"
},
"main": "dist/index.js",
"scripts": {
"start": "rokii-build dev",
"build": "rokii-build build",
"clear": "rokii-build clear",
"prepublish": "pnpm clear && pnpm build"
}
}
56 changes: 56 additions & 0 deletions extensions/todoist/src/components/TaskInfo/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { KeyboardNavItem, KeyboardNav } from "@cerebroapp/cerebro-ui";
import { completeTask, deleteTask, getTaskHour } from "services/taskServices";
import styles from "./styles.module.css";
import lang from "lang";
const strings = lang.TaskInfo;

const ListItem = ({ children, onSelect = () => {} }) => {
return (
<KeyboardNavItem style={{ justifyContent: "center" }} onSelect={onSelect}>
{children}
</KeyboardNavItem>
);
};

const TasksInfoPreview = ({ task, actions, client }) => {
const complete = (task) => {
completeTask(client, task);
actions.hideWindow();
};
const del = (task) => {
deleteTask(client, task);
actions.hideWindow();
};

const goToProject = (task) => {
actions.replaceTerm("tds view ##" + task.projectName);
};

const taskHour = getTaskHour(task);
const { content, description, projectName } = task;

return (
<div className={styles.wrapper}>
<h2 style={{ textAlign: "center" }}>{content}</h2>
<KeyboardNav>
<ul className={styles.list}>
{taskHour && <ListItem>{taskHour}</ListItem>}
{description && <ListItem>{description}</ListItem>}
{projectName && (
<ListItem onSelect={() => goToProject(task)}>
{projectName}
</ListItem>
)}
<ListItem onSelect={() => complete(task)}>
{strings.completeTaskButton}
</ListItem>
<ListItem onSelect={() => del(task)}>
{strings.deleteTaskButton}
</ListItem>
</ul>
</KeyboardNav>
</div>
);
};

export default TasksInfoPreview;
23 changes: 23 additions & 0 deletions extensions/todoist/src/components/TaskInfo/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.wrapper {
background-color: rgba(0, 0, 0, 0.438);
align-self: flex-start;
width: 100%;
margin: -10px;
position: relative;
transition: all 0.3s linear;
}

.list {
margin: 0;
padding: 0;
}

@keyframes scroll {
0% {
top: 50%;
}

100% {
top: -25%;
}
}
3 changes: 3 additions & 0 deletions extensions/todoist/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import notification from './notification';

export { notification };
19 changes: 19 additions & 0 deletions extensions/todoist/src/components/notification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import iconDefault from '../icons';

export default ({
title = 'Rokii-Todoist',
body = '',
icon = iconDefault,
isUpdate = false
} = {}) => {
const noti = new Notification(title, { body, icon });
if (isUpdate) {
noti.onclick = function (event) {
event.preventDefault(); // Previene al buscador de mover el foco a la pestaña del Notification
window.open(
'https://github.com/dubisdev/cerebro-todoist/releases',
'_blank'
);
};
}
};
4 changes: 4 additions & 0 deletions extensions/todoist/src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.png' {
const content: string;
export = content;
}
Binary file added extensions/todoist/src/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions extensions/todoist/src/icons/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import icon from './icon.png';
export default icon;
57 changes: 57 additions & 0 deletions extensions/todoist/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { ExtensionModule, AppItem, ScriptItem, InfoItem } from '@rokii/api';
// import { TodoistApi } from '@doist/todoist-api-typescript';
import { createTask } from './services';
import icon from './icons/icon.png';
import { settings } from './settings';

if (!Notification.permission) Notification.requestPermission();

const APP_NAMES = {
today: 'tds_today',
view: 'tds_view'
};

const todayAppLauncher = new AppItem({
title: 'View Today Tasks',
icon,
keyword: ['tds today'],
appName: APP_NAMES.today
});

const viewAppLauncher = new AppItem({
title: 'View X Day Tasks',
icon,
keyword: ['tds view'],
appName: APP_NAMES.view
});

const noTokenFound = new InfoItem({ title: 'No token found' });

const run: ExtensionModule['run'] = async (ctx) => {
const { display, settings, term } = ctx;
const token = settings.token;

if (!token) return display([noTokenFound]);

const createTaskItem = new ScriptItem({
title: 'New Task',
icon,
keyword: ['tds'],
run: () => createTask(token, { text: term })
});

display([todayAppLauncher, viewAppLauncher, createTaskItem]);
};

const TodoistExtension: ExtensionModule = {
name: 'Todoist',
icon,
run,
apps: {
// [APP_NAMES.today]: null,
// [APP_NAMES.view]: null
},
settings
};

export default TodoistExtension;
55 changes: 55 additions & 0 deletions extensions/todoist/src/lang/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"error": "Rokii Todoist Error",
"noTokenFound": "No token found :(",
"workflow_new": "Todoist: New Task",
"workflow_today": "Todoist: Today Tasks",
"workflow_view": "Todoist: View Someday Tasks",
"workflow_update": "Plugin updated!",
"invalidCommand": "Invalid Todoist Workflow Command",
"gettingTasksMessage": "Searching tasks...",
"settings": {
"descriptionToken": "Your Todoist API Token",
"descriptionOverdue": "Show overdue tasks on Today view",
"descriptionNewCommand": "Command for creating new tasks.",
"descriptionTodayCommand": "Command for showing today tasks.",
"descriptionViewCommand": "Command for showing someday tasks.",
"descriptionUsageData": "We only collect error data and some anonymous logs for fixing errors in the app. We DO NOT share any information with third parts."
},
"notifications": {
"taskCreated": "Task Created",
"taskCompleted": "Task Completed!",
"taskDeleted": "Task Completed!",
"createTaskErrorInternet": "Task couldn't be created: No internet conexion",
"createTaskErrorToken": "Task couldn't be created: Please check the token in the cerebro-todoist settings.",
"updateAvailable": "A new rokii-todoist version is available! Download and install it from cerebroapp plugin settings.",
"sendData_title": "Rokii-Todoist: Help me to help you!",
"sendData_body": "Would you like to send anonymous data usage? Help us by activating this option in the plugin settings ❤"
},
"NewTodayTask": {
"title": "New Todoist Task",
"description": "Creates a new Todoist task in your inbox for today. Use natural language to create the task: date, labels, projects,... will be recognized."
},
"TaskInfo": {
"completeTaskButton": "Complete Task",
"deleteTaskButton": "Delete Task",
"error": "Something was wrong (check your internet connection or your Todoist API token)."
},
"displayArrayGenerator": {
"noFilterFound": "Enter a filter, please.",
"filterError": "Incorrect filter",
"noFilteredTasksFound": "No filtered tasks found",
"noTodayTasks": "No tasks for today! Is this #TodoistZero ?",
"noXDayTasks": "No tasks for this day.",
"dateNeeded": "Enter a date, please.",
"invalidDate": "Enter a valid date, please."
},
"afterUpdate": {
"pluginUpdated": "Plugin updated!",
"viewChangelog": "See changelog",
"clickToHideWindow": "Hide this window"
},
"taskServices": {
"due_lang": "en",
"due_string": "today"
}
}
55 changes: 55 additions & 0 deletions extensions/todoist/src/lang/es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"error": "Error de Rokii-Todoist",
"noTokenFound": "No se ha encontrado un token :(",
"workflow_new": "Todoist: Nueva Tarea",
"workflow_today": "Todoist: Tareas de Hoy",
"workflow_view": "Todoist: Tareas de algún día",
"workflow_update": "¡Plugin Actualizado!",
"invalidCommand": "Comando no válido",
"gettingTasksMessage": "Buscando tareas...",
"settings": {
"descriptionToken": "Tu Token de la API Todoist",
"descriptionOverdue": "Mostrar tareas vencidas en la vista 'hoy'",
"descriptionNewCommand": "Comando para crear nuevas tareas.",
"descriptionTodayCommand": "Comando para ver las tareas de hoy.",
"descriptionViewCommand": "Comando para ver las tareas de un día concreto.",
"descriptionUsageData": "Solo recogemos datos anónimos sobre errores en la aplicación para poder arreglarlos. NO COMPARTIMOS estos datos con terceros."
},
"notifications": {
"taskCreated": "Tarea creada",
"taskCompleted": "¡Tarea completada!",
"taskDeleted": "¡Tarea eliminada!",
"createTaskErrorInternet": "La tarea no se pudo crear: No hay conexión a internet.",
"createTaskErrorToken": "La tarea no se pudo crear: El token de la API es incorrecto.",
"updateAvailable": "¡Una nueva versión de rokii-todoist está disponible! Descárgala desde los ajustes de Rokii",
"sendData_title": "Rokii-Todoist: ¡Ayúdame a mejorar!",
"sendData_body": "Activa la recogida de datos anónimos sobre errores desde los ajustes del plugin para ayudarme a seguir mejorándolo ❤"
},
"NewTodayTask": {
"title": "Nueva Tarea de Todoist",
"description": "Crea una nueva tarea que se asignará para hoy en tu bandeja de entrada. Puedes utilizar el lenguaje natural para añadir fechas, etiquetas, proyectos... y serán interpretados igual que en la aplicación de escritorio"
},
"TaskInfo": {
"completeTaskButton": "Completar Tarea",
"deleteTaskButton": "Eliminar tarea",
"error": "Algo salió mal (comprueba tu conexión a internet o tu token de la API Todoist)."
},
"displayArrayGenerator": {
"noFilterFound": "Introduce un filtro, por favor",
"filterError": "Filtro no válido",
"noFilteredTasksFound": "No se han encontrado tareas para este filtro",
"noTodayTasks": "¡No tienes tareas hoy! ¿Es esto un #TodoistZero ?",
"noXDayTasks": "No hay tareas para este día",
"dateNeeded": "Introduce una fecha por favor",
"invalidDate": "Introduce una fecha correcta, por favor"
},
"afterUpdate": {
"pluginUpdated": "¡Plugin Actualizado!",
"viewChangelog": "Ver el historial de cambios",
"clickToHideWindow": "Pulsa aquí para ocultar esta pestaña"
},
"taskServices": {
"due_lang": "es",
"due_string": "hoy"
}
}
Loading

0 comments on commit e99cf76

Please sign in to comment.