mirror of
https://github.com/goharbor/harbor
synced 2024-09-20 15:15:39 +00:00
Refresh config every time entering the configuration page (#17600)
Signed-off-by: AllForNothing <sshijun@vmware.com> Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
parent
c1c1aaf612
commit
90fe39684b
|
@ -19,7 +19,6 @@ describe('ConfigurationComponent', () => {
|
|||
return false;
|
||||
},
|
||||
updateConfig() {},
|
||||
initConfig() {},
|
||||
};
|
||||
let initSpy: jasmine.Spy;
|
||||
beforeEach(() => {
|
||||
|
@ -34,7 +33,7 @@ describe('ConfigurationComponent', () => {
|
|||
});
|
||||
|
||||
beforeEach(() => {
|
||||
initSpy = spyOn(fakeConfigService, 'initConfig').and.returnValue(
|
||||
initSpy = spyOn(fakeConfigService, 'updateConfig').and.returnValue(
|
||||
undefined
|
||||
);
|
||||
fixture = TestBed.createComponent(ConfigurationComponent);
|
||||
|
|
|
@ -27,7 +27,7 @@ export class ConfigurationComponent implements OnInit {
|
|||
constructor(private conf: ConfigService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
// First load
|
||||
this.conf.initConfig();
|
||||
// Refresh config every time when entering the configuration page
|
||||
this.conf.updateConfig();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,15 +33,15 @@ describe('ConfigService', () => {
|
|||
}
|
||||
));
|
||||
|
||||
it('should init config', inject(
|
||||
it('should update config', inject(
|
||||
[ConfigService],
|
||||
(service: ConfigService) => {
|
||||
expect(getConfigSpy.calls.count()).toEqual(0);
|
||||
service.initConfig();
|
||||
expect(getConfigSpy.calls.count()).toEqual(1);
|
||||
// only init once
|
||||
service.initConfig();
|
||||
service.updateConfig();
|
||||
expect(getConfigSpy.calls.count()).toEqual(1);
|
||||
// update again
|
||||
service.updateConfig();
|
||||
expect(getConfigSpy.calls.count()).toEqual(2);
|
||||
expect(service).toBeTruthy();
|
||||
}
|
||||
));
|
||||
|
|
|
@ -17,7 +17,6 @@ const fakePass = 'aWpLOSYkIzJTTU4wMDkx';
|
|||
@Injectable()
|
||||
export class ConfigService {
|
||||
private _loadingConfig: boolean = false;
|
||||
private _hasInit: boolean = false;
|
||||
private _confirmSub: Subscription;
|
||||
private _currentConfig: Configuration = new Configuration();
|
||||
private _originalConfig: Configuration;
|
||||
|
@ -59,13 +58,6 @@ export class ConfigService {
|
|||
return this._loadingConfig;
|
||||
}
|
||||
|
||||
initConfig() {
|
||||
if (!this._hasInit) {
|
||||
this.updateConfig();
|
||||
this._hasInit = true;
|
||||
}
|
||||
}
|
||||
|
||||
updateConfig() {
|
||||
this._loadingConfig = true;
|
||||
this.configureService
|
||||
|
@ -92,6 +84,8 @@ export class ConfigService {
|
|||
// Handle read only
|
||||
if (this._originalConfig?.read_only?.value) {
|
||||
this.msgHandler.handleReadOnly();
|
||||
} else {
|
||||
this.msgHandler.clear();
|
||||
}
|
||||
},
|
||||
error => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user