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 b01e954
Show file tree
Hide file tree
Showing 4 changed files with 54 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
29 changes: 29 additions & 0 deletions frontend/app/services/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Service, { service } from '@ember/service';

Check failure on line 1 in frontend/app/services/docs.js

View workflow job for this annotation

GitHub Actions / lint (js)

Replace `'@ember/service'` with `"@ember/service"`

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

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

get getDocsURL() {

Check failure on line 11 in frontend/app/services/docs.js

View workflow job for this annotation

GitHub Actions / lint (js)

Expected getter 'getDocsURL' to always return a value
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];
}
}
}
}
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';

Check failure on line 1 in frontend/tests/unit/services/docs-test.js

View workflow job for this annotation

GitHub Actions / lint (js)

Replace `'qunit'` with `"qunit"`
import { setupTest } from 'timed/tests/helpers';

Check failure on line 2 in frontend/tests/unit/services/docs-test.js

View workflow job for this annotation

GitHub Actions / lint (js)

Replace `'timed/tests/helpers'` with `"timed/tests/helpers"`

module('Unit | Service | docs', function (hooks) {

Check failure on line 4 in frontend/tests/unit/services/docs-test.js

View workflow job for this annotation

GitHub Actions / lint (js)

Replace `'Unit·|·Service·|·docs'` with `"Unit·|·Service·|·docs"`
setupTest(hooks);

// TODO: Replace this with your real tests.
test('it exists', function (assert) {

Check failure on line 8 in frontend/tests/unit/services/docs-test.js

View workflow job for this annotation

GitHub Actions / lint (js)

Replace `'it·exists'` with `"it·exists"`
let service = this.owner.lookup('service:docs');

Check failure on line 9 in frontend/tests/unit/services/docs-test.js

View workflow job for this annotation

GitHub Actions / lint (js)

'service' is never reassigned. Use 'const' instead

Check failure on line 9 in frontend/tests/unit/services/docs-test.js

View workflow job for this annotation

GitHub Actions / lint (js)

Replace `'service:docs'` with `"service:docs"`
assert.ok(service);
});
});

0 comments on commit b01e954

Please sign in to comment.