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

feat(page-services): add jobs #392

Merged
merged 10 commits into from Nov 28, 2022
Merged

Conversation

RemiBonnet
Copy link
Member

@RemiBonnet RemiBonnet commented Nov 24, 2022

What does this PR do?

> Link to the JIRA ticket

  • Add cron job and lifecycle job on the Services list and Deployment (test here)

Capture d’écran 2022-11-28 à 15 31 40


PR Checklist

Global

  • This PR does not introduce any breaking change
  • This PR introduces breaking change(s) and has been labeled as such
  • I have found someone to review this PR and pinged him

Store

  • This PR introduces new store changes

NX

  • I have run the dep-graph locally and made sure the tree was clean i.e no circular dependencies
  • I have followed the library pattern i.e feature, ui, data, utils

Clean Code

  • I made sure the code is type safe (no any)
  • I have included a feature flag on my feature, if applicable

@evoxmusic
Copy link
Contributor

A preview environment was automatically created via Qovery.
Click on the link below to follow its deployment and use it.
👉 [PR] staging - feat(page-services): add jobs - 2022-11-24T16:57:48Z

Another comment will be posted when deployments are terminated

@nx-cloud
Copy link

nx-cloud bot commented Nov 24, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 74a3f6d. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@evoxmusic
Copy link
Contributor

Your preview environment has been successfully deployed !
Click on the link below to open your service:
👉 console
👉 storybook

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2022

Codecov Report

Merging #392 (ba444ab) into staging (94db3e3) will decrease coverage by 4.12%.
The diff coverage is 46.87%.

@@             Coverage Diff             @@
##           staging     #392      +/-   ##
===========================================
- Coverage    57.83%   53.70%   -4.13%     
===========================================
  Files           24      298     +274     
  Lines          268     5554    +5286     
  Branches        92     1179    +1087     
===========================================
+ Hits           155     2983    +2828     
- Misses          79     2189    +2110     
- Partials        34      382     +348     
Impacted Files Coverage Δ
...re/storage-modal-feature/storage-modal-feature.tsx 61.53% <ø> (ø)
...plication/src/lib/ui/page-general/page-general.tsx 50.00% <ø> (ø)
...c/lib/ui/table-row-services/table-row-services.tsx 38.46% <29.41%> (ø)
...e-deployments-feature/page-deployments-feature.tsx 79.41% <33.33%> (ø)
...s/application/src/lib/slices/applications.slice.ts 18.51% <40.00%> (ø)
...-feature/crud-modal-feature/crud-modal-feature.tsx 48.57% <100.00%> (ø)
...ings-ports-feature/page-settings-ports-feature.tsx 59.09% <100.00%> (ø)
...ources-feature/page-settings-resources-feature.tsx 79.41% <100.00%> (ø)
...-storage-feature/page-settings-storage-feature.tsx 44.00% <100.00%> (ø)
...ui/page-deployment-rules/page-deployment-rules.tsx 20.00% <0.00%> (ø)
... and 273 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@RemiBonnet RemiBonnet marked this pull request as ready for review November 28, 2022 14:36
Copy link
Contributor

@bdebon bdebon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the DE improvment with the dataDatabase and others trick.
Now in order to make the whole things easier to read and maintain, I'm proposing an light improvement, tell me what you think about it.

@@ -183,9 +198,12 @@ export const fetchApplicationDeployments = createAsyncThunk<
DeploymentHistoryApplication[],
{ applicationId: string; serviceType?: ServiceTypeEnum; silently?: boolean }
>('application/deployments', async (data) => {
console.log(data.serviceType)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yop

@@ -183,9 +198,12 @@ export const fetchApplicationDeployments = createAsyncThunk<
DeploymentHistoryApplication[],
{ applicationId: string; serviceType?: ServiceTypeEnum; silently?: boolean }
>('application/deployments', async (data) => {
console.log(data.serviceType)
let response
if (data.serviceType === ServiceTypeEnum.CONTAINER) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these 3 conditions can we have an util somewhere that contains these 3 methods:
isContainer()
isJob()
isApplication() ?

Like this it would be factorised somewhere and if one day the condition to detect the type changes, we just have to change it in one place. What do you think?

<Icon name={type === ServiceTypeEnum.DATABASE ? IconEnum.DATABASE : IconEnum.APPLICATION} width="20" />
<Icon
name={
type === ServiceTypeEnum.APPLICATION || type === ServiceTypeEnum.CONTAINER
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this multiplication of rather complex tests here and there, I think even more about the util that contains isContainer() isGitApplication() isDatabase() isJob()
It would be much comfortable to read and to maintain no?

@@ -108,25 +116,34 @@ export function TableRowServices(props: TableRowServicesProps) {
<Skeleton className="w-full" show={isLoading} width={160} height={16}>
<div className="w-full flex gap-2 items-center -mt-[1px]">
{type === ServiceTypeEnum.APPLICATION && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because with just these conditions we have to make the effort everytime to see if you test if it's an gitapp, a container app, etc... Frontend joining us could be lost quickly and so could we after many months

@@ -45,33 +46,39 @@ export function TableRowServices(props: TableRowServicesProps) {
isLoading,
} = props

const dataDatabase = data as DatabaseEntity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this

} from '@qovery/shared/interfaces'
import { ServiceTypeEnum } from '../service-type.enum'

export const getServiceType = (data: ApplicationEntity | DatabaseEntity) => {
let currentType: ServiceTypeEnum

const isJob = (data as JobApplicationEntity).max_nb_restart

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so basically this file already exists, I think you could add some utils in this one that are: isDatabase(data) and that basically would check that getServiceType(data) === ServiceType.DATABASE you see?

import { LoadingStatus } from '../types/loading-status.type'
import { ServiceRunningStatus } from './service-running-status.interface'

export interface JobApplicationEntity extends JobResponse {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not JobEntity ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's the same pattern with other application

job-application.entity.ts
git-application.entity.ts
container-application.entity.ts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, others are really applications, a git and a container give an application. For me, a Job is a Job, but anyway, it's not a big problem, it's totally fine like this too.

Copy link
Contributor

@bdebon bdebon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refactoring is a bless! Thanks Remi, I'm very happy with this PR!

} else {
currentType = ServiceTypeEnum.APPLICATION
}

return currentType
}

// Job
export const isJob = (data?: ApplicationEntity | ServiceTypeEnum) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfecto me gusta mucho!!

import { LoadingStatus } from '../types/loading-status.type'
import { ServiceRunningStatus } from './service-running-status.interface'

export interface JobApplicationEntity extends JobResponse {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, others are really applications, a git and a container give an application. For me, a Job is a Job, but anyway, it's not a big problem, it's totally fine like this too.

@RemiBonnet RemiBonnet merged commit eee4336 into staging Nov 28, 2022
@RemiBonnet RemiBonnet deleted the feat/jobs-services-page-FRT-588 branch November 28, 2022 17:38
@bdebon
Copy link
Contributor

bdebon commented Nov 30, 2022

🎉 This PR is included in version 1.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants