Skip to content

feat: add timed docs to top nav #570

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
18c6207
feat: add timed docs to top nav
MitanOmar Jan 20, 2025
39a17d1
Merge branch 'main' into Add-Timed-Docs-To-Top-Nav
MitanOmar Feb 14, 2025
fb6ad61
refactor(docs-service): use router name instate of uri
MitanOmar Mar 20, 2025
1555471
fix(docs-service-test): lint issue
MitanOmar Mar 20, 2025
df2f480
Merge branch 'main' into Add-Timed-Docs-To-Top-Nav
MitanOmar Mar 20, 2025
fb87afa
fix(docs-service-test): linting issue
MitanOmar Mar 20, 2025
47159f4
refactor(docs-service): move the base domain to env
MitanOmar Mar 20, 2025
d342948
fix(docs-service): lint
MitanOmar Mar 20, 2025
9f3dbe7
fix(docs-service): nav icon
MitanOmar Mar 20, 2025
593b203
test(docs-service): write acceptance test for docs service
MitanOmar Mar 20, 2025
b81e0ff
feat: add timed docs to the tour
MitanOmar Mar 21, 2025
4c88f97
Merge branch 'main' into Add-Timed-Docs-To-Top-Nav
MitanOmar Mar 24, 2025
f82a919
refactor(docs-service): update docs variable name with URL fixing
MitanOmar Mar 24, 2025
933b1cd
refactor: better text, and tests all routes
MitanOmar Apr 9, 2025
378d6e4
refactor: the docs nav link icon to `circle-question`
MitanOmar Apr 10, 2025
8cb8516
Merge branch 'main' into Add-Timed-Docs-To-Top-Nav
MitanOmar Apr 10, 2025
90cd9d2
refactor: delete unuseful tests
MitanOmar Apr 10, 2025
f8685cb
refactor: use only docs icon instate of `docs` word
MitanOmar Apr 10, 2025
8e63b56
Merge branch 'main' into Add-Timed-Docs-To-Top-Nav
MitanOmar Apr 23, 2025
d928843
refactor: implement the change requests
MitanOmar Apr 23, 2025
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="Open Timed documentation for current page"
href={{this.docs.endpoint}}
target="_blank"
data-test-docs-link
>
<FaIcon @icon="circle-question" @prefix="fa" />
</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
26 changes: 26 additions & 0 deletions frontend/app/services/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Service, { service } from "@ember/service";

import config from "timed/config/environment";

export const ROUTE_DOCS_MAPPING = {
"index.attendances": "/tracking/attendances",
"index.reports": "/tracking/timesheet",
"analysis.index": "/analysis",
statistics: "/statistics",
projects: "/projects",
"users.index": "/users",
"users.edit.index": "/users",
"index.activities.index": "/tracking/activities",
};

export default class DocsService extends Service {
@service router;

get endpoint() {
return config.docsBaseUrl + this.docsURL;
}

get docsURL() {
return ROUTE_DOCS_MAPPING[this.router.currentRouteName] ?? "";
}
}
11 changes: 11 additions & 0 deletions frontend/app/tours/index/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,15 @@ export default [
</p>
`,
},
{
id: "Docs",
target: "[data-test-docs-link]",
placement: "bottom",
title: "Timed Documentation",
content: `
<p>
You can access the Timed documentation with this link, which will redirect you to the corresponding page.
</p>
`,
},
];
1 change: 1 addition & 0 deletions frontend/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ module.exports = function (environment) {
userinfoEndpoint: "/userinfo",
afterLogoutUri: "/sso-login",
},
docsBaseUrl: process.env.DOCS_BASE_URL || "https://timed.dev/docs",
};

if (process.env.SENTRY_DSN) {
Expand Down
1 change: 1 addition & 0 deletions frontend/config/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module.exports = function () {
"users",
"question",
"magic",
"circle-question",
],
};
};
36 changes: 36 additions & 0 deletions frontend/tests/acceptance/docs-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { visit } from "@ember/test-helpers";
import { setupMirage } from "ember-cli-mirage/test-support";
import { setupApplicationTest } from "ember-qunit";
import { authenticateSession } from "ember-simple-auth/test-support";
import { module, test } from "qunit";

import config from "timed/config/environment";
import { ROUTE_DOCS_MAPPING } from "timed/services/docs";

module("Acceptance | docs", function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);

hooks.beforeEach(async function () {
const user = this.server.create("user", { tourDone: true });

await authenticateSession({ user_id: user.id });
});

test("Each route renders a link to the corresponding documentation page", async function (assert) {
const routesKey = Object.keys(ROUTE_DOCS_MAPPING);
const router = this.owner.lookup("service:router");

for (const routeKey of routesKey) {
if (routeKey === "users.edit.index") continue;
// eslint-disable-next-line no-await-in-loop
await visit(router.urlFor(routeKey));
assert.dom("[data-test-docs-link]").exists();

assert.strictEqual(
document.querySelector("[data-test-docs-link]").href,
`${config.docsBaseUrl}${ROUTE_DOCS_MAPPING[routeKey]}`,
);
}
});
});
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 @@ -50,7 +50,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
Loading