Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<form [formGroup]="addonForm()" (ngSubmit)="handleSubmit()" class="flex flex-column gap-5">
<p-card>
@if (hasConfigurableApiRoot()) {
<h2 class="mb-2">
{{ 'settings.addons.form.fields.hostUrl' | translate }}
</h2>
<p class="mb-2">
{{ 'settings.addons.form.fields.hostUrlDescription' | translate }}
</p>
<input class="mb-4" pInputText [formControlName]="formControls.HostUrl" />
}

@if (isAccessSecretKeysFormat()) {
<h2 class="mb-2">
{{ 'settings.addons.form.fields.accessKey' | translate }}
Expand All @@ -23,13 +33,6 @@ <h2 class="mb-2">
}

@if (isDataverseApiTokenFormat()) {
<h2 class="mb-2">
{{ 'settings.addons.form.fields.hostUrl' | translate }}
</h2>
<p class="mb-2">
{{ 'settings.addons.form.fields.hostUrlDescription' | translate }}
</p>
<input class="mb-4" pInputText [formControlName]="formControls.HostUrl" />
<h2 class="mb-2">
{{ 'settings.addons.form.fields.apiToken' | translate }}
</h2>
Expand All @@ -43,13 +46,6 @@ <h2 class="mb-2">
}

@if (isUsernamePasswordFormat()) {
<h2 class="mb-2">
{{ 'settings.addons.form.fields.hostUrl' | translate }}
</h2>
<p class="mb-2">
{{ 'settings.addons.form.fields.hostUrlDescription' | translate }}
</p>
<input class="mb-4" pInputText [formControlName]="formControls.HostUrl" />
<h2 class="mb-2">
{{ 'settings.addons.form.fields.username' | translate }}
</h2>
Expand All @@ -71,13 +67,6 @@ <h2 class="mb-2">
}

@if (isRepoTokenFormat()) {
<h2 class="mb-2">
{{ 'settings.addons.form.fields.hostUrl' | translate }}
</h2>
<p class="mb-2">
{{ 'settings.addons.form.fields.hostUrlDescription' | translate }}
</p>
<input class="mb-4" pInputText [formControlName]="formControls.HostUrl" />
<h2 class="mb-2">
{{ 'settings.addons.form.fields.personalAccessToken' | translate }}
</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export class AddonSetupAccountFormComponent {
return format === CredentialsFormat.OAUTH2 || format === CredentialsFormat.OAUTH;
});

readonly hasConfigurableApiRoot = computed(() => !!this.addon().configurableApiRoot);

handleSubmit(): void {
if (!this.isFormValid) return;

Expand Down
1 change: 1 addition & 0 deletions src/app/shared/mappers/addon.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class AddonMapper {
credentialsFormat: response.attributes.credentials_format,
providerName: response.attributes.display_name,
iconUrl: response.attributes.icon_url,
configurableApiRoot: response.attributes.configurable_api_root,
};
}

Expand Down
1 change: 1 addition & 0 deletions src/app/shared/models/addons/addon-json-api.models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface AddonGetResponseJsonApi {
credentials_format: string;
wb_key: string;
icon_url: string;
configurable_api_root: boolean;
[key: string]: unknown;
};
relationships: {
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/models/addons/addon.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface AddonModel {
supportedFeatures?: string[];
providerName?: string;
credentialsFormat?: string;
configurableApiRoot?: boolean;
authUrl?: string | null;
authorizedCapabilities?: string[];
authorizedOperationNames?: string[];
Expand Down
6 changes: 3 additions & 3 deletions src/app/shared/services/addons/addon-form.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ export class AddonFormService {
const formControls: Partial<AddonForm> = {
[AddonFormControls.AccountName]: this.formBuilder.control<string>(addon.displayName || '', Validators.required),
};
if (addon.configurableApiRoot) {
formControls[AddonFormControls.HostUrl] = this.formBuilder.control<string>('', Validators.required);
}

switch (addon.credentialsFormat) {
case CredentialsFormat.ACCESS_SECRET_KEYS:
formControls[AddonFormControls.AccessKey] = this.formBuilder.control<string>('', Validators.required);
formControls[AddonFormControls.SecretKey] = this.formBuilder.control<string>('', Validators.required);
break;
case CredentialsFormat.DATAVERSE_API_TOKEN:
formControls[AddonFormControls.HostUrl] = this.formBuilder.control<string>('', Validators.required);
formControls[AddonFormControls.ApiToken] = this.formBuilder.control<string>('', Validators.required);
break;
case CredentialsFormat.USERNAME_PASSWORD:
formControls[AddonFormControls.HostUrl] = this.formBuilder.control<string>('', Validators.required);
formControls[AddonFormControls.Username] = this.formBuilder.control<string>('', Validators.required);
formControls[AddonFormControls.Password] = this.formBuilder.control<string>('', Validators.required);
break;
case CredentialsFormat.REPO_TOKEN:
formControls[AddonFormControls.HostUrl] = this.formBuilder.control<string>('', Validators.required);
formControls[AddonFormControls.PersonalAccessToken] = this.formBuilder.control<string>('', Validators.required);
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/services/addons/addons.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('Service: Addons', () => {
supportedFeatures: ['DOWNLOAD_AS_ZIP', 'FORKING', 'LOGS', 'PERMISSIONS', 'REGISTERING'],
type: 'external-storage-services',
wbKey: 'figshare',
configurableApiRoot: false,
})
);

Expand Down
2 changes: 2 additions & 0 deletions src/app/shared/stores/addons/addons.state.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('State: Addons', () => {
supportedFeatures: ['DOWNLOAD_AS_ZIP', 'FORKING', 'LOGS', 'PERMISSIONS', 'REGISTERING'],
type: 'external-storage-services',
wbKey: 'figshare',
configurableApiRoot: false,
})
);

Expand All @@ -76,6 +77,7 @@ describe('State: Addons', () => {
supportedFeatures: ['DOWNLOAD_AS_ZIP', 'FORKING', 'LOGS', 'PERMISSIONS', 'REGISTERING'],
type: 'external-storage-services',
wbKey: 'figshare',
configurableApiRoot: false,
})
);
expect(loading()).toBeFalsy();
Expand Down
1 change: 1 addition & 0 deletions src/testing/mocks/addon.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export const MOCK_ADDON: AddonModel = {
providerName: 'Test Provider',
wbKey: 'github',
iconUrl: 'https://test.com/icon.png',
configurableApiRoot: false,
};