|
@@ -1,9 +1,11 @@
|
|
|
import React, { Component } from "react";
|
|
import React, { Component } from "react";
|
|
|
import styled from "styled-components";
|
|
import styled from "styled-components";
|
|
|
|
|
+import { Context } from "shared/Context";
|
|
|
|
|
|
|
|
type PropsType = {
|
|
type PropsType = {
|
|
|
activeValue: string;
|
|
activeValue: string;
|
|
|
options: { value: string; label: string }[];
|
|
options: { value: string; label: string }[];
|
|
|
|
|
+ addButton?: boolean;
|
|
|
setActiveValue: (x: string) => void;
|
|
setActiveValue: (x: string) => void;
|
|
|
width: string;
|
|
width: string;
|
|
|
height?: string;
|
|
height?: string;
|
|
@@ -76,6 +78,19 @@ export default class Selector extends Component<PropsType, StateType> {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ renderAddButton = () => {
|
|
|
|
|
+ if (this.props.addButton) {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <NewOption onClick={() => {
|
|
|
|
|
+ this.context.setCurrentModal('NamespaceModal')
|
|
|
|
|
+ }}>
|
|
|
|
|
+ <Plus>+</Plus>
|
|
|
|
|
+ Add Namespace
|
|
|
|
|
+ </NewOption>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
renderDropdown = () => {
|
|
renderDropdown = () => {
|
|
|
if (this.state.expanded) {
|
|
if (this.state.expanded) {
|
|
|
return (
|
|
return (
|
|
@@ -91,6 +106,7 @@ export default class Selector extends Component<PropsType, StateType> {
|
|
|
>
|
|
>
|
|
|
{this.renderDropdownLabel()}
|
|
{this.renderDropdownLabel()}
|
|
|
{this.renderOptionList()}
|
|
{this.renderOptionList()}
|
|
|
|
|
+ {this.renderAddButton()}
|
|
|
</Dropdown>
|
|
</Dropdown>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
@@ -107,6 +123,7 @@ export default class Selector extends Component<PropsType, StateType> {
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
let { activeValue } = this.props;
|
|
let { activeValue } = this.props;
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<StyledSelector width={this.props.width}>
|
|
<StyledSelector width={this.props.width}>
|
|
|
<MainSelector
|
|
<MainSelector
|
|
@@ -127,6 +144,13 @@ export default class Selector extends Component<PropsType, StateType> {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+Selector.contextType = Context;
|
|
|
|
|
+
|
|
|
|
|
+const Plus = styled.div`
|
|
|
|
|
+ margin-right: 10px;
|
|
|
|
|
+ font-size: 15px;
|
|
|
|
|
+`;
|
|
|
|
|
+
|
|
|
const TextWrap = styled.div`
|
|
const TextWrap = styled.div`
|
|
|
white-space: nowrap;
|
|
white-space: nowrap;
|
|
|
overflow: hidden;
|
|
overflow: hidden;
|
|
@@ -141,6 +165,26 @@ const DropdownLabel = styled.div`
|
|
|
margin: 10px 13px;
|
|
margin: 10px 13px;
|
|
|
`;
|
|
`;
|
|
|
|
|
|
|
|
|
|
+const NewOption = styled.div`
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ border-top: 1px solid #00000000;
|
|
|
|
|
+ border-bottom: 1px solid #ffffff00;
|
|
|
|
|
+ height: 37px;
|
|
|
|
|
+ font-size: 13px;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ padding-left: 15px;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ padding-right: 10px;
|
|
|
|
|
+ white-space: nowrap;
|
|
|
|
|
+ overflow: hidden;
|
|
|
|
|
+ text-overflow: ellipsis;
|
|
|
|
|
+
|
|
|
|
|
+ :hover {
|
|
|
|
|
+ background: #ffffff22;
|
|
|
|
|
+ }
|
|
|
|
|
+`;
|
|
|
|
|
+
|
|
|
const Option = styled.div`
|
|
const Option = styled.div`
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
border-top: 1px solid #00000000;
|
|
border-top: 1px solid #00000000;
|