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 2 commits into
base: main
Choose a base branch
from

Conversation

MitanOmar
Copy link
Member

No description provided.

@MitanOmar MitanOmar requested a review from a team as a code owner January 9, 2025 15:31
@MitanOmar MitanOmar force-pushed the Add-Timed-Docs-To-Top-Nav branch 2 times, most recently from 2f4a26f to f15114a Compare January 9, 2025 15:50
@MitanOmar MitanOmar self-assigned this Jan 9, 2025
@MitanOmar MitanOmar force-pushed the Add-Timed-Docs-To-Top-Nav branch from f15114a to 13f9bdc Compare January 9, 2025 15:57
Comment on lines 11 to 31
get getDocsURL() {
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];
}
}
return "";
}
}
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

}

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 = {
   ...
}

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

@MitanOmar MitanOmar force-pushed the Add-Timed-Docs-To-Top-Nav branch from 13f9bdc to a4385aa Compare January 20, 2025 09:35
@MitanOmar MitanOmar force-pushed the Add-Timed-Docs-To-Top-Nav branch from a4385aa to 18c6207 Compare January 20, 2025 09:42
@MitanOmar MitanOmar requested a review from c0rydoras January 20, 2025 09:44
Comment on lines +23 to +31
get getDocsURL() {
for (const timedRouterName of Object.keys(this.docsUrlMatch)) {
if (this.router.currentRouteName === timedRouterName) {
return this.docsUrlMatch[timedRouterName];
}
}
return "";
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
get getDocsURL() {
for (const timedRouterName of Object.keys(this.docsUrlMatch)) {
if (this.router.currentRouteName === timedRouterName) {
return this.docsUrlMatch[timedRouterName];
}
}
return "";
}
}
get getDocsURL() {
return DOCS_URL_MAP[this.router.currentRouteName]
}
}

Comment on lines +2 to +17

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

docsUrlMatch = {
// index.name: DocsUrl
"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",
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

more of a nitpick but personally i'd prefer this over having it in the service

Suggested change
export default class DocsService extends Service {
timedDocsURL = "https://timed.dev/docs/";
@service router;
docsUrlMatch = {
// index.name: DocsUrl
"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",
};
const DOCS_URL_MAP = {
// index.name: DocsUrl
"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 {
timedDocsURL = "https://timed.dev/docs/";
@service router;

Comment on lines +7 to +12
// TODO: Replace this with your real tests.
test("it exists", function (assert) {
const service = this.owner.lookup("service:docs");
assert.ok(service);
});
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

some real tests would be nice 😉

Copy link
Member Author

Choose a reason for hiding this comment

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

This is unit test, and the real functionality of this service depend on routing change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants