Web: People: refactoring - changing document.title with changeTitleDocument()
This commit is contained in:
parent
f3b8e4880c
commit
939a29442f
@ -13,7 +13,7 @@ const i18n = createI18N({
|
|||||||
localesPath: "Article"
|
localesPath: "Article"
|
||||||
});
|
});
|
||||||
|
|
||||||
const { changeLanguage } = commonUtils;
|
const { changeLanguage, changeDocumentTitle } = commonUtils;
|
||||||
const { getCurrentModule, isAdmin } = initStore.auth.selectors;
|
const { getCurrentModule, isAdmin } = initStore.auth.selectors;
|
||||||
|
|
||||||
const StyledTreeMenu = styled(TreeMenu)`
|
const StyledTreeMenu = styled(TreeMenu)`
|
||||||
@ -64,11 +64,13 @@ class ArticleBodyContent extends React.Component {
|
|||||||
this.changeTitleDocument();
|
this.changeTitleDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate(prevProps) {
|
||||||
this.changeTitleDocument();
|
if(prevProps.selectedKeys[0] !== this.props.selectedKeys[0]) {
|
||||||
|
this.changeTitleDocument();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
changeTitleDocument() {
|
changeTitleDocument(data = null) {
|
||||||
const {
|
const {
|
||||||
organizationName,
|
organizationName,
|
||||||
groups,
|
groups,
|
||||||
@ -76,10 +78,10 @@ class ArticleBodyContent extends React.Component {
|
|||||||
currentModuleName
|
currentModuleName
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const currentGroup = getSelectedGroup(groups, selectedKeys[0]);
|
const currentGroup = getSelectedGroup(groups, data ? data[0] : selectedKeys[0]);
|
||||||
document.title = currentGroup
|
currentGroup
|
||||||
? `${currentGroup.name} – ${currentModuleName}`
|
? changeDocumentTitle(`${currentGroup.name} – ${currentModuleName}`)
|
||||||
: `${currentModuleName} – ${organizationName}`;
|
: changeDocumentTitle(`${currentModuleName} – ${organizationName}`);
|
||||||
}
|
}
|
||||||
shouldComponentUpdate(nextProps) {
|
shouldComponentUpdate(nextProps) {
|
||||||
if (
|
if (
|
||||||
@ -97,17 +99,10 @@ class ArticleBodyContent extends React.Component {
|
|||||||
|
|
||||||
onSelect = data => {
|
onSelect = data => {
|
||||||
const {
|
const {
|
||||||
currentModuleName,
|
selectGroup
|
||||||
selectGroup,
|
|
||||||
groups,
|
|
||||||
organizationName
|
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const currentGroup = getSelectedGroup(groups, data[0]);
|
this.changeTitleDocument(data)
|
||||||
document.title = currentGroup
|
|
||||||
? `${currentGroup.name} – ${currentModuleName}`
|
|
||||||
: `${currentModuleName} – ${organizationName}`;
|
|
||||||
|
|
||||||
selectGroup(
|
selectGroup(
|
||||||
data && data.length === 1 && data[0] !== "root" ? data[0] : null
|
data && data.length === 1 && data[0] !== "root" ? data[0] : null
|
||||||
);
|
);
|
||||||
|
@ -15,7 +15,7 @@ const i18n = createI18N({
|
|||||||
page: "GroupAction",
|
page: "GroupAction",
|
||||||
localesPath: "pages/GroupAction"
|
localesPath: "pages/GroupAction"
|
||||||
});
|
});
|
||||||
const { changeLanguage } = utils;
|
const { changeLanguage, changeDocumentTitle } = utils;
|
||||||
const { isAdmin } = store.auth.selectors;
|
const { isAdmin } = store.auth.selectors;
|
||||||
|
|
||||||
class GroupAction extends React.Component {
|
class GroupAction extends React.Component {
|
||||||
@ -23,8 +23,7 @@ class GroupAction extends React.Component {
|
|||||||
const { match, fetchGroup, t } = this.props;
|
const { match, fetchGroup, t } = this.props;
|
||||||
const { groupId } = match.params;
|
const { groupId } = match.params;
|
||||||
|
|
||||||
document.title = `${t("GroupAction")} – ${t("People")}`;
|
changeDocumentTitle(`${t("GroupAction")} – ${t("People")}`);
|
||||||
|
|
||||||
changeLanguage(i18n);
|
changeLanguage(i18n);
|
||||||
|
|
||||||
if (groupId) {
|
if (groupId) {
|
||||||
|
@ -16,15 +16,13 @@ const i18n = createI18N({
|
|||||||
page: "Profile",
|
page: "Profile",
|
||||||
localesPath: "pages/Profile"
|
localesPath: "pages/Profile"
|
||||||
});
|
});
|
||||||
const { changeLanguage } = utils;
|
const { changeLanguage, changeDocumentTitle } = utils;
|
||||||
const { isAdmin } = store.auth.selectors;
|
const { isAdmin } = store.auth.selectors;
|
||||||
|
|
||||||
class PureProfile extends React.Component {
|
class PureProfile extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
document.title = `${props.t("Profile")} – ${props.t("People")}`;
|
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
queryString: `${props.location.search.slice(1)}`
|
queryString: `${props.location.search.slice(1)}`
|
||||||
};
|
};
|
||||||
@ -34,6 +32,8 @@ class PureProfile extends React.Component {
|
|||||||
const { match, fetchProfile, t } = this.props;
|
const { match, fetchProfile, t } = this.props;
|
||||||
const { userId } = match.params;
|
const { userId } = match.params;
|
||||||
|
|
||||||
|
changeDocumentTitle(`${t("Profile")} – ${t("People")}`);
|
||||||
|
|
||||||
const queryParams = this.state.queryString.split("&");
|
const queryParams = this.state.queryString.split("&");
|
||||||
const arrayOfQueryParams = queryParams.map(queryParam =>
|
const arrayOfQueryParams = queryParams.map(queryParam =>
|
||||||
queryParam.split("=")
|
queryParam.split("=")
|
||||||
|
@ -20,7 +20,7 @@ const i18n = createI18N({
|
|||||||
page: "ProfileAction",
|
page: "ProfileAction",
|
||||||
localesPath: "pages/ProfileAction"
|
localesPath: "pages/ProfileAction"
|
||||||
});
|
});
|
||||||
const { changeLanguage } = utils;
|
const { changeLanguage, changeDocumentTitle } = utils;
|
||||||
const { isAdmin } = store.auth.selectors;
|
const { isAdmin } = store.auth.selectors;
|
||||||
|
|
||||||
class ProfileAction extends React.Component {
|
class ProfileAction extends React.Component {
|
||||||
@ -28,8 +28,7 @@ class ProfileAction extends React.Component {
|
|||||||
const { match, fetchProfile, t } = this.props;
|
const { match, fetchProfile, t } = this.props;
|
||||||
const { userId } = match.params;
|
const { userId } = match.params;
|
||||||
|
|
||||||
document.title = `${t("ProfileAction")} – ${t("People")}`;
|
changeDocumentTitle(`${t("ProfileAction")} – ${t("People")}`);
|
||||||
|
|
||||||
changeLanguage(i18n);
|
changeLanguage(i18n);
|
||||||
|
|
||||||
if (userId) {
|
if (userId) {
|
||||||
|
Loading…
Reference in New Issue
Block a user