@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.file', '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') }}
{{-- ── Use your own Google app (self-serve BYO — owner only) ────── The workspace owner pastes their OWN Google Cloud OAuth client ID + secret and connects through their own app: no admin config or approval, no shared-app review limits. Members don't see the keys; when nothing is configured yet they're told to ask the owner. --}} @if ($isOwner && !empty($manualAllowed))
{{ __('Your Google app') }}
{{ $ownApp ? __('Connecting through your own Google app') : __('Connect with your own Google app') }}
{{ $ownApp ? __('keys saved') : __('not set') }}
@if (!$appReady)

{{ __('Create a Google Cloud OAuth client and paste its keys here, then click Connect Google. No approval needed — you use your own Google app.') }}

@endif
@csrf
{{ __('In your Google app, add this exact Authorized redirect URI:') }}
{{ $googleRedirectUri }}
{{-- In-app step-by-step: where to get the keys. --}}
{{ __('Where do I get these keys?') }}
  1. {{ __('Open') }} console.cloud.google.com → {{ __('create a project (or pick one).') }}
  2. {{ __('APIs & Services → Enabled APIs → enable: Google Calendar API, Google Sheets API, Google Docs API, Google Drive API, Google Forms API.') }}
  3. {{ __('OAuth consent screen → External → add your email as a Test user (Testing mode works right away — no Google verification needed for your own use).') }}
  4. {{ __('Credentials → Create credentials → OAuth client ID → Web application.') }}
  5. {{ __('Under Authorized redirect URIs, paste the URI shown above.') }}
  6. {{ __('Copy the Client ID + Client secret and paste them here, then Save.') }}
@if ($ownApp)
@csrf
@endif
@elseif (!$appReady)
@if (!empty($manualAllowed)) {{ __('Google isn\'t connected yet. Ask the workspace owner to add the Google app keys on this page.') }} @else {{ __('Google isn\'t available for this workspace yet.') }} @endif
@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.') }}