-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(content): add notice when content shared
- Loading branch information
1 parent
eecee77
commit ec8ef0c
Showing
8 changed files
with
151 additions
and
82 deletions.
There are no files selected for viewing
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
5 changes: 5 additions & 0 deletions
5
packages/studio-ui/src/web/components/Content/Select/WidgetContext.tsx
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,5 @@ | ||
import { createContext } from 'react' | ||
|
||
export const WidgetContext = createContext({ | ||
itemId: '' | ||
}) |
28 changes: 28 additions & 0 deletions
28
packages/studio-ui/src/web/components/ContentForm/ContentNotice.tsx
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,28 @@ | ||
import { Callout, Intent } from '@blueprintjs/core' | ||
import React, { useContext } from 'react' | ||
import { connect } from 'react-redux' | ||
import { RootReducer } from '~/reducers' | ||
import { FlowReducer } from '~/reducers/flows' | ||
import { WidgetContext } from '../Content/Select/WidgetContext' | ||
import { getContentItemUsage } from '../Shared/Utils' | ||
import style from './style.scss' | ||
|
||
/** Displays a warning to user if cms content used in multiple places */ | ||
export function ContentNotice({ flows, qnaUsage }: { flows: FlowReducer; qnaUsage: any }) { | ||
const { itemId } = useContext(WidgetContext) | ||
const usage = itemId ? getContentItemUsage(itemId, flows, qnaUsage) : [] | ||
if (usage.length <= 1) { | ||
return null | ||
} | ||
return ( | ||
<Callout className={style.contentNotice} title="Changing Shared Content" intent={Intent.PRIMARY} icon="info-sign"> | ||
This content is used in {usage.length} places. Changing it will affect all places. | ||
</Callout> | ||
) | ||
} | ||
|
||
const mapStateToProps = (state: RootReducer) => ({ | ||
flows: state.flows, | ||
qnaUsage: state.content.qnaUsage | ||
}) | ||
export default connect(mapStateToProps)(ContentNotice) |
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 |
---|---|---|
|
@@ -25,3 +25,7 @@ | |
.warning { | ||
color: var(--lighthouse); | ||
} | ||
|
||
.contentNotice { | ||
margin-bottom: 20px; | ||
} |
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