Skip to content

Commit

Permalink
add status on create and overflow (#4265)
Browse files Browse the repository at this point in the history
  • Loading branch information
jusrhee authored Feb 9, 2024
1 parent 8d63f46 commit d06bb6c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
7 changes: 2 additions & 5 deletions dashboard/src/components/porter/DashboardPlaceholder.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React from "react";
import styled from "styled-components";

import placeholder from "assets/placeholder.svg";
Expand All @@ -10,8 +10,6 @@ type Props = {
const DashboardPlaceholder: React.FC<Props> = ({
children,
}) => {
const [isExpanded, setIsExpanded] = useState(false);

return (
<StyledDashboardPlaceholder>
<Bg src={placeholder} />
Expand All @@ -35,8 +33,7 @@ const Bg = styled.img`
z-index: 0;
`;

const StyledDashboardPlaceholder = styled.div<{
}>`
const StyledDashboardPlaceholder = styled.div`
width: 100%;
padding: 25px 30px;
border-radius: 10px;
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/components/porter/Expandable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const ExpandedContents = styled.div<{ isExpanded: boolean }>`
color: ${(props) => props.theme.text.primary};
border-top-left-radius: 0;
border-top-right-radius: 0;
overflow-y: auto;
`;

const FullWidth = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/main/home/env-dashboard/CreateEnvGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const CreateEnvGroup: React.FC<RouteComponentProps> = ({ history }) => {
}
)

history.push(`/environment-groups/${data.name}/env-vars`);
history.push(`/environment-groups/${data.name}/env-vars?created=true`);
} catch (err) {
const errorMessage =
axios.isAxiosError(err) && err.response?.data?.error
Expand Down
40 changes: 38 additions & 2 deletions dashboard/src/main/home/env-dashboard/tabs/EnvVarsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useState, useMemo, useContext } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import axios from "axios";
import styled from "styled-components";

import api from "shared/api";
import { Context } from "shared/Context";
Expand All @@ -26,6 +27,12 @@ type Props = {
const EnvVarsTab: React.FC<Props> = ({ envGroup, fetchEnvGroup }) => {
const { currentProject, currentCluster } = useContext(Context);
const [buttonStatus, setButtonStatus] = useState<string | React.ReactNode>("");
const [wasCreated, setWasCreated] = useState(false);

useEffect(() => {
const created = new URLSearchParams(window.location.search).get("created")
setWasCreated(created === "true");
}, [])

const envGroupFormMethods = useForm<EnvGroupFormData>({
resolver: zodResolver(envGroupFormValidator),
Expand Down Expand Up @@ -191,6 +198,9 @@ const EnvVarsTab: React.FC<Props> = ({ envGroup, fetchEnvGroup }) => {
<EnvGroupArray
values={envVariables}
setValues={(x) => {
if (wasCreated) {
setWasCreated(false);
}
setValue("envVariables", x);
}}
fileUpload={true}
Expand All @@ -202,7 +212,14 @@ const EnvVarsTab: React.FC<Props> = ({ envGroup, fetchEnvGroup }) => {
<Spacer y={1} />
<Button
type="submit"
status={buttonStatus}
status={
wasCreated ? (
<StatusWrapper success={true}>
<i className="material-icons">done</i>
Successfully created
</StatusWrapper>
) : buttonStatus
}
loadingText="Updating env group . . ."
disabled={!isValid}
>
Expand All @@ -216,4 +233,23 @@ const EnvVarsTab: React.FC<Props> = ({ envGroup, fetchEnvGroup }) => {
);
};

export default EnvVarsTab;
export default EnvVarsTab;

const StatusWrapper = styled.div<{
success?: boolean;
}>`
display: flex;
line-height: 1.5;
align-items: center;
font-family: "Work Sans", sans-serif;
font-size: 13px;
color: #ffffff55;
margin-left: 15px;
text-overflow: ellipsis;
> i {
font-size: 18px;
margin-right: 10px;
float: left;
color: ${(props) => (props.success ? "#4797ff" : "#fcba03")};
}
`;

0 comments on commit d06bb6c

Please sign in to comment.