Skip to content

Commit

Permalink
Feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-skriabin committed Jan 20, 2025
1 parent 16e3146 commit 2e791a8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.development
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1
ARG NODE_VERSION=18
ARG PYTHON_VERSION=3.12
ARG POETRY_VERSION=1.8.4
ARG POETRY_VERSION=2.0.1
ARG VERSION_OVERRIDE
ARG BRANCH_OVERRIDE

Expand Down
4 changes: 2 additions & 2 deletions label_studio/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import pandas as pd
import requests
from core import utils
from core.feature_flags import flag_set, all_flags, get_feature_file_path
from core.feature_flags import all_flags, flag_set, get_feature_file_path
from core.label_config import generate_time_series_json
from core.utils.common import collect_versions
from core.utils.io import find_file
Expand Down Expand Up @@ -57,7 +57,7 @@ def main(request):
# business mode access
if flag_set("fflag_all_feat_dia_1777_ls_homepage_short"):
return render(request, 'home/home.html')
else
else:
return redirect(reverse('projects:project-index'))

# not authenticated
Expand Down
12 changes: 8 additions & 4 deletions label_studio/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
home_page_enabled = flag_set("fflag_all_feat_dia_1777_ls_homepage_short")
main_redirect = "projects:project-index"

if home_page_enabled:
main_redirect = "main"

@login_required
def logout(request):
Expand All @@ -45,7 +43,10 @@ def user_signup(request):

# checks if the URL is a safe redirection.
if not next_page or not url_has_allowed_host_and_scheme(url=next_page, allowed_hosts=request.get_host()):
next_page = reverse(main_redirect)
if flag_set("fflag_all_feat_dia_1777_ls_homepage_short"):
next_page = reverse("main")
else:
next_page = reverse("projects:project-index")

user_form = forms.UserSignupForm()
organization_form = OrganizationSignupForm()
Expand Down Expand Up @@ -105,7 +106,10 @@ def user_login(request):

# checks if the URL is a safe redirection.
if not next_page or not url_has_allowed_host_and_scheme(url=next_page, allowed_hosts=request.get_host()):
next_page = reverse(main_redirect)
if flag_set("fflag_all_feat_dia_1777_ls_homepage_short"):
next_page = reverse("main")
else:
next_page = reverse("projects:project-index")

login_form = load_func(settings.USER_LOGIN_FORM)
form = login_form()
Expand Down
4 changes: 2 additions & 2 deletions web/apps/labelstudio/src/components/Menubar/Menubar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import "./Menubar.scss";
import "./MenuContent.scss";
import "./MenuSidebar.scss";
import { ModelsPage } from "../../pages/Organization/Models/ModelsPage";
import { FF_DIA_835, isFF } from "../../utils/feature-flags";
import { FF_DIA_835, FF_HOMEPAGE, isFF } from "../../utils/feature-flags";
import { IconHome } from "@humansignal/ui";

export const MenubarContext = createContext();
Expand Down Expand Up @@ -189,7 +189,7 @@ export const Menubar = ({ enabled, defaultOpened, defaultPinned, children, onSid
style={{ width: 240 }}
>
<Menu>
<Menu.Item label="Home" to="/" icon={<IconHome />} data-external exact />
{isFF(FF_HOMEPAGE) && <Menu.Item label="Home" to="/" icon={<IconHome />} data-external exact />}
<Menu.Item label="Projects" to="/projects" icon={<IconFolder />} data-external exact />
<Menu.Item label="Organization" to="/organization" icon={<IconPersonInCircle />} data-external exact />
{isFF(FF_DIA_835) && <Menu.Item label="Models" to={ModelsPage.path} icon={<IconModel />} exact />}
Expand Down
3 changes: 2 additions & 1 deletion web/apps/labelstudio/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import { ProjectsPage } from "./Projects/Projects";
import { HomePage } from "./Home/HomePage";
import { OrganizationPage } from "./Organization";
import { ModelsPage } from "./Organization/Models/ModelsPage";
import { FF_HOMEPAGE, isFF } from "../utils/feature-flags";

export const Pages = [HomePage, ProjectsPage, OrganizationPage, ModelsPage];
export const Pages = [isFF(FF_HOMEPAGE) && HomePage, ProjectsPage, OrganizationPage, ModelsPage].filter(Boolean);
2 changes: 2 additions & 0 deletions web/apps/labelstudio/src/utils/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export const FF_PRODUCT_TOUR = "fflag_feat_dia_1697_product_tour_short";
*/
export const FF_UNSAVED_CHANGES = "fflag_feat_front_leap_1198_unsaved_changes_180724";

export const FF_HOMEPAGE = "fflag_all_feat_dia_1777_ls_homepage_short";

export function isFF(id: string) {
// TODO: remove the override + if statement once LSE and LSO start building react the same way and fflag_fix_front_lsdv_4620_memory_leaks_100723_short is removed
const override: Record<string, boolean> = {
Expand Down

0 comments on commit 2e791a8

Please sign in to comment.