## Description Rename `design-system` package to `@appsmith/ads` ## Automation /ok-to-test tags="@tag.All" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10319507327> > Commit: 65d9664dd75b750496458a6e1652e0da858e1fc6 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10319507327&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Fri, 09 Aug 2024 13:47:50 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No
133 lines
3.8 KiB
TypeScript
133 lines
3.8 KiB
TypeScript
import type { AppState } from "ee/reducers";
|
|
import * as Sentry from "@sentry/react";
|
|
import { fetchDefaultPlugins } from "actions/pluginActions";
|
|
import { getAllTemplates, getTemplateFilters } from "actions/templateActions";
|
|
import { setHeaderMeta } from "actions/themeActions";
|
|
import { Text } from "@appsmith/ads";
|
|
import { isEmpty } from "lodash";
|
|
import ReconnectDatasourceModal from "pages/Editor/gitSync/ReconnectDatasourceModal";
|
|
import React, { useEffect } from "react";
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
import { Route, Switch, useRouteMatch } from "react-router-dom";
|
|
import {
|
|
allTemplatesFiltersSelector,
|
|
getForkableWorkspaces,
|
|
} from "selectors/templatesSelectors";
|
|
import styled from "styled-components";
|
|
import { editorInitializer } from "utils/editor/EditorUtils";
|
|
|
|
import { fetchAllWorkspaces } from "ee/actions/workspaceActions";
|
|
import TemplateFilters from "./TemplateFilters";
|
|
import { TemplateContent } from "./TemplateContent";
|
|
import TemplateView from "./TemplateView";
|
|
import { getFetchedWorkspaces } from "ee/selectors/workspaceSelectors";
|
|
|
|
const SentryRoute = Sentry.withSentryRouting(Route);
|
|
|
|
const PageWrapper = styled.div`
|
|
margin-top: ${(props) => props.theme.homePage.header}px;
|
|
background-color: var(--ads-v2-color-gray-50);
|
|
`;
|
|
|
|
const SidebarWrapper = styled.div`
|
|
width: ${(props) => props.theme.homePage.sidebar}px;
|
|
height: 100%;
|
|
display: flex;
|
|
padding: 25px 16px 0;
|
|
flex-direction: column;
|
|
position: fixed;
|
|
`;
|
|
|
|
const SecondaryWrapper = styled.div`
|
|
height: calc(
|
|
100vh - ${(props) => props.theme.homePage.header + props.theme.spaces[11]}px
|
|
);
|
|
position: relative;
|
|
`;
|
|
|
|
export const TemplateListWrapper = styled.div`
|
|
padding-top: ${(props) => props.theme.spaces[11]}px;
|
|
width: calc(100% - ${(props) => props.theme.homePage.sidebar}px);
|
|
min-height: 100vh;
|
|
margin-left: ${(props) => props.theme.homePage.sidebar}px;
|
|
`;
|
|
|
|
export const ResultsCount = styled(Text)`
|
|
color: var(--ads-v2-color-fg-emphasis);
|
|
margin-top: 20px;
|
|
margin-left: ${(props) => props.theme.spaces[12] - 8}px;
|
|
padding-bottom: 20px;
|
|
`;
|
|
|
|
function TemplateRoutes() {
|
|
const { path } = useRouteMatch();
|
|
const dispatch = useDispatch();
|
|
const workspaceListLength = useSelector(
|
|
(state: AppState) => getFetchedWorkspaces(state).length,
|
|
);
|
|
const pluginListLength = useSelector(
|
|
(state: AppState) => state.entities.plugins.defaultPluginList.length,
|
|
);
|
|
const templatesCount = useSelector(
|
|
(state: AppState) => state.ui.templates.templates.length,
|
|
);
|
|
const filters = useSelector(allTemplatesFiltersSelector);
|
|
|
|
useEffect(() => {
|
|
dispatch(setHeaderMeta(true, true));
|
|
// Generate the widget config list
|
|
editorInitializer();
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
if (!templatesCount) {
|
|
dispatch(getAllTemplates());
|
|
}
|
|
}, [templatesCount]);
|
|
|
|
useEffect(() => {
|
|
if (!workspaceListLength) {
|
|
dispatch(fetchAllWorkspaces());
|
|
}
|
|
}, [workspaceListLength]);
|
|
|
|
useEffect(() => {
|
|
if (!pluginListLength) {
|
|
dispatch(fetchDefaultPlugins());
|
|
}
|
|
}, [pluginListLength]);
|
|
|
|
useEffect(() => {
|
|
if (isEmpty(filters.functions)) {
|
|
dispatch(getTemplateFilters());
|
|
}
|
|
}, [filters]);
|
|
|
|
return (
|
|
<Switch>
|
|
<SentryRoute component={TemplateView} path={`${path}/:templateId`} />
|
|
<SentryRoute component={Templates} path={path} />
|
|
</Switch>
|
|
);
|
|
}
|
|
|
|
function Templates() {
|
|
const workspaceList = useSelector(getForkableWorkspaces);
|
|
|
|
return (
|
|
<PageWrapper>
|
|
<SidebarWrapper>
|
|
<SecondaryWrapper>
|
|
<ReconnectDatasourceModal />
|
|
<TemplateFilters />
|
|
</SecondaryWrapper>
|
|
</SidebarWrapper>
|
|
<TemplateListWrapper>
|
|
<TemplateContent isForkingEnabled={!!workspaceList.length} />
|
|
</TemplateListWrapper>
|
|
</PageWrapper>
|
|
);
|
|
}
|
|
|
|
export default TemplateRoutes;
|