@php $profileEmail = (string) ($oauth['profile']['email'] ?? ''); $profileName = (string) ($oauth['profile']['name'] ?? ''); $profilePic = (string) ($oauth['profile']['picture'] ?? ''); $connectedAt = (string) ($oauth['connected_at'] ?? ''); $scopes = (array) ($oauth['scopes'] ?? []); if (empty($scopes) && !empty($oauth['scope'] ?? null)) { $scopes = preg_split('/\s+/', (string) $oauth['scope']); } $calendarId = (string) ($oauth['calendar_id'] ?? ''); $expiresAt = (string) ($oauth['expires_at'] ?? ''); $hasRefresh = !empty($oauth['refresh_token'] ?? null); $workspaceName = optional($workspace)->name ?: 'Workspace'; // Scope-by-scope check for the new flow nodes (Sheets / Docs / Forms). // Existing Calendar-only connections will be missing these; surface a // re-consent banner so the operator knows to click reconnect. $integrationScopes = [ 'sheets' => 'https://www.googleapis.com/auth/spreadsheets', 'docs' => 'https://www.googleapis.com/auth/documents', 'drive' => 'https://www.googleapis.com/auth/drive', 'forms' => 'https://www.googleapis.com/auth/forms.body.readonly', ]; $missingScopes = []; if ($isConnected) { foreach ($integrationScopes as $key => $url) { if (!in_array($url, $scopes, true)) { $missingScopes[] = $key; } } } @endphp
@if (session('success'))
{{ session('success') }}
@endif @if (session('error'))
{{ session('error') }}
@endif
{{-- ── Left aside ───────────────────────────────────────────────── --}} {{-- ── Right main ──────────────────────────────────────────────── --}}
{{ __('Workspace') }} · {{ $workspaceName }}

{{ __('Google') }} {{ __('account') }}

{{ __('Connect once — powers Calendar, Meet link generation in flows, and the inbox composer.') }}

@if ($isConnected) {{ __('connected') }}
@csrf
@else {{ __('not connected') }}
@csrf
@endif
{{-- 4-stat row matching /devices --}}
{{ __('Status') }}
{{ $isConnected ? __('live') : __('idle') }}
{{ __('Calendars') }}
{{ count($calendars) }}{{ __('available') }}
{{ __('Scopes') }}
{{ count($scopes) }}{{ __('granted') }}
{{ __('Refresh') }}{{ $hasRefresh ? __('ready') : __('missing') }}
{{ $hasRefresh ? __('auto') : __('re-auth') }}
{{-- Admin-side OAuth check banner --}} @if (!$appReady)
{{ __('Admin setup needed:') }} Platform-level Google OAuth client isn't configured. Ask the admin to set client ID + secret in /admin/settings → Integrations → Google before this page can connect.
@endif {{-- Missing-scope re-consent banner. Existing Calendar-only connections need to reconnect once for the new Sheets / Docs / Forms flow nodes to work. The same Connect button triggers the OAuth flow with all-new scopes; Google will show the user what extra access they're granting. --}} @if ($isConnected && !empty($missingScopes))
{{ __('Reconnect to unlock new flow nodes:') }} Your Google account is connected but missing scopes for @foreach ($missingScopes as $i => $m) {{ $m }} @if ($i + 1 < count($missingScopes)) @if ($i + 2 === count($missingScopes)) and @else, @endif @endif @endforeach. Click {{ __('Reconnect') }} to grant them. Existing Calendar/Meet features keep working either way.
@csrf
@endif {{-- Connection table — matches /devices grid card layout --}}
{{ __('workspace google identity') }}
@if ($isConnected && $expiresAt) token expires {{ \Illuminate\Support\Carbon::parse($expiresAt)->diffForHumans() }} @endif
{{-- Column header strip — matches the row template below --}}
{{ __('Account') }}
{{ __('Calendar') }}
{{ __('Scopes') }}
{{ __('Connected') }}
{{ __('Actions') }}
@if ($isConnected)
@if ($profilePic) @else {{ strtoupper(substr($profileEmail ?: 'G', 0, 1)) }} @endif
{{ $profileName ?: ($profileEmail ?: __('Google user')) }}
{{ $profileEmail ?: '—' }}
@php $picked = collect($calendars)->firstWhere('id', $calendarId); @endphp
{{ $picked['summary'] ?? ($calendarId ?: 'primary') }}
{{ $calendarId ?: 'primary' }}
@if (!empty($scopes))
@foreach (array_slice($scopes, 0, 4) as $s) @php $short = preg_replace('#^https?://www\.googleapis\.com/auth/#', '', (string) $s); @endphp {{ $short }} @endforeach @if (count($scopes) > 4) +{{ count($scopes) - 4 }} @endif
@else @endif
{{ $connectedAt ? \Illuminate\Support\Carbon::parse($connectedAt)->diffForHumans() : '—' }}
@if (count($calendars) > 1) {{ __('Change calendar') }} @endif
@csrf
@else {{-- Empty state row — single Connect CTA spanning the row --}}
{{ __('No Google account linked') }}

{{ __("Until you connect, BookAppointment and Google Meet nodes can't run and the inbox Send Meet button is hidden.") }}

@csrf
@endif
{{ __('Showing') }} {{ $isConnected ? 1 : 0 }} of 1
{{ __('Workspace cap: 1 Google account per workspace') }}
{{-- 3 help cards — matches /devices footer --}}
{{ __('Help - 01') }}
{{ __('What does this unlock?') }}

{{ __('Calendar slot pickers for BookAppointment, on-demand Google Meet links for the Meet node and the inbox composer, plus future Google Workspace nodes.') }}

{{ __('Help - 02') }}
{{ __('Whose account is used?') }}

{{ __("The Google account belongs to whoever clicks Connect first. Calendar events + Meet links appear in that user's Google Calendar — typically the workspace owner.") }}

{{ __('Help - 03') }}
{{ __('What if I disconnect?') }}

{{ __('Existing flow JSON stays intact, but any in-flight runs hitting a Calendar or Meet node will fail. Reconnect anytime — the same token store + node configs pick up immediately.') }}