1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 07:19:41 +02:00

refactor(docker/stacks): migrate table to react [EE-4705] (#9956)

This commit is contained in:
Chaim Lev-Ari 2023-09-07 15:59:59 +01:00 committed by GitHub
parent c3d266931f
commit c8a1f0fa77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 1127 additions and 492 deletions

View file

@ -0,0 +1,99 @@
import { Stack, StackStatus, StackType } from '@/react/common/stacks/types';
import { ResourceControlViewModel } from '@/react/portainer/access-control/models/ResourceControlViewModel';
import { EnvironmentId } from '@/react/portainer/environments/types';
import {
AutoUpdateResponse,
RepoConfigResponse,
} from '@/react/portainer/gitops/types';
import { IResource } from '../../components/datatable/createOwnershipColumn';
export class StackViewModel implements IResource {
Id: number;
Type: StackType;
Name: string;
EndpointId: EnvironmentId;
SwarmId: string;
Env: { name: string; value: string }[];
Option: { Prune: boolean; Force: boolean } | undefined;
IsComposeFormat: boolean;
ResourceControl?: ResourceControlViewModel;
Status: StackStatus;
CreationDate: number;
CreatedBy: string;
UpdateDate: number;
UpdatedBy: string;
Regular: boolean;
External: boolean;
Orphaned: boolean;
OrphanedRunning: boolean;
GitConfig: RepoConfigResponse | undefined;
FromAppTemplate: boolean;
AdditionalFiles: string[] | undefined;
AutoUpdate: AutoUpdateResponse | undefined;
Webhook: string | undefined;
StackFileVersion: string;
PreviousDeploymentInfo: unknown;
constructor(stack: Stack, orphaned = false) {
this.Id = stack.Id;
this.Type = stack.Type;
this.Name = stack.Name;
this.EndpointId = stack.EndpointID;
this.SwarmId = stack.SwarmID;
this.Env = stack.Env ? stack.Env : [];
this.Option = stack.Option;
this.IsComposeFormat = stack.IsComposeFormat;
if (stack.ResourceControl && stack.ResourceControl.Id !== 0) {
this.ResourceControl = new ResourceControlViewModel(
stack.ResourceControl
);
}
this.Status = stack.Status;
this.CreationDate = stack.CreationDate;
this.CreatedBy = stack.CreatedBy;
this.UpdateDate = stack.UpdateDate;
this.UpdatedBy = stack.UpdatedBy;
this.GitConfig = stack.GitConfig;
this.FromAppTemplate = stack.FromAppTemplate;
this.AdditionalFiles = stack.AdditionalFiles;
this.AutoUpdate = stack.AutoUpdate;
this.Webhook = stack.Webhook;
this.StackFileVersion = stack.StackFileVersion;
this.PreviousDeploymentInfo = stack.PreviousDeploymentInfo;
this.Regular = !orphaned;
this.External = false;
this.Orphaned = orphaned;
this.OrphanedRunning = false;
}
}