Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/porter-dev/porter into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sunguroku committed Jan 21, 2021
2 parents 7016ae8 + bd98424 commit 22fa59e
Show file tree
Hide file tree
Showing 53 changed files with 3,607 additions and 1,116 deletions.
1 change: 1 addition & 0 deletions cmd/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func main() {
&models.ClusterCandidate{},
&models.ClusterResolver{},
&models.Infra{},
&models.Invite{},
&ints.KubeIntegration{},
&ints.BasicIntegration{},
&ints.OIDCIntegration{},
Expand Down
1 change: 1 addition & 0 deletions cmd/migrate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func main() {
&models.ClusterCandidate{},
&models.ClusterResolver{},
&models.Infra{},
&models.Invite{},
&ints.KubeIntegration{},
&ints.BasicIntegration{},
&ints.OIDCIntegration{},
Expand Down
Binary file added dashboard/src/assets/loading-dots.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions dashboard/src/assets/settings.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 91 additions & 0 deletions dashboard/src/components/values-form/CheckboxList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import React from 'react';
import styled from 'styled-components';

type PropsType = {
label?: string,
options: { disabled?: boolean, value: string, label: string }[],
selected: { value: string, label: string }[],
setSelected: (x: { value: string, label: string }[]) => void,
};

const CheckboxList = ({
label, options, selected, setSelected,
}: PropsType) => {
let onSelectOption = (option: { value: string, label: string }) => {
if (!selected.includes(option)) {
selected.push(option);
setSelected(selected);
} else {
selected.splice(selected.indexOf(option), 1);
setSelected(selected);
}
}

return (
<StyledCheckboxList>
{label && <Label>{label}</Label>}
{options.map((option: { value: string, label: string }, i: number) => {
return (
<CheckboxOption
isLast={i === options.length - 1}
onClick={() => onSelectOption(option)}
key={i}
>
<Checkbox checked={selected.includes(option)}>
<i className="material-icons">done</i>
</Checkbox>
{option.label}
</CheckboxOption>
);
})}
</StyledCheckboxList>
);
}
export default CheckboxList;

const Checkbox = styled.div`
width: 16px;
height: 16px;
border: 1px solid #ffffff55;
margin: 1px 15px 0px 1px;
border-radius: 3px;
background: ${(props: { checked: boolean }) => props.checked ? '#ffffff22' : '#ffffff11'};
display: flex;
align-items: center;
justify-content: center;
> i {
font-size: 12px;
padding-left: 0px;
display: ${(props: { checked: boolean }) => props.checked ? '' : 'none'};
}
`;

const CheckboxOption = styled.div<{ isLast: boolean }>`
width: 100%;
height: 35px;
padding-left: 10px;
display: flex;
cursor: pointer;
align-items: center;
border-bottom: ${props => props.isLast ? '' : '1px solid #ffffff22'};
font-size: 13px;
:hover {
background: #ffffff18;
}
`;

const Label = styled.div`
color: #ffffff;
margin-bottom: 10px;
`;

const StyledCheckboxList = styled.div`
border-radius: 3px;
border: 1px solid #ffffff55;
padding: 0;
background: #ffffff11;
margin-bottom: 15px;
margin-top: 20px;
`;
8 changes: 4 additions & 4 deletions dashboard/src/components/values-form/Heading.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react';
import styled from 'styled-components';

export default function Heading(props: { children: any }) {
return <StyledHeading>{props.children}</StyledHeading>;
export default function Heading(props: { isAtTop?: boolean, children: any }) {
return <StyledHeading isAtTop={props.isAtTop}>{props.children}</StyledHeading>;
}

const StyledHeading = styled.div`
const StyledHeading = styled.div<{ isAtTop: boolean }>`
color: white;
font-weight: 500;
font-size: 16px;
margin-top: 30px;
margin-top: ${props => props.isAtTop ? '0': '30px'};
margin-bottom: 5px;
display: flex;
align-items: center;
Expand Down
22 changes: 16 additions & 6 deletions dashboard/src/main/CurrentError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,32 @@ import close from '../assets/close.png';
import { Context } from '../shared/Context';

type PropsType = {
currentError: string,
};

type StateType = {
};

export default class CurrentError extends Component<PropsType, StateType> {
state = {
expanded: false
expanded: false,
}

componentDidUpdate(prevProps: PropsType) {
if (
prevProps.currentError !== this.props.currentError
&& this.props.currentError === 'Provisioning failed. Check your credentials and try again.'
) {
this.setState({ expanded: true });
}
}

render() {
if (this.context.currentError) {
if (this.props.currentError) {
if (!this.state.expanded) {
return (
<StyledCurrentError onClick={() => this.setState({ expanded: true })}>
<ErrorText>Error: {this.context.currentError}</ErrorText>
<ErrorText>Error: {this.props.currentError}</ErrorText>
<CloseButton onClick={(e) => {
this.context.setCurrentError(null);
e.stopPropagation();
Expand All @@ -33,7 +43,7 @@ export default class CurrentError extends Component<PropsType, StateType> {

return (
<ExpandedError onClick={() => this.setState({ expanded: false })}>
Error: {this.context.currentError}
Error: {this.props.currentError}
<CloseButtonAlt onClick={() => this.context.setCurrentError(null)}>
<CloseButtonImg src={close} />
</CloseButtonAlt>
Expand Down Expand Up @@ -80,9 +90,9 @@ const ErrorText = styled.div`

const StyledCurrentError = styled.div`
position: fixed;
bottom: 20px;
bottom: 22px;
width: 300px;
left: 17px;
left: 100px;
padding: 15px;
padding-right: 0px;
font-family: 'Work Sans', sans-serif;
Expand Down
5 changes: 3 additions & 2 deletions dashboard/src/main/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class Login extends Component<PropsType, StateType> {
handleLogin = (): void => {
let { email, password } = this.state;
let { authenticate } = this.props;
let { setCurrentError, setUser } = this.context;
let { setUser } = this.context;

// Check for valid input
if (!emailRegex.test(email)) {
Expand All @@ -55,8 +55,9 @@ export default class Login extends Component<PropsType, StateType> {
password: password
}, {}, (err: any, res: any) => {
// TODO: case and set credential error
console.log(res.data);
setUser(res?.data?.id, res?.data?.email)
err ? setCurrentError(err.response.data.errors[0]) : authenticate();
err ? console.log(err) : authenticate();
});
}
}
Expand Down
14 changes: 11 additions & 3 deletions dashboard/src/main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default class Main extends Component<PropsType, StateType> {
componentDidMount() {
let { setUser } = this.context;
api.checkAuth('', {}, {}, (err: any, res: any) => {
console.log(err)
if (err && err.response?.status == 403) {
this.setState({ isLoggedIn: false, loading: false })
}
Expand All @@ -56,6 +55,9 @@ export default class Main extends Component<PropsType, StateType> {
}

handleLogOut = () => {
// Clears local storage for proper rendering of clusters
localStorage.clear();

this.context.clearContext();
this.setState({ isLoggedIn: false, initialized: true });
}
Expand Down Expand Up @@ -85,7 +87,13 @@ export default class Main extends Component<PropsType, StateType> {

<Route path='/dashboard' render={() => {
if (this.state.isLoggedIn && this.state.initialized) {
return <Home logOut={this.handleLogOut} />
return (
<Home
currentProject={this.context.currentProject}
currentCluster={this.context.currentCluster}
logOut={this.handleLogOut}
/>
);
} else {
return <Redirect to='/' />
}
Expand All @@ -111,7 +119,7 @@ export default class Main extends Component<PropsType, StateType> {
<BrowserRouter>
{this.renderMain()}
</BrowserRouter>
<CurrentError />
<CurrentError currentError={this.context.currentError} />
</StyledMain>
);
}
Expand Down
Loading

0 comments on commit 22fa59e

Please sign in to comment.