feat: use orgnization logo as tour logo and allow to configure whether to enable tour in organization edit page (#3046)

This commit is contained in:
赵尧鹏 2024-07-10 14:18:04 +08:00 committed by GitHub
parent d8cb82f67a
commit 5686fe5d22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 0 deletions

View File

@ -73,6 +73,7 @@ type Organization struct {
EnableSoftDeletion bool `json:"enableSoftDeletion"`
IsProfilePublic bool `json:"isProfilePublic"`
UseEmailAsUsername bool `json:"useEmailAsUsername"`
EnableTour bool `json:"enableTour"`
MfaItems []*MfaItem `xorm:"varchar(300)" json:"mfaItems"`
AccountItems []*AccountItem `xorm:"varchar(5000)" json:"accountItems"`

View File

@ -16,6 +16,7 @@ import React, {Component, Suspense, lazy} from "react";
import "./App.less";
import {Helmet} from "react-helmet";
import * as Setting from "./Setting";
import {setIsTourVisible, setTourLogo} from "./TourConfig";
import {StyleProvider, legacyLogicalPropertiesTransformer} from "@ant-design/cssinjs";
import {GithubOutlined, InfoCircleFilled, ShareAltOutlined} from "@ant-design/icons";
import {Alert, Button, ConfigProvider, Drawer, FloatButton, Layout, Result, Tooltip} from "antd";
@ -247,6 +248,8 @@ class App extends Component {
this.setLanguage(account);
this.setTheme(Setting.getThemeData(account.organization), Conf.InitThemeAlgorithm);
setTourLogo(account.organization.logo);
setIsTourVisible(account.organization.enableTour);
} else {
if (res.data !== "Please login first") {
Setting.showMessage("error", `${i18next.t("application:Failed to sign in")}: ${res.msg}`);

View File

@ -446,6 +446,16 @@ class OrganizationEditPage extends React.Component {
}} />
</Col>
</Row>
<Row style={{marginTop: "20px"}} >
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 19 : 2}>
{Setting.getLabel(i18next.t("general:Enable tour"), i18next.t("general:Enable tour - Tooltip"))} :
</Col>
<Col span={1} >
<Switch checked={this.state.organization.enableTour} onChange={checked => {
this.updateOrganizationField("enableTour", checked);
}} />
</Col>
</Row>
<Row style={{marginTop: "20px"}} >
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
{Setting.getLabel(i18next.t("organization:Account items"), i18next.t("organization:Account items - Tooltip"))} :

View File

@ -44,6 +44,7 @@ class OrganizationListPage extends BaseListPage {
defaultPassword: "",
enableSoftDeletion: false,
isProfilePublic: true,
enableTour: true,
accountItems: [
{name: "Organization", visible: true, viewRule: "Public", modifyRule: "Admin"},
{name: "ID", visible: true, viewRule: "Public", modifyRule: "Immutable"},

View File

@ -208,6 +208,12 @@ export function setIsTourVisible(visible) {
window.dispatchEvent(new Event("storageTourChanged"));
}
export function setTourLogo(tourLogoSrc) {
if (tourLogoSrc !== "") {
TourObj["home"][0]["cover"] = (<img alt="casdoor.png" src={tourLogoSrc} />);
}
}
export function getTourVisible() {
return localStorage.getItem("isTourVisible") !== "false";
}