-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: main
Are you sure you want to change the base?
Conversation
2f4a26f
to
f15114a
Compare
f15114a
to
13f9bdc
Compare
frontend/app/services/docs.js
Outdated
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 ""; | ||
} | ||
} |
There was a problem hiding this comment.
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
frontend/app/services/docs.js
Outdated
} | ||
|
||
get getDocsURL() { | ||
const docsUrlMatch = { |
There was a problem hiding this comment.
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 = {
...
}
frontend/app/services/docs.js
Outdated
timedDocsURL = "https://timed.dev/docs/"; | ||
@service router; | ||
|
||
get getDocsEndpoint() { |
There was a problem hiding this comment.
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
13f9bdc
to
a4385aa
Compare
a4385aa
to
18c6207
Compare
get getDocsURL() { | ||
for (const timedRouterName of Object.keys(this.docsUrlMatch)) { | ||
if (this.router.currentRouteName === timedRouterName) { | ||
return this.docsUrlMatch[timedRouterName]; | ||
} | ||
} | ||
return ""; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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] | |
} | |
} |
|
||
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", | ||
}; |
There was a problem hiding this comment.
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
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; | |
// TODO: Replace this with your real tests. | ||
test("it exists", function (assert) { | ||
const service = this.owner.lookup("service:docs"); | ||
assert.ok(service); | ||
}); | ||
}); |
There was a problem hiding this comment.
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 😉
There was a problem hiding this comment.
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
No description provided.