mirror of
https://github.com/Unleash/unleash.git
synced 2024-10-18 20:09:08 +02:00
57928d50c6
* fix: wait for api call before refetching * fix: set active environment from feature instead of cache * fix: remove console logs * fix: add permission icon button to project card * fix: remove project button * fix: empty tooltip if it is not passed * fix: add refresh interval * fix: permission buttons * fix: project permission buttons * fix: remove unused imports * fix: add projectId
66 lines
1.7 KiB
JavaScript
66 lines
1.7 KiB
JavaScript
import React, { Component } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import GeneralSelect from '../common/GeneralSelect/GeneralSelect';
|
|
|
|
class ProjectSelectComponent extends Component {
|
|
componentDidMount() {
|
|
const { fetchProjects, projects, enabled } = this.props;
|
|
if (projects[0].initial && enabled) {
|
|
fetchProjects();
|
|
}
|
|
}
|
|
|
|
render() {
|
|
const { value, projects, onChange, enabled, filter, defaultValue } =
|
|
this.props;
|
|
|
|
if (!enabled) {
|
|
return null;
|
|
}
|
|
|
|
const formatOption = project => {
|
|
return {
|
|
key: project.id,
|
|
label: project.name,
|
|
title: project.description,
|
|
};
|
|
};
|
|
|
|
let options;
|
|
if (filter) {
|
|
options = projects
|
|
.filter(project => {
|
|
return filter(project.id);
|
|
})
|
|
.map(formatOption);
|
|
} else {
|
|
options = projects.map(formatOption);
|
|
}
|
|
|
|
if (value && !options.find(o => o.key === value)) {
|
|
options.push({ key: value, label: value });
|
|
}
|
|
|
|
return (
|
|
<GeneralSelect
|
|
label="Project"
|
|
defaultValue={defaultValue}
|
|
options={options}
|
|
value={value}
|
|
onChange={onChange}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
ProjectSelectComponent.propTypes = {
|
|
value: PropTypes.string,
|
|
filled: PropTypes.bool,
|
|
enabled: PropTypes.bool,
|
|
projects: PropTypes.array.isRequired,
|
|
fetchProjects: PropTypes.func,
|
|
onChange: PropTypes.func.isRequired,
|
|
};
|
|
|
|
export default ProjectSelectComponent;
|