-
-
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 * feat: fix features loading with app state (#775) * fix: distinguish between app launch and start * fix: update state for footer too * fix: wait for application launch event Co-authored-by: Laurent Senta <[email protected]> * feat: tags folder with folder text design (#776) * feat: add folder text * fix: sn stylekit colors * fix: root drop zone * chore: upgrade stylekit * fix: hide dropzone when feature is disabled * chore: bump versions now that they are released Co-authored-by: Mo <[email protected]>
- Loading branch information
1 parent
caaa2d0
commit 784bc72
Showing
24 changed files
with
367 additions
and
230 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.
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, premiumModal] | ||
); | ||
|
||
if (!isNativeFoldersEnabled || !hasFolders) { | ||
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,107 @@ | ||
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, | ||
TAG_FOLDERS_FEATURE_NAME, | ||
TAG_FOLDERS_FEATURE_TOOLTIP, | ||
} from '@/ui_models/app_state/features_state'; | ||
import { Tooltip } from '@reach/tooltip'; | ||
import { observer } from 'mobx-react-lite'; | ||
import { FunctionComponent } from 'preact'; | ||
import { useCallback } from 'preact/hooks'; | ||
import { IconButton } from '../IconButton'; | ||
import { PremiumModalProvider, usePremiumModal } from '../Premium'; | ||
|
||
type Props = { | ||
application: WebApplication; | ||
appState: AppState; | ||
}; | ||
|
||
const TagAddButton: FunctionComponent<{ | ||
appState: AppState; | ||
features: FeaturesState; | ||
}> = observer(({ appState, features }) => { | ||
const isNativeFoldersEnabled = features.enableNativeFoldersFeature; | ||
|
||
if (!isNativeFoldersEnabled) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<IconButton | ||
icon="add" | ||
title="Create a new tag" | ||
onClick={() => appState.createNewTag()} | ||
/> | ||
); | ||
}); | ||
|
||
const TagTitle: FunctionComponent<{ | ||
features: FeaturesState; | ||
}> = observer(({ features }) => { | ||
const isNativeFoldersEnabled = features.enableNativeFoldersFeature; | ||
const hasFolders = features.hasFolders; | ||
const modal = usePremiumModal(); | ||
|
||
const showPremiumAlert = useCallback(() => { | ||
modal.activate(TAG_FOLDERS_FEATURE_NAME); | ||
}, [modal]); | ||
|
||
if (!isNativeFoldersEnabled) { | ||
return ( | ||
<> | ||
<div className="sk-h3 title"> | ||
<span className="sk-bold">Tags</span> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
if (hasFolders) { | ||
return ( | ||
<> | ||
<div className="sk-h3 title"> | ||
<span className="sk-bold">Folders</span> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<div className="sk-h3 title"> | ||
<span className="sk-bold">Tags</span> | ||
<Tooltip label={TAG_FOLDERS_FEATURE_TOOLTIP}> | ||
<label | ||
className="ml-1 sk-bold color-grey-2 cursor-pointer" | ||
onClick={showPremiumAlert} | ||
> | ||
Folders | ||
</label> | ||
</Tooltip> | ||
</div> | ||
</> | ||
); | ||
}); | ||
|
||
export const TagsSection: FunctionComponent<Props> = observer( | ||
({ application, appState }) => { | ||
return ( | ||
<PremiumModalProvider> | ||
<section> | ||
<div className="tags-title-section section-title-bar"> | ||
<div className="section-title-bar-header"> | ||
<TagTitle features={appState.features} /> | ||
<TagAddButton appState={appState} features={appState.features} /> | ||
</div> | ||
</div> | ||
<TagsList application={application} appState={appState} /> | ||
</section> | ||
</PremiumModalProvider> | ||
); | ||
} | ||
); | ||
|
||
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.