-
Notifications
You must be signed in to change notification settings - Fork 19
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
fix: moved routing components to own high-level folder #997
Conversation
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.
IMO it's a bit confusing that SMDatasourceContext
will return UninitialisedRouter
.
Could we have one AppRouter
that controls whether or not the uninitialized/initialized router should be used?
Thought
How about an index.ts
file in src/routing
to "package" and clean up imports.
src/routing/index.ts
export * from './InitialisedRouter';
export * from './UninitialisedRouter';
export * from './constants';
export * from './LegacyEditRedirect';
export * from './utils';
Example
After
import { InitialisedRouter, generateRoutePath, PLUGIN_URL_PATH } from 'routing`;
Before
import { InitialisedRouter } from 'routing/InitialisedRouter';
import { generateRoutePath } from 'routing/utils';
import { PLUGIN_URL_PATH } from 'routing/constants';
The issue with this is I was in the process of implementing this feedback and then I realised we have But if I export the types through the index too, Jest gets confused and errors out. If the files are imported individually this doesn't happen. We can revisit this in the future. I've had another issue with jest like this and had to make some awful 'temporary' shim.
The problem with removing this responsibility from |
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.
Nice! It makes much more sense to organize the routing files their own folder 👌
export enum ROUTES { | ||
Alerts = 'alerts', | ||
CheckDashboard = 'checks/:id', | ||
Checks = 'checks', | ||
ChooseCheckGroup = 'checks/choose-type', | ||
Config = 'config', // config (index) | ||
EditCheck = 'checks/:id/edit', | ||
ViewProbe = 'probes/:id', | ||
EditProbe = 'probes/:id/edit', | ||
Home = 'home', | ||
NewCheck = 'checks/new', | ||
NewProbe = 'probes/new', | ||
Probes = 'probes', | ||
Redirect = 'redirect', | ||
Scene = 'scene', | ||
} |
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.
❤️
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.
When are we going to address the naming of enums 😁
This enum at least uses PascalCase for keys.
// Bad
enum AM_I_A_CONST_OR_A_ENUM {
FOO,
BAR,
}
// Bad 🤨
enum AM_I_A_CONST_OR_A_ENUM {
Foo,
Bar,
}
// Bad 🤨
enum AlmostAnEnum {
FOO,
BAR,
}
// Good 💖
enum ClearlyAnEnum {
Foo,
Bar,
}
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.
#1008 -- soon, made a ticket so we don't forget :)
@@ -3,7 +3,8 @@ import { GrafanaTheme2 } from '@grafana/data'; | |||
import { Icon, IconButton, LinkButton, Tooltip, useStyles2, useTheme2 } from '@grafana/ui'; | |||
import { css, cx } from '@emotion/css'; | |||
|
|||
import { AlertSensitivity, Check, PrometheusAlertsGroup, ROUTES } from 'types'; | |||
import { AlertSensitivity, Check, PrometheusAlertsGroup } from 'types'; |
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.
I like that you moved the routing types away from the huge types.ts
file. Is the idea to do this for most components in upcoming PRs?
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.
Yes :D
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.
🥇 LGTM
b933e5c
to
0ff6666
Compare
Part 1 of addressing: #848
I plan on breaking the above ticket into separate PRs. Because of the nature of the work it is difficult to address up front how many there will be but because each PR will touch many files doing mundane things I intend to silo the work as much as possible to make review and discussion more relevant.
Problem
Addressing how the 'Routing' files are used and referenced as the current place they live is confusing, unintuitive and inconsistent.
Solution
<FOLDER_AREA>/utils.ts
TestRouteInfo
testing component to the tests folder (all test-related components should be easily discoverable in a single location rather than scattered around)General