Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 74 additions & 50 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@mantine/notifications": "^8.3.16",
"@reduxjs/toolkit": "^2.12.0",
"@tanstack/react-query": "^5.101.4",
"@types/d3-transition": "3.0.9",
"d3-axis": "^3.0.0",
"d3-cloud": "^1.2.9",
"d3-color": "^3.1.0",
Expand All @@ -57,6 +58,7 @@
"d3-scale": "^4.0.2",
"d3-selection": "^3.0.0",
"d3-shape": "^3.2.0",
"d3-transition": "3.0.1",
"dayjs": "^1.11.21",
"fast-deep-equal": "^3.1.3",
"fast-xml-parser": "5.3.5",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/gsa-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@
"No credential store found to verify.": "Kein Anmeldedaten-Store zum Verifizieren gefunden.",
"No credentials available": "Keine Anmeldedaten vorhanden",
"No CVEs available": "Keine CVEs vorhanden",
"No data available": "Keine Daten vorhanden",
"No details available for this method.": "Keine Details für diese Methode vorhanden.",
"No DFN-CERT Advisories available": "Keine DFN-CERT-Advisories vorhanden",
"No Displays": "Keine Anzeigen",
Expand Down Expand Up @@ -2191,7 +2192,6 @@
"To change the filter, please filter your results on the report page. This filter will not be stored as default.": "Um den Filter zu ändern, filtern Sie bitte die Ergebnisse in der Berichtansicht. Dieser Filter wird nicht als Standard gespeichert.",
"To change the filter, please select a filter from the dropdown menu.": "Um den Filter zu ändern, wählen Sie bitte einen Filter aus der Drop-down-Liste.",
"To see all assigned resources click here:": "Um alle zugewiesenen Ressourcen zu sehen, klicken Sie bitte hier:",
"Toggle 2D/3D view": "Zwischen 2D-/3D-Ansicht umschalten",
"Toggle Legend": "Legende umschalten",
"Too many resources to list.": "Zu viele Ressourcen, um alle anzuzeigen.",
"Too old ({{age}} days)": "Zu alt ({{age}} Tage)",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/gsa-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@
"No credential store found to verify.": "No credential store found to verify.",
"No credentials available": "No credentials available",
"No CVEs available": "No CVEs available",
"No data available": "No data available",
"No details available for this method.": "No details available for this method.",
"No DFN-CERT Advisories available": "No DFN-CERT Advisories available",
"No Displays": "No Displays",
Expand Down Expand Up @@ -2191,7 +2192,6 @@
"To change the filter, please filter your results on the report page. This filter will not be stored as default.": "To change the filter, please filter your results on the report page. This filter will not be stored as default.",
"To change the filter, please select a filter from the dropdown menu.": "To change the filter, please select a filter from the dropdown menu.",
"To see all assigned resources click here:": "To see all assigned resources click here:",
"Toggle 2D/3D view": "Toggle 2D/3D view",
"Toggle Legend": "Toggle Legend",
"Too many resources to list.": "Too many resources to list.",
"Too old ({{age}} days)": "Too old ({{age}} days)",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/gsa-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@
"No credential store found to verify.": "Nessun gestore credenziali trovato da verificare.",
"No credentials available": "Nessuna credenziale disponibile",
"No CVEs available": "Nessun CVE disponibile",
"No data available": "Nessun dato disponibile",
"No details available for this method.": "Nessun dettaglio disponibile per questo metodo.",
"No DFN-CERT Advisories available": "Nessun advisory DFN-CERT disponibile",
"No Displays": "Nessun display",
Expand Down Expand Up @@ -2191,7 +2192,6 @@
"To change the filter, please filter your results on the report page. This filter will not be stored as default.": "Per modificare il filtro, applica il filtro ai risultati nella pagina del rapporto. Questo filtro non verrà salvato come predefinito.",
"To change the filter, please select a filter from the dropdown menu.": "Per modificare il filtro, seleziona un filtro dal menu a discesa.",
"To see all assigned resources click here:": "Per visualizzare tutte le risorse assegnate, fai clic qui:",
"Toggle 2D/3D view": "Attiva/disattiva vista 2D/3D",
"Toggle Legend": "Attiva/disattiva legenda",
"Too many resources to list.": "Troppe risorse da elencare.",
"Too old ({{age}} days)": "Troppo vecchio ({{age}} giorni)",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/gsa-ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@
"No credential store found to verify.": "検証するクレデンシャルストアが見つかりません。",
"No credentials available": "利用可能なクレデンシャルがありません",
"No CVEs available": "利用可能なCVEがありません",
"No data available": "",
"No details available for this method.": "このメソッドの詳細はありません。",
"No DFN-CERT Advisories available": "利用可能なDFN-CERTアドバイザリがありません",
"No Displays": "表示項目がありません",
Expand Down Expand Up @@ -2191,7 +2192,6 @@
"To change the filter, please filter your results on the report page. This filter will not be stored as default.": "フィルターを変更するには、レポートページで結果をフィルタリングしてください。このフィルターはデフォルトとして保存されません。",
"To change the filter, please select a filter from the dropdown menu.": "フィルターを変更するには、ドロップダウンメニューからフィルターを選択してください。",
"To see all assigned resources click here:": "割り当てられたすべてのリソースを表示するには、こちらをクリック:",
"Toggle 2D/3D view": "2D/3D表示の切り替え",
"Toggle Legend": "凡例の表示切り替え",
"Too many resources to list.": "リソースが多すぎて一覧表示できません。",
"Too old ({{age}} days)": "古すぎます ({{age}} 日)",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/gsa-zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@
"No credential store found to verify.": "未找到要验证的凭据存储。",
"No credentials available": "没有用户凭据",
"No CVEs available": "没有可用的CVEs",
"No data available": "",
"No details available for this method.": "此方法没有详细信息.",
"No DFN-CERT Advisories available": "没有可用的DFN-CERT Advisories",
"No Displays": "无显示",
Expand Down Expand Up @@ -2191,7 +2192,6 @@
"To change the filter, please filter your results on the report page. This filter will not be stored as default.": "要更改过滤器,请在报告页面上过滤结果.此筛选器不会存储为默认值.",
"To change the filter, please select a filter from the dropdown menu.": "要更改过滤器,请从下拉菜单中选择一个过滤器.",
"To see all assigned resources click here:": "要查看所有分配的资源,请单击此处:",
"Toggle 2D/3D view": "切换2D/3D视图",
"Toggle Legend": "切换图例",
"Too many resources to list.": "资源太多,无法列出.",
"Too old ({{age}} days)": "过期 ({{age}}天)",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/gsa-zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@
"No credential store found to verify.": "",
"No credentials available": "",
"No CVEs available": "沒有可用的 CVE",
"No data available": "",
"No details available for this method.": "",
"No DFN-CERT Advisories available": "",
"No Displays": "",
Expand Down Expand Up @@ -2191,7 +2192,6 @@
"To change the filter, please filter your results on the report page. This filter will not be stored as default.": "",
"To change the filter, please select a filter from the dropdown menu.": "",
"To see all assigned resources click here:": "",
"Toggle 2D/3D view": "",
"Toggle Legend": "",
"Too many resources to list.": "",
"Too old ({{age}} days)": "",
Expand Down
24 changes: 20 additions & 4 deletions src/gmp/commands/__tests__/dashboards.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ describe('createDisplay tests', () => {

test('should create a new item with props', () => {
const uuid = testing.fn().mockReturnValue(1);
expect(createDisplay('foo1', {state: {show3d: true}}, uuid)).toEqual({
expect(createDisplay('foo1', {state: {showLegend: true}}, uuid)).toEqual({
id: 1,
displayId: 'foo1',
state: {show3d: true},
state: {showLegend: true},
});
expect(uuid).toHaveBeenCalled();
});
Expand Down Expand Up @@ -132,13 +132,29 @@ describe('DashboardCommand tests', () => {
const dashboardCommand = new DashboardCommand(http);
await dashboardCommand.saveSetting('test-id', {
name: 'Test Dashboard',
rows: [],
rows: [
{
height: 100,
id: 'row-id',
items: [
{
displayId: 'display-id',
id: 'display-id',
state: {show3d: true, showLegend: true} as {
show3d: boolean;
showLegend: boolean;
},
},
],
},
],
});
expect(http.request).toHaveBeenCalledWith('post', {
data: {
cmd: 'save_setting',
setting_id: 'test-id',
setting_value: '{"name":"Test Dashboard","rows":[]}',
setting_value:
'{"name":"Test Dashboard","rows":[{"height":100,"id":"row-id","items":[{"displayId":"display-id","id":"display-id","state":{"showLegend":true}}]}]}',
},
});
});
Expand Down
54 changes: 53 additions & 1 deletion src/gmp/commands/dashboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import {isArray, isDefined} from 'gmp/utils/identity';

interface DisplayState {
showLegend?: boolean;
}

interface LegacyDisplayState extends DisplayState {
show3d?: boolean;
}

Expand Down Expand Up @@ -85,6 +88,55 @@ const convertLoadedSettings = <
};
};

const normalizeDashboardSetting = (
setting: DashboardSetting,
): DashboardSetting => ({
...setting,
rows: setting.rows?.map(row => ({
...row,
items: row.items.map(({state, ...display}) => ({
...display,
state:
state &&
(({show3d: _show3d, ...supportedState}: LegacyDisplayState) =>
supportedState)(state),
})),
})),
});

const isDashboardSettings = (
settings: DashboardSetting | DashboardSettings,
): settings is DashboardSettings =>
'byId' in settings || 'dashboards' in settings || 'defaults' in settings;

const normalizeDashboardSettings = (
settings: DashboardSetting | DashboardSettings,
): DashboardSetting | DashboardSettings => {
if (!isDashboardSettings(settings)) {
return normalizeDashboardSetting(settings);
}

return {
...settings,
byId:
settings.byId &&
Object.fromEntries(
Object.entries(settings.byId).map(([id, setting]) => [
id,
normalizeDashboardSetting(setting),
]),
),
defaults:
settings.defaults &&
Object.fromEntries(
Object.entries(settings.defaults).map(([id, setting]) => [
id,
normalizeDashboardSetting(setting),
]),
),
};
};

class DashboardCommand extends HttpCommand {
async getSetting(id: string) {
const response = await this.httpGetWithTransform({
Expand Down Expand Up @@ -121,7 +173,7 @@ class DashboardCommand extends HttpCommand {

await this.httpPostWithTransform({
setting_id: id,
setting_value: JSON.stringify(settings),
setting_value: JSON.stringify(normalizeDashboardSettings(settings)),
cmd: 'save_setting',
});
}
Expand Down
Loading
Loading