fix: display composed icon for composed model with attribute (#399)

This commit is contained in:
stew-ro 2020-07-10 10:37:40 -07:00 коммит произвёл GitHub
Родитель 57736d0cb4
Коммит 18fb4d7105
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license. // Licensed under the MIT license.
import React from "react"; import React, { ReactElement } from "react";
import {connect} from "react-redux"; import {connect} from "react-redux";
import url from "url"; import url from "url";
import { RouteComponentProps } from "react-router-dom"; import { RouteComponentProps } from "react-router-dom";
@ -71,7 +71,9 @@ export interface IModel {
createdDateTime: string; createdDateTime: string;
lastUpdatedDateTime: string; lastUpdatedDateTime: string;
status: string; status: string;
iconName?: string; attributes?: {
isComposed: boolean;
};
} }
function mapStateToProps(state: IApplicationState) { function mapStateToProps(state: IApplicationState) {
@ -114,7 +116,7 @@ export default class ModelComposePage extends React.Component<IModelComposePageP
minWidth: 20, minWidth: 20,
maxWidth: 20, maxWidth: 20,
isResizable: true, isResizable: true,
onRender: (model: IModel) => <FontIcon iconName={model.iconName} className="model-fontIcon"/>, onRender: this.renderComposedIcon,
headerClassName: "list-header", headerClassName: "list-header",
}, },
{ {
@ -416,7 +418,6 @@ export default class ModelComposePage extends React.Component<IModelComposePageP
private getComposeModelByURl = async (idURL) => { private getComposeModelByURl = async (idURL) => {
const composedRes = await this.getResponse(idURL); const composedRes = await this.getResponse(idURL);
const composedModel: IModel = composedRes.data.modelInfo; const composedModel: IModel = composedRes.data.modelInfo;
composedModel.iconName = "Combine";
composedModel.key = composedModel.modelId; composedModel.key = composedModel.modelId;
return composedModel; return composedModel;
} }
@ -713,4 +714,12 @@ export default class ModelComposePage extends React.Component<IModelComposePageP
}, 1); }, 1);
} }
} }
private renderComposedIcon = (model: IModel): ReactElement => {
if (model.attributes && model.attributes.isComposed) {
return <FontIcon iconName={"Combine"} className="model-fontIcon"/>;
} else {
return null;
}
}
} }