Browse Source

ref(js): Remove old OrganizationTeamsProjectsView (#8450)

This was the old projects list located at
`/organizations/slug/projects/` which will now be redirected to new
dashboard.
Billy Vong 6 years ago
parent
commit
030d97b83b

+ 1 - 5
src/sentry/static/sentry/app/routes.jsx

@@ -54,7 +54,6 @@ import OrganizationRepositoriesView from 'app/views/organizationRepositoriesView
 import OrganizationGeneralSettingsView from 'app/views/settings/organization/general/organizationGeneralSettingsView';
 import OrganizationStats from 'app/views/organizationStats';
 import OrganizationTeams from 'app/views/organizationTeams';
-import OrganizationTeamsProjectsView from 'app/views/organizationTeamsProjects';
 import ProjectEnvironments from 'app/views/projectEnvironments';
 import ProjectTags from 'app/views/projectTags';
 import ProjectChooser from 'app/views/projectChooser';
@@ -688,10 +687,7 @@ function routes() {
           />
 
           <Route path="/organizations/:orgId/" component={OrganizationHomeContainer}>
-            <Route
-              path="projects/"
-              component={errorHandler(OrganizationTeamsProjectsView)}
-            />
+            <Redirect from="projects/" to="/:orgId/" />
             {hooksOrgRoutes}
             {orgSettingsRoutes}
             <Route path="stats/" component={errorHandler(OrganizationStats)} />

+ 0 - 155
src/sentry/static/sentry/app/views/organizationTeamsProjects.jsx

@@ -1,155 +0,0 @@
-import PropTypes from 'prop-types';
-import React from 'react';
-import {Box, Flex} from 'grid-emotion';
-import {Link} from 'react-router';
-import LazyLoad from 'react-lazyload';
-
-import BarChart from 'app/components/barChart';
-import Button from 'app/components/buttons/button';
-import {Client} from 'app/api';
-import {loadStats} from 'app/actionCreators/projects';
-import {Panel, PanelBody, PanelHeader, PanelItem} from 'app/components/panels';
-import ProjectLabel from 'app/components/projectLabel';
-import SentryTypes from 'app/proptypes';
-import SettingsPageHeader from 'app/views/settings/components/settingsPageHeader';
-import {t, tct} from 'app/locale';
-import withProjects from 'app/utils/withProjects';
-import withTeams from 'app/utils/withTeams';
-import getProjectsByTeams from 'app/utils/getProjectsByTeams';
-import {sortProjects} from 'app/utils';
-
-class OrganizationTeamsProjectsView extends React.Component {
-  static propTypes = {
-    params: PropTypes.object,
-    projects: PropTypes.array,
-    teams: PropTypes.array,
-  };
-
-  static contextTypes = {
-    organization: SentryTypes.Organization,
-  };
-
-  componentWillMount() {
-    this.api = new Client();
-  }
-
-  componentDidMount() {
-    this.fetchStats();
-  }
-
-  componentWillUnmount() {
-    this.api.clear();
-  }
-
-  fetchStats() {
-    loadStats(this.api, {
-      orgId: this.props.params.orgId,
-      query: {
-        since: new Date().getTime() / 1000 - 3600 * 24,
-        stat: 'generated',
-        group: 'project',
-      },
-    });
-  }
-
-  renderNoProjects(teamSlug) {
-    let {orgId} = this.props.params;
-    return (
-      <tbody>
-        <tr>
-          <td>
-            <p className="project-list-empty">
-              {tct(
-                'There are no projects in this team. Get started by [link:creating your first project].',
-                {
-                  link: (
-                    <a href={`/organizations/${orgId}/projects/new/?team=' + teamSlug`} />
-                  ),
-                }
-              )}
-            </p>
-          </td>
-        </tr>
-      </tbody>
-    );
-  }
-
-  renderProject = project => {
-    let {orgId} = this.props.params;
-    let chartData =
-      project.stats &&
-      project.stats.map(point => {
-        return {x: point[0], y: point[1]};
-      });
-
-    let access = new Set(this.context.organization.access);
-
-    return (
-      <PanelItem key={project.id} align="center">
-        <Flex flex="1" justify="space-between">
-          <Link to={`/${orgId}/${project.slug}/`}>
-            <ProjectLabel project={project} />
-          </Link>
-          <div className="project-chart">
-            {chartData && (
-              <LazyLoad>
-                <BarChart points={chartData} label="events" />
-              </LazyLoad>
-            )}
-          </div>
-        </Flex>
-        {access.has('project:write') && (
-          <Box ml={2}>
-            <Button size="small" to={`/settings/${orgId}/${project.slug}/`}>
-              {t('Manage Project')}
-            </Button>
-          </Box>
-        )}
-      </PanelItem>
-    );
-  };
-
-  renderProjectList(projects) {
-    return projects.map(this.renderProject);
-  }
-
-  renderTeamNode = (teamSlug, projects) => {
-    let display = teamSlug === null ? t('Projects Without Teams') : `#${teamSlug}`;
-    return (
-      <Panel key={teamSlug}>
-        <PanelHeader css={{textTransform: 'none'}}>{display}</PanelHeader>
-        <PanelBody>
-          {projects.length
-            ? this.renderProjectList(projects)
-            : this.renderNoProjects(teamSlug)}
-        </PanelBody>
-      </Panel>
-    );
-  };
-
-  render() {
-    const {projects, teams} = this.props;
-    const {projectsByTeam, teamlessProjects} = getProjectsByTeams(teams, projects);
-
-    return (
-      <div className="row">
-        <SettingsPageHeader title={t('Projects by Team')} />
-        <div className="col-md-9">
-          <div className="team-list">
-            {Object.keys(projectsByTeam)
-              .sort()
-              .map(teamSlug => {
-                return this.renderTeamNode(
-                  teamSlug,
-                  sortProjects(projectsByTeam[teamSlug])
-                );
-              })}
-            {!!teamlessProjects.length && this.renderTeamNode(null, teamlessProjects)}
-          </div>
-        </div>
-      </div>
-    );
-  }
-}
-
-export default withTeams(withProjects(OrganizationTeamsProjectsView));

+ 0 - 327
tests/js/spec/views/__snapshots__/organizationTeamsProjects.spec.jsx.snap

@@ -1,327 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`OrganizationTeamProjects Should render 1`] = `
-<withTeams
-  params={
-    Object {
-      "orgId": "org-slug",
-    }
-  }
->
-  <withProjects
-    params={
-      Object {
-        "orgId": "org-slug",
-      }
-    }
-    teams={Array []}
-  >
-    <OrganizationTeamsProjectsView
-      params={
-        Object {
-          "orgId": "org-slug",
-        }
-      }
-      projects={
-        Array [
-          Object {
-            "hasAccess": true,
-            "id": "2",
-            "isBookmarked": false,
-            "isMember": true,
-            "name": "Project Name",
-            "slug": "project-slug",
-            "teams": Array [
-              Object {
-                "id": "1",
-                "isMember": true,
-                "name": "Team Name",
-                "slug": "team-slug",
-              },
-            ],
-          },
-          Object {
-            "hasAccess": true,
-            "id": "3",
-            "isBookmarked": false,
-            "isMember": true,
-            "name": "Project Name 2",
-            "slug": "project-slug-2",
-            "teams": Array [],
-          },
-        ]
-      }
-      teams={Array []}
-    >
-      <div
-        className="row"
-      >
-        <SettingsPageHeading
-          title="Projects by Team"
-        >
-          <Wrapper>
-            <div
-              className="css-1pnrn3o-Wrapper e1kblvez0"
-            >
-              <Flex
-                align="center"
-              >
-                <Base
-                  align="center"
-                  className="css-5ipae5"
-                >
-                  <div
-                    className="css-5ipae5"
-                    is={null}
-                  >
-                    <Title>
-                      <div
-                        className="css-zmdcxu-Title e1kblvez1"
-                      >
-                        Projects by Team
-                      </div>
-                    </Title>
-                  </div>
-                </Base>
-              </Flex>
-            </div>
-          </Wrapper>
-        </SettingsPageHeading>
-        <div
-          className="col-md-9"
-        >
-          <div
-            className="team-list"
-          >
-            <Panel
-              key="null"
-            >
-              <StyledPanel>
-                <div
-                  className="css-17lswg2-StyledPanel e1laxa7d0"
-                >
-                  <PanelHeader
-                    className="css-geruia"
-                  >
-                    <StyledPanelHeader
-                      className="css-geruia"
-                    >
-                      <Component
-                        className="css-1v8jmfi-StyledPanelHeader-getPadding e1p8v8nv0"
-                      >
-                        <Flex
-                          align="center"
-                          className="css-1v8jmfi-StyledPanelHeader-getPadding e1p8v8nv0"
-                          justify="space-between"
-                        >
-                          <Base
-                            align="center"
-                            className="e1p8v8nv0 css-6jalzv-StyledPanelHeader-getPadding"
-                            justify="space-between"
-                          >
-                            <div
-                              className="e1p8v8nv0 css-6jalzv-StyledPanelHeader-getPadding"
-                              is={null}
-                            >
-                              Projects Without Teams
-                            </div>
-                          </Base>
-                        </Flex>
-                      </Component>
-                    </StyledPanelHeader>
-                  </PanelHeader>
-                  <PanelBody
-                    direction="column"
-                    disablePadding={true}
-                    flex={false}
-                  >
-                    <div
-                      className="css-9vq8an-textStyles"
-                    >
-                      <PanelItem
-                        align="center"
-                        key="3"
-                        p={2}
-                      >
-                        <StyledPanelItem
-                          align="center"
-                          p={2}
-                        >
-                          <Base
-                            align="center"
-                            className="css-dmmai1-StyledPanelItem eo8n7lk0"
-                            p={2}
-                          >
-                            <div
-                              className="css-dmmai1-StyledPanelItem eo8n7lk0"
-                              is={null}
-                            >
-                              <Flex
-                                flex="1"
-                                justify="space-between"
-                              >
-                                <Base
-                                  className="css-b5qfy7"
-                                  flex="1"
-                                  justify="space-between"
-                                >
-                                  <div
-                                    className="css-b5qfy7"
-                                    is={null}
-                                  >
-                                    <Link
-                                      onlyActiveOnIndex={false}
-                                      style={Object {}}
-                                      to="/org-slug/project-slug-2/"
-                                    >
-                                      <a
-                                        onClick={[Function]}
-                                        style={Object {}}
-                                      >
-                                        <ProjectLabel
-                                          project={
-                                            Object {
-                                              "hasAccess": true,
-                                              "id": "3",
-                                              "isBookmarked": false,
-                                              "isMember": true,
-                                              "name": "Project Name 2",
-                                              "slug": "project-slug-2",
-                                              "teams": Array [],
-                                            }
-                                          }
-                                        >
-                                          <span
-                                            className="project-label"
-                                            project={
-                                              Object {
-                                                "hasAccess": true,
-                                                "id": "3",
-                                                "isBookmarked": false,
-                                                "isMember": true,
-                                                "name": "Project Name 2",
-                                                "slug": "project-slug-2",
-                                                "teams": Array [],
-                                              }
-                                            }
-                                          >
-                                            <span
-                                              className="project-name"
-                                            >
-                                              project-slug-2
-                                            </span>
-                                          </span>
-                                        </ProjectLabel>
-                                      </a>
-                                    </Link>
-                                    <div
-                                      className="project-chart"
-                                    />
-                                  </div>
-                                </Base>
-                              </Flex>
-                              <Box
-                                ml={2}
-                              >
-                                <Base
-                                  className="css-1dvsqd3"
-                                  ml={2}
-                                >
-                                  <div
-                                    className="css-1dvsqd3"
-                                    is={null}
-                                  >
-                                    <Button
-                                      disabled={false}
-                                      size="small"
-                                      to="/settings/org-slug/project-slug-2/"
-                                    >
-                                      <StyledButton
-                                        aria-label="Manage Project"
-                                        disabled={false}
-                                        onClick={[Function]}
-                                        role="button"
-                                        size="small"
-                                        to="/settings/org-slug/project-slug-2/"
-                                      >
-                                        <Component
-                                          aria-label="Manage Project"
-                                          className="css-dkprmi-StyledButton-getColors e17811v30"
-                                          disabled={false}
-                                          onClick={[Function]}
-                                          role="button"
-                                          size="small"
-                                          to="/settings/org-slug/project-slug-2/"
-                                        >
-                                          <Link
-                                            aria-label="Manage Project"
-                                            className="css-dkprmi-StyledButton-getColors e17811v30"
-                                            disabled={false}
-                                            onClick={[Function]}
-                                            onlyActiveOnIndex={false}
-                                            role="button"
-                                            size="small"
-                                            style={Object {}}
-                                            to="/settings/org-slug/project-slug-2/"
-                                          >
-                                            <a
-                                              aria-label="Manage Project"
-                                              className="css-dkprmi-StyledButton-getColors e17811v30"
-                                              disabled={false}
-                                              onClick={[Function]}
-                                              role="button"
-                                              size="small"
-                                              style={Object {}}
-                                            >
-                                              <ButtonLabel
-                                                size="small"
-                                              >
-                                                <Component
-                                                  className="css-179w01k-ButtonLabel e17811v31"
-                                                  size="small"
-                                                >
-                                                  <Flex
-                                                    align="center"
-                                                    className="css-179w01k-ButtonLabel e17811v31"
-                                                    size="small"
-                                                  >
-                                                    <Base
-                                                      align="center"
-                                                      className="e17811v31 css-8mahft-ButtonLabel"
-                                                      size="small"
-                                                    >
-                                                      <div
-                                                        className="e17811v31 css-8mahft-ButtonLabel"
-                                                        is={null}
-                                                        size="small"
-                                                      >
-                                                        Manage Project
-                                                      </div>
-                                                    </Base>
-                                                  </Flex>
-                                                </Component>
-                                              </ButtonLabel>
-                                            </a>
-                                          </Link>
-                                        </Component>
-                                      </StyledButton>
-                                    </Button>
-                                  </div>
-                                </Base>
-                              </Box>
-                            </div>
-                          </Base>
-                        </StyledPanelItem>
-                      </PanelItem>
-                    </div>
-                  </PanelBody>
-                </div>
-              </StyledPanel>
-            </Panel>
-          </div>
-        </div>
-      </div>
-    </OrganizationTeamsProjectsView>
-  </withProjects>
-</withTeams>
-`;

+ 0 - 36
tests/js/spec/views/organizationTeamsProjects.spec.jsx

@@ -1,36 +0,0 @@
-import React from 'react';
-import {mount} from 'enzyme';
-
-import ProjectsStore from 'app/stores/projectsStore';
-
-import OrganizationTeamsProjectsView from 'app/views/organizationTeamsProjects';
-
-describe('OrganizationTeamProjects', function() {
-  let project;
-  let project2;
-  let team;
-
-  beforeEach(function() {
-    team = TestStubs.Team({slug: 'team-slug'});
-    project = TestStubs.Project({teams: [team]});
-    project2 = TestStubs.Project({
-      id: '3',
-      slug: 'project-slug-2',
-      name: 'Project Name 2',
-    });
-
-    ProjectsStore.loadInitialData([project, project2]);
-    MockApiClient.addMockResponse({
-      url: '/organizations/org-slug/stats/',
-    });
-  });
-
-  it('Should render', function() {
-    let wrapper = mount(
-      <OrganizationTeamsProjectsView params={{orgId: 'org-slug'}} />,
-      TestStubs.routerContext()
-    );
-
-    expect(wrapper).toMatchSnapshot();
-  });
-});