Avoid rendering app download buttons if disabled in config (#11741)
* Add default desktop_builds and mobile_builds into SdkConfig.DEFAULTS Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Avoid rendering app download buttons if config sets to `null` Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Disable app download onboarding task if config has no apps to download Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add tests and update types Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix types Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
e22fa2efc1
commit
bdf2ebd301
7 changed files with 723 additions and 70 deletions
|
@ -16,7 +16,7 @@ limitations under the License.
|
|||
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { AppDownloadDialog } from "../components/views/dialogs/AppDownloadDialog";
|
||||
import { AppDownloadDialog, showAppDownloadDialogPrompt } from "../components/views/dialogs/AppDownloadDialog";
|
||||
import { UserTab } from "../components/views/dialogs/UserTab";
|
||||
import { ButtonEvent } from "../components/views/elements/AccessibleButton";
|
||||
import { Action } from "../dispatcher/actions";
|
||||
|
@ -42,6 +42,7 @@ interface UserOnboardingTask {
|
|||
hideOnComplete?: boolean;
|
||||
};
|
||||
completed: (ctx: UserOnboardingContext) => boolean;
|
||||
disabled?(): boolean;
|
||||
}
|
||||
|
||||
export interface UserOnboardingTaskWithResolvedCompletion extends Omit<UserOnboardingTask, "completed"> {
|
||||
|
@ -111,6 +112,9 @@ const tasks: UserOnboardingTask[] = [
|
|||
Modal.createDialog(AppDownloadDialog, {}, "mx_AppDownloadDialog_wrapper", false, true);
|
||||
},
|
||||
},
|
||||
disabled(): boolean {
|
||||
return !showAppDownloadDialogPrompt();
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "setup-profile",
|
||||
|
@ -149,7 +153,10 @@ export function useUserOnboardingTasks(context: UserOnboardingContext): UserOnbo
|
|||
|
||||
return useMemo<UserOnboardingTaskWithResolvedCompletion[]>(() => {
|
||||
return tasks
|
||||
.filter((task) => !task.relevant || task.relevant.includes(useCase))
|
||||
.filter((task) => {
|
||||
if (task.disabled?.()) return false;
|
||||
return !task.relevant || task.relevant.includes(useCase);
|
||||
})
|
||||
.map((task) => ({
|
||||
...task,
|
||||
completed: task.completed(context),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue