Skip to content

Commit 13f9bdc

Browse files
committed
feat: add timed docs to top nav
1 parent 3b3629a commit 13f9bdc

File tree

5 files changed

+56
-1
lines changed

5 files changed

+56
-1
lines changed

frontend/app/components/topnav.hbs

+11
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@
8888
</Topnav::List>
8989
<Topnav::List class="md:ml-auto md:border-t-0">
9090
<ReportReviewWarning @class="max-md:hidden" />
91+
<Topnav::ListItem>
92+
<Topnav::LinkTo
93+
@onClick={{fn (mut this.expand) false}}
94+
title="Timed Documentation Of This Page"
95+
href={{this.docs.getDocsEndpoint}}
96+
target="_blank"
97+
>
98+
<FaIcon @icon="book" />
99+
Docs
100+
</Topnav::LinkTo>
101+
</Topnav::ListItem>
91102
<Topnav::ListItem>
92103
<Topnav::LinkTo
93104
@onClick={{fn (mut this.expand) false}}

frontend/app/components/topnav.js

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export default class Topnav extends Component {
77

88
@service media;
99

10+
@service docs;
11+
1012
@tracked expand = false;
1113

1214
get navMobile() {

frontend/app/services/docs.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Service, { service } from "@ember/service";
2+
3+
export default class DocsService extends Service {
4+
timedDocsURL = "https://timed.dev/docs/";
5+
@service router;
6+
7+
get getDocsEndpoint() {
8+
return this.timedDocsURL + this.getDocsURL;
9+
}
10+
11+
get getDocsURL() {
12+
const docsUrlMatch = {
13+
// timedUrl: DocsUrl
14+
"/attendances": "tracking/attendances",
15+
"/reports": "tracking/timesheet",
16+
"/analysis": "analysis",
17+
"/statistics": "statistics",
18+
"/projects": "projects",
19+
"/users": "users",
20+
"/": "tracking/activities",
21+
};
22+
23+
for (const timedUrl of Object.keys(docsUrlMatch)) {
24+
if (this.router.currentURL?.startsWith(timedUrl)) {
25+
return docsUrlMatch[timedUrl];
26+
}
27+
}
28+
return "";
29+
}
30+
}

frontend/tests/acceptance/external-employee-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module("Acceptance | external employee", function (hooks) {
5151
test("can only view tracking in top navigation", async function (assert) {
5252
await visit("/");
5353

54-
assert.dom("section > ul > li").exists({ count: 3 });
54+
assert.dom("section > ul > li").exists({ count: 4 });
5555
assert.dom("section > ul > li").includesText("Tracking");
5656
});
5757

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { module, test } from "qunit";
2+
import { setupTest } from "timed/tests/helpers";
3+
4+
module("Unit | Service | docs", function (hooks) {
5+
setupTest(hooks);
6+
7+
// TODO: Replace this with your real tests.
8+
test("it exists", function (assert) {
9+
const service = this.owner.lookup("service:docs");
10+
assert.ok(service);
11+
});
12+
});

0 commit comments

Comments
 (0)