|
|
@@ -5,137 +5,83 @@ import styled from "styled-components";
|
|
|
import Text from "components/porter/Text";
|
|
|
import Spacer from "components/porter/Spacer";
|
|
|
import web from "assets/web.png";
|
|
|
+import TabSelector from "components/TabSelector";
|
|
|
|
|
|
|
|
|
interface ServiceProps {
|
|
|
- serviceData: ServiceType;
|
|
|
- editService: (service: ServiceType) => void;
|
|
|
- deleteService: () => void;
|
|
|
+ serviceData: ServiceType;
|
|
|
+ editService: (service: ServiceType) => void;
|
|
|
+ deleteService: () => void;
|
|
|
}
|
|
|
|
|
|
export type ServiceType = {
|
|
|
- name: string;
|
|
|
- type: string;
|
|
|
- runCommand: string;
|
|
|
- ram: number;
|
|
|
- cpu: number;
|
|
|
+ name: string;
|
|
|
+ type: string;
|
|
|
+ runCommand: string;
|
|
|
+ ram: number;
|
|
|
+ cpu: number;
|
|
|
}
|
|
|
|
|
|
export const DEFAULT_SERVICE: ServiceType = {
|
|
|
- name: 'new-service',
|
|
|
- type: '',
|
|
|
- runCommand: '',
|
|
|
- ram: 512,
|
|
|
- cpu: 500,
|
|
|
+ name: 'new-service',
|
|
|
+ type: '',
|
|
|
+ runCommand: '',
|
|
|
+ ram: 512,
|
|
|
+ cpu: 500,
|
|
|
}
|
|
|
|
|
|
const Service: React.FC<ServiceProps> = ({
|
|
|
- serviceData,
|
|
|
- deleteService,
|
|
|
- editService,
|
|
|
+ serviceData,
|
|
|
+ deleteService,
|
|
|
+ editService,
|
|
|
}) => {
|
|
|
- const [showExpanded, setShowExpanded] = React.useState<boolean>(true)
|
|
|
-
|
|
|
- const renderServiceSettings = () => {
|
|
|
- return (
|
|
|
- <>
|
|
|
- <Text color="helper">
|
|
|
- Name your service.
|
|
|
- </Text>
|
|
|
- <Spacer y={0.5} />
|
|
|
- <Input
|
|
|
- placeholder="ex: web-service"
|
|
|
- value={serviceData.name}
|
|
|
- width="300px"
|
|
|
- setValue={(e) => {
|
|
|
- editService({ ...serviceData, name: e })
|
|
|
- }}
|
|
|
- />
|
|
|
- <Spacer y={0.5} />
|
|
|
- <Text color="helper">
|
|
|
- Specify your service type. <a>What is this?</a>
|
|
|
- </Text>
|
|
|
- <Spacer y={0.5} />
|
|
|
- <Input
|
|
|
- placeholder="ex: academic-sophon"
|
|
|
- value={serviceData.type}
|
|
|
- width="300px"
|
|
|
- setValue={(e) => {
|
|
|
- editService({ ...serviceData, type: e })
|
|
|
- }}
|
|
|
- />
|
|
|
- <Spacer y={0.5} />
|
|
|
- <Text color="helper">
|
|
|
- Specify a run command.
|
|
|
- </Text>
|
|
|
- <Spacer y={0.5} />
|
|
|
- <Input
|
|
|
- placeholder="ex: yarn run start"
|
|
|
- value={serviceData.runCommand}
|
|
|
- width="300px"
|
|
|
- setValue={(e) => {
|
|
|
- editService({ ...serviceData, runCommand: e })
|
|
|
- }}
|
|
|
- />
|
|
|
- <Spacer y={0.5} />
|
|
|
- <Text color="helper">
|
|
|
- Specify resources.
|
|
|
- </Text>
|
|
|
- <Spacer y={0.5} />
|
|
|
- <SliderContainer>
|
|
|
- RAM <Input
|
|
|
- placeholder="ex: yarn run start"
|
|
|
- value="TURN THESE INTO SLIDERS"
|
|
|
- width="300px"
|
|
|
- setValue={(e) => { }}
|
|
|
- />
|
|
|
- </SliderContainer>
|
|
|
- <Spacer y={0.5} />
|
|
|
-
|
|
|
- <SliderContainer>
|
|
|
- CPU <Input
|
|
|
- placeholder="ex: yarn run start"
|
|
|
- value="TURN THESE INTO SLIDERS"
|
|
|
- width="300px"
|
|
|
- setValue={(e) => { }}
|
|
|
- />
|
|
|
- </SliderContainer>
|
|
|
- <Spacer y={0.5} />
|
|
|
-
|
|
|
- </>
|
|
|
- )
|
|
|
- }
|
|
|
+ const [showExpanded, setShowExpanded] = React.useState<boolean>(true)
|
|
|
|
|
|
+ const renderServiceSettings = () => {
|
|
|
return (
|
|
|
- <>
|
|
|
- <ServiceHeader
|
|
|
- showExpanded={showExpanded}
|
|
|
- onClick={() => setShowExpanded(!showExpanded)}
|
|
|
- >
|
|
|
- <ServiceTitle>
|
|
|
- <ActionButton >
|
|
|
- <span className="material-icons dropdown">arrow_drop_down</span>
|
|
|
- </ActionButton>
|
|
|
- {serviceData.name !== DEFAULT_SERVICE.name && serviceData.name.trim().length > 0 ? serviceData.name : "New Service"}
|
|
|
- {serviceData.type === 'web' && <Icon src={web} />}
|
|
|
- </ServiceTitle>
|
|
|
- <ActionButton onClick={(e) => {
|
|
|
- deleteService();
|
|
|
- }}>
|
|
|
- <span className="material-icons">delete</span>
|
|
|
- </ActionButton>
|
|
|
- </ServiceHeader>
|
|
|
- <AnimateHeight
|
|
|
- height={showExpanded ? "auto" : 0}
|
|
|
- >
|
|
|
- <StyledSourceBox
|
|
|
- showExpanded={showExpanded}
|
|
|
- >
|
|
|
- {renderServiceSettings()}
|
|
|
- </StyledSourceBox>
|
|
|
- </AnimateHeight>
|
|
|
- </>
|
|
|
+ <>
|
|
|
+ <TabSelector
|
|
|
+ options={[
|
|
|
+ { label: 'Web', value: 'web' },
|
|
|
+ { label: 'Worker', value: 'worker' },
|
|
|
+ { label: 'Cron', value: 'cron' },
|
|
|
+ ]}
|
|
|
+ currentTab="web"
|
|
|
+ setCurrentTab={(e) => {}}
|
|
|
+ />
|
|
|
+ </>
|
|
|
)
|
|
|
+ }
|
|
|
+
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <ServiceHeader
|
|
|
+ showExpanded={showExpanded}
|
|
|
+ onClick={() => setShowExpanded(!showExpanded)}
|
|
|
+ >
|
|
|
+ <ServiceTitle>
|
|
|
+ <ActionButton >
|
|
|
+ <span className="material-icons dropdown">arrow_drop_down</span>
|
|
|
+ </ActionButton>
|
|
|
+ {serviceData.name !== DEFAULT_SERVICE.name && serviceData.name.trim().length > 0 ? serviceData.name : "New Service"}
|
|
|
+ {serviceData.type === 'web' && <Icon src={web} />}
|
|
|
+ </ServiceTitle>
|
|
|
+ <ActionButton onClick={(e) => {
|
|
|
+ deleteService();
|
|
|
+ }}>
|
|
|
+ <span className="material-icons">delete</span>
|
|
|
+ </ActionButton>
|
|
|
+ </ServiceHeader>
|
|
|
+ <AnimateHeight
|
|
|
+ height={showExpanded ? "auto" : 0}
|
|
|
+ >
|
|
|
+ <StyledSourceBox showExpanded={showExpanded}>
|
|
|
+ {renderServiceSettings()}
|
|
|
+ </StyledSourceBox>
|
|
|
+ </AnimateHeight>
|
|
|
+ <Spacer y={0.5} />
|
|
|
+ </>
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
export default Service;
|
|
|
@@ -145,10 +91,10 @@ const ServiceTitle = styled.div`
|
|
|
align-items: center;
|
|
|
`;
|
|
|
|
|
|
-const StyledSourceBox = styled.div`
|
|
|
+const StyledSourceBox = styled.div<{ showExpanded: boolean }>`
|
|
|
width: 100%;
|
|
|
color: #ffffff;
|
|
|
- padding: 14px 35px 20px;
|
|
|
+ padding: 14px 25px 20px;
|
|
|
position: relative;
|
|
|
font-size: 13px;
|
|
|
border-radius: 5px;
|
|
|
@@ -158,11 +104,6 @@ const StyledSourceBox = styled.div`
|
|
|
border-top-left-radius: 0px;
|
|
|
border-top-right-radius: 0px;
|
|
|
height: 400px;
|
|
|
- :hover {
|
|
|
- border-bottom: ${(props: { showExpanded: boolean }) => props.showExpanded && "#7a7b80"};
|
|
|
- border-left: ${({ showExpanded }) => showExpanded && "#7a7b80"};
|
|
|
- border-right: ${({ showExpanded }) => showExpanded && "#7a7b80"};
|
|
|
- }
|
|
|
`;
|
|
|
|
|
|
const ActionButton = styled.button`
|
|
|
@@ -196,6 +137,7 @@ const SliderContainer = styled.div`
|
|
|
const ServiceHeader = styled.div`
|
|
|
flex-direction: row;
|
|
|
display: flex;
|
|
|
+ height: 60px;
|
|
|
justify-content: space-between;
|
|
|
cursor: pointer;
|
|
|
padding: 20px;
|
|
|
@@ -206,7 +148,6 @@ const ServiceHeader = styled.div`
|
|
|
border: 1px solid #494b4f;
|
|
|
:hover {
|
|
|
border: 1px solid #7a7b80;
|
|
|
- border-bottom: ${({ showExpanded }) => showExpanded && "0px"};
|
|
|
}
|
|
|
|
|
|
border-bottom-left-radius: ${({ showExpanded }) => showExpanded && "0px"};
|
|
|
@@ -219,7 +160,6 @@ const ServiceHeader = styled.div`
|
|
|
margin-left: -10px;
|
|
|
transform: ${(props: { showExpanded: boolean }) => props.showExpanded ? "" : "rotate(-90deg)"};
|
|
|
}
|
|
|
- border-bottom: ${({ showExpanded }) => showExpanded && "0px"};
|
|
|
|
|
|
animation: fadeIn 0.3s 0s;
|
|
|
@keyframes fadeIn {
|