mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 14:28:20 +00:00
feat: save selected env on url
This commit is contained in:
@@ -189,6 +189,7 @@ export default function Dashboard() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
|
const { push, query } = router
|
||||||
const tempNumSnapshots = await getProjectSercetSnapshotsCount({
|
const tempNumSnapshots = await getProjectSercetSnapshotsCount({
|
||||||
workspaceId
|
workspaceId
|
||||||
});
|
});
|
||||||
@@ -196,19 +197,35 @@ export default function Dashboard() {
|
|||||||
const userWorkspaces = await getWorkspaces();
|
const userWorkspaces = await getWorkspaces();
|
||||||
const workspace = userWorkspaces.find((wp) => wp._id === workspaceId);
|
const workspace = userWorkspaces.find((wp) => wp._id === workspaceId);
|
||||||
if (!workspace) {
|
if (!workspace) {
|
||||||
router.push(`/dashboard/${userWorkspaces?.[0]?._id}`);
|
push(`/dashboard/${userWorkspaces?.[0]?._id}`);
|
||||||
}
|
}
|
||||||
setAutoCapitalization(workspace?.autoCapitalization ?? true);
|
setAutoCapitalization(workspace?.autoCapitalization ?? true);
|
||||||
|
|
||||||
const accessibleEnvironments = await getWorkspaceEnvironments({ workspaceId });
|
const accessibleEnvironments = await getWorkspaceEnvironments({ workspaceId });
|
||||||
setWorkspaceEnvs(accessibleEnvironments || []);
|
setWorkspaceEnvs(accessibleEnvironments || []);
|
||||||
|
|
||||||
// set env
|
// set env
|
||||||
const env = accessibleEnvironments?.[0] || {
|
const env = accessibleEnvironments?.[0] || {
|
||||||
name: 'unknown',
|
name: 'unknown',
|
||||||
slug: 'unkown'
|
slug: 'unknown'
|
||||||
};
|
};
|
||||||
setSelectedEnv(env);
|
setSelectedEnv(env);
|
||||||
setSelectedSnapshotEnv(env);
|
setSelectedSnapshotEnv(env);
|
||||||
|
|
||||||
|
if (query.env) {
|
||||||
|
const index = accessibleEnvironments?.findIndex(({ slug }: { slug: string }) => slug === query.env)
|
||||||
|
|
||||||
|
setSelectedEnv({
|
||||||
|
name: accessibleEnvironments?.[index]?.name as string,
|
||||||
|
slug: query.env as string
|
||||||
|
})
|
||||||
|
setSelectedSnapshotEnv({
|
||||||
|
name: accessibleEnvironments?.[index]?.name as string,
|
||||||
|
slug: query.env as string
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
const user = await getUser();
|
const user = await getUser();
|
||||||
setIsNew((Date.parse(String(new Date())) - Date.parse(user.createdAt)) / 60000 < 3);
|
setIsNew((Date.parse(String(new Date())) - Date.parse(user.createdAt)) / 60000 < 3);
|
||||||
|
|
||||||
@@ -577,6 +594,10 @@ export default function Dashboard() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setHasUnsavedChanges(false);
|
setHasUnsavedChanges(false);
|
||||||
|
router.push({
|
||||||
|
pathname: router.pathname,
|
||||||
|
query: { ...router.query, env: selectedWorkspaceEnv.slug },
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
return data ? (
|
return data ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user