Commit a289e20d authored by Fernando's avatar Fernando

Rework loading state

* Rework hasLoading to use isLoading
* Remove unused mutations due to set endpoint action being removed
* Remove hasLoading mutations
parent 406e57ce
...@@ -52,12 +52,12 @@ export default { ...@@ -52,12 +52,12 @@ export default {
containsHiddenGroups: false, containsHiddenGroups: false,
...this.getInitialData(), ...this.getInitialData(),
}; };
// TODO: Remove feature flag in https://gitlab.com/gitlab-org/gitlab/-/issues/235114 // TODO: Remove feature flag in https://gitlab.com/gitlab-org/gitlab/-/issues/235114
if(this.glFeatures.approvalSuggestions){ if (this.glFeatures.approvalSuggestions) {
return { ...defaults, name: this.defaultRuleName || ''}; return { ...defaults, name: this.defaultRuleName || '' };
} }
return defaults return defaults;
}, },
computed: { computed: {
...mapState(['settings']), ...mapState(['settings']),
......
...@@ -23,11 +23,11 @@ export default { ...@@ -23,11 +23,11 @@ export default {
...mapState('securityConfiguration', ['configuration']), ...mapState('securityConfiguration', ['configuration']),
...mapState({ ...mapState({
rules: state => state.approvals.rules, rules: state => state.approvals.rules,
hasApprovalsLoaded: state => state.approvals.hasLoaded, isApprovalsLoading: state => state.approvals.isLoading,
hasSecurityConfigurationLoaded: state => state.securityConfiguration.hasLoaded, isSecurityConfigurationLoading: state => state.securityConfiguration.isLoading,
}), }),
isRulesLoading() { isRulesLoading() {
return !this.hasApprovalsLoaded || !this.hasSecurityConfigurationLoaded; return this.isApprovalsLoading || this.isSecurityConfigurationLoading;
}, },
securityRules() { securityRules() {
return [ return [
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
}, },
created() { created() {
this.fetchSecurityConfiguration(); this.fetchSecurityConfiguration();
}, },
methods: { methods: {
...mapActions('securityConfiguration', ['fetchSecurityConfiguration']), ...mapActions('securityConfiguration', ['fetchSecurityConfiguration']),
...mapActions({ openCreateModal: 'createModal/open' }), ...mapActions({ openCreateModal: 'createModal/open' }),
......
...@@ -2,9 +2,7 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -2,9 +2,7 @@ import axios from '~/lib/utils/axios_utils';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import * as types from './mutation_types'; import * as types from './mutation_types';
export const setSecurityConfigurationEndpoint = ({ commit }, endpoint) => // eslint-disable-next-line import/prefer-default-export
commit(types.SET_SECURITY_CONFIGURATION_ENDPOINT, endpoint);
export const fetchSecurityConfiguration = ({ commit, state }) => { export const fetchSecurityConfiguration = ({ commit, state }) => {
if (!state.securityConfigurationPath) { if (!state.securityConfigurationPath) {
return commit(types.RECEIVE_SECURITY_CONFIGURATION_ERROR); return commit(types.RECEIVE_SECURITY_CONFIGURATION_ERROR);
......
export const SET_SECURITY_CONFIGURATION_ENDPOINT = 'SET_SECURITY_CONFIGURATION_ENDPOINT';
export const REQUEST_SECURITY_CONFIGURATION = 'REQUEST_SECURITY_CONFIGURATION'; export const REQUEST_SECURITY_CONFIGURATION = 'REQUEST_SECURITY_CONFIGURATION';
export const RECEIVE_SECURITY_CONFIGURATION_SUCCESS = 'RECEIVE_SECURITY_CONFIGURATION_SUCCESS'; export const RECEIVE_SECURITY_CONFIGURATION_SUCCESS = 'RECEIVE_SECURITY_CONFIGURATION_SUCCESS';
export const RECEIVE_SECURITY_CONFIGURATION_ERROR = 'RECEIVE_SECURITY_CONFIGURATION_ERROR'; export const RECEIVE_SECURITY_CONFIGURATION_ERROR = 'RECEIVE_SECURITY_CONFIGURATION_ERROR';
import * as types from './mutation_types'; import * as types from './mutation_types';
export default { export default {
[types.SET_SECURITY_CONFIGURATION_ENDPOINT](state, payload) {
state.securityConfigurationPath = payload;
},
[types.REQUEST_SECURITY_CONFIGURATION](state) { [types.REQUEST_SECURITY_CONFIGURATION](state) {
state.isLoading = true; state.isLoading = true;
state.errorLoading = false; state.errorLoading = false;
}, },
[types.RECEIVE_SECURITY_CONFIGURATION_SUCCESS](state, payload) { [types.RECEIVE_SECURITY_CONFIGURATION_SUCCESS](state, payload) {
state.isLoading = false; state.isLoading = false;
state.hasLoaded = true;
state.errorLoading = false; state.errorLoading = false;
state.configuration = payload; state.configuration = payload;
}, },
......
export default ({ securityConfigurationPath }) => ({ export default ({ securityConfigurationPath }) => ({
securityConfigurationPath, securityConfigurationPath,
isLoading: false, isLoading: false,
hasLoaded: false,
errorLoading: false, errorLoading: false,
configuration: {}, configuration: {},
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment