Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
633281b
refactor(ui): rename InjectionKey to SnackbarInjectionKey
luizhf42 May 7, 2025
eabec76
refactor(ui): migrate view components and tests to new snackbar
luizhf42 May 7, 2025
0943c7d
refactor(ui): migrate Account components to new snackbar
luizhf42 May 7, 2025
ed802d5
refactor(ui): migrate AppBar components to new snackbar
luizhf42 May 7, 2025
17cee26
refactor(ui): migrate AuthMFA components to new snackbar
luizhf42 May 7, 2025
d8f391c
refactor(ui): migrate Box component to new snackbar
luizhf42 May 7, 2025
07dbbfb
refactor(ui): migrate Connector components to new snackbar
luizhf42 May 8, 2025
fcbd61f
refactor(ui): migrate Containers components to new snackbar
luizhf42 May 8, 2025
e3749d7
refactor(ui): migrate Device components to new snackbar
luizhf42 May 8, 2025
cfe6d42
refactor(ui): migrate Firewall components to new snackbar
luizhf42 May 8, 2025
9ab280d
refactor(ui): migrate Namespace components to new snackbar
luizhf42 May 8, 2025
d80762c
refactor(ui): migrate PrivateKey components to new snackbar
luizhf42 May 8, 2025
32cca4d
refactor(ui): migrate PublicKey components to new snackbar
luizhf42 May 8, 2025
2b1d5db
refactor(ui): migrate QuickConnection components to new snackbar
luizhf42 May 8, 2025
0c88f15
refactor(ui): migrate Session components to new snackbar
luizhf42 May 8, 2025
6d49285
refactor(ui): migrate Setting components to new snackbar
luizhf42 May 8, 2025
66369a1
refactor(ui): migrate Tables components to new snackbar
luizhf42 May 8, 2025
621acb6
refactor(ui): migrate Tags components to new snackbar
luizhf42 May 8, 2025
7af8503
refactor(ui): migrate ApiKeys components to new snackbar
luizhf42 May 8, 2025
f6f09b4
refactor(ui): migrate Member components to new snackbar
luizhf42 May 8, 2025
eaebb1a
refactor(ui): migrate Tunnel components to new snackbar
luizhf42 May 8, 2025
86b832d
refactor(ui): migrate User components to new snackbar
luizhf42 May 9, 2025
993257b
refactor(ui): migrate Welcome components to new snackbar
luizhf42 May 9, 2025
1419af9
refactor(ui): remove old snackbar code
luizhf42 May 9, 2025
abd27b3
refactor(ui): rename SnackbarNew to Snackbar
luizhf42 May 9, 2025
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
7 changes: 4 additions & 3 deletions ui/src/components/Account/AccountCreated.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
<script setup lang="ts">
import { computed, PropType, watch } from "vue";
import { useRouter, useRoute } from "vue-router";
import { INotificationsSuccess } from "@/interfaces/INotifications";
import { useStore } from "@/store";
import handleError from "@/utils/handleError";
import useSnackbar from "@/helpers/snackbar";

const props = defineProps({
messageKind: {
Expand All @@ -62,6 +62,7 @@ const emit = defineEmits(["show"]);
const store = useStore();
const router = useRouter();
const route = useRoute();
const snackbar = useSnackbar();

const token = computed(() => store.getters["users/getSignToken"]);

Expand All @@ -78,9 +79,9 @@ const buttonDataTest = computed(() => (isNormalMessage.value ? "resendEmail-btn"
const resendEmail = async () => {
try {
await store.dispatch("users/resendEmail", props.username);
store.dispatch("snackbar/showSnackbarSuccessAction", INotificationsSuccess.resendEmail);
snackbar.showSuccess("Email successfully sent.");
} catch (error) {
store.dispatch("snackbar/showSnackbarErrorDefault");
snackbar.showError("Failed to send email.");
handleError(error);
}
};
Expand Down
15 changes: 5 additions & 10 deletions ui/src/components/AppBar/Notifications/Notification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ import axios, { AxiosError } from "axios";
import { useStore } from "@/store";
import { authorizer, actions } from "@/authorizer";
import hasPermission from "@/utils/permission";
import { INotificationsError } from "@/interfaces/INotifications";
import DeviceActionButton from "@/components/Devices/DeviceActionButton.vue";
import handleError from "@/utils/handleError";
import useSnackbar from "@/helpers/snackbar";

const store = useStore();
const snackbar = useSnackbar();
defineProps({
style: {
type: [String, Object],
Expand Down Expand Up @@ -180,23 +181,17 @@ const getNotifications = async () => {
break;
}
case axiosError.response?.status === 403: {
store.dispatch("snackbar/showSnackbarErrorAssociation");
snackbar.showError("You don't have permission to view notifications.");
handleError(error);
break;
}
default: {
store.dispatch(
"snackbar/showSnackbarErrorLoading",
INotificationsError.notificationList,
);
snackbar.showError("Failed to load notifications.");
handleError(error);
}
}
} else {
store.dispatch(
"snackbar/showSnackbarErrorLoading",
INotificationsError.notificationList,
);
snackbar.showError("Failed to load notifications.");
handleError(error);
}
}
Expand Down
8 changes: 3 additions & 5 deletions ui/src/components/AuthMFA/MfaDisable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ import axios, { AxiosError } from "axios";
import { useStore } from "@/store";
import handleError from "@/utils/handleError";
import Logo from "@/assets/logo-inverted.png";
import { INotificationsSuccess } from "@/interfaces/INotifications";
import useSnackbar from "@/helpers/snackbar";

const store = useStore();
const snackbar = useSnackbar();
const verificationCode = ref("");
const recoveryCode = ref("");
const el = ref<number>(1);
Expand All @@ -188,10 +189,7 @@ const mfaValidate = async () => {
default:
break;
}
store.dispatch(
"snackbar/showSnackbarSuccessAction",
INotificationsSuccess.cancelMfa,
);
snackbar.showSuccess("MFA disabled successfully.");
showDialog.value = false;
} catch (error) {
if (axios.isAxiosError(error)) {
Expand Down
8 changes: 3 additions & 5 deletions ui/src/components/AuthMFA/MfaForceRecoveryMail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ import { useField } from "vee-validate";
import { computed, ref } from "vue";
import axios, { AxiosError } from "axios";
import { useStore } from "@/store";
import { INotificationsSuccess } from "@/interfaces/INotifications";
import handleError from "@/utils/handleError";
import useSnackbar from "@/helpers/snackbar";

const dialog = ref(false);
const store = useStore();
const snackbar = useSnackbar();
const email = computed(() => store.getters["auth/email"]);
const {
value: recoveryEmail,
Expand Down Expand Up @@ -91,10 +92,7 @@ const updateUserData = async () => {
try {
await store.dispatch("users/patchData", data);
store.dispatch("auth/changeUserData", data);
store.dispatch(
"snackbar/showSnackbarSuccessAction",
INotificationsSuccess.profileData,
);
snackbar.showSuccess("Recovery email updated successfully.");
} catch (error) {
if (axios.isAxiosError(error)) {
const axiosError = error as AxiosError;
Expand Down
13 changes: 4 additions & 9 deletions ui/src/components/AuthMFA/MfaSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,10 @@ import axios, { AxiosError } from "axios";
import { useClipboard } from "@vueuse/core";
import { useStore } from "@/store";
import handleError from "@/utils/handleError";
import { INotificationsCopy, INotificationsSuccess } from "@/interfaces/INotifications";
import useSnackbar from "@/helpers/snackbar";

const store = useStore();
const snackbar = useSnackbar();
const el = ref<number>(1);
const emit = defineEmits(["enabled", "resetForm"]);
const showDialog = defineModel({ default: false });
Expand Down Expand Up @@ -300,10 +301,7 @@ const updateUserData = async () => {
try {
await store.dispatch("users/patchData", data);
store.dispatch("auth/changeRecoveryEmail", data.recovery_email);
store.dispatch(
"snackbar/showSnackbarSuccessAction",
INotificationsSuccess.profileData,
);
snackbar.showSuccess("Recovery email updated successfully.");
emit("resetForm");
} catch (error) {
if (axios.isAxiosError(error)) {
Expand Down Expand Up @@ -349,10 +347,7 @@ const copyRecoveryCodes = () => {
const { copy } = useClipboard();
copy(codesText);

store.dispatch(
"snackbar/showSnackbarCopy",
INotificationsCopy.recoveryCodes,
);
snackbar.showInfo("Recovery codes copied to clipboard.");
};

const downloadRecoveryCodes = () => {
Expand Down
12 changes: 4 additions & 8 deletions ui/src/components/AuthMFA/RecoveryHelper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,16 @@
import { computed, onMounted, reactive, ref, watch } from "vue";
import { useStore } from "@/store";
import handleError from "@/utils/handleError";
import { INotificationsSuccess } from "@/interfaces/INotifications";
import useCountdown from "@/utils/countdownTimeout";
import useSnackbar from "@/helpers/snackbar";

const dialog = ref(false);
const checkbox = ref(false);
const invalid = reactive({ title: "", msg: "", timeout: false });
const tokenCountdownAlert = ref(true);
const isCountdownFinished = ref(false);
const store = useStore();
const snackbar = useSnackbar();
const disableTimeout = computed(() => store.getters["auth/getDisableTokenTimeout"]);
const recoveryCode = computed(() => store.getters["auth/stateRecoveryCode"]);
const { startCountdown, countdown } = useCountdown();
Expand All @@ -124,16 +125,11 @@ watch(countdown, (newValue) => {
const disableMFA = async () => {
try {
await store.dispatch("auth/disableMfa", { recovery_code: recoveryCode.value });
store.dispatch(
"snackbar/showSnackbarSuccessAction",
INotificationsSuccess.recoveryHelper,
);
snackbar.showSuccess("MFA disabled successfully.");
store.commit("auth/accountRecoveryHelper");
dialog.value = false;
} catch (error) {
store.commit(
"snackbar/setSnackbarErrorDefault",
);
snackbar.showError("An error occurred while disabling MFA.");
handleError(error);
}
};
Expand Down
14 changes: 5 additions & 9 deletions ui/src/components/Box/BoxMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ import { useStore } from "@/store";
import DeviceAdd from "../Devices/DeviceAdd.vue";
import FirewallRuleAdd from "../firewall/FirewallRuleAdd.vue";
import PublicKeyAdd from "../PublicKeys/PublicKeyAdd.vue";
import { INotificationsError } from "@/interfaces/INotifications";
import handleError from "@/utils/handleError";
import useSnackbar from "@/helpers/snackbar";

const snackbar = useSnackbar();

const items = {
device: {
Expand Down Expand Up @@ -204,10 +206,7 @@ const refreshFirewallRule = async () => {
try {
await store.dispatch("firewallRules/refresh");
} catch (error: unknown) {
store.dispatch(
"snackbar/showSnackbarErrorLoading",
INotificationsError.firewallRuleList,
);
snackbar.showError("Failed to refresh firewall rules list.");
handleError(error);
}
};
Expand All @@ -216,10 +215,7 @@ const refreshPublicKey = async () => {
try {
await store.dispatch("publicKeys/refresh");
} catch (error: unknown) {
store.dispatch(
"snackbar/showSnackbarErrorLoading",
INotificationsError.publicKeyList,
);
snackbar.showError("Failed to refresh public keys list.");
handleError(error);
}
};
Expand Down
16 changes: 4 additions & 12 deletions ui/src/components/Connector/ConnectorDelete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,9 @@

<script setup lang="ts">
import { ref } from "vue";
import {
INotificationsError,
INotificationsSuccess,
} from "@/interfaces/INotifications";
import { useStore } from "@/store";
import handleError from "@/utils/handleError";
import useSnackbar from "@/helpers/snackbar";

const props = defineProps({
uid: {
Expand All @@ -67,20 +64,15 @@ const props = defineProps({
const emit = defineEmits(["update"]);
const showDialog = ref(false);
const store = useStore();
const snackbar = useSnackbar();
const remove = async () => {
try {
await store.dispatch("connectors/remove", props.uid);
store.dispatch(
"snackbar/showSnackbarSuccessAction",
INotificationsSuccess.connectorDelete,
);
snackbar.showSuccess("Successfully removed connector.");
showDialog.value = false;
emit("update");
} catch (error: unknown) {
store.dispatch(
"snackbar/showSnackbarErrorAction",
INotificationsError.connectorDelete,
);
snackbar.showError("Failed to remove connector.");
handleError(error);
}
};
Expand Down
17 changes: 4 additions & 13 deletions ui/src/components/Connector/ConnectorForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,12 @@ import * as yup from "yup";
import { computed, ref, watch } from "vue";
import { envVariables } from "@/envVariables";
import { useStore } from "@/store";
import {
INotificationsError,
INotificationsSuccess,
} from "@/interfaces/INotifications";
import { IConnectorPayload } from "@/interfaces/IConnector";
import { parseCertificate, parsePrivateKeySsh } from "@/utils/validate";
import hasPermission from "@/utils/permission";
import { actions, authorizer } from "@/authorizer";
import handleError from "@/utils/handleError";
import useSnackbar from "@/helpers/snackbar";

const props = defineProps({
isEditing: {
Expand Down Expand Up @@ -154,7 +151,7 @@ const props = defineProps({
});

const emit = defineEmits(["update", "close"]);

const snackbar = useSnackbar();
const localDialog = ref(props.showDialog);

watch(() => props.showDialog, (newValue) => {
Expand Down Expand Up @@ -344,18 +341,12 @@ const saveConnector = async () => {
}
try {
await props.storeMethod(payload);
store.dispatch(
"snackbar/showSnackbarSuccessAction",
props.isEditing ? INotificationsSuccess.connectorEdit : INotificationsSuccess.connectorAdd,
);
snackbar.showSuccess(props.isEditing ? "Connector edited successfully" : "Connector added successfully");
emit("update");
emit("close");
localDialog.value = false;
} catch (error) {
store.dispatch(
"snackbar/showSnackbarErrorAction",
props.isEditing ? INotificationsError.connectorEdit : INotificationsError.connectorAdd,
);
snackbar.showError(props.isEditing ? "Failed to edit connector" : "Failed to add connector");
handleError(error);
}
};
Expand Down
Loading