Files
ERP_Distribution/distribution_fe/components/shared/row-actions.tsx
T
Kalana B. Thilakarathna 03d01d4c4e name: CI/CD - ERP Core Monorepo
on:
  pull_request:
    branches:
      - production
    types:
      - closed

jobs:
  backend-build-and-deploy:
    name: Build & Deploy ERP Core Backend
    runs-on: linux
    if: github.event.pull_request.merged == true
    steps:
      - name: Checkout code
        run: |
          git clone \
            --depth 1 \
            --branch production \
            https://oauth2:${{ secrets.ERPCORE }}@gitea.hexdive.com/New_REP_SYSTEM/ERP-core.git \
            .

      - name: Restore backend
        run: dotnet restore Backend/ERPCore.sln

      - name: Publish backend
        run: |
          rm -rf /tmp/erpcore-deploy
          mkdir -p /tmp/erpcore-deploy
          dotnet publish Backend/ERPCore/ERPCore.csproj \
            -c Release \
            -r linux-x64 \
            --self-contained true \
            -o /tmp/erpcore-deploy

      - name: Stop backend service
        run: systemctl stop erpcore.service

      - name: Copy backend to deploy folder
        run: |
          mkdir -p /home/erp/core/publish
          rm -rf /home/erp/core/publish/*
          cp -r /tmp/erpcore-deploy/* /home/erp/core/publish/

      - name: Fix backend ownership and permissions
        run: |
          chown -R erpuser:erpuser /home/erp/core/publish
          find /home/erp/core/publish -type d -exec chmod 755 {} +
          find /home/erp/core/publish -type f -exec chmod 644 {} +
          chmod +x /home/erp/core/publish/ERPCore

      - name: Restart backend service
        run: systemctl restart erpcore.service

      - name: Verify backend
        run: |
          systemctl is-active erpcore.service && echo "Backend service running" || echo "Backend service failed"

  frontend-build-and-deploy:
    name: Build & Deploy ERP Core Frontend
    runs-on: linux
    needs: backend-build-and-deploy
    if: github.event.pull_request.merged == true
    steps:
      - name: Checkout code
        run: |
          git clone \
            --depth 1 \
            --branch Production \
            https://oauth2:${{ secrets.ERPCORE }}@gitea.hexdive.com/New_REP_SYSTEM/ERP-core.git \
            .

      - name: Build frontend Docker image
        run: docker build -t erpcore-frontend:latest Frontend/erp-system

      - name: Stop & remove existing frontend container
        run: |
          docker stop erpcore-frontend 2>/dev/null || true
          docker rm erpcore-frontend 2>/dev/null || true

      - name: Start frontend container
        run: |
          docker run -d \
            --name erpcore-frontend \
            -p 6702:6702 \
            --add-host=host.docker.internal:host-gateway \
            -e BACKEND_ORIGIN=http://host.docker.internal:6701 \
            --restart unless-stopped \
            --memory="512m" \
            --cpus="1.0" \
            --cap-drop ALL \
            --security-opt no-new-privileges \
            erpcore-frontend:latest

      - name: Remove old frontend images
        run: docker image prune -f

      - name: Verify frontend
        run: |
          docker ps --filter name=erpcore-frontend --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" \
            | grep erpcore-frontend && echo "Frontend container running" || echo "Frontend container failed"
2026-09-17 13:59:05 +05:30

77 lines
1.5 KiB
TypeScript

"use client"
import * as React from "react"
import { HugeiconsIcon } from "@hugeicons/react"
import {
Cancel01Icon,
CheckmarkCircle02Icon,
CheckmarkSquare01Icon,
Delete02Icon,
EyeIcon,
PencilEdit01Icon,
PrinterIcon,
} from "@hugeicons/core-free-icons"
import { Button } from "@/components/ui/button"
import { cn } from "@/lib/utils"
const ACTION_ICONS = {
activate: CheckmarkCircle02Icon,
cancel: Delete02Icon,
close: Cancel01Icon,
confirm: CheckmarkCircle02Icon,
deactivate: Cancel01Icon,
edit: PencilEdit01Icon,
finalize: CheckmarkSquare01Icon,
print: PrinterIcon,
view: EyeIcon,
} as const
type RowActionKind = keyof typeof ACTION_ICONS
function RowActions({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
className={cn("flex items-center justify-end gap-1", className)}
{...props}
/>
)
}
function RowActionButton({
action,
label,
tone = "default",
className,
...props
}: Omit<React.ComponentProps<typeof Button>, "children"> & {
action: RowActionKind
label: string
tone?: "default" | "destructive"
}) {
const icon = ACTION_ICONS[action]
return (
<Button
variant="ghost"
size="icon-sm"
className={cn(
tone === "destructive"
? "text-destructive hover:text-destructive"
: "text-muted-foreground hover:text-foreground",
className
)}
aria-label={label}
title={label}
{...props}
>
<HugeiconsIcon icon={icon} size={16} />
</Button>
)
}
export { RowActions, RowActionButton }