-
Notifications
You must be signed in to change notification settings - Fork 267
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
Use install properties to check if triggers is installed #1370
Conversation
e3b31d6
to
fdadae6
Compare
fdadae6
to
f6c91f5
Compare
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.
The install properties are already available in the redux store (fetched in App.js) so there should be no need to request them again here.
We could just add an isTriggersInstalled
(or similar) selector in https://github.com/tektoncd/dashboard/blob/master/src/reducers/properties.js and use that in the SideNav.
Sorry, i didn't know that, I just borrowed the code from the About page. Time to learn about reducers i guess 😂 |
f6c91f5
to
e29193b
Compare
e29193b
to
4d772a4
Compare
648d21a
to
4fbeded
Compare
/test tekton-dashboard-unit-tests |
4fbeded
to
21e5706
Compare
I don't understand why tests are failing, any help on this would be nice ! 🙏 |
Taking a look |
OK so in the SideNav test you're mocking both If you want to override the behaviour for a specific test (e.g. the 'SideNav renders with triggers' test below), you can do this: beforeEach(() => {
jest.spyOn(selectors, 'isReadOnly').mockImplementation(() => true);
jest.spyOn(selectors, 'isTriggersInstalled').mockImplementation(() => false);
});
...
it('SideNav renders with triggers', async () => {
selectors.isTriggersInstalled.mockImplementation(() => true); Calling I'm not sure why the error message wasn't helpful this time, they're usually much better... |
Thank you, I will test this tomorrow ! |
No luck. Test I might be doing something wrong but dunno what :( |
Strange, I'll take another look at this later today and see what I can come up with. |
There's something strange going on with the SideNavMenu component in Carbon. I've reached out to the devs to see if it's a bug or if perhaps we're using the component in an unexpected way and there's something else we can do to resolve / work around this. In the meantime, adding defaultProps on the SideNav component does the trick: diff --git a/src/containers/SideNav/SideNav.js b/src/containers/SideNav/SideNav.js
index c435667..3f71868 100644
--- a/src/containers/SideNav/SideNav.js
+++ b/src/containers/SideNav/SideNav.js
@@ -338,6 +338,10 @@ class SideNav extends Component {
}
}
+SideNav.defaultProps = {
+ isTriggersInstalled: false
+};
+
/* istanbul ignore next */
const mapStateToProps = state => ({
extensions: getExtensions(state),
diff --git a/src/containers/SideNav/SideNav.test.js b/src/containers/SideNav/SideNav.test.js
index e056716..ed33d34 100644
--- a/src/containers/SideNav/SideNav.test.js
+++ b/src/containers/SideNav/SideNav.test.js
@@ -62,7 +62,8 @@ it('SideNav renders with extensions', () => {
});
it('SideNav renders with triggers', async () => {
- jest.spyOn(selectors, 'isReadOnly').mockImplementation(() => false);
+ selectors.isReadOnly.mockImplementation(() => false);
+ selectors.isTriggersInstalled.mockImplementation(() => true);
const middleware = [thunk];
const mockStore = configureStore(middleware);
@@ -586,7 +587,7 @@ it('SideNav updates namespace in URL', async () => {
});
it('SideNav renders import in not read-only mode', async () => {
- jest.spyOn(selectors, 'isReadOnly').mockImplementation(() => false);
+ selectors.isReadOnly.mockImplementation(() => false);
const middleware = [thunk];
const mockStore = configureStore(middleware); |
21e5706
to
f57db9e
Compare
f57db9e
to
92d6646
Compare
Thank you so much ! 😅 |
@a-roberts @AlanGreene i think this one should be pretty safe to merge also |
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.
Yeah, so the jist of it being
export function isTriggersInstalled(state) {
return (state.TriggersNamespace && state.TriggersVersion) || false;
}
I see, nice compact way of doing it, those detection mechanisms are already good on OpenShift so let's get it in unless @AlanGreene has any objections (holding the lgtm)
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: a-roberts The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Yeah looks good to me, tested it out locally and working nicely. I need to think a bit about how it affects #1388 (the client app approach I demoed today) but won't hold it up for that since it's still very much experimental and there are ways around it. /lgtm |
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Changes
This PR changes the way we detect if triggers is installed.
It uses the
getInstallProperties
api instead of trying to access the CRD./cc @a-roberts @AlanGreene
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide
for more details.