Skip to content

Commit a4385aa

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

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-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.docsEndpoint}}
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

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
docsUrlMatch = {
8+
// index.name: DocsUrl
9+
"index.attendances": "tracking/attendances",
10+
"index.reports": "tracking/timesheet",
11+
"analysis.index": "analysis",
12+
statistics: "statistics",
13+
projects: "projects",
14+
"users.index": "users",
15+
"users.edit.index": "users",
16+
"index.activities.index": "tracking/activities",
17+
};
18+
19+
get docsEndpoint() {
20+
console.log(this.router.currentRouteName);
21+
return this.timedDocsURL + this.getDocsURL;
22+
}
23+
24+
get getDocsURL() {
25+
for (const timedRouterName of Object.keys(this.docsUrlMatch)) {
26+
if (this.router.currentRouteName === timedRouterName) {
27+
return this.docsUrlMatch[timedRouterName];
28+
}
29+
}
30+
return "";
31+
}
32+
}

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)