-
-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upgrade premium in tags section
refactor: move TagsSection to react feat: show premium on Tag section feat: keep drag and drop features always active fix: drag & drop tweak with premium feat: premium messages fix: remove fill in svg icons fix: change tag list color (temporary) style: remove dead code refactor: clarify names and modules fix: draggable behind feature toggle feat: add button in TagSection & design
- Loading branch information
1 parent
c10a425
commit 163cb50
Showing
17 changed files
with
254 additions
and
178 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
export { usePremiumModal, PremiumModalProvider } from './usePremiumModal'; |
49 changes: 49 additions & 0 deletions
49
app/assets/javascripts/components/Premium/usePremiumModal.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,49 @@ | ||
import { FunctionalComponent } from 'preact'; | ||
import { useCallback, useContext, useState } from 'preact/hooks'; | ||
import { createContext } from 'react'; | ||
import { PremiumFeaturesModal } from '../PremiumFeaturesModal'; | ||
|
||
type PremiumModalContextData = { | ||
activate: (featureName: string) => void; | ||
}; | ||
|
||
const PremiumModalContext = createContext<PremiumModalContextData | null>(null); | ||
|
||
const PremiumModalProvider_ = PremiumModalContext.Provider; | ||
|
||
export const usePremiumModal = (): PremiumModalContextData => { | ||
const value = useContext(PremiumModalContext); | ||
|
||
if (!value) { | ||
throw new Error('invalid PremiumModal context'); | ||
} | ||
|
||
return value; | ||
}; | ||
|
||
export const PremiumModalProvider: FunctionalComponent = ({ children }) => { | ||
const [featureName, setFeatureName] = useState<null | string>(null); | ||
|
||
const activate = setFeatureName; | ||
|
||
const closeModal = useCallback(() => { | ||
setFeatureName(null); | ||
}, [setFeatureName]); | ||
|
||
const showModal = !!featureName; | ||
|
||
return ( | ||
<> | ||
{showModal && ( | ||
<PremiumFeaturesModal | ||
showModal={!!featureName} | ||
featureName={featureName} | ||
onClose={closeModal} | ||
/> | ||
)} | ||
<PremiumModalProvider_ value={{ activate }}> | ||
{children} | ||
</PremiumModalProvider_> | ||
</> | ||
); | ||
}; |
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
66 changes: 0 additions & 66 deletions
66
app/assets/javascripts/components/QuickSettingsMenu/TagNestingSwitch.tsx
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { | ||
FeaturesState, | ||
TAG_FOLDERS_FEATURE_NAME, | ||
} from '@/ui_models/app_state/features_state'; | ||
import { TagsState } from '@/ui_models/app_state/tags_state'; | ||
import { observer } from 'mobx-react-lite'; | ||
import { useDrop } from 'react-dnd'; | ||
import { usePremiumModal } from './Premium'; | ||
import { DropItem, DropProps, ItemTypes } from './TagsListItem'; | ||
|
||
type Props = { | ||
tagsState: TagsState; | ||
featuresState: FeaturesState; | ||
}; | ||
|
||
export const RootTagDropZone: React.FC<Props> = observer( | ||
({ tagsState, featuresState }) => { | ||
const premiumModal = usePremiumModal(); | ||
const isNativeFoldersEnabled = featuresState.enableNativeFoldersFeature; | ||
const hasFolders = tagsState.hasFolders; | ||
|
||
const [{ isOver, canDrop }, dropRef] = useDrop<DropItem, void, DropProps>( | ||
() => ({ | ||
accept: ItemTypes.TAG, | ||
canDrop: () => { | ||
return true; | ||
}, | ||
drop: (item) => { | ||
if (!hasFolders) { | ||
premiumModal.activate(TAG_FOLDERS_FEATURE_NAME); | ||
return; | ||
} | ||
|
||
tagsState.assignParent(item.uuid, undefined); | ||
}, | ||
collect: (monitor) => ({ | ||
isOver: !!monitor.isOver(), | ||
canDrop: !!monitor.canDrop(), | ||
}), | ||
}), | ||
[tagsState, hasFolders, modal] | ||
); | ||
|
||
if (!isNativeFoldersEnabled) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div | ||
ref={dropRef} | ||
className={`root-drop ${canDrop ? 'active' : ''} ${ | ||
isOver ? 'is-over' : '' | ||
}`} | ||
> | ||
Move the tag here to remove it from its folder. | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { TagsList } from '@/components/TagsList'; | ||
import { toDirective } from '@/components/utils'; | ||
import { WebApplication } from '@/ui_models/application'; | ||
import { AppState } from '@/ui_models/app_state'; | ||
import { FeaturesState } from '@/ui_models/app_state/features_state'; | ||
import { TagsState } from '@/ui_models/app_state/tags_state'; | ||
import { Tooltip } from '@reach/tooltip'; | ||
import { observer } from 'mobx-react-lite'; | ||
import { FunctionComponent } from 'preact'; | ||
import { Icon } from '../Icon'; | ||
|
||
type Props = { | ||
application: WebApplication; | ||
appState: AppState; | ||
}; | ||
|
||
const TagAddButton: FunctionComponent<{ | ||
appState: AppState; | ||
features: FeaturesState; | ||
}> = observer(({ appState, features }) => { | ||
const isNativeFoldersEnabled = features.enableNativeFoldersFeature; | ||
const hasFolders = features.hasFolders; | ||
|
||
if (!isNativeFoldersEnabled) { | ||
return null; | ||
} | ||
|
||
if (!hasFolders) { | ||
return ( | ||
<Tooltip label={'A Plus or Pro plan is required to enable Tag folders.'}> | ||
<div title="Premium feature"> | ||
<Icon type="premium-feature" /> | ||
</div> | ||
</Tooltip> | ||
); | ||
} | ||
|
||
return ( | ||
<div onClick={() => appState.createNewTag()}> | ||
<Icon type="add" /> | ||
</div> | ||
); | ||
}); | ||
|
||
export const TagsSection: FunctionComponent<Props> = observer( | ||
({ application, appState }) => { | ||
return ( | ||
<section> | ||
<div className="tags-title-section section-title-bar"> | ||
<div className="section-title-bar-header"> | ||
<div className="sk-h3 title"> | ||
<span className="sk-bold">Tags</span> | ||
</div> | ||
<TagAddButton appState={appState} features={appState.features} /> | ||
</div> | ||
</div> | ||
<TagsList application={application} appState={appState} /> | ||
</section> | ||
); | ||
} | ||
); | ||
|
||
export const TagsSectionDirective = toDirective<Props>(TagsSection); |
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
Oops, something went wrong.