Skip to content

Commit

Permalink
Plugins update manager: Add weekday to track events (#88843)
Browse files Browse the repository at this point in the history
  • Loading branch information
bogiii authored Mar 25, 2024
1 parent 922803b commit 4b68c31
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions client/blocks/plugins-update-manager/schedule-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const ScheduleCreate = ( props: Props ) => {
frequency: params.frequency,
plugins_number: params.plugins.length,
hours: params.hours,
weekday: params.weekday,
} );

createMonitor();
Expand Down
1 change: 1 addition & 0 deletions client/blocks/plugins-update-manager/schedule-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const ScheduleEdit = ( props: Props ) => {
frequency: params.frequency,
plugins_number: params.plugins.length,
hours: params.hours,
weekday: params.weekday,
} );

setSyncError( '' );
Expand Down
12 changes: 7 additions & 5 deletions client/blocks/plugins-update-manager/schedule-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ export const ScheduleForm = ( props: Props ) => {
const [ fieldTouched, setFieldTouched ] = useState< Record< string, boolean > >( {} );

const serverSyncCallbacks = {
onSuccess: () =>
onSyncSuccess &&
onSyncSuccess( {
onSuccess: () => {
const date = new Date( timestamp * 1000 );
onSyncSuccess?.( {
plugins: selectedPlugins,
frequency,
hours: new Date( timestamp * 1000 ).getHours(),
} ),
hours: date.getHours(),
weekday: frequency === 'weekly' ? date.getDay() : undefined,
} );
},
onError: ( e: Error ) => onSyncError && onSyncError( e.message ),
};
const { createUpdateSchedule } = useCreateUpdateScheduleMutation( siteSlug, serverSyncCallbacks );
Expand Down
1 change: 1 addition & 0 deletions client/blocks/plugins-update-manager/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export type SyncSuccessParams = {
plugins: string[];
frequency: 'daily' | 'weekly';
hours: number;
weekday?: number;
};

0 comments on commit 4b68c31

Please sign in to comment.