generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2383 from obsidian-tasks-group/add-statuses-report
feat: Enable visualisation of the Status settings
- Loading branch information
Showing
5 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Tasks Plugin - Review and check your Statuses* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { StatusRegistry } from './StatusRegistry'; | ||
|
||
export function createStatusRegistryReport(statusRegistry: StatusRegistry, buttonName: string, versionString: string) { | ||
// Ideas for further improvement | ||
// - Actually make it an informative report, that shows any issues in settings with duplicate symbols. | ||
// - Show any 'next status symbols' that are not known to the plugin. | ||
// - Show any status transitions that won't work with recurring tasks currently, as DONE not followed by TODO. | ||
|
||
const detailed = true; | ||
const mermaidText = statusRegistry.mermaidDiagram(detailed); | ||
return `# ${buttonName} | ||
This file was created by the Obsidian Tasks plugin (version ${versionString}) to help visualise the task statuses in this vault. | ||
You can delete this file any time. | ||
<!-- Switch to Live Preview or Reading Mode to see the diagram. --> | ||
${mermaidText}`; | ||
} |
23 changes: 23 additions & 0 deletions
23
...atusRegistryReport.test.StatusRegistryReport_should_create_a_report.approved.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Review and check your Statuses | ||
|
||
This file was created by the Obsidian Tasks plugin (version x.y.z) to help visualise the task statuses in this vault. | ||
|
||
You can delete this file any time. | ||
|
||
<!-- Switch to Live Preview or Reading Mode to see the diagram. --> | ||
|
||
```mermaid | ||
flowchart LR | ||
1["'Todo'<br>[ ] -> [x]<br>(TODO)"] | ||
2["'In Progress'<br>[/] -> [x]<br>(IN_PROGRESS)"] | ||
3["'Done'<br>[x] -> [ ]<br>(DONE)"] | ||
4["'Cancelled'<br>[-] -> [ ]<br>(CANCELLED)"] | ||
5["'Question'<br>[Q] -> [A]<br>(NON_TASK)"] | ||
6["'Answer'<br>[A] -> [Q]<br>(NON_TASK)"] | ||
1 --> 3 | ||
2 --> 3 | ||
3 --> 1 | ||
4 --> 1 | ||
5 --> 6 | ||
6 --> 5 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { StatusRegistry } from '../src/StatusRegistry'; | ||
import { StatusConfiguration, StatusType } from '../src/StatusConfiguration'; | ||
import { createStatusRegistryReport } from '../src/StatusRegistryReport'; | ||
import { verifyWithFileExtension } from './TestingTools/ApprovalTestHelpers'; | ||
|
||
describe('StatusRegistryReport', function () { | ||
it('should create a report', () => { | ||
// Arrange | ||
const statusRegistry = new StatusRegistry(); | ||
statusRegistry.add(new StatusConfiguration('Q', 'Question', 'A', false, StatusType.NON_TASK)); | ||
statusRegistry.add(new StatusConfiguration('A', 'Answer', 'Q', false, StatusType.NON_TASK)); | ||
const reportName = 'Review and check your Statuses'; | ||
|
||
// Act | ||
const version = 'x.y.z'; // lower-case, as the capitalised version would get edited at the next release. | ||
const report = createStatusRegistryReport(statusRegistry, reportName, version); | ||
|
||
// Assert | ||
verifyWithFileExtension(report, '.md'); | ||
}); | ||
}); |