Skip to content

Commit 438954d

Browse files
authored
Merge pull request #741 from futa-ikeda/refactor/configurable-api-root
[ENG-9649] Use configurable api root
2 parents a1ee72c + 2fbcf46 commit 438954d

File tree

9 files changed

+22
-24
lines changed

9 files changed

+22
-24
lines changed

src/app/shared/components/addons/addon-setup-account-form/addon-setup-account-form.component.html

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<form [formGroup]="addonForm()" (ngSubmit)="handleSubmit()" class="flex flex-column gap-5">
22
<p-card>
3+
@if (hasConfigurableApiRoot()) {
4+
<h2 class="mb-2">
5+
{{ 'settings.addons.form.fields.hostUrl' | translate }}
6+
</h2>
7+
<p class="mb-2">
8+
{{ 'settings.addons.form.fields.hostUrlDescription' | translate }}
9+
</p>
10+
<input class="mb-4" pInputText [formControlName]="formControls.HostUrl" />
11+
}
12+
313
@if (isAccessSecretKeysFormat()) {
414
<h2 class="mb-2">
515
{{ 'settings.addons.form.fields.accessKey' | translate }}
@@ -23,13 +33,6 @@ <h2 class="mb-2">
2333
}
2434

2535
@if (isDataverseApiTokenFormat()) {
26-
<h2 class="mb-2">
27-
{{ 'settings.addons.form.fields.hostUrl' | translate }}
28-
</h2>
29-
<p class="mb-2">
30-
{{ 'settings.addons.form.fields.hostUrlDescription' | translate }}
31-
</p>
32-
<input class="mb-4" pInputText [formControlName]="formControls.HostUrl" />
3336
<h2 class="mb-2">
3437
{{ 'settings.addons.form.fields.apiToken' | translate }}
3538
</h2>
@@ -43,13 +46,6 @@ <h2 class="mb-2">
4346
}
4447

4548
@if (isUsernamePasswordFormat()) {
46-
<h2 class="mb-2">
47-
{{ 'settings.addons.form.fields.hostUrl' | translate }}
48-
</h2>
49-
<p class="mb-2">
50-
{{ 'settings.addons.form.fields.hostUrlDescription' | translate }}
51-
</p>
52-
<input class="mb-4" pInputText [formControlName]="formControls.HostUrl" />
5349
<h2 class="mb-2">
5450
{{ 'settings.addons.form.fields.username' | translate }}
5551
</h2>
@@ -71,13 +67,6 @@ <h2 class="mb-2">
7167
}
7268

7369
@if (isRepoTokenFormat()) {
74-
<h2 class="mb-2">
75-
{{ 'settings.addons.form.fields.hostUrl' | translate }}
76-
</h2>
77-
<p class="mb-2">
78-
{{ 'settings.addons.form.fields.hostUrlDescription' | translate }}
79-
</p>
80-
<input class="mb-4" pInputText [formControlName]="formControls.HostUrl" />
8170
<h2 class="mb-2">
8271
{{ 'settings.addons.form.fields.personalAccessToken' | translate }}
8372
</h2>

src/app/shared/components/addons/addon-setup-account-form/addon-setup-account-form.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ export class AddonSetupAccountFormComponent {
6666
return format === CredentialsFormat.OAUTH2 || format === CredentialsFormat.OAUTH;
6767
});
6868

69+
readonly hasConfigurableApiRoot = computed(() => !!this.addon().configurableApiRoot);
70+
6971
handleSubmit(): void {
7072
if (!this.isFormValid) return;
7173

src/app/shared/mappers/addon.mapper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class AddonMapper {
2929
credentialsFormat: response.attributes.credentials_format,
3030
providerName: response.attributes.display_name,
3131
iconUrl: response.attributes.icon_url,
32+
configurableApiRoot: response.attributes.configurable_api_root,
3233
};
3334
}
3435

src/app/shared/models/addons/addon-json-api.models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface AddonGetResponseJsonApi {
1010
credentials_format: string;
1111
wb_key: string;
1212
icon_url: string;
13+
configurable_api_root: boolean;
1314
[key: string]: unknown;
1415
};
1516
relationships: {

src/app/shared/models/addons/addon.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface AddonModel {
77
supportedFeatures?: string[];
88
providerName?: string;
99
credentialsFormat?: string;
10+
configurableApiRoot?: boolean;
1011
authUrl?: string | null;
1112
authorizedCapabilities?: string[];
1213
authorizedOperationNames?: string[];

src/app/shared/services/addons/addon-form.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ export class AddonFormService {
2828
const formControls: Partial<AddonForm> = {
2929
[AddonFormControls.AccountName]: this.formBuilder.control<string>(addon.displayName || '', Validators.required),
3030
};
31+
if (addon.configurableApiRoot) {
32+
formControls[AddonFormControls.HostUrl] = this.formBuilder.control<string>('', Validators.required);
33+
}
3134

3235
switch (addon.credentialsFormat) {
3336
case CredentialsFormat.ACCESS_SECRET_KEYS:
3437
formControls[AddonFormControls.AccessKey] = this.formBuilder.control<string>('', Validators.required);
3538
formControls[AddonFormControls.SecretKey] = this.formBuilder.control<string>('', Validators.required);
3639
break;
3740
case CredentialsFormat.DATAVERSE_API_TOKEN:
38-
formControls[AddonFormControls.HostUrl] = this.formBuilder.control<string>('', Validators.required);
3941
formControls[AddonFormControls.ApiToken] = this.formBuilder.control<string>('', Validators.required);
4042
break;
4143
case CredentialsFormat.USERNAME_PASSWORD:
42-
formControls[AddonFormControls.HostUrl] = this.formBuilder.control<string>('', Validators.required);
4344
formControls[AddonFormControls.Username] = this.formBuilder.control<string>('', Validators.required);
4445
formControls[AddonFormControls.Password] = this.formBuilder.control<string>('', Validators.required);
4546
break;
4647
case CredentialsFormat.REPO_TOKEN:
47-
formControls[AddonFormControls.HostUrl] = this.formBuilder.control<string>('', Validators.required);
4848
formControls[AddonFormControls.PersonalAccessToken] = this.formBuilder.control<string>('', Validators.required);
4949
break;
5050
}

src/app/shared/services/addons/addons.service.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ describe('Service: Addons', () => {
4242
supportedFeatures: ['DOWNLOAD_AS_ZIP', 'FORKING', 'LOGS', 'PERMISSIONS', 'REGISTERING'],
4343
type: 'external-storage-services',
4444
wbKey: 'figshare',
45+
configurableApiRoot: false,
4546
})
4647
);
4748

src/app/shared/stores/addons/addons.state.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ describe('State: Addons', () => {
5959
supportedFeatures: ['DOWNLOAD_AS_ZIP', 'FORKING', 'LOGS', 'PERMISSIONS', 'REGISTERING'],
6060
type: 'external-storage-services',
6161
wbKey: 'figshare',
62+
configurableApiRoot: false,
6263
})
6364
);
6465

@@ -76,6 +77,7 @@ describe('State: Addons', () => {
7677
supportedFeatures: ['DOWNLOAD_AS_ZIP', 'FORKING', 'LOGS', 'PERMISSIONS', 'REGISTERING'],
7778
type: 'external-storage-services',
7879
wbKey: 'figshare',
80+
configurableApiRoot: false,
7981
})
8082
);
8183
expect(loading()).toBeFalsy();

src/testing/mocks/addon.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ export const MOCK_ADDON: AddonModel = {
1212
providerName: 'Test Provider',
1313
wbKey: 'github',
1414
iconUrl: 'https://test.com/icon.png',
15+
configurableApiRoot: false,
1516
};

0 commit comments

Comments
 (0)