import { FC, Fragment } from 'react' import { useRouter } from 'next/router' import { Button, IconExternalLink } from 'ui' import { Action, ActionReason, ActionType } from '@supabase/shared-types/out/notifications' import { Project } from 'types' import Link from 'next/link' // [Joshen TODO] Remove all things about "ownerReassignStatus" after 5th November // double check with Qiao before we remove them. interface Props { project: Project changelogLink?: string ownerReassignStatus?: any availableActions: Action[] onSelectRestartProject: () => void onSelectApplyMigration: () => void onSelectRollbackMigration: () => void onSelectFinalizeMigration: () => void } const NotificationActions: FC = ({ project, changelogLink, ownerReassignStatus, availableActions, onSelectRestartProject, onSelectApplyMigration, onSelectRollbackMigration, onSelectFinalizeMigration, }) => { const router = useRouter() const onSelectUpgradeProject = () => { return router.push(`/project/${project.ref}/settings/billing/update/pro`) } const renderActionButton = (action: Action) => { switch (action.action_type) { case ActionType.UpgradeProjectToPro: return ( ) case ActionType.SchedulePostgresRestart: return ( ) case ActionType.MigratePostgresSchema: if (action.reason === ActionReason.Finalize) { return ( ownerReassignStatus?.desired !== 'migrated' && ( ) ) } else if (action.reason === ActionReason.Rollback) { return ( ownerReassignStatus?.desired === 'temp_role' && ( ) ) } else { return ( ownerReassignStatus?.desired === 'unmigrated' && ( ) ) } } } return (
{availableActions.map((action) => { return ( {renderActionButton(action)} ) })} {changelogLink && ( )}
) } export default NotificationActions