mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-17 06:52:59 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
@@ -98,13 +98,13 @@ const AddUser = (props) => {
|
|||||||
.then((data) => dispatchPageChange(data, 0))
|
.then((data) => dispatchPageChange(data, 0))
|
||||||
.then(() => history.push("/"))
|
.then(() => history.push("/"))
|
||||||
.catch(() =>
|
.catch(() =>
|
||||||
setErrorAlert(`Failed to update users.`)
|
setErrorAlert(`Failed to update users.`),
|
||||||
)
|
)
|
||||||
: setErrorAlert(
|
: setErrorAlert(
|
||||||
`Failed to create user. ${
|
`Failed to create user. ${
|
||||||
data.status == 409 ? "User already exists." : ""
|
data.status == 409 ? "User already exists." : ""
|
||||||
}`
|
}`,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.catch(() => setErrorAlert(`Failed to create user.`));
|
.catch(() => setErrorAlert(`Failed to create user.`));
|
||||||
}}
|
}}
|
||||||
|
@@ -131,7 +131,7 @@ test("Shows a more specific UI error dialogue when user creation returns an impr
|
|||||||
});
|
});
|
||||||
|
|
||||||
let errorDialog = screen.getByText(
|
let errorDialog = screen.getByText(
|
||||||
"Failed to create user. User already exists."
|
"Failed to create user. User already exists.",
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(errorDialog).toBeVisible();
|
expect(errorDialog).toBeVisible();
|
||||||
|
@@ -81,14 +81,14 @@ const CreateGroup = (props) => {
|
|||||||
.then((data) => dispatchPageUpdate(data, 0))
|
.then((data) => dispatchPageUpdate(data, 0))
|
||||||
.then(() => history.push("/groups"))
|
.then(() => history.push("/groups"))
|
||||||
.catch(() =>
|
.catch(() =>
|
||||||
setErrorAlert(`Could not update groups list.`)
|
setErrorAlert(`Could not update groups list.`),
|
||||||
)
|
)
|
||||||
: setErrorAlert(
|
: setErrorAlert(
|
||||||
`Failed to create group. ${
|
`Failed to create group. ${
|
||||||
data.status == 409
|
data.status == 409
|
||||||
? "Group already exists."
|
? "Group already exists."
|
||||||
: ""
|
: ""
|
||||||
}`
|
}`,
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch(() => setErrorAlert(`Failed to create group.`));
|
.catch(() => setErrorAlert(`Failed to create group.`));
|
||||||
|
@@ -107,7 +107,7 @@ test("Shows a more specific UI error dialogue when user creation returns an impr
|
|||||||
});
|
});
|
||||||
|
|
||||||
let errorDialog = screen.getByText(
|
let errorDialog = screen.getByText(
|
||||||
"Failed to create group. Group already exists."
|
"Failed to create group. Group already exists.",
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(errorDialog).toBeVisible();
|
expect(errorDialog).toBeVisible();
|
||||||
|
@@ -96,8 +96,8 @@ const EditUser = (props) => {
|
|||||||
.then(() => history.push("/"))
|
.then(() => history.push("/"))
|
||||||
.catch(() =>
|
.catch(() =>
|
||||||
setErrorAlert(
|
setErrorAlert(
|
||||||
`Could not update users list.`
|
`Could not update users list.`,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
: setErrorAlert(`Failed to edit user.`);
|
: setErrorAlert(`Failed to edit user.`);
|
||||||
})
|
})
|
||||||
@@ -129,7 +129,7 @@ const EditUser = (props) => {
|
|||||||
editUser(
|
editUser(
|
||||||
username,
|
username,
|
||||||
updatedUsername != "" ? updatedUsername : username,
|
updatedUsername != "" ? updatedUsername : username,
|
||||||
admin
|
admin,
|
||||||
)
|
)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
data.status < 300
|
data.status < 300
|
||||||
@@ -137,7 +137,7 @@ const EditUser = (props) => {
|
|||||||
.then((data) => dispatchPageChange(data, 0))
|
.then((data) => dispatchPageChange(data, 0))
|
||||||
.then(() => history.push("/"))
|
.then(() => history.push("/"))
|
||||||
.catch(() =>
|
.catch(() =>
|
||||||
setErrorAlert(`Could not update users list.`)
|
setErrorAlert(`Could not update users list.`),
|
||||||
)
|
)
|
||||||
: setErrorAlert(`Failed to edit user.`);
|
: setErrorAlert(`Failed to edit user.`);
|
||||||
})
|
})
|
||||||
|
@@ -94,10 +94,10 @@ const GroupEdit = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let new_users = selected.filter(
|
let new_users = selected.filter(
|
||||||
(e) => !group_data.users.includes(e)
|
(e) => !group_data.users.includes(e),
|
||||||
);
|
);
|
||||||
let removed_users = group_data.users.filter(
|
let removed_users = group_data.users.filter(
|
||||||
(e) => !selected.includes(e)
|
(e) => !selected.includes(e),
|
||||||
);
|
);
|
||||||
|
|
||||||
let promiseQueue = [];
|
let promiseQueue = [];
|
||||||
@@ -105,7 +105,7 @@ const GroupEdit = (props) => {
|
|||||||
promiseQueue.push(addToGroup(new_users, group_data.name));
|
promiseQueue.push(addToGroup(new_users, group_data.name));
|
||||||
if (removed_users.length > 0)
|
if (removed_users.length > 0)
|
||||||
promiseQueue.push(
|
promiseQueue.push(
|
||||||
removeFromGroup(removed_users, group_data.name)
|
removeFromGroup(removed_users, group_data.name),
|
||||||
);
|
);
|
||||||
|
|
||||||
Promise.all(promiseQueue)
|
Promise.all(promiseQueue)
|
||||||
|
@@ -90,7 +90,7 @@ const GroupSelect = (props) => {
|
|||||||
>
|
>
|
||||||
{e}
|
{e}
|
||||||
</div>
|
</div>
|
||||||
)
|
),
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -37,7 +37,7 @@ const Groups = (props) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateGroups(offset, limit).then((data) =>
|
updateGroups(offset, limit).then((data) =>
|
||||||
dispatchPageUpdate(data.items, data._pagination)
|
dispatchPageUpdate(data.items, data._pagination),
|
||||||
);
|
);
|
||||||
}, [offset, limit]);
|
}, [offset, limit]);
|
||||||
|
|
||||||
|
@@ -38,11 +38,11 @@ const ServerDashboard = (props) => {
|
|||||||
adminAsc = (e) => e.sort((a) => (a.admin ? 1 : -1)),
|
adminAsc = (e) => e.sort((a) => (a.admin ? 1 : -1)),
|
||||||
dateDesc = (e) =>
|
dateDesc = (e) =>
|
||||||
e.sort((a, b) =>
|
e.sort((a, b) =>
|
||||||
new Date(a.last_activity) - new Date(b.last_activity) > 0 ? -1 : 1
|
new Date(a.last_activity) - new Date(b.last_activity) > 0 ? -1 : 1,
|
||||||
),
|
),
|
||||||
dateAsc = (e) =>
|
dateAsc = (e) =>
|
||||||
e.sort((a, b) =>
|
e.sort((a, b) =>
|
||||||
new Date(a.last_activity) - new Date(b.last_activity) > 0 ? 1 : -1
|
new Date(a.last_activity) - new Date(b.last_activity) > 0 ? 1 : -1,
|
||||||
),
|
),
|
||||||
runningAsc = (e) => e.sort((a) => (a.server == null ? -1 : 1)),
|
runningAsc = (e) => e.sort((a) => (a.server == null ? -1 : 1)),
|
||||||
runningDesc = (e) => e.sort((a) => (a.server == null ? 1 : -1));
|
runningDesc = (e) => e.sort((a) => (a.server == null ? 1 : -1));
|
||||||
@@ -136,7 +136,7 @@ const ServerDashboard = (props) => {
|
|||||||
dispatchPageUpdate(
|
dispatchPageUpdate(
|
||||||
data.items,
|
data.items,
|
||||||
data._pagination,
|
data._pagination,
|
||||||
name_filter
|
name_filter,
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@@ -176,7 +176,7 @@ const ServerDashboard = (props) => {
|
|||||||
dispatchPageUpdate(
|
dispatchPageUpdate(
|
||||||
data.items,
|
data.items,
|
||||||
data._pagination,
|
data._pagination,
|
||||||
name_filter
|
name_filter,
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@@ -471,7 +471,7 @@ const ServerDashboard = (props) => {
|
|||||||
failedServers.length > 1 ? "servers" : "server"
|
failedServers.length > 1 ? "servers" : "server"
|
||||||
}. ${
|
}. ${
|
||||||
failedServers.length > 1 ? "Are they " : "Is it "
|
failedServers.length > 1 ? "Are they " : "Is it "
|
||||||
} already running?`
|
} already running?`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
@@ -482,11 +482,11 @@ const ServerDashboard = (props) => {
|
|||||||
dispatchPageUpdate(
|
dispatchPageUpdate(
|
||||||
data.items,
|
data.items,
|
||||||
data._pagination,
|
data._pagination,
|
||||||
name_filter
|
name_filter,
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch(() =>
|
.catch(() =>
|
||||||
setErrorAlert(`Failed to update users list.`)
|
setErrorAlert(`Failed to update users list.`),
|
||||||
);
|
);
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
@@ -511,7 +511,7 @@ const ServerDashboard = (props) => {
|
|||||||
failedServers.length > 1 ? "servers" : "server"
|
failedServers.length > 1 ? "servers" : "server"
|
||||||
}. ${
|
}. ${
|
||||||
failedServers.length > 1 ? "Are they " : "Is it "
|
failedServers.length > 1 ? "Are they " : "Is it "
|
||||||
} already stopped?`
|
} already stopped?`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
@@ -522,11 +522,11 @@ const ServerDashboard = (props) => {
|
|||||||
dispatchPageUpdate(
|
dispatchPageUpdate(
|
||||||
data.items,
|
data.items,
|
||||||
data._pagination,
|
data._pagination,
|
||||||
name_filter
|
name_filter,
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch(() =>
|
.catch(() =>
|
||||||
setErrorAlert(`Failed to update users list.`)
|
setErrorAlert(`Failed to update users list.`),
|
||||||
);
|
);
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
|
@@ -369,7 +369,7 @@ test("Shows a UI error dialogue when start all servers fails", async () => {
|
|||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
</Provider>
|
</Provider>,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -403,7 +403,7 @@ test("Shows a UI error dialogue when stop all servers fails", async () => {
|
|||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
</Provider>
|
</Provider>,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -437,7 +437,7 @@ test("Shows a UI error dialogue when start user server fails", async () => {
|
|||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
</Provider>
|
</Provider>,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -471,7 +471,7 @@ test("Shows a UI error dialogue when start user server returns an improper statu
|
|||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
</Provider>
|
</Provider>,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -505,7 +505,7 @@ test("Shows a UI error dialogue when stop user servers fails", async () => {
|
|||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
</Provider>
|
</Provider>,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -539,7 +539,7 @@ test("Shows a UI error dialogue when stop user server returns an improper status
|
|||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
</Provider>
|
</Provider>,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -585,7 +585,7 @@ test("Search for user calls updateUsers with name filter", async () => {
|
|||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
</Provider>
|
</Provider>,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -7,11 +7,11 @@ const withAPI = withProps(() => ({
|
|||||||
`/users?include_stopped_servers&offset=${offset}&limit=${limit}&name_filter=${
|
`/users?include_stopped_servers&offset=${offset}&limit=${limit}&name_filter=${
|
||||||
name_filter || ""
|
name_filter || ""
|
||||||
}`,
|
}`,
|
||||||
"GET"
|
"GET",
|
||||||
).then((data) => data.json()),
|
).then((data) => data.json()),
|
||||||
updateGroups: (offset, limit) =>
|
updateGroups: (offset, limit) =>
|
||||||
jhapiRequest(`/groups?offset=${offset}&limit=${limit}`, "GET").then(
|
jhapiRequest(`/groups?offset=${offset}&limit=${limit}`, "GET").then(
|
||||||
(data) => data.json()
|
(data) => data.json(),
|
||||||
),
|
),
|
||||||
shutdownHub: () => jhapiRequest("/shutdown", "POST"),
|
shutdownHub: () => jhapiRequest("/shutdown", "POST"),
|
||||||
startServer: (name, serverName = "") =>
|
startServer: (name, serverName = "") =>
|
||||||
|
@@ -41,10 +41,10 @@ module.exports = {
|
|||||||
const app = devServer.app;
|
const app = devServer.app;
|
||||||
|
|
||||||
var user_data = JSON.parse(
|
var user_data = JSON.parse(
|
||||||
'[{"kind":"user","name":"foo","admin":true,"groups":[],"server":"/user/foo/","pending":null,"created":"2020-12-07T18:46:27.112695Z","last_activity":"2020-12-07T21:00:33.336354Z","servers":{"":{"name":"","last_activity":"2020-12-07T20:58:02.437408Z","started":"2020-12-07T20:58:01.508266Z","pending":null,"ready":true,"state":{"pid":28085},"url":"/user/foo/","user_options":{},"progress_url":"/hub/api/users/foo/server/progress"}}},{"kind":"user","name":"bar","admin":false,"groups":[],"server":null,"pending":null,"created":"2020-12-07T18:46:27.115528Z","last_activity":"2020-12-07T20:43:51.013613Z","servers":{}}]'
|
'[{"kind":"user","name":"foo","admin":true,"groups":[],"server":"/user/foo/","pending":null,"created":"2020-12-07T18:46:27.112695Z","last_activity":"2020-12-07T21:00:33.336354Z","servers":{"":{"name":"","last_activity":"2020-12-07T20:58:02.437408Z","started":"2020-12-07T20:58:01.508266Z","pending":null,"ready":true,"state":{"pid":28085},"url":"/user/foo/","user_options":{},"progress_url":"/hub/api/users/foo/server/progress"}}},{"kind":"user","name":"bar","admin":false,"groups":[],"server":null,"pending":null,"created":"2020-12-07T18:46:27.115528Z","last_activity":"2020-12-07T20:43:51.013613Z","servers":{}}]',
|
||||||
);
|
);
|
||||||
var group_data = JSON.parse(
|
var group_data = JSON.parse(
|
||||||
'[{"kind":"group","name":"testgroup","users":[]}, {"kind":"group","name":"testgroup2","users":["foo", "bar"]}]'
|
'[{"kind":"group","name":"testgroup","users":[]}, {"kind":"group","name":"testgroup2","users":["foo", "bar"]}]',
|
||||||
);
|
);
|
||||||
|
|
||||||
// get user_data
|
// get user_data
|
||||||
|
@@ -5,7 +5,7 @@ require(["jquery", "moment", "jhapi", "utils"], function (
|
|||||||
$,
|
$,
|
||||||
moment,
|
moment,
|
||||||
JHAPI,
|
JHAPI,
|
||||||
utils
|
utils,
|
||||||
) {
|
) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ require(["jquery", "moment", "jhapi", "utils"], function (
|
|||||||
var serverName = row.data("server-name");
|
var serverName = row.data("server-name");
|
||||||
el.attr(
|
el.attr(
|
||||||
"href",
|
"href",
|
||||||
utils.url_path_join(prefix, "user", user, serverName) + "/"
|
utils.url_path_join(prefix, "user", user, serverName) + "/",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ require(["jquery", "moment", "jhapi", "utils"], function (
|
|||||||
var serverName = row.data("server-name");
|
var serverName = row.data("server-name");
|
||||||
el.attr(
|
el.attr(
|
||||||
"href",
|
"href",
|
||||||
utils.url_path_join(prefix, "hub/spawn", user, serverName)
|
utils.url_path_join(prefix, "hub/spawn", user, serverName),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
// cannot start all servers in this case
|
// cannot start all servers in this case
|
||||||
@@ -187,7 +187,7 @@ require(["jquery", "moment", "jhapi", "utils"], function (
|
|||||||
success: function () {
|
success: function () {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -241,7 +241,7 @@ require(["jquery", "moment", "jhapi", "utils"], function (
|
|||||||
success: function () {
|
success: function () {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -38,7 +38,7 @@ define(["jquery", "utils"], function ($, utils) {
|
|||||||
var url = utils.url_path_join(
|
var url = utils.url_path_join(
|
||||||
this.base_url,
|
this.base_url,
|
||||||
"api",
|
"api",
|
||||||
utils.encode_uri_components(path)
|
utils.encode_uri_components(path),
|
||||||
);
|
);
|
||||||
$.ajax(url, options);
|
$.ajax(url, options);
|
||||||
};
|
};
|
||||||
@@ -54,7 +54,7 @@ define(["jquery", "utils"], function ($, utils) {
|
|||||||
options = update(options, { type: "POST", dataType: null });
|
options = update(options, { type: "POST", dataType: null });
|
||||||
this.api_request(
|
this.api_request(
|
||||||
utils.url_path_join("users", user, "servers", server_name),
|
utils.url_path_join("users", user, "servers", server_name),
|
||||||
options
|
options,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ define(["jquery", "utils"], function ($, utils) {
|
|||||||
options = update(options, { type: "DELETE", dataType: null });
|
options = update(options, { type: "DELETE", dataType: null });
|
||||||
this.api_request(
|
this.api_request(
|
||||||
utils.url_path_join("users", user, "servers", server_name),
|
utils.url_path_join("users", user, "servers", server_name),
|
||||||
options
|
options,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ define(["jquery", "utils"], function ($, utils) {
|
|||||||
|
|
||||||
this.api_request(
|
this.api_request(
|
||||||
utils.url_path_join("users", user, "admin-access"),
|
utils.url_path_join("users", user, "admin-access"),
|
||||||
options
|
options,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ define(["jquery", "utils"], function ($, utils) {
|
|||||||
options = update(options, { type: "DELETE" });
|
options = update(options, { type: "DELETE" });
|
||||||
this.api_request(
|
this.api_request(
|
||||||
utils.url_path_join("users", user, "tokens", token_id),
|
utils.url_path_join("users", user, "tokens", token_id),
|
||||||
options
|
options,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@ require(["jquery", "jhapi", "moment"], function ($, JHAPI, moment) {
|
|||||||
$("#token-result").text(reply.token);
|
$("#token-result").text(reply.token);
|
||||||
$("#token-area").show();
|
$("#token-area").show();
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@@ -73,7 +73,7 @@ define(["jquery"], function ($) {
|
|||||||
ua = navigator.userAgent,
|
ua = navigator.userAgent,
|
||||||
tem;
|
tem;
|
||||||
var M = ua.match(
|
var M = ua.match(
|
||||||
/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i
|
/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i,
|
||||||
);
|
);
|
||||||
if (M && (tem = ua.match(/version\/([\.\d]+)/i)) !== null) M[2] = tem[1];
|
if (M && (tem = ua.match(/version\/([\.\d]+)/i)) !== null) M[2] = tem[1];
|
||||||
M = M ? [M[1], M[2]] : [N, navigator.appVersion, "-?"];
|
M = M ? [M[1], M[2]] : [N, navigator.appVersion, "-?"];
|
||||||
|
Reference in New Issue
Block a user