Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add timed docs to top nav #570

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could just call it docsEndpoint

return this.timedDocsURL + this.getDocsURL;
}

get getDocsURL() {
const docsUrlMatch = {
Copy link
Collaborator

@c0rydoras c0rydoras Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be a constant

// filename.js

const ROUTE_DOCS_MAP = {
   ...
}

// 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 "";
}
}
Comment on lines +11 to +30
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use the current route instead of the current url

2 changes: 1 addition & 1 deletion frontend/tests/acceptance/external-employee-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module("Acceptance | external employee", function (hooks) {
test("can only view tracking in top navigation", async function (assert) {
await visit("/");

assert.dom("section > ul > li").exists({ count: 3 });
assert.dom("section > ul > li").exists({ count: 4 });
assert.dom("section > ul > li").includesText("Tracking");
});

Expand Down
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);
});
});
Loading