Skip to content

Commit

Permalink
Merge pull request #488 from lowcoder-org/dev
Browse files Browse the repository at this point in the history
Dev -> Main for v2.1.5
  • Loading branch information
FalkWolsky authored Nov 10, 2023
2 parents 445f960 + 05c0cc8 commit 31b7d99
Show file tree
Hide file tree
Showing 65 changed files with 2,122 additions and 637 deletions.
8 changes: 2 additions & 6 deletions client/packages/lowcoder-cli/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ declare module "*.svg" {
React.SVGProps<SVGSVGElement> & { title?: string }
>;

const src: string;
export default src;
// const src: string;
// export default src;
}

declare module "*.md" {
Expand All @@ -31,10 +31,6 @@ declare var REACT_APP_LANGUAGES: string;
declare var REACT_APP_COMMIT_ID: string;
declare var REACT_APP_API_HOST: string;
declare var LOWCODER_NODE_SERVICE_URL: string;
declare var REACT_APP_LOWCODER_SHOW_BRAND: string;
declare var REACT_APP_LOWCODER_CUSTOM_LOGO: string;
declare var REACT_APP_LOWCODER_CUSTOM_LOGO_SQUARE: string;
declare var REACT_APP_LOWCODER_CUSTOM_AUTH_WELCOME_TEXT: string;
declare var REACT_APP_ENV: string;
declare var REACT_APP_BUILD_ID: string;
declare var REACT_APP_LOG_LEVEL: string;
Expand Down
16 changes: 0 additions & 16 deletions client/packages/lowcoder-dev-utils/buildVars.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,6 @@ export const buildVars = [
name: "REACT_APP_API_HOST",
defaultValue: "",
},
{
name: "REACT_APP_LOWCODER_SHOW_BRAND",
defaultValue: 'false',
},
{
name: "REACT_APP_LOWCODER_CUSTOM_LOGO",
defaultValue: '',
},
{
name: "REACT_APP_LOWCODER_CUSTOM_LOGO_SQUARE",
defaultValue: '',
},
{
name: "REACT_APP_LOWCODER_CUSTOM_AUTH_WELCOME_TEXT",
defaultValue: '',
},
{
name: "LOWCODER_NODE_SERVICE_URL",
defaultValue: "",
Expand Down
6 changes: 0 additions & 6 deletions client/packages/lowcoder/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,5 @@
<div id="root"></div>
<script type="module" src="/src/index.ts"></script>
<!-- <%- browserCheckScript %> -->
<script>
window.lowcoder_show_brand = "<%= process.env.REACT_APP_LOWCODER_SHOW_BRAND %>";
window.lowcoder_custom_auth_welcome_text = "<%= process.env.REACT_APP_LOWCODER_CUSTOM_AUTH_WELCOME_TEXT %>";
window.lowcoder_custom_logo = "<%= process.env.REACT_APP_LOWCODER_CUSTOM_LOGO %>";
window.lowcoder_custom_logo_square = "<%= process.env.REACT_APP_LOWCODER_CUSTOM_LOGO_SQUARE %>";
</script>
</body>
</html>
4 changes: 0 additions & 4 deletions client/packages/lowcoder/src/app-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ declare var REACT_APP_LANGUAGES: string;
declare var REACT_APP_COMMIT_ID: string;
declare var REACT_APP_API_HOST: string;
declare var LOWCODER_NODE_SERVICE_URL: string;
declare var REACT_APP_LOWCODER_SHOW_BRAND: string;
declare var REACT_APP_LOWCODER_CUSTOM_LOGO: string;
declare var REACT_APP_LOWCODER_CUSTOM_LOGO_SQUARE: string;
declare var REACT_APP_LOWCODER_CUSTOM_AUTH_WELCOME_TEXT: string;
declare var REACT_APP_ENV: string;
declare var REACT_APP_BUILD_ID: string;
declare var REACT_APP_LOG_LEVEL: string;
Expand Down
27 changes: 3 additions & 24 deletions client/packages/lowcoder/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ import { CodeEditorTooltipContainer } from "base/codeEditor/codeEditor";
import { ProductLoading } from "components/ProductLoading";
import { language, trans } from "i18n";
import { loadComps } from "comps";
import { fetchHomeData } from "redux/reduxActions/applicationActions";
import { initApp } from "util/commonUtils";
import ApplicationHome from "./pages/ApplicationV2";
import { favicon } from "@lowcoder-ee/assets/images";
import { hasQueryParam } from "util/urlUtils";
import { isFetchUserFinished } from "redux/selectors/usersSelectors";
import { SystemWarning } from "./components/SystemWarning";
import { getBrandingConfig, getSystemConfigFetching } from "./redux/selectors/configSelectors";
import { getBrandingConfig } from "./redux/selectors/configSelectors";
import { buildMaterialPreviewURL } from "./util/materialUtils";
import GlobalInstances from 'components/GlobalInstances';

Expand All @@ -71,35 +70,22 @@ const Wrapper = (props: { children: React.ReactNode }) => (

type AppIndexProps = {
isFetchUserFinished: boolean;
isFetchHomeFinished: boolean;
// isFetchingConfig: boolean;
currentOrgId?: string;
orgDev: boolean;
defaultHomePage: string | null | undefined;
fetchConfig: (orgId?: string) => void;
getCurrentUser: () => void;
fetchHome: () => void;
favicon: string;
brandName: string;
};

class AppIndex extends React.Component<AppIndexProps, any> {
componentDidMount() {
this.props.getCurrentUser();
const { pathname } = history.location;

this.props.fetchConfig(this.props.currentOrgId);

if (pathname === BASE_URL) {
this.props.fetchHome();
}
}

componentDidUpdate(prevProps: AppIndexProps) {
if (history.location.pathname === BASE_URL) {
this.props.fetchHome();
}
if(prevProps.currentOrgId !== this.props.currentOrgId) {
if(prevProps.currentOrgId !== this.props.currentOrgId && this.props.currentOrgId !== '') {
this.props.fetchConfig(this.props.currentOrgId);
}
}
Expand All @@ -108,11 +94,7 @@ class AppIndex extends React.Component<AppIndexProps, any> {
const isTemplate = hasQueryParam("template");
const pathname = history.location.pathname;
// make sure all users in this app have checked login info
if (
!this.props.isFetchUserFinished ||
// this.props.isFetchingConfig ||
(pathname === BASE_URL && !this.props.isFetchHomeFinished)
) {
if (!this.props.isFetchUserFinished) {
const hideLoadingHeader = isTemplate || isAuthUnRequired(pathname);
return <ProductLoading hideHeader={hideLoadingHeader} />;
}
Expand Down Expand Up @@ -185,11 +167,9 @@ class AppIndex extends React.Component<AppIndexProps, any> {

const mapStateToProps = (state: AppState) => ({
isFetchUserFinished: isFetchUserFinished(state),
// isFetchingConfig: getSystemConfigFetching(state),
orgDev: state.ui.users.user.orgDev,
currentOrgId: state.ui.users.user.currentOrgId,
defaultHomePage: state.ui.application.homeOrg?.commonSettings.defaultHomePage,
isFetchHomeFinished: state.ui.application.loadingStatus.fetchHomeDataFinished,
favicon: getBrandingConfig(state)?.favicon
? buildMaterialPreviewURL(getBrandingConfig(state)?.favicon!)
: favicon,
Expand All @@ -201,7 +181,6 @@ const mapDispatchToProps = (dispatch: any) => ({
dispatch(fetchUserAction());
},
fetchConfig: (orgId?: string) => dispatch(fetchConfigAction(orgId)),
fetchHome: () => dispatch(fetchHomeData({})),
});

const AppIndexWithProps = connect(mapStateToProps, mapDispatchToProps)(AppIndex);
Expand Down
4 changes: 2 additions & 2 deletions client/packages/lowcoder/src/assets/images/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches
import { ReactComponent as LogoIcon } from "./logo.svg";
import { ReactComponent as LogoWithNameIcon } from "./logo-with-name.svg";
import { ReactComponent as LogoIcon } from "./logo-with-name-home.svg";
import { ReactComponent as LogoWithNameIcon } from "./logo-with-name-home.svg";
import { ReactComponent as LogoHomeIcon } from "./logo-with-name-home.svg";

export { default as favicon } from "./favicon.ico";
Expand Down
11 changes: 5 additions & 6 deletions client/packages/lowcoder/src/components/PageSkeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,13 @@ export default function PageSkeleton(props: IProps) {
</SkeletonWrapper>
);

// {/* headerStart={REACT_APP_LOWCODER_SHOW_BRAND === 'true' ? REACT_APP_LOWCODER_CUSTOM_LOGO !== "" ? <img src={REACT_APP_LOWCODER_CUSTOM_LOGO} alt="logo" /> :<StyledLogoWithName branding={true} /> : <StyledLogoHome branding={true} />} */}

return (
<Layout>
{!hideHeader && isHeaderReady && (
<Header
headerStart={
REACT_APP_LOWCODER_SHOW_BRAND === 'true' ?
REACT_APP_LOWCODER_CUSTOM_LOGO !== "" ? <img src={REACT_APP_LOWCODER_CUSTOM_LOGO} alt="logo" /> :<StyledLogoWithName branding={true} /> :
<StyledLogoHome branding={true} />
}
<Header
headerStart={<StyledLogoWithName branding={true} />}
style={{ backgroundColor: brandingConfig?.headerColor, ...props.headStyle }}
/>
)}
Expand All @@ -95,5 +93,6 @@ export default function PageSkeleton(props: IProps) {
<MainContent>{!hideContent && skeleton}</MainContent>
</Layout>
</Layout>

);
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export const getStyle = (style: DateTimeStyleType) => {
: style.text};
}
.ant-picker-clear {
inset-inline-end: 18px
}
.ant-picker-clear:hover {
color: ${style.text === "#222222"
? "#8B8FA3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ const LabelWrapper = styled.div<{
}>`
display: flex;
align-items: center;
line-height: 100%;
margin-right: 8px;
margin-bottom: ${(props) => (props.position === "row" ? 0 : "3.5px")};
justify-content: ${(props) => (props.align === "left" ? "start" : "end")};
Expand Down
4 changes: 0 additions & 4 deletions client/packages/lowcoder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ debug(`REACT_APP_LANGUAGES:, ${REACT_APP_LANGUAGES}`);
debug(`REACT_APP_API_HOST:, ${REACT_APP_API_HOST}`);
debug(`REACT_APP_ENV:, ${REACT_APP_ENV}`);
debug(`REACT_APP_LOG_LEVEL:, ${REACT_APP_LOG_LEVEL}`);
debug(`REACT_APP_LOWCODER_SHOW_BRAND:, ${REACT_APP_LOWCODER_SHOW_BRAND}`);
debug(`REACT_APP_LOWCODER_CUSTOM_AUTH_WELCOME_TEXT:, ${REACT_APP_LOWCODER_CUSTOM_AUTH_WELCOME_TEXT}`);
debug(`LOWCODER_CUSTOM_LOGO:, ${REACT_APP_LOWCODER_CUSTOM_LOGO}`);
debug(`LOWCODER_CUSTOM_LOGO_SQUARE:, ${REACT_APP_LOWCODER_CUSTOM_LOGO_SQUARE}`);

try {
bootstrap();
Expand Down
10 changes: 1 addition & 9 deletions client/packages/lowcoder/src/pages/ApplicationV2/HomeView.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import { useDispatch, useSelector } from "react-redux";
import { useSelector } from "react-redux";
import { HomeLayout } from "./HomeLayout";
import { useEffect } from "react";
import { fetchFolderElements } from "../../redux/reduxActions/folderActions";
import { getUser } from "../../redux/selectors/usersSelectors";
import { folderElementsSelector } from "../../redux/selectors/folderSelector";

export function HomeView() {
const dispatch = useDispatch();

const elements = useSelector(folderElementsSelector)[""];
const user = useSelector(getUser);

useEffect(() => {
dispatch(fetchFolderElements({}));
}, []);

if (!user.currentOrgId) {
return null;
}
Expand Down
10 changes: 4 additions & 6 deletions client/packages/lowcoder/src/pages/common/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,8 @@ export default function Header(props: HeaderProps) {
const headerStart = (
<>
<StyledLink onClick={() => history.push(ALL_APPLICATIONS_URL)}>
{REACT_APP_LOWCODER_SHOW_BRAND === 'true' ?
REACT_APP_LOWCODER_CUSTOM_LOGO_SQUARE !== "" ? <img src={REACT_APP_LOWCODER_CUSTOM_LOGO_SQUARE } height={24} width={24} alt="logo" /> :<LogoIcon /> :
<LogoHome />}
{/* {REACT_APP_LOWCODER_SHOW_BRAND === 'true' ? REACT_APP_LOWCODER_CUSTOM_LOGO_SQUARE !== "" ? <img src={REACT_APP_LOWCODER_CUSTOM_LOGO_SQUARE } height={24} width={24} alt="logo" /> :<LogoIcon /> : <LogoHome />} */}
<LogoHome />
</StyledLink>
{editName ? (
<Wrapper>
Expand Down Expand Up @@ -434,9 +433,8 @@ export function AppHeader() {
const brandingConfig = useSelector(getBrandingConfig);
const headerStart = (
<StyledLink onClick={() => history.push(ALL_APPLICATIONS_URL)}>
{REACT_APP_LOWCODER_SHOW_BRAND === 'true' ?
REACT_APP_LOWCODER_CUSTOM_LOGO !== "" ? <img src={REACT_APP_LOWCODER_CUSTOM_LOGO} height={28} alt="logo" /> :<LogoWithName branding={!user.orgDev} /> :
<LogoHome />}
{/* {REACT_APP_LOWCODER_SHOW_BRAND === 'true' ? REACT_APP_LOWCODER_CUSTOM_LOGO !== "" ? <img src={REACT_APP_LOWCODER_CUSTOM_LOGO} height={28} alt="logo" /> :<LogoWithName branding={!user.orgDev} /> : <LogoHome />} */}
<LogoHome />
</StyledLink>
);
const headerEnd = <HeaderProfile user={user} />;
Expand Down
18 changes: 14 additions & 4 deletions client/packages/lowcoder/src/pages/userAuth/authUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import {
ThirdPartyAuthType,
ThirdPartyConfigType,
} from "constants/authConstants";
import history from "util/history";

export const AuthContext = createContext<{
systemConfig?: SystemConfig;
inviteInfo?: AuthInviteInfo;
thirdPartyAuthError?: boolean;
fetchUserAfterAuthSuccess?: () => void;
}>(undefined as any);

export const getSafeAuthRedirectURL = (redirectUrl: string | null) => {
Expand All @@ -39,15 +41,21 @@ export const getSafeAuthRedirectURL = (redirectUrl: string | null) => {
export function useAuthSubmit(
requestFunc: () => AxiosPromise<ApiResponse>,
infoCompleteCheck: boolean,
redirectUrl: string | null
redirectUrl: string | null,
onAuthSuccess?: () => void,
) {
const [loading, setLoading] = useState(false);
return {
loading: loading,
onSubmit: () => {
setLoading(true);
requestFunc()
.then((resp) => authRespValidate(resp, infoCompleteCheck, redirectUrl))
.then((resp) => authRespValidate(
resp,
infoCompleteCheck,
redirectUrl,
onAuthSuccess,
))
.catch((e) => {
messageInstance.error(e.message);
})
Expand All @@ -66,7 +74,8 @@ export function useAuthSubmit(
export function authRespValidate(
resp: AxiosResponse<ApiResponse>,
infoCompleteCheck: boolean,
redirectUrl: string | null
redirectUrl: string | null,
onAuthSuccess?: () => void
) {
let replaceUrl = redirectUrl || BASE_URL;
if (infoCompleteCheck) {
Expand All @@ -76,7 +85,8 @@ export function authRespValidate(
: USER_INFO_COMPLETION;
}
if (doValidResponse(resp)) {
window.location.replace(replaceUrl);
onAuthSuccess?.();
history.replace(replaceUrl);
} else if (
resp.data.code === SERVER_ERROR_CODES.EXCEED_MAX_USER_ORG_COUNT ||
resp.data.code === SERVER_ERROR_CODES.ALREADY_IN_ORGANIZATION
Expand Down
5 changes: 3 additions & 2 deletions client/packages/lowcoder/src/pages/userAuth/formLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function FormLogin(props: FormLoginProps) {
const [account, setAccount] = useState("");
const [password, setPassword] = useState("");
const redirectUrl = useRedirectUrl();
const { systemConfig, inviteInfo } = useContext(AuthContext);
const { systemConfig, inviteInfo, fetchUserAfterAuthSuccess } = useContext(AuthContext);
const invitationId = inviteInfo?.invitationId;
const authId = systemConfig?.form.id;
const location = useLocation();
Expand All @@ -49,7 +49,8 @@ export default function FormLogin(props: FormLoginProps) {
authId,
}),
false,
redirectUrl
redirectUrl,
fetchUserAfterAuthSuccess,
);

return (
Expand Down
6 changes: 6 additions & 0 deletions client/packages/lowcoder/src/pages/userAuth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AuthRoutes } from "@lowcoder-ee/constants/authConstants";
import { AuthLocationState } from "constants/authConstants";
import { ProductLoading } from "components/ProductLoading";
import { fetchConfigAction } from "redux/reduxActions/configActions";
import { fetchUserAction } from "redux/reduxActions/userActions";
import _ from "lodash";

export default function UserAuth() {
Expand All @@ -34,12 +35,17 @@ export default function UserAuth() {
return <ProductLoading hideHeader />;
}

const fetchUserAfterAuthSuccess = () => {
dispatch(fetchUserAction());
}

return (
<AuthContext.Provider
value={{
systemConfig: systemConfig,
inviteInfo: location.state?.inviteInfo,
thirdPartyAuthError: location.state?.thirdPartyAuthError,
fetchUserAfterAuthSuccess,
}}
>
<Switch location={location}>
Expand Down
11 changes: 3 additions & 8 deletions client/packages/lowcoder/src/pages/userAuth/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,15 @@ function Login() {
loginCardView = thirdPartyLoginView;
}

const loginHeading = REACT_APP_LOWCODER_CUSTOM_AUTH_WELCOME_TEXT !== ""
? REACT_APP_LOWCODER_CUSTOM_AUTH_WELCOME_TEXT
: getLoginTitle(inviteInfo?.createUserName, systemConfig?.branding?.brandName)

const loginSubHeading = REACT_APP_LOWCODER_CUSTOM_AUTH_WELCOME_TEXT !== ""
? trans("userAuth.poweredByLowcoder")
: ''
const loginHeading = getLoginTitle(inviteInfo?.createUserName, systemConfig?.branding?.brandName)
const loginSubHeading = '' // REACT_APP_LOWCODER_CUSTOM_AUTH_WELCOME_TEXT !== "" ? trans("userAuth.poweredByLowcoder") : ''

return (
<AuthContainer
heading={loginHeading}
subHeading={loginSubHeading}
>
{loginCardView}
<FormLogin organizationId={organizationId} />
</AuthContainer>
);
}
Expand Down
Loading

0 comments on commit 31b7d99

Please sign in to comment.