Skip to content

Commit

Permalink
chore: bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
rustygreen committed Mar 26, 2024
1 parent beb5fd8 commit 75c4a41
Show file tree
Hide file tree
Showing 39 changed files with 520 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.0-rc.13 (2024-03-26)

This was a version bump only, there were no code changes.

## 1.0.0-rc.12 (2024-03-14)

This was a version bump only, there were no code changes.
4 changes: 4 additions & 0 deletions apps/demo/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import { RegisterOrSignInComponent as BootstrapRegisterOrSignInComponent } from
export const appRoutes: Routes = [
{ path: '', component: MainComponent },
{ path: 'sign-in', redirectTo: 'primeng/sign-in' },
{ path: 'register', redirectTo: 'primeng/register' },
{ path: 'set-password', redirectTo: 'primeng/set-password' },
{ path: 'reset-password', redirectTo: 'primeng/reset-password' },
{ path: 'auth', redirectTo: 'primeng/auth' },
{
path: 'private-content',
component: PrivateContentComponent,
Expand Down
14 changes: 7 additions & 7 deletions apps/demo/src/app/main/main.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ <h3>
@if(supabase.isSignedIn){
<h3>
Display Name:
<p-chip label="{{ supabase.displayName | async }}"></p-chip>
<p-chip label="{{ supabase.userDisplayName | async }}"></p-chip>
</h3>
} @if(supabase.isSignedIn){
<div>
Expand All @@ -86,14 +86,14 @@ <h1>
</h1>
<div class="mb-3">
<p-button
label="Register"
label="Sign Up"
icon="pi pi-user-plus"
severity="success"
routerLink="/primeng/register"
></p-button>

<p-button
label="Sign In"
label="Log In"
class="ml-3"
routerLink="/primeng/sign-in"
icon="pi pi-sign-in"
Expand Down Expand Up @@ -131,15 +131,15 @@ <h1>
<h3 class="text-400">Coming soon...</h3>
<div class="mb-3">
<p-button
label="Register"
label="Sign Up"
icon="pi pi-user-plus"
severity="success"
routerLink="/material/register"
[disabled]="true"
></p-button>

<p-button
label="Sign In"
label="Log In"
class="ml-3"
routerLink="/material/sign-in"
icon="pi pi-sign-in"
Expand Down Expand Up @@ -180,15 +180,15 @@ <h1>
<h3 class="text-400">Coming soon...</h3>
<div class="mb-3">
<p-button
label="Register"
label="Sign Up"
icon="pi pi-user-plus"
severity="success"
routerLink="/bootstrap/register"
[disabled]="true"
></p-button>

<p-button
label="Sign In"
label="Log In"
class="ml-3"
routerLink="/bootstrap/sign-in"
icon="pi pi-sign-in"
Expand Down
4 changes: 4 additions & 0 deletions apps/demo/src/app/primeng/register/register.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
justify-content: center;
align-items: center;
}

supabase-register {
max-width: 650px;
}
10 changes: 5 additions & 5 deletions apps/demo/src/app/toolbar/toolbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ <h1 class="m-0 mr-2">ng-supabase</h1>
<div class="p-toolbar-group-end">
<p-button
icon="pi pi-github"
class="mr-2"
severity="secondary"
[rounded]="true"
[text]="true"
severity="secondary"
[link]="true"
(click)="openGitHub()"
>
</p-button>

<!-- <a href="https://angular.dev/" target="_blank" rel="noopener noreferrer">
<i class="pi pi-github"></i>
</a> -->
<supabase-active-user-avatar-button></supabase-active-user-avatar-button>

<p-button
icon="pi pi-cog"
[rounded]="true"
class="ml-2"
severity="secondary"
[rounded]="true"
(click)="showSettings.emit()"
></p-button>
</div>
Expand Down
5 changes: 4 additions & 1 deletion apps/demo/src/app/toolbar/toolbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ import {
import { ButtonModule } from 'primeng/button';
import { ToolbarModule } from 'primeng/toolbar';

// ng-supabase.
import { ActiveUserAvatarButtonComponent } from '@ng-supabase/primeng';

@Component({
selector: 'ng-supabase-toolbar',
standalone: true,
imports: [ToolbarModule, ButtonModule],
imports: [ToolbarModule, ButtonModule, ActiveUserAvatarButtonComponent],
templateUrl: './toolbar.component.html',
styleUrl: './toolbar.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
2 changes: 1 addition & 1 deletion libs/bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ng-supabase/bootstrap",
"version": "1.0.0-rc.12",
"version": "1.0.0-rc.13",
"author": "Rusty Green <me@rusty.green>",
"contributors": [
"Rusty Green <me@rusty.green>"
Expand Down
2 changes: 1 addition & 1 deletion libs/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ng-supabase/core",
"version": "1.0.0-rc.12",
"version": "1.0.0-rc.13",
"author": "Rusty Green <me@rusty.green>",
"contributors": [
"Rusty Green <me@rusty.green>"
Expand Down
7 changes: 7 additions & 0 deletions libs/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@ export * from './lib/storage/persistent-storage.service';

export * from './lib/register/register.component';

export * from './lib/user-avatar/user-avatar.component';

export * from './lib/user-avatar-button/user-avatar-button.component';

export * from './lib/active-user-avatar-button/active-user-avatar-button.component';

export * from './lib/register-or-sign-in/register-or-sign-in.component';

export * from './lib/wait-message';
export * from './lib/initials.pipe';
export * from './lib/route.service';
export * from './lib/supabase-config';
export * from './lib/supabase.service';
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActiveUserAvatarButtonComponent } from './active-user-avatar-button.component';

describe('ActiveUserAvatarButtonComponent', () => {
let component: ActiveUserAvatarButtonComponent;
let fixture: ComponentFixture<ActiveUserAvatarButtonComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ActiveUserAvatarButtonComponent],
}).compileComponents();

fixture = TestBed.createComponent(ActiveUserAvatarButtonComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Angular.
import { Router } from '@angular/router';
import { CommonModule } from '@angular/common';
import {
OnInit,
inject,
signal,
Component,
ChangeDetectionStrategy,
} from '@angular/core';

// Local.
import { SupabaseConfig } from '../supabase-config';
import { SupabaseService } from '../supabase.service';

@Component({
selector: 'supabase-active-user-avatar-button',
standalone: true,
imports: [CommonModule],
templateUrl: './active-user-avatar-button.component.html',
styleUrl: './active-user-avatar-button.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ActiveUserAvatarButtonComponent implements OnInit {
loading = signal<boolean>(true);

protected router = inject(Router);
protected config = inject(SupabaseConfig);
protected supabase = inject(SupabaseService);

async ngOnInit(): Promise<void> {
await this.supabase.clientReady;
this.loading.set(false);
}

signOut(): void {
this.supabase.client.auth.signOut();
if (this.config.routes.postSignOut) {
this.router.navigate([this.config.routes.postSignOut]);
}
}
}
19 changes: 19 additions & 0 deletions libs/core/src/lib/initials.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'initials',
standalone: true,
})
export class InitialsPipe implements PipeTransform {
transform(fullName: string | null | undefined, numChars: number = 2): string {
if (!fullName) {
return '';
}

return fullName
.split(' ')
.slice(0, numChars)
.map((n) => n[0].toUpperCase())
.join('');
}
}
22 changes: 22 additions & 0 deletions libs/core/src/lib/supabase-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const DEFAULT_ROUTES: ComponentRoutes = {
registerOrSignIn: '/auth',
setPassword: '/set-password',
resetPassword: '/reset-password',
postSignOut: '/sign-in',
};

export interface SupabaseConfigProperties {
Expand All @@ -31,6 +32,7 @@ export interface SupabaseConfigProperties {
register?: RegisterProperties;
setPassword?: SetPasswordProperties;
routes?: Partial<ComponentRoutes>;
profile?: ProfileProperties;
}

interface ComponentRoutes {
Expand All @@ -41,6 +43,7 @@ interface ComponentRoutes {
setPassword: string;
resetPassword: string;
userProfile?: string;
postSignOut?: string;
}

interface UserRegistrationMetadata {
Expand All @@ -56,6 +59,12 @@ interface RegisterProperties {
metadata?: UserRegistrationMetadata[];
}

interface ProfileProperties {
table?: string;
firstNameField?: string;
lastNameField?: string;
}

type SocialSignInFn = (social: SocialSignIn) => boolean | void;

interface SignInConfigProperties {
Expand Down Expand Up @@ -91,6 +100,17 @@ class SetPasswordConfig implements SetPasswordProperties {
}
}

class ProfileConfig implements ProfileProperties {
table = '';
userIdField = 'user_id';
firstNameField = 'first_name';
lastNameField = 'last_name';

constructor(init?: Partial<ProfileProperties>) {
Object.assign(this, init);
}
}

class RegisterConfig implements RegisterConfig {
title = '';
metadata: UserRegistrationMetadata[] = [];
Expand Down Expand Up @@ -139,13 +159,15 @@ export class SupabaseConfig {
register: RegisterConfig;
routes: ComponentRoutes = DEFAULT_ROUTES;
redirectParamName: string | null | undefined = 'redirect';
profile: ProfileConfig;

constructor(init: SupabaseConfigProperties) {
Object.assign(this.routes, init.routes);
this.logging = init.logging;
this.setPassword = new SetPasswordConfig(init.setPassword);
this.signIn = new SignInConfig(init.signIn);
this.register = new RegisterConfig(init.register);
this.profile = new ProfileConfig(init.profile);
this.api = new BehaviorSubject<ApiInfo>({
url: init.apiUrl,
key: init.apiKey,
Expand Down
Loading

0 comments on commit 75c4a41

Please sign in to comment.