mirror of
https://github.com/Unleash/unleash.git
synced 2024-10-18 20:09:08 +02:00
ae38000cf7
* chore: update changelog * 4.1.0-beta.1 * fix: Project filter was trying to filter based on full project object * 4.0.6 * fix: add user to archived toggle view * fix: remove console log * 4.0.7 * 4.0.8 * fix: make sure the index we're trying to access exists * fix: load fonts from google, fallback to system fonts * fix: snapshot * 4.0.10 * fix: update package json * fix update fonts * fix: remove custom font family for archive * fix: update snapshot Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com> Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
64 lines
1.6 KiB
JavaScript
64 lines
1.6 KiB
JavaScript
import React, { Component } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import MySelect from '../common/select';
|
|
|
|
class ProjectSelectComponent extends Component {
|
|
componentDidMount() {
|
|
const { fetchProjects, projects, enabled } = this.props;
|
|
if (projects[0].initial && enabled) {
|
|
fetchProjects();
|
|
}
|
|
}
|
|
|
|
render() {
|
|
const { value, projects, onChange, enabled, filter } = 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 (
|
|
<MySelect
|
|
label="Project"
|
|
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;
|