Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only displaying active databases in the sidebar's database selector #698

Merged
merged 1 commit into from
Nov 21, 2023
Merged
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
2 changes: 1 addition & 1 deletion src/dashboard/DashboardThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@
}

// Attempt upgrade if dashboard version is outdated.
while (VERSION_TO_MIGRATE[dashboard.version]) {
const upgradedDashboard = upgradeDashboardVersion(

Check warning on line 81 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L80-L81

Added lines #L80 - L81 were not covered by tests
dashboard,
dashboard.version,
VERSION_TO_MIGRATE[dashboard.version]
);
dispatch(setDashboard(upgradedDashboard));
dispatch(setWelcomeScreenOpen(false));
dispatch(setDraft(true));

Check warning on line 88 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L88

Added line #L88 was not covered by tests
dispatch(
createNotificationThunk(
'Successfully upgraded dashboard',
Expand Down Expand Up @@ -119,33 +119,33 @@

// Pre-2.3.4 dashboards might now always have a UUID. Set it if not present.
if (!dashboard.uuid) {
dispatch(setDashboardUuid(uuid));

Check warning on line 122 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L122

Added line #L122 was not covered by tests
}
} catch (e) {
console.log(e);

Check warning on line 125 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L125

Added line #L125 was not covered by tests
dispatch(createNotificationThunk('Unable to load dashboard', e));
}
};

export const saveDashboardToNeo4jThunk = (driver, database, dashboard, date, user, onSuccess) => (dispatch: any) => {
try {
let { uuid } = dashboard;

Check warning on line 132 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L131-L132

Added lines #L131 - L132 were not covered by tests

// Dashboards pre-2.3.4 may not always have a UUID. If this is the case, generate one just before we save.
if (!dashboard.uuid) {
uuid = createUUID();
dashboard.uuid = uuid;
dispatch(setDashboardUuid(uuid));
createUUID();

Check warning on line 139 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L136-L139

Added lines #L136 - L139 were not covered by tests
}

const { title, version } = dashboard;

Check warning on line 142 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L142

Added line #L142 was not covered by tests

// Generate a cypher query to save the dashboard.
const query =
'MERGE (n:_Neodash_Dashboard {uuid: $uuid }) SET n.title = $title, n.version = $version, n.user = $user, n.content = $content, n.date = datetime($date) RETURN $uuid as uuid';

Check warning on line 146 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L146

Added line #L146 was not covered by tests

const parameters = {

Check warning on line 148 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L148

Added line #L148 was not covered by tests
uuid: uuid,
title: title,
version: version,
Expand All @@ -153,19 +153,19 @@
content: JSON.stringify(dashboard, null, 2),
date: date,
};
runCypherQuery(

Check warning on line 156 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L156

Added line #L156 was not covered by tests
driver,
database,
query,
parameters,
1,
() => {},
(records) => {

Check warning on line 163 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L162-L163

Added lines #L162 - L163 were not covered by tests
if (records && records[0] && records[0]._fields && records[0]._fields[0] && records[0]._fields[0] == uuid) {
dispatch(createNotificationThunk('🎉 Success!', 'Your current dashboard was saved to Neo4j.'));
onSuccess(uuid);
} else {
dispatch(

Check warning on line 168 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L165-L168

Added lines #L165 - L168 were not covered by tests
createNotificationThunk(
'Unable to save dashboard',
`Do you have write access to the '${database}' database?`
Expand All @@ -175,30 +175,30 @@
}
);
} catch (e) {
dispatch(createNotificationThunk('Unable to save dashboard to Neo4j', e));

Check warning on line 178 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L178

Added line #L178 was not covered by tests
}
};

export const deleteDashboardFromNeo4jThunk = (driver, database, uuid, onSuccess) => (dispatch: any) => {
try {

Check warning on line 183 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L183

Added line #L183 was not covered by tests
// Generate a cypher query to save the dashboard.
const query = 'MATCH (n:_Neodash_Dashboard {uuid: $uuid }) DETACH DELETE n RETURN $uuid as uuid';

Check warning on line 185 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L185

Added line #L185 was not covered by tests

const parameters = {

Check warning on line 187 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L187

Added line #L187 was not covered by tests
uuid: uuid,
};
runCypherQuery(

Check warning on line 190 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L190

Added line #L190 was not covered by tests
driver,
database,
query,
parameters,
1,
() => {},
(records) => {

Check warning on line 197 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L196-L197

Added lines #L196 - L197 were not covered by tests
if (records && records[0] && records[0]._fields && records[0]._fields[0] && records[0]._fields[0] == uuid) {
onSuccess(uuid);
} else {
dispatch(

Check warning on line 201 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L199-L201

Added lines #L199 - L201 were not covered by tests
createNotificationThunk(
'Unable to delete dashboard',
`Do you have write access to the '${database}' database?`
Expand All @@ -208,7 +208,7 @@
}
);
} catch (e) {
dispatch(createNotificationThunk('Unable to delete dashboard from Neo4j', e));

Check warning on line 211 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L211

Added line #L211 was not covered by tests
}
};

Expand All @@ -221,9 +221,9 @@
query,
{ uuid: uuid },
1,
(status) => {

Check warning on line 224 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L224

Added line #L224 was not covered by tests
if (status == QueryStatus.NO_DATA) {
dispatch(

Check warning on line 226 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L226

Added line #L226 was not covered by tests
createNotificationThunk(
`Unable to load dashboard from database '${database}'.`,
`A dashboard with UUID '${uuid}' does not exist.`
Expand All @@ -239,8 +239,8 @@
`A dashboard with UUID '${uuid}' could not be loaded.`
)
);
} else {
callback(records[0]._fields[0]);

Check warning on line 243 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L242-L243

Added lines #L242 - L243 were not covered by tests
}
}
);
Expand All @@ -259,9 +259,9 @@
query,
{ name: name },
1,
(status) => {

Check warning on line 262 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L262

Added line #L262 was not covered by tests
if (status == QueryStatus.NO_DATA) {
dispatch(

Check warning on line 264 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L264

Added line #L264 was not covered by tests
createNotificationThunk(
'Unable to load dashboard.',
'A dashboard with the provided name could not be found.'
Expand Down Expand Up @@ -307,7 +307,7 @@
callback([]);
return;
}
const result = records.map((r, index) => {

Check warning on line 310 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L310

Added line #L310 was not covered by tests
return {
uuid: r._fields[0],
title: r._fields[1],
Expand All @@ -330,7 +330,7 @@
runCypherQuery(
driver,
'system',
'SHOW DATABASES yield name RETURN DISTINCT name',
'SHOW DATABASES yield name, currentStatus WHERE currentStatus = "online" RETURN DISTINCT name',
{},
1000,
() => {},
Expand All @@ -355,16 +355,16 @@

export function upgradeDashboardVersion(dashboard: any, origin: string, target: string) {
if (origin == '2.3' && target == '2.4') {
dashboard.pages.forEach((p) => {
p.reports.forEach((r) => {
r.x *= 2;
r.y *= 2;
r.width *= 2;
r.height *= 2;

Check warning on line 363 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L358-L363

Added lines #L358 - L363 were not covered by tests
});
});
dashboard.version = '2.4';
return dashboard;

Check warning on line 367 in src/dashboard/DashboardThunks.ts

View check run for this annotation

Codecov / codecov/patch

src/dashboard/DashboardThunks.ts#L366-L367

Added lines #L366 - L367 were not covered by tests
}
// In 2.3 uuids were created, as well as a new format for specificing extensions.
if (origin == '2.2' && target == '2.3') {
Expand Down
Loading