From 220ecfca43e621ebd0bdbe7847a34f2e817dcfa1 Mon Sep 17 00:00:00 2001 From: Ben Zhang Date: Fri, 30 Aug 2024 11:08:27 -0700 Subject: [PATCH] Remove old onboarding form (#3066) The old onboarding form has been deprecated in a while now (https://github.com/WATonomous/infra-config/pull/2777). This PR removes the old onboarding form completely. `/onboarding-form` is replaced with a placeholder page that redirects to the new onboarding form. The initial form data query param is preserved for backwards compatibility. The initial form data query param conversion is tested using the following query param: ``` /onboarding-form?initialFormData=%7B%22compute_cluster%22%3A%20%7B%22additional_groups%22%3A%20%5B%22planning-research%22%5D%2C%20%22enabled%22%3A%20true%2C%20%22github_username%22%3A%20%22ben-z%22%2C%20%22linger%22%3A%20false%2C%20%22linux_shell%22%3A%20%22%2Fbin%2Fzsh%22%2C%20%22roles%22%3A%20%5B%22ADMIN%22%5D%2C%20%22ssh_public_keys%22%3A%20%5B%22ecdsa-sha2-nistp256%20AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLdGR4%2FAXCyUxsT%2F9zH5MIVkV9%2FnoAnLiBFtavcCk%2FYGQz9SVtOi6P%2BIAzdtbPF4tENKJI%2B27FYSjQ3yOf%2FVknc%3D%20wato%40secretive.MPB-19.local%22%2C%20%22port-forwarding%2Cno-pty%2Ccommand%3D%5C%22%2Fbin%2Ffalse%5C%22%20ecdsa-sha2-nistp256%20AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBG5RXpWbl8UXTGzTvDw6EGLytjjImdDskNxpsDO8T31fSNty6FaAx%2B6Ch1z02%2FCtyLym%2BZiijzWGX6IFxyGCD1k%3D%20wato-proxyjump%40secretive.MPB-19.local%22%2C%20%22ecdsa-sha2-nistp256%20AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBASa8mkCnrSuE2sB424myXkHUisHyiBlarYi5u76fT3ksFJw6Xz8MI6jiK2dIKoNbYPx608wK%2F2UZf0Y4p6%2FjFM%3D%20wato-noauth%40secretive.MPB-19.local%22%2C%20%22ssh-ed25519%20AAAAC3NzaC1lZDI1NTE5AAAAIDTZ1SUwgEIVwP9ZFoxe60wIc81isc8PfGu%2FJFkdyOhs%201password%20WATonomous%20SSH%20key%22%2C%20%22ssh-ed25519%20AAAAC3NzaC1lZDI1NTE5AAAAIOVkfo8KehqkIvNo%2F01nNVWr9itu%2BKWtvLlkViveM67x%20Termius%20iOS%22%5D%2C%20%22uid%22%3A%201507%2C%20%22username%22%3A%20%22ben%22%7D%2C%20%22discord%22%3A%20%7B%22discriminator%22%3A%20%22%22%2C%20%22enabled%22%3A%20true%2C%20%22is_owner%22%3A%20false%2C%20%22roles%22%3A%20%5B%22Admin%22%2C%20%22WATcloud%22%2C%20%22Core%20Member%22%5D%2C%20%22username%22%3A%20%22un1c0rnio%22%7D%2C%20%22finance_system%22%3A%20%7B%22enabled%22%3A%20false%7D%2C%20%22general%22%3A%20%7B%22affiliations%22%3A%20%5B%5D%2C%20%22contact_emails%22%3A%20%5B%22ben.zhang%40uwaterloo.ca%22%5D%2C%20%22name%22%3A%20%22Ben%20Zhang%22%2C%20%22send_onboarding_email%22%3A%20true%7D%2C%20%22github%22%3A%20%7B%22enabled%22%3A%20true%2C%20%22org_membership%22%3A%20%22Owner%22%2C%20%22teams%22%3A%20%5B%22WATonomous%20Team%22%5D%2C%20%22username%22%3A%20%22ben-z%22%7D%2C%20%22google_workspace%22%3A%20%7B%22emails%22%3A%20%5B%7B%22email_address%22%3A%20%22ben%40watorace.ca%22%2C%20%22groups%22%3A%20%5B%22%5BWATcloud%20team%5D%20Infrastructure%20Outreach%22%2C%20%22%5BWATcloud%20team%5D%20Elastic%22%5D%2C%20%22is_legacy_account%22%3A%20true%2C%20%22is_superadmin%22%3A%20false%7D%5D%2C%20%22enabled%22%3A%20true%2C%20%22first_name%22%3A%20%22Ben%22%2C%20%22last_name%22%3A%20%22Zhang%22%2C%20%22recovery_email%22%3A%20%22ben.zhang%40uwaterloo.ca%22%7D%2C%20%22internal_tools%22%3A%20%7B%22enabled%22%3A%20false%2C%20%22github_username%22%3A%20%22ben-z%22%7D%2C%20%22jira%22%3A%20%7B%22enabled%22%3A%20false%7D%2C%20%22sentry%22%3A%20%7B%22email%22%3A%20%22ben.zhang%40watonomous.ca%22%2C%20%22enabled%22%3A%20true%2C%20%22org_role%22%3A%20%22member%22%2C%20%22teams%22%3A%20%5B%22WATcloud%22%5D%7D%2C%20%22uw_gitlab%22%3A%20%7B%22enabled%22%3A%20false%7D%7D ``` Before/after: image --- components/onboarding-form.tsx | 2 +- pages/_meta.json | 3 +++ pages/onboarding-form.mdx | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 pages/onboarding-form.mdx diff --git a/components/onboarding-form.tsx b/components/onboarding-form.tsx index 4c355f2..9ff9ea8 100644 --- a/components/onboarding-form.tsx +++ b/components/onboarding-form.tsx @@ -42,7 +42,7 @@ import { deepEquals } from "@rjsf/utils" import { useRouter } from "next/router"; import { encodeURI as b64EncodeURI, decode as b64Decode } from "js-base64"; -const INITIAL_FORM_DATA_QUERY_PARAM = "initialformdatab64"; +export const INITIAL_FORM_DATA_QUERY_PARAM = "initialformdatab64"; const FORM_STATE_KEY = "onboarding-form-state"; function saveFormState(obj: Record) { diff --git a/pages/_meta.json b/pages/_meta.json index 94f982e..3fa6f77 100644 --- a/pages/_meta.json +++ b/pages/_meta.json @@ -34,5 +34,8 @@ "theme": { "timestamp": false } + }, + "onboarding-form": { + "display": "hidden" } } diff --git a/pages/onboarding-form.mdx b/pages/onboarding-form.mdx new file mode 100644 index 0000000..576cf12 --- /dev/null +++ b/pages/onboarding-form.mdx @@ -0,0 +1,20 @@ +# Onboarding Form (Moved) + +import { INITIAL_FORM_DATA_QUERY_PARAM } from '@/components/onboarding-form' +import { encodeURI as b64EncodeURI } from 'js-base64'; +import { Link } from 'nextra-theme-docs' + +export function RedirectLink({ children }) { + const urlParams = new URLSearchParams(typeof window === "undefined" ? "" : window.location.search); + const initialFormDataStr = urlParams.get('initialFormData'); + + const newURLParams = new URLSearchParams(); + if (initialFormDataStr) { + newURLParams.append(INITIAL_FORM_DATA_QUERY_PARAM, b64EncodeURI(initialFormDataStr)); + } + const newURLParamsStr = newURLParams.toString(); + + return {children} +} + +This page has moved! Please click here to go to the new location.