mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
This is part two of a [PR breakdown](https://github.com/supabase/supabase/pull/42276) that introduces our connect schema and how content is retrieved. This focuses on the Framework tab to start. Fields are generated and content is rendered using a connect.schema file. This schema file defines modes, fields and steps. Each mode has a set of fields. Each field can be dependent on another field. The steps generated are then based off the values of the modes and fields. Each step can also render varying content dynamically using a template {{framework}}/{{frameworkVariant}}/{{library}} which just replaces those values with what's in state (fields selected). [Part one needs to be merged first.](https://github.com/supabase/supabase/pull/42367) The next stage will add back all other tabs and content. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * New Connect Sheet UI to guide app-to-project connections with dynamic configuration and copyable connection parameters. * Multi-framework & mobile support with ready-to-use code examples, install commands, and step-by-step setup for 20+ frameworks. * Multiple PostgreSQL connection methods (direct, transaction, session) with safe/masked connection previews. * Copy-prompt that aggregates step content and code for easy sharing. * **UI** * Multi-file code viewer with tabbed code blocks and added syntax support (Swift, TOML, HTML). * **Tests** * Comprehensive unit tests for resolver and state logic. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
128 lines
2.9 KiB
TypeScript
128 lines
2.9 KiB
TypeScript
import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
|
|
|
|
import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
|
|
|
|
const ContentFile = ({ projectKeys }: StepContentProps) => {
|
|
const files = [
|
|
{
|
|
name: 'environments/environment.ts',
|
|
language: 'ts',
|
|
code: `
|
|
export const environment = {
|
|
supabaseUrl: '${projectKeys.apiUrl ?? 'your-project-url'}',
|
|
supabaseKey: '${projectKeys.publishableKey ?? '<prefer publishable key instead of anon key for mobile apps>'}',
|
|
};
|
|
`,
|
|
},
|
|
{
|
|
name: 'src/app/supabase.service.ts',
|
|
language: 'ts',
|
|
code: `
|
|
import { Injectable } from '@angular/core';
|
|
import { createClient, SupabaseClient } from '@supabase/supabase-js';
|
|
import { environment } from '../environments/environment';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class SupabaseService {
|
|
private supabase: SupabaseClient;
|
|
constructor() {
|
|
this.supabase = createClient(
|
|
environment.supabaseUrl,
|
|
environment.supabaseKey
|
|
);
|
|
}
|
|
|
|
getTodos() {
|
|
return this.supabase.from('todos').select('*');
|
|
}
|
|
}
|
|
`,
|
|
},
|
|
{
|
|
name: 'src/app/app.component.ts',
|
|
language: 'ts',
|
|
code: `
|
|
import { Component, OnInit } from '@angular/core';
|
|
import { SupabaseService } from './supabase.service';
|
|
|
|
@Component({
|
|
selector: 'app-root',
|
|
templateUrl: 'app.component.html',
|
|
styleUrls: ['app.component.scss'],
|
|
})
|
|
export class AppComponent implements OnInit {
|
|
todos: any[] = [];
|
|
|
|
constructor(private supabaseService: SupabaseService) {}
|
|
|
|
async ngOnInit() {
|
|
await this.loadTodos();
|
|
}
|
|
|
|
async loadTodos() {
|
|
const { data, error } = await this.supabaseService.getTodos();
|
|
if (error) {
|
|
console.error('Error fetching todos:', error);
|
|
} else {
|
|
this.todos = data;
|
|
}
|
|
}
|
|
}
|
|
`,
|
|
},
|
|
{
|
|
name: 'src/app/app.component.html',
|
|
language: 'html',
|
|
code: `
|
|
<ion-header>
|
|
<ion-toolbar>
|
|
<ion-title>Todo List</ion-title>
|
|
</ion-toolbar>
|
|
</ion-header>
|
|
|
|
<ion-content>
|
|
<ion-list>
|
|
<ion-item *ngFor="let todo of todos">
|
|
<ion-label>{{ todo.name }}</ion-label>
|
|
</ion-item>
|
|
</ion-list>
|
|
</ion-content>
|
|
`,
|
|
},
|
|
{
|
|
name: 'src/app/app.module.ts',
|
|
language: 'ts',
|
|
code: `
|
|
import { NgModule } from '@angular/core';
|
|
import { FormsModule } from '@angular/forms';
|
|
import { BrowserModule } from '@angular/platform-browser';
|
|
import { RouterModule } from '@angular/router';
|
|
|
|
import { IonicModule } from '@ionic/angular';
|
|
|
|
import { AppComponent } from './app.component';
|
|
import { SupabaseService } from './supabase.service';
|
|
|
|
@NgModule({
|
|
imports: [
|
|
BrowserModule,
|
|
FormsModule,
|
|
RouterModule.forRoot([]),
|
|
IonicModule.forRoot({ mode: 'ios' }),
|
|
],
|
|
declarations: [AppComponent],
|
|
providers: [SupabaseService],
|
|
bootstrap: [AppComponent],
|
|
})
|
|
export class AppModule {}
|
|
`,
|
|
},
|
|
]
|
|
|
|
return <MultipleCodeBlock files={files} />
|
|
}
|
|
|
|
export default ContentFile
|