Skip to content

Commit

Permalink
Fix Updates status column when is up to date (#6163)
Browse files Browse the repository at this point in the history
* Fix Updates status column when is up to date

* Fix Updates status column when is up to date
  • Loading branch information
lucianogorza authored Nov 28, 2023
1 parent 85541a0 commit e6e6e94
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions plugins/wazuh-check-updates/server/services/updates/get-updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,28 @@ export const getUpdates = async (checkAvailableUpdates?: boolean): Promise<Avail

const update = response.data.data as ResponseApiAvailableUpdates;

const status =
update?.update_check === false
? API_UPDATES_STATUS.DISABLED
: update.last_available_patch ||
update.last_available_minor ||
update.last_available_patch
? API_UPDATES_STATUS.AVAILABLE_UPDATES
: API_UPDATES_STATUS.UP_TO_DATE;
const getStatus = () => {
if (update?.update_check === false) {
return API_UPDATES_STATUS.DISABLED;
}

if (
update?.last_available_patch?.tag ||
update?.last_available_minor?.tag ||
update?.last_available_patch?.tag
) {
return API_UPDATES_STATUS.AVAILABLE_UPDATES;
}

return API_UPDATES_STATUS.UP_TO_DATE;
};

const updateWithoutUUID = _.omit(update, 'uuid');

return {
...updateWithoutUUID,
api_id: api.id,
status,
status: getStatus(),
};
} catch (e: any) {
const error = {
Expand Down

0 comments on commit e6e6e94

Please sign in to comment.