Skip to content

Commit 3dd9aa5

Browse files
committed
Merge branch 'main' into test/387-settings-page-tokens
2 parents c938a37 + cf5041d commit 3dd9aa5

50 files changed

Lines changed: 680 additions & 335 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ module.exports = tseslint.config(
8282
],
8383
'simple-import-sort/exports': 'error',
8484
'unused-imports/no-unused-imports': 'error',
85+
'no-console': 'error',
8586
},
8687
},
8788
{

src/app/features/project/addons/addons.component.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { AddonsComponent } from './addons.component';
1010

1111
import { OSFTestingModule } from '@testing/osf.testing.module';
1212

13-
describe('AddonsComponent', () => {
13+
describe('Component: Addons', () => {
1414
let component: AddonsComponent;
1515
let fixture: ComponentFixture<AddonsComponent>;
1616

@@ -33,10 +33,6 @@ describe('AddonsComponent', () => {
3333
fixture.detectChanges();
3434
});
3535

36-
it('should create', () => {
37-
expect(component).toBeTruthy();
38-
});
39-
4036
it('should render the connected description paragraph', () => {
4137
component['selectedTab'].set(component['AddonTabValue'].ALL_ADDONS);
4238
fixture.detectChanges();

src/app/features/project/addons/components/configure-addon/configure-addon.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ <h2 class="align-self-center">
6565
</div>
6666
<osf-folder-selector
6767
[isGoogleFilePicker]="isGoogleDrive()"
68+
[accountId]="addon()?.baseAccountId || ''"
6869
[accountName]="addon()?.displayName || ''"
6970
[operationInvocationResult]="operationInvocation()?.operationResult || []"
7071
[accountNameControl]="accountNameControl"

src/app/features/project/addons/components/connect-configured-addon/connect-configured-addon.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ <h2 class="pt-2">{{ 'settings.addons.connectAddon.chooseExistingAccount' | trans
114114
<section class="flex flex-column gap-5">
115115
<h2 class="pt-2">{{ 'settings.addons.connectAddon.configure' | translate }} {{ addon()?.displayName }}</h2>
116116
<osf-folder-selector
117-
[isGoogleFilePicker]="false"
117+
[isGoogleFilePicker]="isGoogleDrive()"
118+
[accountId]="chosenAccountId()"
118119
[accountName]="chosenAccountName()"
119120
[operationInvocationResult]="operationInvocation()?.operationResult || []"
120121
[accountNameControl]="accountNameControl"

src/app/features/project/addons/components/connect-configured-addon/connect-configured-addon.component.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ export class ConnectConfiguredAddonComponent {
8181
protected chosenAccountId = signal('');
8282
protected chosenAccountName = signal('');
8383
protected selectedRootFolderId = signal('');
84+
private selectedAccount = signal<AuthorizedAccountModel>({} as AuthorizedAccountModel);
85+
public readonly isGoogleDrive = computed(() => {
86+
return this.selectedAccount()?.externalServiceName === 'googledrive';
87+
});
8488

8589
protected addonsUserReference = select(AddonsSelectors.getAddonsUserReference);
8690
protected createdAuthorizedAddon = select(AddonsSelectors.getCreatedOrUpdatedAuthorizedAddon);
@@ -137,14 +141,15 @@ export class ConnectConfiguredAddonComponent {
137141

138142
protected handleCreateConfiguredAddon() {
139143
const addon = this.addon();
140-
const selectedAccount = this.currentAuthorizedAddonAccounts().find(
141-
(account) => account.id === this.chosenAccountId()
144+
this.selectedAccount.set(
145+
this.currentAuthorizedAddonAccounts().find((account) => account.id === this.chosenAccountId()) ||
146+
({} as AuthorizedAccountModel)
142147
);
143-
if (!addon || !selectedAccount) return;
148+
if (!addon || !this.selectedAccount()) return;
144149

145150
const payload = this.addonFormService.generateConfiguredAddonCreatePayload(
146151
addon,
147-
selectedAccount,
152+
this.selectedAccount(),
148153
this.userReferenceId(),
149154
this.resourceUri(),
150155
this.accountNameControl.value || '',
@@ -181,19 +186,20 @@ export class ConnectConfiguredAddonComponent {
181186
}
182187

183188
protected handleConfirmAccountConnection(): void {
184-
const selectedAccount = this.currentAuthorizedAddonAccounts().find(
185-
(account) => account.id === this.chosenAccountId()
189+
this.selectedAccount.set(
190+
this.currentAuthorizedAddonAccounts().find((account) => account.id === this.chosenAccountId()) ||
191+
({} as AuthorizedAccountModel)
186192
);
187193

188-
if (!selectedAccount) return;
194+
if (!this.selectedAccount()) return;
189195

190-
const dialogRef = this.addonDialogService.openConfirmAccountConnectionDialog(selectedAccount);
196+
const dialogRef = this.addonDialogService.openConfirmAccountConnectionDialog(this.selectedAccount());
191197

192198
dialogRef.subscribe((result) => {
193199
if (result?.success) {
194200
this.stepper()?.value.set(ProjectAddonsStepperValue.CONFIGURE_ROOT_FOLDER);
195-
this.chosenAccountName.set(selectedAccount.displayName);
196-
this.accountNameControl.setValue(selectedAccount.displayName);
201+
this.chosenAccountName.set(this.selectedAccount().displayName);
202+
this.accountNameControl.setValue(this.selectedAccount().displayName);
197203
}
198204
});
199205
}

src/app/features/project/contributors/components/create-view-link-dialog/create-view-link-dialog.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
<p-checkbox
3939
variant="filled"
4040
binary="true"
41-
[class.pl-4]="!isCurrentProject(item)"
41+
[class.pl-4]="!item.isCurrentResource"
4242
[ngModel]="selectedComponents()[item.id]"
4343
(ngModelChange)="onCheckboxToggle(item.id, $event)"
44-
[disabled]="isCurrentProject(item)"
44+
[disabled]="item.isCurrentResource"
4545
>
4646
</p-checkbox>
4747
<p>
4848
{{ item.title }}
49-
@if (isCurrentProject(item)) {
49+
@if (item.isCurrentResource) {
5050
<span>
5151
{{ 'myProjects.settings.viewOnlyLinkCurrentProject' | translate }}
5252
</span>
@@ -86,7 +86,7 @@
8686
class="w-full"
8787
styleClass="w-full"
8888
(onClick)="addLink()"
89-
[disabled]="!isFormValid"
89+
[disabled]="linkName.invalid"
9090
[label]="'project.contributors.addDialog.next' | translate"
9191
></p-button>
9292
</div>

src/app/features/project/contributors/components/create-view-link-dialog/create-view-link-dialog.component.ts

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';
99
import { ChangeDetectionStrategy, Component, effect, inject, OnInit, signal } from '@angular/core';
1010
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
1111

12-
import { GetComponents, ProjectOverviewSelectors } from '@osf/features/project/overview/store';
1312
import { LoadingSpinnerComponent, TextInputComponent } from '@osf/shared/components';
1413
import { InputLimits } from '@osf/shared/constants';
1514
import { CustomValidators } from '@osf/shared/helpers';
16-
import { ViewOnlyLinkComponent } from '@shared/models';
15+
import { CurrentResourceSelectors, GetResourceChildren } from '@osf/shared/stores';
16+
import { ViewOnlyLinkChildren } from '@shared/models';
17+
18+
import { ResourceInfoModel } from '../../models';
1719

1820
@Component({
1921
selector: 'osf-create-view-link-dialog',
@@ -31,44 +33,42 @@ import { ViewOnlyLinkComponent } from '@shared/models';
3133
changeDetection: ChangeDetectionStrategy.OnPush,
3234
})
3335
export class CreateViewLinkDialogComponent implements OnInit {
34-
linkName = new FormControl('', { nonNullable: true, validators: [CustomValidators.requiredTrimmed()] });
35-
3636
readonly dialogRef = inject(DynamicDialogRef);
37-
protected readonly config = inject(DynamicDialogConfig);
38-
inputLimits = InputLimits;
37+
readonly config = inject(DynamicDialogConfig);
38+
readonly inputLimits = InputLimits;
39+
40+
linkName = new FormControl('', { nonNullable: true, validators: [CustomValidators.requiredTrimmed()] });
3941

4042
anonymous = signal(true);
41-
protected selectedComponents = signal<Record<string, boolean>>({});
42-
protected components = select(ProjectOverviewSelectors.getComponents);
43-
protected isLoading = select(ProjectOverviewSelectors.getComponentsLoading);
43+
selectedComponents = signal<Record<string, boolean>>({});
44+
components = select(CurrentResourceSelectors.getResourceChildren);
45+
isLoading = select(CurrentResourceSelectors.isResourceChildrenLoading);
4446

45-
protected actions = createDispatchMap({
46-
getComponents: GetComponents,
47-
});
47+
actions = createDispatchMap({ getComponents: GetResourceChildren });
4848

49-
get currentProjectId(): string {
50-
return this.config.data?.['projectId'] || '';
49+
get currentResource() {
50+
return this.config.data as ResourceInfoModel;
5151
}
5252

53-
get allComponents(): ViewOnlyLinkComponent[] {
54-
const currentProjectData = this.config.data?.['currentProject'];
53+
get allComponents(): ViewOnlyLinkChildren[] {
54+
const currentResourceData = this.currentResource;
5555
const components = this.components();
5656

57-
const result: ViewOnlyLinkComponent[] = [];
57+
const result: ViewOnlyLinkChildren[] = [];
5858

59-
if (currentProjectData) {
59+
if (currentResourceData) {
6060
result.push({
61-
id: currentProjectData.id,
62-
title: currentProjectData.title,
63-
isCurrentProject: true,
61+
id: currentResourceData.id,
62+
title: currentResourceData.title,
63+
isCurrentResource: true,
6464
});
6565
}
6666

6767
components.forEach((comp) => {
6868
result.push({
6969
id: comp.id,
7070
title: comp.title,
71-
isCurrentProject: false,
71+
isCurrentResource: false,
7272
});
7373
});
7474

@@ -85,10 +85,10 @@ export class CreateViewLinkDialogComponent implements OnInit {
8585
}
8686

8787
ngOnInit(): void {
88-
const projectId = this.currentProjectId;
88+
const projectId = this.currentResource.id;
8989

9090
if (projectId) {
91-
this.actions.getComponents(projectId);
91+
this.actions.getComponents(projectId, this.currentResource.type);
9292
} else {
9393
this.initializeSelection();
9494
}
@@ -98,28 +98,20 @@ export class CreateViewLinkDialogComponent implements OnInit {
9898
const initialState: Record<string, boolean> = {};
9999

100100
this.allComponents.forEach((component) => {
101-
initialState[component.id] = component.isCurrentProject;
101+
initialState[component.id] = component.isCurrentResource;
102102
});
103103

104104
this.selectedComponents.set(initialState);
105105
}
106106

107-
isCurrentProject(item: ViewOnlyLinkComponent): boolean {
108-
return item.isCurrentProject;
109-
}
110-
111-
get isFormValid(): boolean {
112-
return this.linkName.valid && !!this.linkName.value.trim().length;
113-
}
114-
115107
addLink(): void {
116-
if (!this.isFormValid) return;
108+
if (this.linkName.invalid) return;
117109

118110
const selectedIds = Object.entries(this.selectedComponents())
119111
.filter(([, checked]) => checked)
120112
.map(([id]) => id);
121113

122-
const rootProjectId = this.currentProjectId;
114+
const rootProjectId = this.currentResource.id;
123115
const rootProject = selectedIds.includes(rootProjectId) ? [{ id: rootProjectId, type: 'nodes' }] : [];
124116

125117
const relationshipComponents = selectedIds
@@ -160,7 +152,7 @@ export class CreateViewLinkDialogComponent implements OnInit {
160152
deselectAllComponents(): void {
161153
const allIds: Record<string, boolean> = {};
162154
this.allComponents.forEach((component) => {
163-
allIds[component.id] = component.isCurrentProject;
155+
allIds[component.id] = component.isCurrentResource;
164156
});
165157
this.selectedComponents.set(allIds);
166158
}

0 commit comments

Comments
 (0)