feat: remove deletion functionality for default discussion topic (#125)
* feat: remove deletion functionality for default discussion topic * refactor: update variables name and add general topic condition
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
} from '../../../../data/slice';
|
||||
|
||||
const TopicItem = ({
|
||||
intl, index, name, onDelete,
|
||||
intl, index, name, onDelete, id,
|
||||
}) => {
|
||||
const [title, setTitle] = useState(name);
|
||||
const [showDeletePopup, setShowDeletePopup] = useState(false);
|
||||
@@ -24,6 +24,7 @@ const TopicItem = ({
|
||||
errors,
|
||||
} = useFormikContext();
|
||||
const dispatch = useDispatch();
|
||||
const isGeneralTopic = id === 'course';
|
||||
|
||||
useEffect(() => {
|
||||
setTitle(name);
|
||||
@@ -47,10 +48,10 @@ const TopicItem = ({
|
||||
|
||||
const getHeading = (isOpen = false) => {
|
||||
let heading;
|
||||
if (!title) {
|
||||
heading = <span className="h4 py-2 mr-auto">Configure topic</span>;
|
||||
if (isGeneralTopic && isOpen) {
|
||||
heading = <span className="h4 py-2 mr-auto">{intl.formatMessage(messages.renameGeneralTopic)}</span>;
|
||||
} else if (isOpen) {
|
||||
heading = <span className="h4 py-2 mr-auto">Rename {title} topic</span>;
|
||||
heading = <span className="h4 py-2 mr-auto">{intl.formatMessage(messages.configureAdditionalTopic)}</span>;
|
||||
} else {
|
||||
heading = <span className="py-2">{title}</span>;
|
||||
}
|
||||
@@ -124,15 +125,19 @@ const TopicItem = ({
|
||||
</Collapsible.Visible>
|
||||
<Collapsible.Visible whenOpen>
|
||||
{getHeading(true)}
|
||||
<div className="pr-4 border-right">
|
||||
<IconButton
|
||||
onClick={deleteDiscussionTopic}
|
||||
alt={intl.formatMessage(messages.deleteAltText)}
|
||||
src={Delete}
|
||||
iconAs={Icon}
|
||||
variant="dark"
|
||||
/>
|
||||
</div>
|
||||
{
|
||||
!isGeneralTopic && (
|
||||
<div className="pr-4 border-right">
|
||||
<IconButton
|
||||
onClick={deleteDiscussionTopic}
|
||||
alt={intl.formatMessage(messages.deleteAltText)}
|
||||
src={Delete}
|
||||
iconAs={Icon}
|
||||
variant="dark"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<div className="pl-4">
|
||||
<IconButton
|
||||
alt={intl.formatMessage(messages.collapseAltText)}
|
||||
@@ -181,6 +186,7 @@ const TopicItem = ({
|
||||
|
||||
TopicItem.propTypes = {
|
||||
name: PropTypes.string.isRequired,
|
||||
id: PropTypes.string.isRequired,
|
||||
index: PropTypes.number.isRequired,
|
||||
onDelete: PropTypes.func.isRequired,
|
||||
intl: intlShape.isRequired,
|
||||
|
||||
@@ -147,6 +147,16 @@ const messages = defineMessages({
|
||||
defaultMessage: 'Delete this topic?',
|
||||
description: 'Label for discussion topic delete popup allowing a user to delete a topic.',
|
||||
},
|
||||
renameGeneralTopic: {
|
||||
id: 'authoring.discussions.builtIn.renameGeneralTopic.label',
|
||||
defaultMessage: 'Rename general topic',
|
||||
description: 'Label for default topic allowing user to rename default general topic',
|
||||
},
|
||||
configureAdditionalTopic: {
|
||||
id: 'authoring.discussions.builtIn.configureAdditionalTopic.label',
|
||||
defaultMessage: 'Configure topic',
|
||||
description: 'Label for Additional topic allowing user to configure additional topic name',
|
||||
},
|
||||
// Blackout dates
|
||||
blackoutDates: {
|
||||
id: 'authoring.discussions.blackoutDates',
|
||||
|
||||
Reference in New Issue
Block a user