Skip to content

Commit

Permalink
optimize fetching of some vars in header
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Oct 28, 2024
1 parent 931da78 commit c9df6f1
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions public/pages/workflow_detail/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,16 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
>();

// workflow state
const [workflowName, setWorkflowName] = useState<string>('');
const [workflowLastUpdated, setWorkflowLastUpdated] = useState<string>('');
//const [workflowName, setWorkflowName] = useState<string>('');
const workflowName = getCharacterLimitedString(
props.workflow?.name,
MAX_WORKFLOW_NAME_TO_DISPLAY
);
const workflowLastUpdated = toFormattedDate(
// @ts-ignore
props.workflow?.lastUpdated
).toString();
// const [workflowLastUpdated, setWorkflowLastUpdated] = useState<string>('');

// export modal state
const [isExportModalOpen, setIsExportModalOpen] = useState<boolean>(false);
Expand All @@ -92,27 +100,6 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
chrome: { setHeaderVariant },
} = getCore();

// get some workflow details
useEffect(() => {
if (props.workflow) {
setWorkflowName(
getCharacterLimitedString(
props.workflow.name,
MAX_WORKFLOW_NAME_TO_DISPLAY
)
);
try {
const formattedDate = toFormattedDate(
// @ts-ignore
props.workflow.lastUpdated
).toString();
setWorkflowLastUpdated(formattedDate);
} catch (err) {
setWorkflowLastUpdated('');
}
}
}, [props.workflow]);

// When NewHomePage is enabled, use 'application' HeaderVariant; otherwise, use 'page' HeaderVariant (default).
useEffect(() => {
if (SHOW_ACTIONS_IN_HEADER) {
Expand Down

0 comments on commit c9df6f1

Please sign in to comment.