From 140e5d35bacddf1c42808eb46633c0bcdc39ef24 Mon Sep 17 00:00:00 2001 From: Jarvis Raymond Date: Mon, 6 Nov 2023 09:34:10 -0600 Subject: [PATCH] feat(addTeamProjectHeaderToAnalysisApps): Changed all instances of variable name showButton to isEditable --- src/Analysis/Analysis.jsx | 2 +- src/Analysis/AnalysisApp.jsx | 2 +- .../TeamProjectHeader/TeamProjectHeader.jsx | 16 ++++++++-------- .../TeamProjectHeader.stories.jsx | 4 ++-- .../TeamProjectHeader/TeamProjectHeader.test.jsx | 12 ++++++------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Analysis/Analysis.jsx b/src/Analysis/Analysis.jsx index fdce5e70fa..a5a86730f2 100644 --- a/src/Analysis/Analysis.jsx +++ b/src/Analysis/Analysis.jsx @@ -23,7 +23,7 @@ class Analysis extends React.Component { {CheckForTeamProjectApplication(analysisApps) && ( - + )} diff --git a/src/Analysis/AnalysisApp.jsx b/src/Analysis/AnalysisApp.jsx index 4479168a1e..5ea8200840 100644 --- a/src/Analysis/AnalysisApp.jsx +++ b/src/Analysis/AnalysisApp.jsx @@ -239,7 +239,7 @@ class AnalysisApp extends React.Component { client={new QueryClient()} contextSharing > - + )} diff --git a/src/Analysis/SharedUtils/TeamProject/TeamProjectHeader/TeamProjectHeader.jsx b/src/Analysis/SharedUtils/TeamProject/TeamProjectHeader/TeamProjectHeader.jsx index b279dfe07c..4ffd07f099 100644 --- a/src/Analysis/SharedUtils/TeamProject/TeamProjectHeader/TeamProjectHeader.jsx +++ b/src/Analysis/SharedUtils/TeamProject/TeamProjectHeader/TeamProjectHeader.jsx @@ -6,7 +6,7 @@ import isEnterOrSpace from '../../IsEnterOrSpace'; import TeamProjectModal from '../TeamProjectModal/TeamProjectModal'; import './TeamProjectHeader.css'; -const TeamProjectHeader = ({ showButton }) => { +const TeamProjectHeader = ({ isEditable }) => { const [isModalOpen, setIsModalOpen] = useState(false); const [bannerText, setBannerText] = useState('- -'); const showModal = () => { @@ -18,19 +18,19 @@ const TeamProjectHeader = ({ showButton }) => { const storedTeamProject = localStorage.getItem('teamProject'); if (storedTeamProject) { setBannerText(storedTeamProject); - } else if (showButton) { + } else if (isEditable) { showModal(); - } else if (!showButton && !storedTeamProject) { + } else if (!isEditable && !storedTeamProject) { // non-editable view should redirect to app selection if user doesn't have a storedTeamProject history.push('/analysis'); } - }, [history, showButton]); + }, [history, isEditable]); return (
Team Project / {bannerText} - {showButton && ( + {isEditable && ( { )}
- {showButton && ( + {isEditable && ( { }; TeamProjectHeader.propTypes = { - showButton: PropTypes.bool, + isEditable: PropTypes.bool, }; TeamProjectHeader.defaultProps = { - showButton: false, + isEditable: false, }; export default TeamProjectHeader; diff --git a/src/Analysis/SharedUtils/TeamProject/TeamProjectHeader/TeamProjectHeader.stories.jsx b/src/Analysis/SharedUtils/TeamProject/TeamProjectHeader/TeamProjectHeader.stories.jsx index 5af7f92c28..7d9e7620b1 100644 --- a/src/Analysis/SharedUtils/TeamProject/TeamProjectHeader/TeamProjectHeader.stories.jsx +++ b/src/Analysis/SharedUtils/TeamProject/TeamProjectHeader/TeamProjectHeader.stories.jsx @@ -17,10 +17,10 @@ const Template = (args) => ( export const withButton = Template.bind({}); withButton.args = { - showButton: true, + isEditable: true, }; export const withNoButton = Template.bind({}); withNoButton.args = { - showButton: false, + isEditable: false, }; diff --git a/src/Analysis/SharedUtils/TeamProject/TeamProjectHeader/TeamProjectHeader.test.jsx b/src/Analysis/SharedUtils/TeamProject/TeamProjectHeader/TeamProjectHeader.test.jsx index 6d04c9bdd6..2da1ccf93f 100644 --- a/src/Analysis/SharedUtils/TeamProject/TeamProjectHeader/TeamProjectHeader.test.jsx +++ b/src/Analysis/SharedUtils/TeamProject/TeamProjectHeader/TeamProjectHeader.test.jsx @@ -19,11 +19,11 @@ beforeEach(() => { }); }); -test('renders TeamProjectHeader with default props when showButton is true and no local storage', () => { +test('renders TeamProjectHeader with default props when isEditable is true and no local storage', () => { localStorageMock.getItem.mockReturnValueOnce(null); render( - + , ); // Assert that the component renders without crashing without button @@ -31,7 +31,7 @@ test('renders TeamProjectHeader with default props when showButton is true and n expect(screen.getByText('/ - -')).toBeInTheDocument(); }); -test(`Calls useHistory for redirect to analysis page when showButton is +test(`Calls useHistory for redirect to analysis page when isEditable is false and teamProject is not set in local storage`, () => { localStorageMock.getItem.mockReturnValueOnce(null); const history = createMemoryHistory(); @@ -39,7 +39,7 @@ test(`Calls useHistory for redirect to analysis page when showButton is render( - + , ); @@ -47,10 +47,10 @@ test(`Calls useHistory for redirect to analysis page when showButton is expect(history.location.pathname).toBe('/analysis'); }); -test('renders TeamProjectHeader with edit button when showButton is true and can open modal', () => { +test('renders TeamProjectHeader with edit button when isEditable is true and can open modal', () => { render( - + , );