Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move apps and team page scripts out of landing-page.js #27137

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
team: Extract script to run to its own file.
  • Loading branch information
amanagr committed Oct 25, 2023
commit 3ea1dac231279c3f1e6cc43a68795289d606b64c
2 changes: 1 addition & 1 deletion templates/corporate/team.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "zerver/portico.html" %}
{% set entrypoint = "landing-page" %}
{% set entrypoint = "teams-page" %}

{% set PAGE_TITLE = "The Zulip team" %}

Expand Down
12 changes: 0 additions & 12 deletions web/src/portico/landing-page.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
import $ from "jquery";

import {page_params} from "../page_params";

import render_tabs from "./team";

export function path_parts() {
return window.location.pathname.split("/").filter((chunk) => chunk !== "");
}

$(() => {
if (window.location.pathname === "/team/") {
const contributors = page_params.contributors;
delete page_params.contributors;
render_tabs(contributors);
}
});

// Scroll to anchor link when clicked. Note that help.js has a similar
// function; this file and help.js are never included on the same
// page.
Expand Down
18 changes: 9 additions & 9 deletions web/src/portico/team.ts → web/src/portico/teams_page.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import $ from "jquery";
import _ from "lodash";

// The list of repository names is duplicated here in order to provide
// a clear type for Contributor objects.
//
// TODO: We can avoid this if we introduce a `contributions` object
// referenced from Contributor, rather than having repository names be
// direct keys in the namespace that also has `email`.
const all_repository_names = [
export const all_repository_names = [
"zulip",
"zulip-desktop",
"zulip-mobile",
Expand All @@ -20,7 +14,7 @@ const all_repository_names = [
] as const;
type RepositoryName = (typeof all_repository_names)[number];

const repo_name_to_tab_name: Record<RepositoryName, string> = {
export const repo_name_to_tab_name: Record<RepositoryName, string> = {
zulip: "server",
"zulip-desktop": "desktop",
"zulip-mobile": "mobile",
Expand Down Expand Up @@ -90,7 +84,10 @@ function exclude_bot_contributors(contributor: Contributor): boolean {
// TODO (for v2 of /team/ contributors):
// - Make tab header responsive.
// - Display full name instead of GitHub username.
export default function render_tabs(contributors: Contributor[]): void {
export default function render_tabs(contributors: Contributor[] | undefined): void {
if (!contributors) {
return;
}
const template = _.template($("#contributors-template").html());
const count_template = _.template($("#count-template").html());
const total_count_template = _.template($("#total-count-template").html());
Expand Down Expand Up @@ -171,3 +168,6 @@ export default function render_tabs(contributors: Contributor[]): void {
});
}
}

const contributors: Contributor[] | undefined = $("#page-params").data("params").contributors;
render_tabs(contributors);
5 changes: 5 additions & 0 deletions web/webpack.assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
"./src/portico/apps_download",
"./styles/portico/landing_page.css"
],
"teams-page": [
"./src/bundles/portico",
"./src/portico/teams_page",
"./styles/portico/landing_page.css"
],
"landing-page-hello": [
"./src/bundles/hello",
"./src/portico/hello",
Expand Down