Skip to content

Commit

Permalink
fix(pci-workflow): workflow type filter
Browse files Browse the repository at this point in the history
ref: DTCORE-2769
Signed-off-by: Florian Renaut <[email protected]>
  • Loading branch information
frenautvh committed Oct 23, 2024
1 parent f1089c5 commit 4b16baa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
10 changes: 10 additions & 0 deletions packages/manager/apps/pci-workflow/src/api/hooks/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
import { deleteWorkflow } from '@/api/data/workflow';
import { paginateResults } from '@/helpers';

export const WORKFLOW_TYPE = 'instance_backup';

export type TWorkflow = {
name: string;
id: string;
Expand Down Expand Up @@ -137,13 +139,19 @@ export const sortWorkflows = (
return data;
};

export type TPaginatedWorkflow = TWorkflow & {
type: string;
typeLabel: string;
};

export const usePaginatedWorkflows = (
projectId: string,
pagination: PaginationState,
sorting: ColumnSort,
filters: Filter[] = [],
searchQueries: string[] = [],
) => {
const { t } = useTranslation('listing');
const { data: workflows, isPending: isWorkflowsPending } = useWorkflows(
projectId,
);
Expand All @@ -159,6 +167,8 @@ export const usePaginatedWorkflows = (
data: useMemo(() => {
const workflowsWithInstanceIds = workflows.map((workflow, i) => ({
...workflow,
type: WORKFLOW_TYPE,
typeLabel: t(`pci_workflow_type_${WORKFLOW_TYPE}_title`),
instanceName: results[i].data?.name,
}));
return paginateResults<TWorkflow>(
Expand Down
29 changes: 15 additions & 14 deletions packages/manager/apps/pci-workflow/src/pages/list/List.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ import {
import { FilterCategories } from '@ovh-ux/manager-core-api';
import { PciDiscoveryBanner, useProject } from '@ovh-ux/manager-pci-common';
import Actions from '@/components/actions.component';
import { TWorkflow, usePaginatedWorkflows } from '@/api/hooks/workflows';
import {
TPaginatedWorkflow,
usePaginatedWorkflows,
} from '@/api/hooks/workflows';
import ExecutionStatusComponent from '@/components/execution-status.component';
import HidePreloader from '@/core/HidePreloader';

Expand All @@ -64,34 +67,32 @@ export default function ListingPage() {
searchQueries,
);

const columns: DatagridColumn<TWorkflow>[] = [
const columns: DatagridColumn<TPaginatedWorkflow>[] = [
{
id: 'name',
cell: (workflow: TWorkflow) => (
cell: (workflow: TPaginatedWorkflow) => (
<DataGridTextCell>{workflow.name}</DataGridTextCell>
),
label: t('pci_workflow_name'),
},
{
id: 'id',
cell: (workflow: TWorkflow) => (
cell: (workflow: TPaginatedWorkflow) => (
<DataGridTextCell>{workflow.id}</DataGridTextCell>
),
label: t('pci_workflow_id'),
isSortable: false,
},
{
id: 'type',
cell: () => (
<DataGridTextCell>
{t('pci_workflow_type_instance_backup_title')}
</DataGridTextCell>
cell: (workflow: TPaginatedWorkflow) => (
<DataGridTextCell>{workflow.typeLabel}</DataGridTextCell>
),
label: t('pci_workflow_type'),
},
{
id: 'instanceName',
cell: (workflow: TWorkflow) => (
cell: (workflow: TPaginatedWorkflow) => (
<OsdsLink
color={ODS_THEME_COLOR_INTENT.primary}
href={`${projectUrl}/instances/${workflow.instanceId}`}
Expand All @@ -103,21 +104,21 @@ export default function ListingPage() {
},
{
id: 'cron',
cell: (workflow: TWorkflow) => (
cell: (workflow: TPaginatedWorkflow) => (
<DataGridTextCell>{workflow.cron}</DataGridTextCell>
),
label: t('pci_workflow_schedule'),
},
{
id: 'lastExecution',
cell: (workflow: TWorkflow) => (
cell: (workflow: TPaginatedWorkflow) => (
<DataGridTextCell>{workflow.lastExecution}</DataGridTextCell>
),
label: t('pci_workflow_last_execution'),
},
{
id: 'lastExecutionStatus',
cell: (workflow: TWorkflow) =>
cell: (workflow: TPaginatedWorkflow) =>
workflow.lastExecutionStatus ? (
<ExecutionStatusComponent status={workflow.lastExecutionStatus} />
) : null,
Expand All @@ -126,7 +127,7 @@ export default function ListingPage() {
},
{
id: 'actions',
cell: (workflow: TWorkflow) => (
cell: (workflow: TPaginatedWorkflow) => (
<div className="min-w-16">
<Actions workflow={workflow} />
</div>
Expand Down Expand Up @@ -241,7 +242,7 @@ export default function ListingPage() {
comparators: FilterCategories.String,
},
{
id: 'type',
id: 'typeLabel',
label: t('pci_workflow_type'),
comparators: FilterCategories.String,
},
Expand Down

0 comments on commit 4b16baa

Please sign in to comment.