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
41 changes: 38 additions & 3 deletions web/messages/en/modal.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"modal_change_password_title": "Change password",
"modal_change_password_submit": "Change password",
"modal_delete_authorized_app_title": "Delete authorized app",
"modal_delete_authorized_app_content_1": "Are you sure you want to remove this application? If you do, you won't be able to use it to log in with defguard anymore.",
"modal_delete_authorized_app_content_2": "Please note: until you log out from this application, it will remain signed in with DefGuard.",
"modal_delete_authorized_app": "Are you sure you want to remove this application? This action cannot be undone.",
"modal_delete_logstream_destination": " Are you sure you want to delete this activity log destination? All related logs will stop being sent to this location. This action cannot be undone.",
"modal_delete_gateway_title": "Delete Gateway",
"modal_delete_gateway_body": "Deleting gateway {name} may cause location {locationName} to stop working if it is the only Gateway connected to this location or if other connected Gateways are currently unavailable. This action cannot be undone.",
Expand All @@ -14,10 +13,16 @@
"modal_delete_network_device_body": "Are you sure you want to delete this device? This action cannot be undone.",
"modal_delete_user_title": "Delete user",
"modal_delete_user_body": "Are you sure you want to delete user {name}? This action cannot be undone.",
"modal_delete_user_success": "User deleted",
"modal_delete_user_error": "Failed to delete user",
"modal_delete_edge_title": "Delete edge",
"modal_delete_edge_body": "Are you sure you want to delete edge {name}? This action cannot be undone.",
"modal_delete_edge_success": "Edge deleted",
"modal_delete_edge_error": "Failed to delete edge",
"modal_delete_group_title": "Delete group",
"modal_delete_group_body": "Are you sure you want to delete group {name}? This action cannot be undone.",
"modal_delete_group_success": "Group deleted",
"modal_delete_group_error": "Failed to delete group",
"modal_delete_user_device_title": "Delete device",
"modal_delete_user_device_body": "Are you sure you want to delete the {name} device? This action cannot be undone.",
"modal_delete_openid_client_title": "Delete application",
Expand Down Expand Up @@ -168,5 +173,35 @@
"modal_assign_user_device_ip_error": "Failed to update IP addresses",
"modal_no_available_locations_title": "Cannot add network device",
"modal_no_available_locations_body": "Network devices can only be added to locations that have MFA disabled. You don't have any locations that meet this requirement. You can create a new location in the Locations section.",
"modal_no_available_locations_go_to_locations": "Go to locations"
"modal_no_available_locations_go_to_locations": "Go to locations",
"modal_disable_mfa_email_title": "Disable Email MFA",
"modal_disable_mfa_email_content": "Are you sure you want to disable Email MFA method? This action cannot be undone.",
"modal_disable_mfa_email_success": "Email MFA disabled",
"modal_disable_mfa_email_error": "Failed to disable Email MFA",
"modal_disable_mfa_totp_title": "Disable TOTP",
"modal_disable_mfa_totp_content": "Are you sure you want to disable Time-based One-Time Password authentication method? This action cannot be undone.",
"modal_disable_mfa_totp_success": "TOTP disabled",
"modal_disable_mfa_totp_error": "Failed to disable TOTP",
"modal_disable_mfa_passkeys_title": "Delete all Passkeys",
"modal_disable_mfa_passkeys_content": "Are you sure you want to delete all passkeys? This action cannot be undone.",
"modal_disable_mfa_passkeys_success": "All passkeys deleted",
"modal_disable_mfa_passkeys_error": "Failed to delete passkeys",
"modal_disable_mfa_all_title": "Disable all MFA",
"modal_disable_mfa_all_content": "Are you sure you want to disable all MFA methods? This will remove all configured MFA methods and recovery codes.",
"modal_disable_mfa_all_success": "MFA disabled",
"modal_disable_mfa_all_error": "Failed to disable MFA",
"modal_delete_mfa_passkey_title": "Delete passkey",
"modal_delete_mfa_passkey_content": "Are you sure you want to delete passkey {name}? This action cannot be undone.",
"modal_delete_mfa_passkey_success": "Passkey deleted",
"modal_delete_mfa_passkey_error": "Failed to delete passkey",
"modal_delete_auth_key_title": "Delete authentication key",
"modal_delete_auth_key_content": "Are you sure you want to delete authentication key {name}? This action cannot be undone.",
"modal_delete_auth_key_success": "Authentication key deleted",
"modal_delete_auth_key_error": "Failed to delete authentication key",
"modal_delete_api_token_title": "Delete API token",
"modal_delete_api_token_content": "Are you sure you want to delete API token {name}? This action cannot be undone.",
"modal_delete_api_token_success": "API token deleted",
"modal_delete_api_token_error": "Failed to delete API token",
"modal_delete_authorized_app_success": "Application removed",
"modal_delete_authorized_app_error": "Failed to remove application"
}
1 change: 1 addition & 0 deletions web/messages/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"settings_activity_log_streaming_no_upstreams_subtitle": "Click the button below to add an activity log provider and start streaming events.",
"settings_activity_log_streaming_add_log_streaming_button": "Add log streaming.",
"settings_activity_log_streaming_delete_log_streaming_title": "Delete destination confirmation",
"settings_activity_log_streaming_delete_log_streaming_success": "Log stream destination deleted",
"settings_activity_log_streaming_delete_log_streaming_failed": "Failed to delete log stream destination.",
"settings_activity_log_streaming_table_title": "All log streams",
"settings_activity_log_streaming_table_header_name": "Name",
Expand Down
10 changes: 9 additions & 1 deletion web/messages/en/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@
"users_row_menu_initiate_self_enrollment": "Initiate self-enrollment",
"users_row_menu_ip_settings": "User devices IP settings",
"users_modal_disable_mfa_title": "Disable MFA",
"users_modal_disable_mfa_content": "Are you sure you want to disable MFA for **{name}**? This will remove all configured MFA methods and recovery codes.",
"users_modal_disable_mfa_content": "Are you sure you want to disable MFA for {name}? This will remove all configured MFA methods and recovery codes.",
"users_disable_mfa_success": "MFA disabled",
"users_disable_mfa_error": "Failed to disable MFA",
"users_modal_disable_title": "Disable account",
"users_modal_disable_content": "Are you sure you want to disable {name} account?",
"users_disable_success": "Account disabled",
"users_disable_error": "Failed to disable account",
"users_modal_enable_title": "Enable account",
"users_modal_enable_content": "Are you sure you want to enable {name} account?",
"users_enable_success": "Account enabled",
"users_enable_error": "Failed to enable account",
"modal_edit_user_groups_title": "Edit user groups"
}
3 changes: 3 additions & 0 deletions web/src/pages/EdgesPage/EdgesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { TableBody } from '../../shared/defguard-ui/components/table/TableBody/T
import { TableCell } from '../../shared/defguard-ui/components/table/TableCell/TableCell';
import { TableEditCell } from '../../shared/defguard-ui/components/table/TableEditCell/TableEditCell';
import { TableTop } from '../../shared/defguard-ui/components/table/TableTop/TableTop';
import { Snackbar } from '../../shared/defguard-ui/providers/snackbar/snackbar';
import { isPresent } from '../../shared/defguard-ui/utils/isPresent';
import { openModal } from '../../shared/hooks/modalControls/modalsSubjects';
import { ModalName } from '../../shared/hooks/modalControls/modalTypes';
Expand Down Expand Up @@ -240,6 +241,8 @@ export const EdgesTable = () => {
actionPromise: () => api.edge.deleteEdge(rowData.id),
invalidateKeys: [['edge']],
submitProps: { text: m.controls_delete(), variant: 'critical' },
onSuccess: () => Snackbar.default(m.modal_delete_edge_success()),
onError: () => Snackbar.error(m.modal_delete_edge_error()),
});
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { TableBody } from '../../../../shared/defguard-ui/components/table/Table
import { TableCell } from '../../../../shared/defguard-ui/components/table/TableCell/TableCell';
import { TableEditCell } from '../../../../shared/defguard-ui/components/table/TableEditCell/TableEditCell';
import { TableTop } from '../../../../shared/defguard-ui/components/table/TableTop/TableTop';
import { Snackbar } from '../../../../shared/defguard-ui/providers/snackbar/snackbar';
import { openModal } from '../../../../shared/hooks/modalControls/modalsSubjects';
import { ModalName } from '../../../../shared/hooks/modalControls/modalTypes';

Expand Down Expand Up @@ -122,6 +123,8 @@ export const GroupsTable = ({ groups, users }: Props) => {
actionPromise: () => api.group.deleteGroup(rowData.name),
invalidateKeys: [['group'], ['group-info']],
submitProps: { text: m.controls_delete(), variant: 'critical' },
onSuccess: () => Snackbar.default(m.modal_delete_group_success()),
onError: () => Snackbar.error(m.modal_delete_group_error()),
});
},
},
Expand Down
48 changes: 36 additions & 12 deletions web/src/pages/UsersOverviewPage/UsersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ export const UsersTable = () => {
[groups?.map, groups],
);

const { mutate: changeAccountActiveState } = useMutation({
mutationFn: api.user.activeStateChange,
meta: {
invalidate: [['user-overview'], ['user']],
},
});

const { mutate: editUser } = useMutation({
mutationFn: api.user.editUser,
meta: {
Expand Down Expand Up @@ -263,10 +256,40 @@ export const UsersTable = () => {
icon: rowData.is_active ? 'disabled' : 'check-circle',
testId: 'change-account-status',
onClick: () => {
changeAccountActiveState({
active: !rowData.is_active,
username: rowData.username,
});
if (rowData.is_active) {
openModal(ModalName.ConfirmAction, {
title: m.users_modal_disable_title(),
contentMd: m.users_modal_disable_content({ name: rowData.name }),
actionPromise: () =>
api.user.activeStateChange({
active: false,
username: rowData.username,
}),
invalidateKeys: [['user-overview'], ['user']],
submitProps: {
text: m.users_row_menu_disable(),
variant: 'critical',
},
onSuccess: () => Snackbar.default(m.users_disable_success()),
onError: () => Snackbar.error(m.users_disable_error()),
});
} else {
openModal(ModalName.ConfirmAction, {
title: m.users_modal_enable_title(),
contentMd: m.users_modal_enable_content({ name: rowData.name }),
actionPromise: () =>
api.user.activeStateChange({
active: true,
username: rowData.username,
}),
invalidateKeys: [['user-overview'], ['user']],
submitProps: {
text: m.users_row_menu_enable(),
},
onSuccess: () => Snackbar.default(m.users_enable_success()),
onError: () => Snackbar.error(m.users_enable_error()),
});
}
},
},
],
Expand Down Expand Up @@ -370,6 +393,8 @@ export const UsersTable = () => {
text: m.users_row_menu_delete(),
variant: 'critical',
},
onSuccess: () => Snackbar.default(m.modal_delete_user_success()),
onError: () => Snackbar.error(m.modal_delete_user_error()),
});
},
},
Expand Down Expand Up @@ -455,7 +480,6 @@ export const UsersTable = () => {
navigate,
reservedEmails,
reservedUsernames,
changeAccountActiveState,
groupsOptions,
handleEditGroups,
groups,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export const ActivityLogStreamTable = ({ data: rowData }: Props) => {
actionPromise: () => api.activityLogStream.deleteStream(row.id),
invalidateKeys: [['activity_log_stream']],
submitProps: { text: m.controls_delete(), variant: 'critical' },
onSuccess: () =>
Snackbar.default(
m.settings_activity_log_streaming_delete_log_streaming_success(),
),
onError: () =>
Snackbar.error(
m.settings_activity_log_streaming_delete_log_streaming_failed(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useMutation } from '@tanstack/react-query';
import {
createColumnHelper,
getCoreRowModel,
Expand All @@ -13,6 +12,7 @@ import { tableEditColumnSize } from '../../../../../../../shared/defguard-ui/com
import { TableBody } from '../../../../../../../shared/defguard-ui/components/table/TableBody/TableBody';
import { TableCell } from '../../../../../../../shared/defguard-ui/components/table/TableCell/TableCell';
import { TableEditCell } from '../../../../../../../shared/defguard-ui/components/table/TableEditCell/TableEditCell';
import { Snackbar } from '../../../../../../../shared/defguard-ui/providers/snackbar/snackbar';
import { openModal } from '../../../../../../../shared/hooks/modalControls/modalsSubjects';
import { ModalName } from '../../../../../../../shared/hooks/modalControls/modalTypes';
import { tableSortingFns } from '../../../../../../../shared/utils/dateSortingFn';
Expand All @@ -27,13 +27,6 @@ export const ProfileApiTokensTable = () => {
const username = useUserProfile((s) => s.user.username);
const data = useUserProfile((s) => s.apiTokens);

const { mutate: deleteApiToken } = useMutation({
mutationFn: api.user.deleteApiToken,
meta: {
invalidate: [['user-overview'], ['user', username, 'api_token']],
},
});

const columns = useMemo(
() => [
columnHelper.accessor('name', {
Expand Down Expand Up @@ -92,9 +85,21 @@ export const ProfileApiTokensTable = () => {
variant: 'danger',
text: m.controls_delete(),
onClick: () => {
deleteApiToken({
id: rowData.id,
username,
openModal(ModalName.ConfirmAction, {
title: m.modal_delete_api_token_title(),
contentMd: m.modal_delete_api_token_content({
name: rowData.name,
}),
actionPromise: () =>
api.user.deleteApiToken({ id: rowData.id, username }),
invalidateKeys: [
['user-overview'],
['user', username, 'api_token'],
],
submitProps: { text: m.controls_delete(), variant: 'critical' },
onSuccess: () =>
Snackbar.default(m.modal_delete_api_token_success()),
onError: () => Snackbar.error(m.modal_delete_api_token_error()),
});
},
},
Expand All @@ -106,7 +111,7 @@ export const ProfileApiTokensTable = () => {
},
}),
],
[deleteApiToken, username],
[username],
);

const table = useReactTable({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useMutation } from '@tanstack/react-query';
import {
createColumnHelper,
getCoreRowModel,
Expand All @@ -19,6 +18,7 @@ import { TableBody } from '../../../../../shared/defguard-ui/components/table/Ta
import { TableCell } from '../../../../../shared/defguard-ui/components/table/TableCell/TableCell';
import { TableEditCell } from '../../../../../shared/defguard-ui/components/table/TableEditCell/TableEditCell';
import { useClipboard } from '../../../../../shared/defguard-ui/hooks/useClipboard';
import { Snackbar } from '../../../../../shared/defguard-ui/providers/snackbar/snackbar';
import { isPresent } from '../../../../../shared/defguard-ui/utils/isPresent';
import { openModal } from '../../../../../shared/hooks/modalControls/modalsSubjects';
import { ModalName } from '../../../../../shared/hooks/modalControls/modalTypes';
Expand Down Expand Up @@ -84,13 +84,6 @@ export const ProfileAuthKeysTable = () => {
const authKeys = useUserProfile((s) => s.authKeys);
const mapped = useMemo(() => mapData(authKeys), [authKeys]);

const { mutate: deleteAuthKey } = useMutation({
mutationFn: api.user.deleteAuthKey,
meta: {
invalidate: [['user-overview'], ['user', username, 'auth_key']],
},
});

const columns = useMemo(
() => [
columnHelper.accessor('name', {
Expand Down Expand Up @@ -188,9 +181,16 @@ export const ProfileAuthKeysTable = () => {
variant: 'danger',
text: m.controls_delete(),
onClick: () => {
deleteAuthKey({
id: rowData.id,
username,
openModal(ModalName.ConfirmAction, {
title: m.modal_delete_auth_key_title(),
contentMd: m.modal_delete_auth_key_content({ name: rowData.name }),
actionPromise: () =>
api.user.deleteAuthKey({ id: rowData.id, username }),
invalidateKeys: [['user-overview'], ['user', username, 'auth_key']],
submitProps: { text: m.controls_delete(), variant: 'critical' },
onSuccess: () =>
Snackbar.default(m.modal_delete_auth_key_success()),
onError: () => Snackbar.error(m.modal_delete_auth_key_error()),
});
},
},
Expand All @@ -201,7 +201,7 @@ export const ProfileAuthKeysTable = () => {
},
}),
],
[deleteAuthKey, username, writeToClipboard, mapped],
[username, writeToClipboard, mapped],
);

const table = useReactTable({
Expand Down
Loading
Loading