Skip to content

Commit

Permalink
Use install properties to check if triggers is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-edouard.breteche committed May 12, 2020
1 parent 57082bc commit e3b31d6
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions src/containers/SideNav/SideNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
getSelectedNamespace,
isReadOnly
} from '../../reducers';
import { getCustomResource } from '../../api';
import { getInstallProperties } from '../../api';

import './SideNav.scss';

Expand All @@ -48,7 +48,7 @@ class SideNav extends Component {
this.props.selectNamespace(match.params.namespace);
}

this.checkTriggersInstalled();
this.fetchDashboardInfo();
}

componentDidUpdate(prevProps) {
Expand All @@ -66,6 +66,27 @@ class SideNav extends Component {
}
}

async fetchDashboardInfo() {
try {
const dashboardInfo = await getInstallProperties();
const isTriggersInstalled = dashboardInfo.TriggersNamespace && dashboardInfo.TriggersVersion;
this.setState({ isTriggersInstalled });
} catch (error) {}
}

// checkTriggersInstalled() {
// getCustomResource({
// group: 'apiextensions.k8s.io',
// version: 'v1beta1',
// type: 'customresourcedefinitions',
// name: 'eventlisteners.triggers.tekton.dev'
// })
// .then(() => {
// this.setState({ isTriggersInstalled: true });
// })
// .catch(() => {});
// }

setPath(path) {
const { history, location } = this.props;
history.push(path + location.search);
Expand Down Expand Up @@ -150,19 +171,6 @@ class SideNav extends Component {
history.push('/');
};

checkTriggersInstalled() {
getCustomResource({
group: 'apiextensions.k8s.io',
version: 'v1beta1',
type: 'customresourcedefinitions',
name: 'eventlisteners.triggers.tekton.dev'
})
.then(() => {
this.setState({ isTriggersInstalled: true });
})
.catch(() => {});
}

render() {
const { extensions, intl, namespace } = this.props;
const { isTriggersInstalled } = this.state;
Expand Down

0 comments on commit e3b31d6

Please sign in to comment.