Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: Add refetch functionality for deployments & tasks #146

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/components/AddTask/components/DrushArchiveDump.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const taskDrushArchiveDump = gql`
}
`;

const DrushArchiveDump = ({ pageEnvironment, onCompleted, onError }) => (
const DrushArchiveDump = ({ pageEnvironment, onCompleted, onError, onNewTask }) => (
<Mutation
mutation={taskDrushArchiveDump}
onCompleted={onCompleted}
Expand All @@ -32,7 +32,10 @@ const DrushArchiveDump = ({ pageEnvironment, onCompleted, onError }) => (
environment: pageEnvironment.id,
}}
>
{taskDrushArchiveDump => {
{(taskDrushArchiveDump, { loading, data }) => {
if (data) {
onNewTask();
}
return (
<SelectWrapper>
<div className="envSelect">
Expand All @@ -54,7 +57,7 @@ const DrushArchiveDump = ({ pageEnvironment, onCompleted, onError }) => (
required
/>
</div>
<Button action={taskDrushArchiveDump}>Run task</Button>
<Button action={taskDrushArchiveDump} disabled={loading}>{loading ? <span className="loader"></span> : "Run task"}</Button>
</SelectWrapper>
);
}}
Expand Down
9 changes: 6 additions & 3 deletions src/components/AddTask/components/DrushCacheClear.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const taskDrushCacheClear = gql`
}
`;

const DrushCacheClear = ({ pageEnvironment, onCompleted, onError }) => (
const DrushCacheClear = ({ pageEnvironment, onCompleted, onError, onNewTask }) => (
<Mutation
mutation={taskDrushCacheClear}
onCompleted={onCompleted}
Expand All @@ -32,7 +32,10 @@ const DrushCacheClear = ({ pageEnvironment, onCompleted, onError }) => (
environment: pageEnvironment.id,
}}
>
{taskDrushCacheClear => {
{(taskDrushCacheClear, { loading, data }) => {
if (data) {
onNewTask();
}
return (
<SelectWrapper>
<div className="envSelect">
Expand All @@ -54,7 +57,7 @@ const DrushCacheClear = ({ pageEnvironment, onCompleted, onError }) => (
required
/>
</div>
<Button action={taskDrushCacheClear}>Run task</Button>
<Button disabled={loading} action={taskDrushCacheClear}>{loading ? <span className="loader"></span> : "Run task"}</Button>
</SelectWrapper>
);
}}
Expand Down
10 changes: 7 additions & 3 deletions src/components/AddTask/components/DrushCron.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const taskDrushCron = gql`
}
`;

const DrushCron = ({ pageEnvironment, onCompleted, onError }) => (
const DrushCron = ({ pageEnvironment, onCompleted, onError, onNewTask }) => (
<Mutation
mutation={taskDrushCron}
onCompleted={onCompleted}
Expand All @@ -33,7 +33,10 @@ const DrushCron = ({ pageEnvironment, onCompleted, onError }) => (
environment: pageEnvironment.id,
}}
>
{taskDrushCron => {
{(taskDrushCron, { loading, data }) => {
if (data) {
onNewTask();
}
return (
<SelectWrapper>
<div className="envSelect">
Expand All @@ -55,7 +58,8 @@ const DrushCron = ({ pageEnvironment, onCompleted, onError }) => (
required
/>
</div>
<Button action={taskDrushCron}>Run task</Button>
<Button action={taskDrushCron} disabled={!loading}>{loading ? <span className="loader"></span> : "Run task"}</Button>
<Button action={taskDrushCron} disabled={loading}>{loading ? <span className="loader"></span> : "Run task"}</Button>
</SelectWrapper>
);
}}
Expand Down
8 changes: 6 additions & 2 deletions src/components/AddTask/components/DrushRsyncFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ const DrushRsyncFiles = ({
onError,
options,
getEnvName,
onNewTask,
}) => (
<Mutation mutation={taskDrushRsyncFiles} onCompleted={onCompleted} onError={onError}>
{(taskDrushRsyncFiles, { loading, called, error, data }) => {
if (data) {
onNewTask();
}
return (
<SelectWrapper>
<div className="warning">
Expand Down Expand Up @@ -82,9 +86,9 @@ const DrushRsyncFiles = ({
},
})
}
disabled={!selectedSourceEnv}
disabled={!selectedSourceEnv || loading }
>
Run task
{loading ? <span className="loader"></span> : "Run task"}
</Button>
</SelectWrapper>
);
Expand Down
9 changes: 6 additions & 3 deletions src/components/AddTask/components/DrushSqlDump.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const taskDrushSqlDump = gql`
}
`;

const DrushSqlDump = ({ pageEnvironment, onCompleted, onError }) => (
const DrushSqlDump = ({ pageEnvironment, onCompleted, onError, onNewTask }) => (
<Mutation
mutation={taskDrushSqlDump}
onCompleted={onCompleted}
Expand All @@ -32,7 +32,10 @@ const DrushSqlDump = ({ pageEnvironment, onCompleted, onError }) => (
environment: pageEnvironment.id,
}}
>
{taskDrushSqlDump => {
{(taskDrushSqlDump, { loading, data }) => {
if (data) {
onNewTask();
}
return (
<SelectWrapper>
<div className="envSelect">
Expand All @@ -54,7 +57,7 @@ const DrushSqlDump = ({ pageEnvironment, onCompleted, onError }) => (
required
/>
</div>
<Button action={taskDrushSqlDump}>Run task</Button>
<Button action={taskDrushSqlDump} disabled={loading}>{loading ? <span className="loader"></span> : "Run task"}</Button>
</SelectWrapper>
);
}}
Expand Down
8 changes: 6 additions & 2 deletions src/components/AddTask/components/DrushSqlSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ const DrushSqlSync = ({
onError,
options,
getEnvName,
onNewTask,
}) => (
<Mutation mutation={taskDrushSqlSync} onCompleted={onCompleted} onError={onError}>
{(taskDrushSqlSync, { loading, called, error, data }) => {
if (data) {
onNewTask();
}
return (
<SelectWrapper>
<div className="warning">
Expand Down Expand Up @@ -82,9 +86,9 @@ const DrushSqlSync = ({
},
})
}
disabled={!selectedSourceEnv}
disabled={!selectedSourceEnv || loading}
>
Run task
{loading ? <span className="loader"></span> : "Run task"}
</Button>
</SelectWrapper>
);
Expand Down
9 changes: 6 additions & 3 deletions src/components/AddTask/components/DrushUserLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const taskDrushUserLogin = gql`
}
`;

const DrushUserLogin = ({ pageEnvironment, onCompleted, onError }) => (
const DrushUserLogin = ({ pageEnvironment, onCompleted, onError, onNewTask }) => (
<Mutation
mutation={taskDrushUserLogin}
onCompleted={onCompleted}
Expand All @@ -32,7 +32,10 @@ const DrushUserLogin = ({ pageEnvironment, onCompleted, onError }) => (
environment: pageEnvironment.id,
}}
>
{taskDrushUserLogin => {
{(taskDrushUserLogin, { loading, data }) => {
if (data) {
onNewTask();
}
return (
<SelectWrapper>
<div className="envSelect">
Expand All @@ -54,7 +57,7 @@ const DrushUserLogin = ({ pageEnvironment, onCompleted, onError }) => (
required
/>
</div>
<Button action={taskDrushUserLogin}>Run task</Button>
<Button action={taskDrushUserLogin} disabled={loading}>{loading ? <span className="loader"></span> : "Run task"}</Button>
</SelectWrapper>
);
}}
Expand Down
10 changes: 7 additions & 3 deletions src/components/AddTask/components/InvokeRegisteredTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const InvokeRegisteredTask = ({
onError,
isConfirmOpen,
setIsConfirmOpen,
onNewTask,
}) => {
let taskArgumentsExist = false;
let argumentVariablesHaveValues = true;
Expand Down Expand Up @@ -78,7 +79,10 @@ const InvokeRegisteredTask = ({
})(),
}}
>
{mutationInvokeRegisteredTask => {
{(mutationInvokeRegisteredTask, { loading, data }) => {
if (data) {
onNewTask();
}
return (
<StyledRegisteredTasks>
<div className="taskArguments">
Expand Down Expand Up @@ -147,10 +151,10 @@ const InvokeRegisteredTask = ({
/>
)) || (
<Button
disabled={taskArgumentsExist && !argumentVariablesHaveValues}
disabled={taskArgumentsExist && !argumentVariablesHaveValues || loading}
action={mutationInvokeRegisteredTask}
>
Run task
{loading ? <span className="loader"></span> : "Run task"}
</Button>
)}
</StyledRegisteredTasks>
Expand Down
62 changes: 62 additions & 0 deletions src/components/AddTask/components/Styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,37 @@ export const SelectWrapper = styled.div`
color: white;
padding: 10px;
}

.btn--disabled {
margin-right: 0;
}

.loader {
display: inline-block;
width: 50px;
height: 15px;
}

.loader:after {
content: " ";
display: block;
width: 20px;
height: 20px;
margin-left: 15px;
border-radius: 50%;
border: 2px solid ${color.blue};
border-color: ${color.blue} transparent ${color.blue} transparent;
animation: loader 1.2s linear infinite;
}

@keyframes loader {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
`;

export const StyledRegisteredTasks = styled.div`
Expand Down Expand Up @@ -63,4 +94,35 @@ export const StyledRegisteredTasks = styled.div`
color: white;
padding: 10px;
}

.btn--disabled {
margin-right: 0;
}

.loader {
display: inline-block;
width: 50px;
height: 15px;
}

.loader:after {
content: " ";
display: block;
width: 20px;
height: 20px;
margin-left: 15px;
border-radius: 50%;
border: 2px solid ${color.blue};
border-color: ${color.blue} transparent ${color.blue} transparent;
animation: loader 1.2s linear infinite;
}

@keyframes loader {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
`;
2 changes: 2 additions & 0 deletions src/components/AddTask/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const AddTask = ({
onCompleted,
onError,
options,
onNewTask,
}) => {
const newTaskComponents = {
DrushArchiveDump,
Expand Down Expand Up @@ -70,6 +71,7 @@ const AddTask = ({
selectedTask={selectedTask}
onCompleted={onCompleted}
onError={onError}
onNewTask={onNewTask}
/>
</div>
)}
Expand Down
27 changes: 27 additions & 0 deletions src/components/DeployLatest/StyledDeployLatest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,31 @@ export const NewDeployment = styled.div`
text-align: right;
width: 100%;
}
.btn--disabled {
margin-right: 0;
}
.loader {
display: inline-block;
width: 50px;
height: 15px;
}
.loader:after {
content: " ";
display: block;
width: 20px;
height: 20px;
margin-left: 15px;
border-radius: 50%;
border: 2px solid ${color.blue};
border-color: ${color.blue} transparent ${color.blue} transparent;
animation: loader 1.2s linear infinite;
}
@keyframes loader {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
`;
10 changes: 6 additions & 4 deletions src/components/DeployLatest/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, {useState} from 'react';
import { Mutation } from 'react-apollo';

import Button from 'components/Button';
Expand All @@ -15,7 +15,7 @@ const DEPLOY_ENVIRONMENT_LATEST_MUTATION = gql`
/**
* Button that deploys the latest environment.
*/
const DeployLatest = ({ pageEnvironment: environment, ...rest }) => {
const DeployLatest = ({ pageEnvironment: environment, onDeploy, ...rest }) => {
let deploymentsEnabled = true;

if (environment.deployType === 'branch' || environment.deployType === 'promote') {
Expand Down Expand Up @@ -55,12 +55,14 @@ const DeployLatest = ({ pageEnvironment: environment, ...rest }) => {
>
{(deploy, { loading, error, data }) => {
const success = data && data.deployEnvironmentLatest === 'success';
if (success) {
onDeploy();
}
return (
<React.Fragment>
<Button action={deploy} disabled={loading}>
Deploy
{loading ? <span className="loader"></span> : "Deploy"}
</Button>

{success && <div className="deploy_result">Deployment queued.</div>}

{error && (
Expand Down
Loading