diff --git a/app/src/api/api.js b/app/src/api/api.js index daeb56b0..e7c8e061 100644 --- a/app/src/api/api.js +++ b/app/src/api/api.js @@ -217,12 +217,12 @@ export default { const api = this function reconnect(n) { - api - .get('logout', {}, { key: 'reconnecting' }) + store + .dispatch('GET_YUNOHOST_INFOS') .then(resolve) .catch((err) => { if (err.name === 'APIUnauthorizedError') { - resolve() + reject(err) } else if (n < 1) { reject(err) } else { diff --git a/app/src/helpers/yunohostArguments.js b/app/src/helpers/yunohostArguments.js index 7322ccb9..aa518b6f 100644 --- a/app/src/helpers/yunohostArguments.js +++ b/app/src/helpers/yunohostArguments.js @@ -120,18 +120,13 @@ function addEvaluationGetter(prop, obj, expr, ctx, nested) { * @return {Object} an formated argument containing formItem props, validation and base value. */ export function formatYunoHostArgument(arg) { - let value = - arg.value !== undefined - ? arg.value - : arg.current_value !== undefined - ? arg.current_value - : null + let value = arg.value !== undefined ? arg.value : null const validation = {} const error = { message: null } arg.ask = formatI18nField(arg.ask) const field = { is: arg.readonly ? 'ReadOnlyField' : 'FormField', - visible: [undefined, true, '"true"'].includes(arg.visible), + visible: arg.visible, props: { label: arg.ask, component: undefined, @@ -168,11 +163,11 @@ export function formatYunoHostArgument(arg) { name: 'InputItem', props: defaultProps.concat(['type', 'min', 'max', 'step']), callback: function () { - if (!isNaN(parseInt(arg.min))) { - validation.minValue = validators.minValue(parseInt(arg.min)) + if (arg.min !== undefined) { + validation.minValue = validators.minValue(arg.min) } - if (!isNaN(parseInt(arg.max))) { - validation.maxValue = validators.maxValue(parseInt(arg.max)) + if (arg.max !== undefined) { + validation.maxValue = validators.maxValue(arg.max) } validation.numValue = validators.integer }, @@ -278,10 +273,9 @@ export function formatYunoHostArgument(arg) { // Default type management if no one is filled if (arg.type !== 'tags' && arg.choices && arg.choices.length) { - arg.type = 'select' - } - if (arg.type === undefined) { - arg.type = 'string' + arg.type = 'select' + } else if (arg.type === undefined) { + arg.type = 'string' } // Search the component bind to the type @@ -328,9 +322,6 @@ export function formatYunoHostArgument(arg) { } // Default value if still `null` - if (value === null && arg.current_value) { - value = arg.current_value - } if (value === null && arg.default) { value = arg.default } @@ -433,12 +424,12 @@ export function formatYunoHostConfigPanels(data) { const section = { id: _section.id, isActionSection: _section.is_action_section, - visible: [undefined, true, '"true"'].includes(_section.visible), + visible: _section.visible, } if (_section.help) section.help = formatI18nField(_section.help) if (_section.name) section.name = formatI18nField(_section.name) - if (_section.visible && ![false, '"false"'].includes(_section.visible)) { - addEvaluationGetter('visible', section, _section.visible, result.forms) + if (typeof _section.visible === 'string') { + addEvaluationGetter('visible', section, section.visible, result.forms) } const { form, fields, validations, errors } = formatYunoHostArguments( diff --git a/app/src/i18n/locales/en.json b/app/src/i18n/locales/en.json index 3684f6c9..e8542309 100644 --- a/app/src/i18n/locales/en.json +++ b/app/src/i18n/locales/en.json @@ -31,7 +31,7 @@ "unknown": "Connection with the server has been closed for unknown reasons.", "upgrade_system": "Connection with the server has been closed due to YunoHost upgrade. Waiting for the server to be reachable again…" }, - "success": "The server is now reachable! You can try to login", + "session_expired": "The server is now reachable! But it looks like your session expired, please login.", "title": "Trying to communicate with the server…" } }, diff --git a/app/src/store/info.js b/app/src/store/info.js index 9bed6a85..5bc5ce3f 100644 --- a/app/src/store/info.js +++ b/app/src/store/info.js @@ -179,10 +179,9 @@ export default { return api.get('logout') }, - TRY_TO_RECONNECT({ commit, dispatch }, args = {}) { + TRY_TO_RECONNECT({ commit }, args = {}) { // FIXME This is very ugly arguments forwarding, will use proper component way of doing this when switching to Vue 3 (teleport) commit('SET_RECONNECTING', args) - dispatch('RESET_CONNECTED') }, GET_YUNOHOST_INFOS({ commit }) { diff --git a/app/src/views/_partials/ReconnectingDisplay.vue b/app/src/views/_partials/ReconnectingDisplay.vue index 5d33778a..65e94c4a 100644 --- a/app/src/views/_partials/ReconnectingDisplay.vue +++ b/app/src/views/_partials/ReconnectingDisplay.vue @@ -28,8 +28,8 @@ -