Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi-filtering to tables; refactor details pages into tabs #63

Merged
merged 4 commits into from
Feb 26, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Handle invalid tab IDs
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
ohltyler committed Oct 23, 2023
commit be8f92c0ea0dfe222313b5ee3a5d3391875d676f
18 changes: 9 additions & 9 deletions public/pages/workflow_detail/workflow_detail.tsx
Original file line number Diff line number Diff line change
@@ -21,21 +21,18 @@ export interface WorkflowDetailRouterProps {
workflowId: string;
}

export interface WorkflowDetailProps
interface WorkflowDetailProps
extends RouteComponentProps<WorkflowDetailRouterProps> {}

export enum WORKFLOW_DETAILS_TAB {
enum WORKFLOW_DETAILS_TAB {
EDITOR = 'editor',
LAUNCHES = 'launches',
PROTOTYPE = 'prototype',
}

export const ACTIVE_TAB_PARAM = 'tab';
const ACTIVE_TAB_PARAM = 'tab';

export function replaceActiveTab(
activeTab: string,
props: WorkflowDetailProps
) {
function replaceActiveTab(activeTab: string, props: WorkflowDetailProps) {
props.history.replace({
...history,
search: queryString.stringify({
@@ -64,9 +61,12 @@ export function WorkflowDetail(props: WorkflowDetailProps) {
tabFromUrl
);

// Default to editor tab if there is none specified via url.
// Default to editor tab if there is none or invalid tab ID specified via url.
useEffect(() => {
if (!selectedTabId) {
if (
!selectedTabId ||
!Object.values(WORKFLOW_DETAILS_TAB).includes(selectedTabId)
) {
setSelectedTabId(WORKFLOW_DETAILS_TAB.EDITOR);
replaceActiveTab(WORKFLOW_DETAILS_TAB.EDITOR, props);
}
9 changes: 6 additions & 3 deletions public/pages/workflows/workflows.tsx
Original file line number Diff line number Diff line change
@@ -54,10 +54,13 @@ export function Workflows(props: WorkflowsProps) {
] as WORKFLOWS_TAB;
const [selectedTabId, setSelectedTabId] = useState<WORKFLOWS_TAB>(tabFromUrl);

// If there is no selected tab, default to a tab depending on if user
// has existing created workflows or not.
// If there is no selected tab or invalid tab, default to a tab depending
// on if user has existing created workflows or not.
useEffect(() => {
if (!selectedTabId) {
if (
!selectedTabId ||
!Object.values(WORKFLOWS_TAB).includes(selectedTabId)
) {
if (workflows?.length > 0) {
setSelectedTabId(WORKFLOWS_TAB.MANAGE);
replaceActiveTab(WORKFLOWS_TAB.MANAGE, props);