-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Changes position of feedback button (#1455)
* change position of feedback button * restore return types on app title functions * add a test for the feedback button * float feedback button in mobile view * fix code smell * add padding to tooltip * remove unused imports * add padding to tooltip content * fix linting error
- Loading branch information
Showing
7 changed files
with
120 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { DirectionalHint, IconButton, IIconProps, TooltipHost } from '@fluentui/react'; | ||
import React, { useState } from 'react'; | ||
import { translateMessage } from '../../utils/translate-messages'; | ||
import { useSelector } from 'react-redux'; | ||
import FeedbackForm from '../query-runner/request/feedback/FeedbackForm'; | ||
import { IRootState } from '../../../types/root'; | ||
import { ACCOUNT_TYPE } from '../../services/graph-constants'; | ||
|
||
export const FeedbackButton = () => { | ||
const [enableSurvey, setEnableShowSurvey] = useState(false); | ||
const { profile } = useSelector( (state: IRootState) => state ); | ||
|
||
const toggleFeedback = () => { | ||
setEnableShowSurvey(prevState => !prevState); | ||
} | ||
|
||
const feedbackIcon : IIconProps = { | ||
iconName : 'Feedback' | ||
} | ||
const feedbackTitle = translateMessage('Feedback'); | ||
const content_ = <div style={{padding:'3px'}}>{translateMessage('Feedback')}</div> | ||
|
||
const feedbackIconStyles = { | ||
root:{ | ||
height: '50px', | ||
width: '50px' | ||
} | ||
} | ||
const calloutProps = { | ||
gapSpace: 0 | ||
}; | ||
const hostStyles = { root: { | ||
display: 'inline-block', | ||
padding: '15px' | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
{profile?.profileType !== ACCOUNT_TYPE.AAD && | ||
<div> | ||
<TooltipHost | ||
content={content_} | ||
calloutProps={calloutProps} | ||
styles={hostStyles} | ||
directionalHint={DirectionalHint.leftBottomEdge} | ||
> | ||
<IconButton onClick={toggleFeedback} | ||
iconProps={feedbackIcon} | ||
ariaDescription={feedbackTitle} | ||
ariaLabel={feedbackTitle} | ||
styles={feedbackIconStyles} | ||
role={'button'} | ||
disabled={enableSurvey} | ||
/> | ||
</TooltipHost> | ||
<FeedbackForm dismissSurvey={toggleFeedback} activated={enableSurvey} /> | ||
</div> | ||
} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import { cleanup, render } from '@testing-library/react'; | ||
import { FeedbackButton } from '../../app/views/app-sections/FeedbackButton'; | ||
|
||
afterEach(cleanup); | ||
const renderFeedbackButton = () => { | ||
return render ( | ||
<FeedbackButton /> | ||
) | ||
} | ||
|
||
jest.mock('react-redux', () => ({ | ||
useSelector: jest.fn(() => { | ||
return { | ||
profile: { | ||
profileType: 'MSA' | ||
} | ||
} | ||
}), | ||
useDispatch: jest.fn() | ||
})); | ||
|
||
// eslint-disable-next-line no-console | ||
console.warn = jest.fn(); | ||
|
||
// eslint-disable-next-line react/display-name | ||
jest.mock('../../app/views/query-runner/request/feedback/FeedbackForm.tsx', () => () => { | ||
return <div>Feedback</div> | ||
}) | ||
|
||
describe('Tests Feedback button', () => { | ||
it('Renders feedback button without crashing', () => { | ||
const { getByText } = renderFeedbackButton(); | ||
expect(getByText(/Feedback/)).toBeDefined(); | ||
|
||
}); | ||
}) |