Skip to content

Commit

Permalink
rerender only the schedules which toggled (#3244)
Browse files Browse the repository at this point in the history
  • Loading branch information
pnaik1 authored Sep 26, 2024
1 parent 027278b commit 063d974
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import PipelineRecurringRunTableToolbar from './PipelineRecurringRunTableToolbar

type PipelineRecurringRunTableProps = {
recurringRuns: PipelineRecurringRunKFv2[];
refresh: () => void;
loading?: boolean;
totalSize: number;
page: number;
Expand All @@ -33,6 +34,7 @@ type PipelineRecurringRunTableProps = {

const PipelineRecurringRunTable: React.FC<PipelineRecurringRunTableProps> = ({
recurringRuns,
refresh,
loading,
totalSize,
page,
Expand Down Expand Up @@ -122,6 +124,7 @@ const PipelineRecurringRunTable: React.FC<PipelineRecurringRunTableProps> = ({
rowRenderer={(recurringRun) => (
<PipelineRecurringRunTableRow
key={recurringRun.recurring_run_id}
refresh={refresh}
isChecked={isSelected(recurringRun.recurring_run_id)}
onToggleCheck={() => toggleSelection(recurringRun.recurring_run_id)}
onDelete={() => setDeleteResources([recurringRun])}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,22 @@ import useExperimentById from '~/concepts/pipelines/apiHooks/useExperimentById';

type PipelineRecurringRunTableRowProps = {
isChecked: boolean;
refresh: () => void;
onToggleCheck: () => void;
onDelete: () => void;
recurringRun: PipelineRecurringRunKFv2;
};

const PipelineRecurringRunTableRow: React.FC<PipelineRecurringRunTableRowProps> = ({
isChecked,
refresh,
onToggleCheck,
onDelete,
recurringRun,
}) => {
const navigate = useNavigate();
const { experimentId, pipelineId, pipelineVersionId } = useParams();
const { namespace, api, refreshAllAPI } = usePipelinesAPI();
const { namespace, api } = usePipelinesAPI();
const { version, loaded, error } = usePipelineRunVersionInfo(recurringRun);
const isExperimentsAvailable = useIsAreaAvailable(SupportedArea.PIPELINE_EXPERIMENTS).status;
const isExperimentsContext = isExperimentsAvailable && experimentId;
Expand Down Expand Up @@ -98,7 +100,7 @@ const PipelineRecurringRunTableRow: React.FC<PipelineRecurringRunTableRowProps>
onToggle={(checked) =>
api
.updatePipelineRecurringRun({}, recurringRun.recurring_run_id, checked)
.then(refreshAllAPI)
.then(() => refresh())
}
/>
</Td>
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/pages/pipelines/global/runs/ScheduledRuns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import PipelineRecurringRunTable from '~/concepts/pipelines/content/tables/pipel

const ScheduledRuns: React.FC = () => {
const { experimentId, pipelineVersionId } = useParams();
const [[{ items: recurringRuns, totalSize }, loaded, error], { initialLoaded, ...tableProps }] =
usePipelineRecurringRunsTable({ experimentId, pipelineVersionId });
const [
[{ items: recurringRuns, totalSize }, loaded, error, refresh],
{ initialLoaded, ...tableProps },
] = usePipelineRecurringRunsTable({ experimentId, pipelineVersionId });
const isExperimentArchived = useIsExperimentArchived();

if (error) {
Expand Down Expand Up @@ -73,6 +75,7 @@ const ScheduledRuns: React.FC = () => {

return (
<PipelineRecurringRunTable
refresh={refresh}
recurringRuns={recurringRuns}
loading={!loaded}
totalSize={totalSize}
Expand Down

0 comments on commit 063d974

Please sign in to comment.