Skip to content

Commit

Permalink
feat: display redeploy button only on change append
Browse files Browse the repository at this point in the history
  • Loading branch information
cchalop1 committed Aug 26, 2024
1 parent 61b811f commit a6a5f2f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
11 changes: 10 additions & 1 deletion web/src/components/DeployButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ import ModalDeleteConfirmation from "./modals/ModalDeleteConfirmation";

type DeployButtonsProps = {
deploy: DeployDto;
toReDeploy: boolean;
setToReDeploy: (toReDeploy: boolean) => void;
fetchDeployById: (deployId: string) => void;
};

export default function DeployButtons({
deploy,
toReDeploy,
setToReDeploy,
fetchDeployById,
}: DeployButtonsProps) {
const navigate = useNavigate();
Expand Down Expand Up @@ -48,6 +52,7 @@ export default function DeployButtons({
navigate(`/deploy/${deploy.id}/installation`);
await reDeployAppApi(deploy.id);
setReDeployButtonState(ButtonStateEnum.SUCESS);
setToReDeploy(false);
fetchDeployById(deploy.id);
} catch (e) {
console.error(e);
Expand Down Expand Up @@ -99,7 +104,11 @@ export default function DeployButtons({
"Start"
)}
</Button>
<Button variant="secondary" onClick={() => reDeployApplication()}>
<Button
variant={toReDeploy ? "default" : "ghost"}
color="bg-yellow-600"
onClick={() => reDeployApplication()}
>
{redeployButtonState === ButtonStateEnum.PENDING ? (
<SpinnerIcon color="text-black" />
) : (
Expand Down
5 changes: 4 additions & 1 deletion web/src/components/DeploySettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ type DeploySettingsProps = {
deploy: DeployDto;
serverDomain: string;
fetchDeployById: (id: string) => void;
setToReDeploy: (toReDeploy: boolean) => void;
};

export default function DeploySettings({
deploy,
serverDomain,
setToReDeploy,
fetchDeployById,
}: DeploySettingsProps) {
const envs: Env[] =
Expand All @@ -33,13 +35,14 @@ export default function DeploySettings({
try {
await editDeployementApi(editDeployDto);
fetchDeployById(deploy.id);
setToReDeploy(true);
} catch (e) {
console.error(e);
}
}

return (
<div>
<div className="pb-20">
<div className="font-bold text-xl">Git Hooks</div>
<div className="mt-4 flex items-center space-x-2">
<Checkbox
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/DisplayLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type DisplayLogsProps = {

export default function DisplayLogs({ logs }: DisplayLogsProps) {
return (
<div className="flex flex-col">
<div className="flex flex-col pb-20">
{logs.map((log, idx) => (
<code
key={idx}
Expand Down
9 changes: 8 additions & 1 deletion web/src/pages/DeployPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function DeployPage() {
const navigate = useNavigate();
const [deploy, setDeploy] = useState<DeployDto | null>(null);
const [server, setServer] = useState<ServerDto | null>(null);
const [toReDeploy, setToReDeploy] = useState(false);

async function fetchDeployById(id: string) {
const res = await getDeployByIdApi(id);
Expand Down Expand Up @@ -47,7 +48,12 @@ export default function DeployPage() {
<div className="mt-40">
<div className="flex justify-between">
<div className="text-xl font-bold mb-2">{deploy.name}</div>
<DeployButtons deploy={deploy} fetchDeployById={fetchDeployById} />
<DeployButtons
deploy={deploy}
toReDeploy={toReDeploy}
setToReDeploy={setToReDeploy}
fetchDeployById={fetchDeployById}
/>
</div>
<Status status={deploy.status} />
<div className="flex items-center mt-2 gap-2">
Expand Down Expand Up @@ -81,6 +87,7 @@ export default function DeployPage() {
<DeploySettings
serverDomain={server.domain}
deploy={deploy}
setToReDeploy={setToReDeploy}
fetchDeployById={fetchDeployById}
/>
</TabsContent>
Expand Down

0 comments on commit a6a5f2f

Please sign in to comment.