Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboard): re run activity item #7459

Open
wants to merge 6 commits into
base: next
Choose a base branch
from
Open

Conversation

scopsy
Copy link
Contributor

@scopsy scopsy commented Jan 8, 2025

What changed? Why was the change needed?

Screenshots

CleanShot 2025-01-08 at 16 08 52@2x

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

netlify bot commented Jan 8, 2025

Deploy Preview for dashboard-v2-novu-staging ready!

Name Link
🔨 Latest commit 4065e93
🔍 Latest deploy log https://app.netlify.com/sites/dashboard-v2-novu-staging/deploys/678e0063cb8c390008794307
😎 Deploy Preview https://deploy-preview-7459.dashboard-v2.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 8, 2025

Deploy Preview for dev-web-novu ready!

Name Link
🔨 Latest commit 4065e93
🔍 Latest deploy log https://app.netlify.com/sites/dev-web-novu/deploys/678e0063b748420008ff4da6
😎 Deploy Preview https://deploy-preview-7459.dashboard.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@scopsy scopsy marked this pull request as ready for review January 20, 2025 07:48
Comment on lines +70 to +75
<CardContent className="overflow-hidden rounded-lg bg-neutral-50 p-2">
<div className="flex min-w-0 items-center gap-2">
<div className="min-w-0 flex-1 overflow-hidden">
<span className="text-foreground-400 block truncate text-xs">{getStatusMessage(job)}</span>
</div>
<Badge variant="lighter" color="gray" size="sm" className="shrink-0 whitespace-nowrap">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed clipping of the date badge on long text

@scopsy scopsy changed the title feat(dashboard): re run activity item - WIP feat(dashboard): re run activity item Jan 20, 2025
Comment on lines 26 to +43

export function ActivityPanel({
activityId,
transactionId: initialTransactionId,
onActivitySelect,
headerClassName,
overviewHeaderClassName,
}: ActivityPanelProps) {
const queryClient = useQueryClient();
const [shouldRefetch, setShouldRefetch] = useState(true);
const track = useTelemetry();
const { isLoadingTransaction, setTransactionId } = useActivityByTransaction({
transactionId: initialTransactionId,
onActivityFound: onActivitySelect,
});

const { activity, isPending, error } = useActivityPolling({
activityId,
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the logic of fetching and refetching by transaction id to the activity panel to allow initializing by either activityId or transaction id

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please elaborate on why do we need to do both? The transaction is identified by transactionID, so I think we can just use that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When vieweing an item from the activity feed, we want to view a specific activityId, transacitonId is used in cases of a re-trigger, and also from the test workflow sidebar. As a trigger can potentially generate multiple activity ids, when testing we assume it generates one and just take the first.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Let's continue here. My suggestion is to work with the notification list (activity feed) page as the main resource and the selected notification (details of a run).

If not mistaken, the transactionId for the rerun should be available in the selected notification resource.

Comment on lines +139 to 145
isLoading?: boolean;
}
>(({ children, icon: Icon, ...rest }, forwardedRef) => {
>(({ children, icon: Icon, isLoading, disabled, ...rest }, forwardedRef) => {
return (
<CompactButtonRoot ref={forwardedRef} {...rest}>
<CompactButtonIcon as={Icon} />
<CompactButtonRoot ref={forwardedRef} disabled={isLoading || disabled} {...rest}>
<CompactButtonIcon as={isLoading ? RiLoader4Line : Icon} className={isLoading ? 'loading' : ''} />
</CompactButtonRoot>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add's a nice loading state

Comment on lines 26 to +43

export function ActivityPanel({
activityId,
transactionId: initialTransactionId,
onActivitySelect,
headerClassName,
overviewHeaderClassName,
}: ActivityPanelProps) {
const queryClient = useQueryClient();
const [shouldRefetch, setShouldRefetch] = useState(true);
const track = useTelemetry();
const { isLoadingTransaction, setTransactionId } = useActivityByTransaction({
transactionId: initialTransactionId,
onActivityFound: onActivitySelect,
});

const { activity, isPending, error } = useActivityPolling({
activityId,
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please elaborate on why do we need to do both? The transaction is identified by transactionID, so I think we can just use that.

});
}, [activity, queryClient, currentEnvironment, activityId]);

return {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit picky: return all the results from useFetchActivity.

onActivityFound: (activityId: string) => void;
}

export function useActivityByTransaction({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hook is needed to correct a misalignment in the dashboard's Activity Feed. The current notification item, ? activityItemFeed=..., is already present in the address bar.

So, it's unclear if we rerun based on transactionID or Notification ID.

Screenshot 2025-01-21 at 12 42 34

My suggestion is to use the notificationId for now. We shouldn't need the useState; we should get it from the URL. That would eliminate the need for this hook.

Having said that, I suggest changing the URL schema to
https://dashboard-v2.novu.co/env/:env_id/activity-feed/:notificationId to map with the API powering this screen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I do not entirely follow your suggestion. The re run uses the current notification entity, and performs a trigger using the same payload and recipient properties as the previous trigger.

useActivityByTransactionId is just a refactor I did that encapsulates the fetch activities given a specific transactionId, this happens in 2 cases:

  • We perform a trigger in the test workflow sidebar (Workflow editor), the API returns a transactionId, and we need to obtain the notification Id by searching the notification feed based on the transaction id and select the first activity item.
  • When we re-run an activity item, the API returns us a transactionId, which we again need to convert to a notificationId/activityId to display the full details.

Copy link
Member

@BiswaViraj BiswaViraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen.Recording.2025-01-21.at.8.52.56.PM.mov

Triggering 2nd time is not updating the activity log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants