Skip to content

Commit

Permalink
Merge branch 'opensight-ui' into add-enhance-error-feed-for-missing-d…
Browse files Browse the repository at this point in the history
…etials
  • Loading branch information
a-h-abdelsalam authored Oct 22, 2024
2 parents d872a7e + a0d5ec2 commit f4393fb
Show file tree
Hide file tree
Showing 38 changed files with 724 additions and 451 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gsa",
"version": "23.3.1-dev1",
"version": "24.0.2-dev1",
"description": "Greenbone Security Assistant",
"keywords": [
"openvas",
Expand All @@ -13,7 +13,7 @@
"type": "git",
"url": "https://github.com/greenbone/gsa/"
},
"author": "Björn Ricks <[email protected]>",
"author": "Bj\u00f6rn Ricks <[email protected]>",
"license": "AGPL-3.0+",
"type": "module",
"scripts": {
Expand Down Expand Up @@ -118,4 +118,4 @@
"prettier --write"
]
}
}
}
6 changes: 6 additions & 0 deletions public/locales/gsa-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@
"Dashboards": "Dashboards",
"Dashboards limit reached": "Dashboardgrenze erreicht",
"Date": "Datum",
"Date Format": "Datumsformat",
"Day": "Tag",
"Debug": "Debug",
"Decrease the minimum QoD in the filter settings to 30 percent to see those results.": "Die Minimum-QdE im Filter auf 30 Prozent verringern, um diese Ergebnisse zu sehen.",
Expand Down Expand Up @@ -1549,6 +1550,7 @@
"Super (Has super access)": "Super (hat Super-Zugriff)",
"Support for LDAP is not available.": "Unterstützung für LDAP ist nicht verfügbar.",
"Support for RADIUS is not available.": "Unterstützung für RADIUS ist nicht verfügbar.",
"System Default": "Systemstandard",
"System Logger": "System-Logger",
"System Reports": "Systemberichte",
"Synchronization issue: {{error}}": "Synchronisationsproblem: {{error}}",
Expand Down Expand Up @@ -1742,6 +1744,7 @@
"Tickets by Creation Time (Total: {{count}})": "Tickets nach Erstellungszeit (Gesamt: {{count}})",
"Tickets by Status (Total: {{count}})": "Tickets nach Status (Gesamt: {{count}})",
"Time": "Zeit",
"Time Format": "Zeitformat",
"Timeout": "Timeout",
"Timezone": "Zeitzone",
"TippingPoint SMS": "TippingPoint SMS",
Expand Down Expand Up @@ -1810,6 +1813,7 @@
"Uploading": "Hochladen",
"Urgency": "Dringlichkeit",
"Use LDAPS only": "Ausschließlich LDAPS verwenden",
"Use System Default for Time and Date Format": "Systemstandard für Zeit- und Datumsformat verwenden",
"Use workaround for default certificate": "Problemumgehung für Standard-Zertifikat verwenden",
"User": "Benutzer",
"User ID": "Benutzer-ID",
Expand Down Expand Up @@ -1872,6 +1876,8 @@
"Wednesday": "Mittwoch",
"Week": "Woche",
"Weekly": "Wöchentlich",
"Weekday, Month, Day, Year": "Wochentag, Monat, Tag, Jahr",
"Weekday, Day, Month, Year": "Wochentag, Tag, Monat, Jahr",
"When changing status to \"closed\", a \"Note for Closed\" is required.": "Wenn der Status zu \"Geschlossen\" geändert wird, ist eine \"Notiz für Geschlossen\" erforderlich.",
"When changing status to \"fixed\", a \"Note for Fixed\" is required.": "Wenn der Status zu \"Behoben\" geändert wird, ist eine \"Notiz für Behoben\" erforderlich.",
"When changing status to \"open\", a \"Note for Open\" is required.": "Wenn der Status zu \"Offen\" geändert wird, ist eine \"Notiz für Offen\" erforderlich.",
Expand Down
8 changes: 8 additions & 0 deletions src/gmp/commands/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export const DEFAULT_FILTER_SETTINGS = {
vulnerability: '17c9d269-95e7-4bfa-b1b2-bc106a2175c7',
};

const PARAM_KEYS = {
DATE: 'date_format',
TIME: 'time_format',
};

const saveDefaultFilterSettingId = entityType =>
`settings_filter:${DEFAULT_FILTER_SETTINGS[entityType]}`;

Expand Down Expand Up @@ -251,9 +256,12 @@ export class UserCommand extends EntityCommand {

saveSettings(data) {
log.debug('Saving settings', data);

return this.httpPost({
cmd: 'save_my_settings',
text: data.timezone,
[PARAM_KEYS.DATE]: data.userInterfaceDateFormat,
[PARAM_KEYS.TIME]: data.userInterfaceTimeFormat,
old_password: data.oldPassword,
password: data.newPassword,
lang: data.userInterfaceLanguage,
Expand Down
2 changes: 1 addition & 1 deletion src/gmp/gmpsettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const warnDeprecatedSetting = (oldName, newName) => {
class GmpSettings {
constructor(storage = global.localStorage, options = {}) {
const {
enableEPSS = false,
enableEPSS = true,
enableGreenboneSensor = false,
disableLoginForm = false,
enableStoreDebugLog,
Expand Down
158 changes: 143 additions & 15 deletions src/gmp/locale/__tests__/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import {describe, test, expect} from '@gsa/testing';
import {describe, test, expect, beforeEach} from '@gsa/testing';

import date, {setLocale as locale} from '../../models/date';

Expand Down Expand Up @@ -55,15 +55,30 @@ describe('shortDate tests', () => {
expect(shortDate(d)).toEqual('01/01/2018');
});

test('should format string', () => {
setLocale('en');
expect(shortDate('2018-01-01')).toEqual('01/01/2018');
test('should format date locale', () => {
setLocale('de');
expect(
shortDate(date('2018-11-24T15:30:00Z'), 'UTC', 'system_default'),
).toEqual('24.11.2018');
});

test('should format JS date', () => {
const d = new Date('2018-01-01');
setLocale('en');
expect(shortDate(d)).toEqual('01/01/2018');
describe('shortDate tests', () => {
beforeEach(() => {
setLocale('en');
});

test.each([
['2018-01-01', undefined, undefined, '01/01/2018'],
[new Date('2018-01-01'), undefined, undefined, '01/01/2018'],
[new Date('2018-11-24'), undefined, 'wmdy', '11/24/2018'],
[new Date('2018-11-24'), undefined, 'wdmy', '24/11/2018'],
[new Date('2018-11-24'), undefined, 'system_default', '11/24/2018'],
])(
'should format date %p with tz %p and userInterfaceDateFormat %p to %p',
(input, tz, userInterfaceDateFormat, expected) => {
expect(shortDate(input, tz, userInterfaceDateFormat)).toEqual(expected);
},
);
});
});

Expand All @@ -83,15 +98,61 @@ describe('longDate tests', () => {
expect(longDate(d)).toEqual('Mon, Jan 1, 2018 12:00 AM');
});

test('should format string', () => {
setLocale('en');
expect(longDate('2018-01-01')).toEqual('Mon, Jan 1, 2018 12:00 AM');
test('should format date locale', () => {
setLocale('de');
expect(
longDate(
date('2018-11-24T15:30:00Z'),
'UTC',
'system_default',
'system_default',
),
).toEqual('Sa., 24. Nov. 2018 15:30');
});

test('should format JS date', () => {
const d = new Date('2018-01-01T00:00:00');
setLocale('en');
expect(longDate(d)).toEqual('Mon, Jan 1, 2018 12:00 AM');
describe('longDate tests', () => {
beforeEach(() => {
setLocale('en');
});

test.each([
[
'2018-11-24',
undefined,
undefined,
undefined,
'Sat, Nov 24, 2018 12:00 AM',
],
[
new Date('2018-11-23T00:00:00'),
undefined,
undefined,
undefined,
'Fri, Nov 23, 2018 12:00 AM',
],
['2018-11-24T15:30:00Z', 'UTC', 12, 'wdmy', 'Sat, 24 Nov 2018 3:30 PM'],
['2018-11-24T15:30:00Z', 'UTC', 24, 'wmdy', 'Sat, Nov 24, 2018 15:30'],
[
'2018-11-24T15:30:00Z',
'UTC',
'system_default',
'system_default',
'Sat, Nov 24, 2018 3:30 PM',
],
])(
'should format date %p with tz %p, userInterfaceTimeFormat %p, and userInterfaceDateFormat %p to %p',
(
input,
tz,
userInterfaceTimeFormat,
userInterfaceDateFormat,
expected,
) => {
expect(
longDate(input, tz, userInterfaceTimeFormat, userInterfaceDateFormat),
).toEqual(expected);
},
);
});
});

Expand All @@ -110,6 +171,73 @@ describe('dateTimeWithTimeZone tests', () => {
const d = date('2018-01-01T00:00:00+01:00').tz('CET');
expect(dateTimeWithTimeZone(d)).toEqual('Mon, Jan 1, 2018 12:00 AM CET');
});

test('should format date locale', () => {
setLocale('de');
expect(
dateTimeWithTimeZone(
date('2018-11-24T15:30:00Z'),
'UTC',
'system_default',
'system_default',
),
).toEqual('Sa., 24. Nov. 2018 15:30 UTC');
});

describe('dateTimeWithTimeZone tests', () => {
beforeEach(() => {
setLocale('en');
});

test.each([
[
new Date('2018-11-23T00:00:00'),
undefined,
undefined,
undefined,
'Fri, Nov 23, 2018 12:00 AM ',
],
[
'2018-11-24T15:30:00Z',
'UTC',
12,
'wdmy',
'Sat, 24 Nov 2018 3:30 PM UTC',
],
[
'2018-11-24T15:30:00Z',
'UTC',
24,
'wmdy',
'Sat, Nov 24, 2018 15:30 UTC',
],
[
'2018-11-24T15:30:00Z',
'UTC',
'system_default',
'system_default',
'Sat, Nov 24, 2018 3:30 PM UTC',
],
])(
'should format date %p with tz %p, userInterfaceTimeFormat %p, and userInterfaceDateFormat %p to %p',
(
input,
tz,
userInterfaceTimeFormat,
userInterfaceDateFormat,
expected,
) => {
expect(
dateTimeWithTimeZone(
input,
tz,
userInterfaceTimeFormat,
userInterfaceDateFormat,
),
).toEqual(expected);
},
);
});
});

// vim: set ts=2 sw=2 tw=80:
Loading

0 comments on commit f4393fb

Please sign in to comment.