Skip to content

Commit 07ee24d

Browse files
authored
Merge branch 'main' into renojeda/fix/cert-ref-title
2 parents 8b0a709 + 21e7614 commit 07ee24d

47 files changed

Lines changed: 980 additions & 106 deletions

Some content is hidden

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

desktop/python/server/aad_auth.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import azext.batch
22
from msrestazure.azure_active_directory import AdalAuthentication
3+
from azure.core.credentials import TokenCredential, AccessToken
4+
5+
class BatchExplorerTokenCredential(TokenCredential):
6+
def __init__(self, access_token) -> None:
7+
super().__init__()
8+
self.access_token = access_token
9+
10+
def get_token(self, *scopes, **kwargs):
11+
return AccessToken(token=self.access_token, expires_on=0)
312

413
class BatchAccount:
514
def __init__(self, account_id: str, name: str, account_endpoint: str, subscription_id: str):
@@ -22,8 +31,8 @@ class AADAuth:
2231
def __init__(self, batchToken: str, armToken: str, armUrl: str, storage_endpoint: str, account: BatchAccount):
2332
self.batchCreds = AdalAuthentication(
2433
lambda: {'accessToken': batchToken, 'tokenType': 'Bearer'})
25-
self.armCreds = AdalAuthentication(
26-
lambda: {'accessToken': armToken, 'tokenType': 'Bearer'})
34+
35+
self.armCreds = BatchExplorerTokenCredential(armToken)
2736
self.armUrl = armUrl
2837
self.storage_endpoint = storage_endpoint
2938
self.account = account

desktop/src/@batch-flask/core/data/targeted-data-cache/targeted-data-cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class TargetedDataCache<TParams, TEntity extends Record<any>> {
2727
* Return the key of the cache associated to the given params
2828
*/
2929
public getCacheKey(params: TParams) {
30-
return this._options.key!(params);
30+
return this._options.key?.call(null, params);
3131
}
3232

3333
public getCache(params: TParams): DataCache<TEntity> {

desktop/src/@batch-flask/core/record/decorators.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@ export function ListProp<T>(type: any) {
5656
};
5757
}
5858

59-
export function Model() {
59+
export function Model(name?: string) {
6060
return <T extends new(...args: any[]) => {}>(ctr: T) => {
6161
if (!(ctr.prototype instanceof Record)) {
6262
throw new RecordMissingExtendsError(ctr);
6363
}
64-
65-
return (class extends ctr {
64+
const model = (class extends ctr {
6665
constructor(...args: any[]) {
6766
const [data] = args;
6867
if (data instanceof ctr) {
@@ -72,5 +71,7 @@ export function Model() {
7271
(this as any)._completeInitialization();
7372
}
7473
});
74+
Object.defineProperty(model, "name", { value: name || ctr.name });
75+
return model;
7576
};
7677
}

desktop/src/@batch-flask/core/record/record.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ class InheritedTestRec extends SimpleTestRec {
4444
public d: number;
4545
}
4646

47+
@Model("CustomName")
48+
class CustomNameRec extends Record<any> {
49+
@Prop()
50+
public id: string = "default-id";
51+
}
52+
4753
describe("Record", () => {
4854
it("should throw an exeption when record doesn't extends Record class", () => {
4955
try {
@@ -176,4 +182,12 @@ describe("Record", () => {
176182
expect(SimpleTestRec.isStaticMethod).not.toBeFalsy();
177183
expect(SimpleTestRec.isStaticMethod()).toBe(true);
178184
});
185+
186+
it("should allow a custom record name to be set", () => {
187+
const rec1 = new TestRec();
188+
expect(rec1.constructor.name).toEqual("TestRec");
189+
190+
const rec2 = new CustomNameRec();
191+
expect(rec2.constructor.name).toEqual("CustomName");
192+
});
179193
});

desktop/src/@batch-flask/ui/buttons/button.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,9 @@ bl-button {
180180
@media (forced-colors: active) {
181181
bl-button {
182182
border: 1px solid currentColor;
183+
184+
&.disabled {
185+
opacity: 0.3;
186+
}
183187
}
184188
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { HttpClientTestingModule } from "@angular/common/http/testing";
2+
import { Component, DebugElement } from "@angular/core";
3+
import { ComponentFixture, TestBed } from "@angular/core/testing";
4+
import { FormControl, FormsModule, ReactiveFormsModule } from "@angular/forms";
5+
import { By } from "@angular/platform-browser";
6+
import { BrowserDynamicTestingModule }
7+
from "@angular/platform-browser-dynamic/testing";
8+
import { RouterTestingModule } from "@angular/router/testing";
9+
import { GlobalStorage, USER_SERVICE, UserConfigurationService }
10+
from "@batch-flask/core";
11+
import {
12+
I18nTestingModule,
13+
MockGlobalStorage,
14+
MockUserConfigurationService
15+
} from "@batch-flask/core/testing";
16+
import { ElectronTestingModule } from "@batch-flask/electron/testing";
17+
import { ButtonsModule, DialogService, FormModule, SelectModule }
18+
from "@batch-flask/ui";
19+
import { AuthService, BatchExplorerService } from "app/services";
20+
import { BehaviorSubject } from "rxjs";
21+
import { FileGroupPickerComponent } from "./file-group-picker.component";
22+
import { FileGroupPickerModule } from "./file-group-picker.module";
23+
24+
@Component({
25+
template: `<bl-file-group-picker [formControl]="control"></bl-file-group-picker>`,
26+
})
27+
class TestComponent {
28+
public control = new FormControl();
29+
}
30+
31+
describe("FileGroupPickerComponent", () => {
32+
let testComponent: TestComponent;
33+
let component: FileGroupPickerComponent;
34+
let fixture: ComponentFixture<TestComponent>;
35+
let de: DebugElement;
36+
37+
const userServiceSpy = { currentUser: new BehaviorSubject(null) };
38+
39+
beforeEach(async () => {
40+
await TestBed.configureTestingModule({
41+
imports: [
42+
FormModule,
43+
FormsModule,
44+
ReactiveFormsModule,
45+
SelectModule,
46+
RouterTestingModule,
47+
I18nTestingModule,
48+
HttpClientTestingModule,
49+
ButtonsModule,
50+
ElectronTestingModule,
51+
BrowserDynamicTestingModule,
52+
FileGroupPickerModule
53+
],
54+
declarations: [TestComponent],
55+
providers: [
56+
{ provide: BatchExplorerService, useValue: {} },
57+
{ provide: UserConfigurationService, useValue:
58+
new MockUserConfigurationService({}) },
59+
{ provide: AuthService, useValue: userServiceSpy },
60+
{ provide: GlobalStorage, useValue: new MockGlobalStorage() },
61+
{ provide: USER_SERVICE, useValue: userServiceSpy },
62+
{ provide: DialogService, useValue: {} },
63+
]
64+
}).compileComponents();
65+
66+
fixture = TestBed.createComponent(TestComponent);
67+
testComponent = fixture.componentInstance;
68+
de = fixture.debugElement.query(By.css("bl-file-group-picker"));
69+
component = fixture.debugElement.query(By.css("bl-file-group-picker"))
70+
.componentInstance;
71+
fixture.detectChanges();
72+
});
73+
74+
it("should pick an existing value", () => {
75+
const testValue = 'existingValue';
76+
component.fileGroupPicked(testValue);
77+
fixture.detectChanges();
78+
expect(component.value.value).toEqual(testValue);
79+
});
80+
81+
it("should create a new file group on null value", () => {
82+
const spy = spyOn(component, "createFileGroup");
83+
const testValue = null;
84+
component.fileGroupPicked(testValue);
85+
fixture.detectChanges();
86+
expect(spy).toHaveBeenCalledOnce();
87+
});
88+
89+
afterEach(() => {
90+
fixture.destroy();
91+
});
92+
});

desktop/src/app/components/data/shared/file-group-picker/file-group-picker.component.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
import {
55
ControlValueAccessor, FormControl, NG_VALIDATORS, NG_VALUE_ACCESSOR,
66
} from "@angular/forms";
7-
import { MatOptionSelectionChange } from "@angular/material/core";
87
import { FilterBuilder, ListView } from "@batch-flask/core";
98
import { Activity, DialogService } from "@batch-flask/ui";
109
import { FileGroupCreateFormComponent } from "app/components/data/action";
@@ -141,18 +140,25 @@ export class FileGroupPickerComponent implements ControlValueAccessor, OnInit, O
141140
return null;
142141
}
143142

144-
public createFileGroup(dropdownValue: string) {
145-
if (!dropdownValue) {
146-
const dialog = this.dialogService.open(FileGroupCreateFormComponent);
147-
dialog.afterClosed().subscribe((activity?: Activity) => {
148-
const newFileGroupName = dialog.componentInstance.getCurrentValue().name;
149-
this.value.setValue(this.fileGroupService.addFileGroupPrefix(newFileGroupName));
150-
this.changeDetector.markForCheck();
151-
this._uploadActivity.next(activity);
152-
});
143+
public fileGroupPicked(value: string) {
144+
if (value) {
145+
this.writeValue(value);
146+
this.changeDetector.markForCheck();
147+
} else {
148+
this.createFileGroup();
153149
}
154150
}
155151

152+
public createFileGroup() {
153+
const dialog = this.dialogService.open(FileGroupCreateFormComponent);
154+
dialog.afterClosed().subscribe((activity?: Activity) => {
155+
const newFileGroupName = dialog.componentInstance.getCurrentValue().name;
156+
this.value.setValue(this.fileGroupService.addFileGroupPrefix(newFileGroupName));
157+
this.changeDetector.markForCheck();
158+
this._uploadActivity.next(activity);
159+
});
160+
}
161+
156162
public trackFileGroup(_: number, fileGroup: BlobContainer) {
157163
return fileGroup.id;
158164
}

desktop/src/app/components/data/shared/file-group-picker/file-group-picker.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
<bl-hint *ngIf="hint" align="end">
99
{{hint}}
1010
</bl-hint>
11-
<bl-select placeholder="File group" [filterable]="true" (change)="createFileGroup($event)">
11+
<bl-select placeholder="File group" [filterable]="true" (change)="fileGroupPicked($event)">
1212
<bl-option value="" label="+ {{'file-group-picker.create' | i18n}}"></bl-option>
1313
<bl-option
1414
*ngFor="let fileGroup of fileGroups;trackBy: trackFileGroup"
15-
[value]="fileGroup">
15+
[value]="fileGroup.name"
16+
[label]="fileGroup.name">
1617
</bl-option>
1718
</bl-select>
1819
</bl-form-field>

desktop/src/app/components/gallery/submit/market-application.model.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ export class NcjParameterWrapper {
3838
}
3939

4040
private _computeDefaultValue() {
41-
if (this.param.defaultValue) {
42-
this.defaultValue = this.param.defaultValue;
41+
let defaultValue = this.param.defaultValue;
42+
if (typeof defaultValue === "string" &&
43+
defaultValue.toLowerCase().trim() === "none") {
44+
defaultValue = "";
4345
}
46+
this.defaultValue = this.param.defaultValue = defaultValue;
4447
}
4548

4649
private _computeDescription() {

desktop/src/app/components/gallery/submit/parameter-input/parameter-input.component.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ export class ParameterInputComponent implements ControlValueAccessor, OnChanges,
4141
this._subs.push(this.parameterValue.valueChanges.pipe(
4242
distinctUntilChanged(),
4343
).subscribe((query: string) => {
44-
if (this._propagateChange) {
45-
this._propagateChange(query);
46-
}
47-
}),
48-
);
44+
if (this._propagateChange) {
45+
this._propagateChange(query);
46+
}
47+
}));
4948
}
5049

5150
public ngOnChanges(changes) {

0 commit comments

Comments
 (0)