Skip to content

Commit

Permalink
feat: add timed docs to top nav
Browse files Browse the repository at this point in the history
  • Loading branch information
MitanOmar committed Jan 9, 2025
1 parent 3b3629a commit 2f4a26f
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
11 changes: 11 additions & 0 deletions frontend/app/components/topnav.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@
</Topnav::List>
<Topnav::List class="md:ml-auto md:border-t-0">
<ReportReviewWarning @class="max-md:hidden" />
<Topnav::ListItem>
<Topnav::LinkTo
@onClick={{fn (mut this.expand) false}}
title="Timed Documentation Of This Page"
href={{this.docs.getDocsEndpoint}}
target="_blank"
>
<FaIcon @icon="book" />
Docs
</Topnav::LinkTo>
</Topnav::ListItem>
<Topnav::ListItem>
<Topnav::LinkTo
@onClick={{fn (mut this.expand) false}}
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/components/topnav.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export default class Topnav extends Component {

@service media;

@service docs;

@tracked expand = false;

get navMobile() {
Expand Down
30 changes: 30 additions & 0 deletions frontend/app/services/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Service, { service } from "@ember/service";

export default class DocsService extends Service {
timedDocsURL = "https://timed.dev/docs/";
@service router;

get getDocsEndpoint() {
return this.timedDocsURL + this.getDocsURL;
}

get getDocsURL() {
const docsUrlMatch = {
// timedUrl: DocsUrl
"/attendances": "tracking/attendances",
"/reports": "tracking/timesheet",
"/analysis": "analysis",
"/statistics": "statistics",
"/projects": "projects",
"/users": "users",
"/": "tracking/activities",
};

for (const timedUrl of Object.keys(docsUrlMatch)) {
if (this.router.currentURL.startsWith(timedUrl)) {
return docsUrlMatch[timedUrl];
}
}
return "";
}
}
12 changes: 12 additions & 0 deletions frontend/tests/unit/services/docs-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { module, test } from "qunit";
import { setupTest } from "timed/tests/helpers";

module("Unit | Service | docs", function (hooks) {
setupTest(hooks);

// TODO: Replace this with your real tests.
test("it exists", function (assert) {
const service = this.owner.lookup("service:docs");
assert.ok(service);
});
});

0 comments on commit 2f4a26f

Please sign in to comment.