1
0
mirror of https://github.com/quay/quay.git synced 2025-04-18 10:44:06 +03:00
quay/static/js/services/state-service.js
Kenny Lee Sin Cheong a839a78eb5
chore: allows Quay to run for account recoveries (PROJQUAY-970) (#793)
Adds ACCOUNT_RECOVERY_MODE to allow Quay to run with some core
features disabled. When this is set, the instance should only be used
in order by existing users who hasn't linked their account to an
external login service, after database authentication has been
disabled.
2021-07-07 12:45:24 -04:00

50 lines
1.2 KiB
JavaScript

/**
* Service which monitors the current state of the registry.
*/
angular.module('quay')
.factory('StateService', ['$rootScope', '$timeout', function($rootScope, $timeout) {
var stateService = {};
var currentState = {
'inReadOnlyMode': false,
'inAccountRecoveryMode': false
};
stateService.inReadOnlyMode = function() {
return currentState.inReadOnlyMode;
};
stateService.setInReadOnlyMode = function() {
currentState.inReadOnlyMode = true;
};
stateService.inAccountRecoveryMode = function() {
return currentState.inAccountRecoveryMode;
};
stateService.setInAccountRecoveryMode = function() {
currentState.inAccountRecoveryMode = true;
};
stateService.updateStateIn = function(scope, opt_callback) {
scope.$watch(function () { return stateService.currentState(); }, function (currentState) {
$timeout(function(){
scope.currentRegistryState = currentState;
if (opt_callback) {
opt_callback(currentState);
}
}, 0, false);
}, true);
};
stateService.currentState = function() {
return currentState;
};
// Update the state in the root scope.
stateService.updateStateIn($rootScope);
return stateService;
}]);