Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2d64295
refactor(developer-apps): Changed structure of developer apps compone…
rrromchIk Mar 14, 2025
dc3e93e
Merge branch 'refs/heads/main' into feat/96-developer-apps-ui
rrromchIk Mar 17, 2025
9016dd8
feat(developer-apps): Finished developer Apps List page, started work…
rrromchIk Mar 18, 2025
9a8beff
style(primeng-override): Added styles for button, card and iconfield
rrromchIk Mar 19, 2025
8e49dd2
feat(developer-apps): Added create developer app form component
rrromchIk Mar 19, 2025
882d8d8
style(developer-apps): Adapted developer apps component for mobile
rrromchIk Mar 19, 2025
88d995c
feat(developer-apps): Added create app dialog
rrromchIk Mar 19, 2025
bab0d9b
refactor(developer-apps): Refactored developer apps component
rrromchIk Mar 19, 2025
76a0005
feat(developer-apps): Added edit app form, adapted for mobile
rrromchIk Mar 19, 2025
153916d
Merge branch 'main' into feat/96-developer-apps-ui
rrromchIk Mar 19, 2025
5268209
Merge branch 'main' into feat/96-developer-apps-ui
rrromchIk Mar 20, 2025
9894243
Merge branch 'main' into feat/96-developer-apps-ui
rrromchIk Mar 20, 2025
fe5e31f
Merge branch 'main' into feat/96-developer-apps-ui
rrromchIk Mar 21, 2025
140e1d6
feat(developer-apps): Confirmation dialog before deleting app and res…
rrromchIk Mar 21, 2025
a5fd4c9
feat(developer-apps): Renamed developer create form submit button's l…
rrromchIk Mar 21, 2025
9dce87d
feat(developer-apps): Adjusted create developer app dialog width for …
rrromchIk Mar 21, 2025
1c9c7aa
style(developer-apps): Fixed styles so apps list takes full height
rrromchIk Mar 21, 2025
5e32efb
feat(developer-apps): Added notification when client secret or id is …
rrromchIk Mar 21, 2025
0726959
Merge branch 'main' into feat/96-developer-apps-ui
rrromchIk Mar 21, 2025
6247699
fix(styles): Fix after merging main
rrromchIk Mar 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/app/core/components/breadcrumb/breadcrumb.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, computed, inject, signal } from '@angular/core';
import { Router } from '@angular/router';
import { Component, computed, DestroyRef, inject, signal } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';

@Component({
selector: 'osf-breadcrumb',
Expand All @@ -9,8 +10,19 @@ import { Router } from '@angular/router';
})
export class BreadcrumbComponent {
#router = inject(Router);
#destroyRef = inject(DestroyRef);
protected readonly url = signal(this.#router.url);
protected readonly parsedUrl = computed(() => {
return this.url().split('/').filter(Boolean);
});

constructor() {
this.#router.events
.pipe(takeUntilDestroyed(this.#destroyRef))
.subscribe((event) => {
if (event instanceof NavigationEnd) {
this.url.set(this.#router.url);
}
});
}
}
16 changes: 16 additions & 0 deletions src/app/core/helpers/link-validator.helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';

export function linkValidator(): ValidatorFn {
return (control: AbstractControl): ValidationErrors | null => {
const value = control.value;
if (!value) {
return null;
}

const urlPattern = /^(https?):\/\/.+/i;

const isValid = urlPattern.test(value);

return isValid ? null : { link: true };
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<form
[formGroup]="createAppForm"
(ngSubmit)="submitForm()"
class="flex flex-column gap-3"
>
<div class="flex flex-column">
<label for="app-name">App Name</label>
<input
pInputText
id="app-name"
type="text"
autocomplete="off"
[formControlName]="DeveloperAppFormFormControls.AppName"
/>
</div>

<div class="flex flex-column">
<label for="proj-homepage-url">Project homepage URL</label>
<input
pInputText
id="proj-homepage-url"
type="url"
autocomplete="off"
[formControlName]="DeveloperAppFormFormControls.ProjectHomePageUrl"
/>
</div>

<div class="flex flex-column">
<label for="app-descr">App description (optional)</label>
<input
pInputText
id="app-descr"
type="text"
autocomplete="off"
[formControlName]="DeveloperAppFormFormControls.AppDescription"
/>
</div>

<div class="flex flex-column">
<label for="auth-callback-url">Authorization callback URL</label>
<input
pInputText
type="url"
autocomplete="off"
id="auth-callback-url"
[formControlName]="DeveloperAppFormFormControls.AuthorizationCallbackUrl"
/>
</div>

<div class="flex justify-content-end gap-2">
<p-button label="Cancel" severity="info" (click)="dialogRef.close()" />
<p-button
label="Create Developer App"
type="submit"
[disabled]="!createAppForm.valid"
/>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { CreateDeveloperAppComponent } from './create-developer-app.component';

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

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

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

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { DynamicDialogRef } from 'primeng/dynamicdialog';
import { Button } from 'primeng/button';
import { InputText } from 'primeng/inputtext';
import {
FormControl,
FormGroup,
ReactiveFormsModule,
Validators,
} from '@angular/forms';
import {
DeveloperAppForm,
DeveloperAppFormFormControls,
} from '@osf/features/settings/developer-apps/developer-app.entities';
import { linkValidator } from '@core/helpers/link-validator.helper';

@Component({
selector: 'osf-create-developer-app',
imports: [Button, InputText, ReactiveFormsModule],
templateUrl: './create-developer-app.component.html',
styleUrl: './create-developer-app.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CreateDeveloperAppComponent {
readonly dialogRef = inject(DynamicDialogRef);
protected readonly DeveloperAppFormFormControls =
DeveloperAppFormFormControls;

readonly createAppForm: DeveloperAppForm = new FormGroup({
[DeveloperAppFormFormControls.AppName]: new FormControl('', {
nonNullable: true,
validators: [Validators.required],
}),
[DeveloperAppFormFormControls.ProjectHomePageUrl]: new FormControl('', {
nonNullable: true,
validators: [Validators.required, linkValidator()],
}),
[DeveloperAppFormFormControls.AppDescription]: new FormControl('', {
nonNullable: false,
}),
[DeveloperAppFormFormControls.AuthorizationCallbackUrl]: new FormControl(
'',
{
nonNullable: true,
validators: [Validators.required, linkValidator()],
},
),
});

submitForm(): void {
if (!this.createAppForm.valid) {
this.createAppForm.markAllAsTouched();
this.createAppForm
.get([DeveloperAppFormFormControls.AppName])
?.markAsDirty();
this.createAppForm
.get(DeveloperAppFormFormControls.ProjectHomePageUrl)
?.markAsDirty();
this.createAppForm
.get(DeveloperAppFormFormControls.AppDescription)
?.markAsDirty();
this.createAppForm
.get(DeveloperAppFormFormControls.AuthorizationCallbackUrl)
?.markAsDirty();
return;
}

//TODO integrate API
this.dialogRef.close();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<section class="content-container" [class.mobile]="isXSmall()">
<nav class="navigation-bar-container">
<a routerLink="/settings/developer-apps">
<!-- TODO - Add icon -->
Back to list of developer apps
</a>
</nav>

<section class="tittle-container" [class.mobile]="isXSmall()">
<h1>{{ developerApp().appName + developerAppId() }}</h1>
<p-button
label="Delete"
[class.btn-full-width]="isXSmall()"
severity="danger"
(click)="deleteApp()"
/>
</section>

<section class="cards-container" [class.mobile]="isXSmall()">
<p-card>
<section class="card-body">
<h2>Client ID</h2>

<p>
The client ID is the developer app's unique identifier and is safe to
share publicly.
</p>

<div class="inline-block relative">
<span
class="copy-notification"
[class.visible]="clientIdCopiedNotificationVisible()"
>
Copied!
</span>
<p-iconfield iconPosition="right">
<input type="text" pInputText readonly [value]="clientId()" />
<p-inputicon
[cdkCopyToClipboard]="clientId()"
(cdkCopyToClipboardCopied)="clientIdCopiedToClipboard()"
>
<i class="osf-icon-copy"></i>
</p-inputicon>
</p-iconfield>
</div>
</section>
</p-card>

<p-card>
<section class="card-body">
<h2>Client Secret</h2>

<p>
The client secret is available only to you. Keep it private and do not
share it.
</p>

<section class="client-secret-container" [class.mobile]="isXSmall()">
<div class="relative">
<span
class="copy-notification"
[class.visible]="clientSecretCopiedNotificationVisible()"
>
Copied!
</span>
<p-iconfield iconPosition="right">
<input
pInputText
[value]="
isClientSecretVisible()
? clientSecret()
: hiddenClientSecret()
"
readonly
/>
<p-inputicon
[cdkCopyToClipboard]="clientSecret()"
(cdkCopyToClipboardCopied)="clientSecretCopiedToClipboard()"
>
<i class="osf-icon-copy"></i>
</p-inputicon>
</p-iconfield>
</div>

<p-button
[label]="
isClientSecretVisible()
? 'Hide client secret'
: 'Show client secret'
"
severity="secondary"
(click)="isClientSecretVisible.set(!isClientSecretVisible())"
/>
</section>

<section class="card-actions">
<p-button
label="Reset Secret"
[class.btn-half-width]="isXSmall()"
(click)="resetClientSecret()"
/>
</section>
</section>
</p-card>

<p-card>
<section class="card-body">
<h2>Edit app</h2>

<form
[formGroup]="editAppForm"
class="flex flex-column gap-3"
(ngSubmit)="submitForm()"
>
<div class="flex flex-column">
<label for="app-name">App Name</label>
<input
id="app-name"
type="text"
autocomplete="off"
pInputText
[formControlName]="DeveloperAppFormFormControls.AppName"
/>
</div>

<div class="flex flex-column">
<label for="proj-homepage-url">Project homepage URL</label>
<input
id="proj-homepage-url"
type="url"
autocomplete="off"
pInputText
[formControlName]="
DeveloperAppFormFormControls.ProjectHomePageUrl
"
/>
</div>

<div class="flex flex-column">
<label for="app-descr">App description (optional)</label>
<input
id="app-descr"
type="text"
autocomplete="off"
pInputText
[formControlName]="DeveloperAppFormFormControls.AppDescription"
/>
</div>

<div class="flex flex-column">
<label for="auth-callback-url">Authorization callback URL</label>
<input
id="auth-callback-url"
type="url"
autocomplete="off"
pInputText
[formControlName]="
DeveloperAppFormFormControls.AuthorizationCallbackUrl
"
/>
</div>

<section class="card-actions">
<p-button
label="Save"
type="submit"
[class.btn-half-width]="isXSmall()"
[disabled]="!editAppForm.dirty || !editAppForm.valid"
/>
</section>
</form>
</section>
</p-card>
</section>
</section>
Loading