misc: added auto redirect to workflow settings tab

This commit is contained in:
Sheen Capadngan
2024-09-04 02:22:53 +08:00
parent 8c03c160a9
commit 5343c7af00
3 changed files with 18 additions and 4 deletions

View File

@@ -262,7 +262,7 @@ export const registerSlackRouter = async (server: FastifyZodProvider) => {
orgId: string;
};
return res.redirect(`${appCfg.SITE_URL}/org/${metadata.orgId}/settings`);
return res.redirect(`${appCfg.SITE_URL}/org/${metadata.orgId}/settings?selectedTab=workflow-integrations`);
}
});
}

View File

@@ -1,4 +1,5 @@
import { Fragment } from "react";
import { Fragment, useEffect, useState } from "react";
import { useRouter } from "next/router";
import { Tab } from "@headlessui/react";
import { AuditLogStreamsTab } from "../AuditLogStreamTab";
@@ -15,8 +16,21 @@ const tabs = [
{ name: "Audit Log Streams", key: "tag-audit-log-streams" }
];
export const OrgTabGroup = () => {
const { query } = useRouter();
const [selectedTabIndex, setSelectedTabIndex] = useState(0);
const selectedTab = query.selectedTab as string;
useEffect(() => {
if (selectedTab) {
const index = tabs.findIndex((tab) => tab.key === selectedTab);
if (index !== -1) {
setSelectedTabIndex(index);
}
}
}, [selectedTab]);
return (
<Tab.Group>
<Tab.Group selectedIndex={selectedTabIndex} onChange={setSelectedTabIndex}>
<Tab.List className="mb-6 w-full border-b-2 border-mineshaft-800">
{tabs.map((tab) => (
<Tab as={Fragment} key={tab.key}>

View File

@@ -99,7 +99,7 @@ export const WorkflowIntegrationTab = () => {
return !slackIntegrations?.length ? (
<EmptyState title="You do not have any integrations configured.">
<Link href={`/org/${currentWorkspace?.orgId}/settings?tab=workflowIntegrations`}>
<Link href={`/org/${currentWorkspace?.orgId}/settings?selectedTab=workflow-integrations`}>
<div className="mt-2 underline decoration-primary-800 underline-offset-4 duration-200 hover:cursor-pointer hover:text-mineshaft-100 hover:decoration-primary-600">
Create one now
</div>