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

Migration task #520

Merged
merged 29 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e4892e1
Add useLazyLoadQuery to Task
ikatemart Feb 24, 2023
5b59745
Add useFragment to TaskDetails
ikatemart Feb 24, 2023
28653fe
Add useMutation to TaskDetails
ikatemart Feb 24, 2023
4b26b1c
Tryings with useSubscription
ikatemart Feb 28, 2023
08bc4f4
Add useSubscription to TaskDetails
ikatemart Mar 1, 2023
4fc9e34
Minors
ikatemart Mar 1, 2023
d6d3cf9
Add useFragment to TaskArtifacts
ikatemart Mar 1, 2023
c34d45c
Add useFragment to TaskCreatedChip
ikatemart Mar 1, 2023
3e0fd96
Add useFragment to TaskOptionalChip
ikatemart Mar 1, 2023
bed794d
Add useFragment to TaskScheduledChip
ikatemart Mar 1, 2023
418a139
Add useFragment to TaskStatusChip
ikatemart Mar 1, 2023
5354c7c
Add useFragment to TaskTransactionChip
ikatemart Mar 1, 2023
d2432b5
Add useFragment to TaskCommandList
ikatemart Mar 1, 2023
3be7130
Fix
ikatemart Mar 1, 2023
e4d63a6
Add useFragment to TaskCommandsProgress
ikatemart Mar 1, 2023
b7460d7
Add useFragment to TaskResourcesChip
ikatemart Mar 1, 2023
294febe
Add useFragment to TaskExecutionInfo
ikatemart Mar 1, 2023
c7f23c9
Add useFragment to TaskExperimentalChip
ikatemart Mar 1, 2023
dae1400
Add useLazyLoadQuery to TaskDebuggingInformation
ikatemart Mar 1, 2023
490d230
Add useFragment to TaskCancellerChip
ikatemart Mar 1, 2023
d784946
Add useFragment to TaskRerunnerChip
ikatemart Mar 1, 2023
ff85cb6
Add useFragment to Notification
ikatemart Mar 1, 2023
41bf575
Add useFragment to TaskTimeoutChip
ikatemart Mar 1, 2023
287d06a
Add useFragment to TaskStatefulChip
ikatemart Mar 1, 2023
009e72a
Add useFragment to AppBreadcrumbs
ikatemart Mar 2, 2023
762d16d
Change useSubscription to requestSubscription
ikatemart Mar 2, 2023
8a98fd1
Improve task subscription for TaskDetails
ikatemart Mar 3, 2023
74b0a81
Minors
ikatemart Mar 3, 2023
51df3a3
useMemo for isTaskFinalStatus value
ikatemart Mar 3, 2023
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
37 changes: 19 additions & 18 deletions src/components/artifacts/TaskArtifacts.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import React from 'react';
import { createFragmentContainer } from 'react-relay';
import { useFragment } from 'react-relay';
import { graphql } from 'babel-plugin-relay/macro';
import ArtifactsView from './ArtifactsView';

function TaskArtifacts(props) {
if (!props.task.artifacts || props.task.artifacts.length === 0) return <div />;
return <ArtifactsView task={props.task} />;
}

export default createFragmentContainer(TaskArtifacts, {
task: graphql`
fragment TaskArtifacts_task on Task {
id
artifacts {
name
files {
path
size
export default function TaskArtifacts(props) {
let task = useFragment(
graphql`
fragment TaskArtifacts_task on Task {
id
artifacts {
name
files {
path
size
}
}
}
}
`,
});
`,
props.task,
);

if (!task.artifacts || task.artifacts.length === 0) return <div />;
return <ArtifactsView task={props.task} />;
}
3 changes: 1 addition & 2 deletions src/components/builds/BuildsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import InfoIcon from '@mui/icons-material/Info';
import CommitIcon from '@mui/icons-material/Commit';
import Typography from '@mui/material/Typography';
import CallSplitIcon from '@mui/icons-material/CallSplit';
import BookOutlinedIcon from '@mui/icons-material/BookOutlined';
import UnarchiveIcon from '@mui/icons-material/UnarchiveOutlined';

import BuildStatusChipNew from '../chips/BuildStatusChipNew';
Expand All @@ -33,8 +34,6 @@ import { navigateBuildHelper } from '../../utils/navigateHelper';

import { BuildsTable_builds } from './__generated__/BuildsTable_builds.graphql';

import BookOutlinedIcon from '@mui/icons-material/BookOutlined';

// todo: move custom values to mui theme adjustments
const useStyles = makeStyles(theme => {
return {
Expand Down
31 changes: 16 additions & 15 deletions src/components/chips/TaskCancellerChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,32 @@ import React from 'react';
import Avatar from '@mui/material/Avatar';
import Chip from '@mui/material/Chip';

import { createFragmentContainer } from 'react-relay';
import { useFragment } from 'react-relay';
import { graphql } from 'babel-plugin-relay/macro';
import { TaskCancellerChip_task } from './__generated__/TaskCancellerChip_task.graphql';
import { TaskCancellerChip_task$key } from './__generated__/TaskCancellerChip_task.graphql';

interface Props {
task: TaskCancellerChip_task;
task: TaskCancellerChip_task$key;
className?: string;
}

function TaskCancellerChip(props: Props) {
let { cancelledBy } = props.task;
export default function TaskCancellerChip(props: Props) {
let task = useFragment(
graphql`
fragment TaskCancellerChip_task on Task {
cancelledBy {
avatarURL
}
}
`,
props.task,
);

let { cancelledBy } = task;

if (!cancelledBy) return <></>;

return (
<Chip className={props.className} label="Cancelled by a user" avatar={<Avatar src={cancelledBy.avatarURL} />} />
);
}

export default createFragmentContainer(TaskCancellerChip, {
task: graphql`
fragment TaskCancellerChip_task on Task {
cancelledBy {
avatarURL
}
}
`,
});
29 changes: 15 additions & 14 deletions src/components/chips/TaskCreatedChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,30 @@ import Icon from '@mui/material/Icon';
import Tooltip from '@mui/material/Tooltip';
import { graphql } from 'babel-plugin-relay/macro';
import React, { useEffect } from 'react';
import { createFragmentContainer } from 'react-relay';
import { useFragment } from 'react-relay';
import { useTaskStatusColor } from '../../utils/colors';
import { taskStatusIconName } from '../../utils/status';
import { roundAndPresentDuration } from '../../utils/time';
import { TaskCreatedChip_task } from './__generated__/TaskCreatedChip_task.graphql';
import { TaskCreatedChip_task$key } from './__generated__/TaskCreatedChip_task.graphql';
import { useTheme } from '@mui/material';

interface Props {
task: TaskCreatedChip_task;
task: TaskCreatedChip_task$key;
className?: string;
}

let TaskCreatedChip = (props: Props) => {
export default function TaskCreatedChip(props: Props) {
let task = useFragment(
graphql`
fragment TaskCreatedChip_task on Task {
creationTimestamp
}
`,
props.task,
);

let theme = useTheme();
const creationTimestamp = props.task.creationTimestamp;
const creationTimestamp = task.creationTimestamp;

const [durationAgoInSeconds, setDurationAgoInSeconds] = React.useState((Date.now() - creationTimestamp) / 1000);

Expand Down Expand Up @@ -51,12 +60,4 @@ let TaskCreatedChip = (props: Props) => {
/>
</Tooltip>
);
};

export default createFragmentContainer(TaskCreatedChip, {
task: graphql`
fragment TaskCreatedChip_task on Task {
creationTimestamp
}
`,
});
}
28 changes: 14 additions & 14 deletions src/components/chips/TaskExperimentalChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,27 @@ import Avatar from '@mui/material/Avatar';
import Chip from '@mui/material/Chip';
import CasinoIcon from '@mui/icons-material/Casino';

import { createFragmentContainer } from 'react-relay';
import { useFragment } from 'react-relay';
import { graphql } from 'babel-plugin-relay/macro';
import { TaskExperimentalChip_task } from './__generated__/TaskExperimentalChip_task.graphql';
import { TaskExperimentalChip_task$key } from './__generated__/TaskExperimentalChip_task.graphql';
import { useTheme } from '@mui/material';

interface Props {
className?: string;
task: TaskExperimentalChip_task;
task: TaskExperimentalChip_task$key;
}

let TaskExperimentalChip = (props: Props) => {
export default function TaskExperimentalChip(props: Props) {
let task = useFragment(
graphql`
fragment TaskExperimentalChip_task on Task {
experimental
}
`,
props.task,
);

let theme = useTheme();
const { task } = props;
const { experimental } = task;

if (!experimental) return <div />;
Expand All @@ -32,12 +40,4 @@ let TaskExperimentalChip = (props: Props) => {
}
/>
);
};

export default createFragmentContainer(TaskExperimentalChip, {
task: graphql`
fragment TaskExperimentalChip_task on Task {
experimental
}
`,
});
}
27 changes: 14 additions & 13 deletions src/components/chips/TaskOptionalChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,29 @@ import Avatar from '@mui/material/Avatar';
import Chip from '@mui/material/Chip';
import Report from '@mui/icons-material/Report';

import { createFragmentContainer } from 'react-relay';
import { useFragment } from 'react-relay';
import { graphql } from 'babel-plugin-relay/macro';
import { TaskOptionalChip_task } from './__generated__/TaskOptionalChip_task.graphql';
import { TaskOptionalChip_task$key } from './__generated__/TaskOptionalChip_task.graphql';
import { useTheme } from '@mui/material';

interface Props {
task: TaskOptionalChip_task;
task: TaskOptionalChip_task$key;
className?: string;
}

function TaskOptionalChip(props: Props) {
export default function TaskOptionalChip(props: Props) {
let task = useFragment(
graphql`
fragment TaskOptionalChip_task on Task {
optional
}
`,
props.task,
);

let theme = useTheme();

let { optional } = props.task;
let { optional } = task;
if (!optional) return <div />;

return (
Expand All @@ -32,11 +41,3 @@ function TaskOptionalChip(props: Props) {
/>
);
}

export default createFragmentContainer(TaskOptionalChip, {
task: graphql`
fragment TaskOptionalChip_task on Task {
optional
}
`,
});
31 changes: 16 additions & 15 deletions src/components/chips/TaskRerunnerChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,30 @@ import React from 'react';
import Avatar from '@mui/material/Avatar';
import Chip from '@mui/material/Chip';

import { createFragmentContainer } from 'react-relay';
import { useFragment } from 'react-relay';
import { graphql } from 'babel-plugin-relay/macro';
import { TaskRerunnerChip_task } from './__generated__/TaskRerunnerChip_task.graphql';
import { TaskRerunnerChip_task$key } from './__generated__/TaskRerunnerChip_task.graphql';

interface Props {
task: TaskRerunnerChip_task;
task: TaskRerunnerChip_task$key;
className?: string;
}

function TaskRerunnerChip(props: Props) {
let { reranBy } = props.task;
export default function TaskRerunnerChip(props: Props) {
let task = useFragment(
graphql`
fragment TaskRerunnerChip_task on Task {
reranBy {
avatarURL
}
}
`,
props.task,
);

let { reranBy } = task;

if (!reranBy) return <></>;

return <Chip className={props.className} label="Re-ran by a user" avatar={<Avatar src={reranBy.avatarURL} />} />;
}

export default createFragmentContainer(TaskRerunnerChip, {
task: graphql`
fragment TaskRerunnerChip_task on Task {
reranBy {
avatarURL
}
}
`,
});
33 changes: 17 additions & 16 deletions src/components/chips/TaskResourcesChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import Avatar from '@mui/material/Avatar';
import Chip from '@mui/material/Chip';
import Tooltip from '@mui/material/Tooltip';
import Memory from '@mui/icons-material/Memory';
import { createFragmentContainer } from 'react-relay';
import { useFragment } from 'react-relay';
import { graphql } from 'babel-plugin-relay/macro';
import { makeStyles } from '@mui/styles';
import { TaskResourcesChip_task } from './__generated__/TaskResourcesChip_task.graphql';
import { TaskResourcesChip_task$key } from './__generated__/TaskResourcesChip_task.graphql';

const useStyles = makeStyles(theme => {
return {
Expand All @@ -21,13 +21,25 @@ const useStyles = makeStyles(theme => {
});

interface Props {
task: TaskResourcesChip_task;
task: TaskResourcesChip_task$key;
className?: string;
}

function TaskResourcesChip(props: Props) {
export default function TaskResourcesChip(props: Props) {
let task = useFragment(
graphql`
fragment TaskResourcesChip_task on Task {
instanceResources {
cpu
memory
}
}
`,
props.task,
);

let classes = useStyles();
let { task, className } = props;
let { className } = props;
let resources = task.instanceResources;
if (!resources) {
return null;
Expand All @@ -48,14 +60,3 @@ function TaskResourcesChip(props: Props) {
</Tooltip>
);
}

export default createFragmentContainer(TaskResourcesChip, {
task: graphql`
fragment TaskResourcesChip_task on Task {
instanceResources {
cpu
memory
}
}
`,
});
Loading