diff --git a/action.yml b/action.yml index b08ecaad..860333ca 100644 --- a/action.yml +++ b/action.yml @@ -374,6 +374,11 @@ inputs: description: Number of active projects to display default: 4 + # Display projects descriptions if enabled + plugin_projects_descriptions: + description: Display projects descriptions + default: no + # Tweets plugin # Enable it to display recent tweets of the twitter username attached to "user" plugin_tweets: diff --git a/source/app/action/index.mjs b/source/app/action/index.mjs index df066a96..bab95f2f 100644 --- a/source/app/action/index.mjs +++ b/source/app/action/index.mjs @@ -210,6 +210,8 @@ info(`Projects ${option}`, q[`projects.${option}`] = input.string(`plugin_projects_${option}`)) for (const option of ["limit"]) info(`Projects ${option}`, q[`projects.${option}`] = input.number(`plugin_projects_${option}`)) + for (const option of ["descriptions"]) + info(`Projects ${option}`, q[`projects.${option}`] = input.bool(`plugin_projects_${option}`)) } //Tweets if (plugins.tweets.enabled) { diff --git a/source/app/mocks.mjs b/source/app/mocks.mjs index 5a221bb2..9c61d69e 100644 --- a/source/app/mocks.mjs +++ b/source/app/mocks.mjs @@ -210,7 +210,7 @@ } //Gists query if (/^query Gists /.test(query)) { - console.debug(`metrics/compute/mocks > mocking graphql api result > Projects`) + console.debug(`metrics/compute/mocks > mocking graphql api result > Gists`) return /after: "MOCKED_CURSOR"/m.test(query) ? ({ user:{ gists:{ @@ -258,6 +258,7 @@ { name:"User-owned project", updatedAt:`${faker.date.recent()}`, + body:faker.lorem.paragraph(), progress:{ doneCount:faker.random.number(10), inProgressCount:faker.random.number(10), @@ -279,6 +280,7 @@ project:{ name:"Repository project example", updatedAt:`${faker.date.recent()}`, + body:faker.lorem.paragraph(), progress:{ doneCount:faker.random.number(10), inProgressCount:faker.random.number(10), diff --git a/source/plugins/projects/index.mjs b/source/plugins/projects/index.mjs index bb6d70d2..0ac50cd3 100644 --- a/source/plugins/projects/index.mjs +++ b/source/plugins/projects/index.mjs @@ -6,7 +6,7 @@ if ((!enabled)||(!q.projects)) return null //Parameters override - let {"projects.limit":limit = 4, "projects.repositories":repositories = ""} = q + let {"projects.limit":limit = 4, "projects.repositories":repositories = "", "projects.descriptions":descriptions = false} = q //Repositories projects repositories = decodeURIComponent(repositories ?? "").split(",").map(repository => repository.trim()).filter(repository => /[-\w]+[/][-\w]+[/]projects[/]\d+/.test(repository)) ?? [] //Limit @@ -41,13 +41,13 @@ //Format progress const {enabled, todoCount:todo, inProgressCount:doing, doneCount:done} = project.progress //Append - list.push({name:project.name, updated, progress:{enabled, todo, doing, done, total:todo+doing+done}}) + list.push({name:project.name, updated, description:project.body, progress:{enabled, todo, doing, done, total:todo+doing+done}}) } //Limit console.debug(`metrics/compute/${login}/plugins > projects > keeping only ${limit} projects`) list.splice(limit) //Results - return {list, totalCount:projects.totalCount} + return {list, totalCount:projects.totalCount, descriptions} } //Handle errors catch (error) { diff --git a/source/queries/projects.graphql b/source/queries/projects.graphql index 21e8fc87..01b5af8a 100644 --- a/source/queries/projects.graphql +++ b/source/queries/projects.graphql @@ -4,6 +4,7 @@ query Projects { totalCount nodes { name + body updatedAt progress { doneCount diff --git a/source/queries/projects.repository.graphql b/source/queries/projects.repository.graphql index f18f833d..5c4a5b78 100644 --- a/source/queries/projects.repository.graphql +++ b/source/queries/projects.repository.graphql @@ -3,6 +3,7 @@ query RepositoryProject { repository(name: "$repository") { project(number: $id) { name + body updatedAt progress { doneCount diff --git a/source/templates/classic/partials/projects.ejs b/source/templates/classic/partials/projects.ejs index 75c91050..599d000b 100644 --- a/source/templates/classic/partials/projects.ejs +++ b/source/templates/classic/partials/projects.ejs @@ -13,8 +13,8 @@ <% } else { %> -
- <% for (const {name, updated, progress} of plugins.projects.list) { %> +
+ <% for (const {name, updated, progress, description = ""} of plugins.projects.list) { %>
@@ -23,6 +23,15 @@
+ <% if (plugins.projects.descriptions) { %> +
+
+
+ <%= description %> +
+
+
+ <% } %>
diff --git a/source/templates/classic/style.css b/source/templates/classic/style.css index e527ea6a..46b05d9a 100644 --- a/source/templates/classic/style.css +++ b/source/templates/classic/style.css @@ -511,6 +511,22 @@ margin: 0 2px; } +/* Projects */ + .project .description { + overflow: hidden; + text-overflow: ellipsis; + display: block; + width: 420px; + margin-left: 37px; + max-height: 38px; + font-size: 12px; + white-space: normal; + /* May not work in all browsers */ + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + } + /* Fade animation */ .af { opacity: 0; diff --git a/tests/metrics.test.js b/tests/metrics.test.js index b881c877..80e84d5b 100644 --- a/tests/metrics.test.js +++ b/tests/metrics.test.js @@ -211,6 +211,12 @@ plugin_projects_repositories:"lowlighter/metrics/projects/1", plugin_projects_limit:0, }, {skip:["terminal"]}], + ["Projects plugin (descriptions)", { + plugin_projects:true, + plugin_projects_repositories:"lowlighter/metrics/projects/1", + plugin_projects_limit:0, + plugin_projects_descriptions:true, + }, {skip:["terminal"]}], ["Lines plugin (default)", { base:"repositories", plugin_lines:true,