-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
14 changed files
with
403 additions
and
38 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import React from "react"; | ||
import { Form, FormGroup, FormText, Input, Label } from "reactstrap"; | ||
|
||
import { useProjectMetadataQuery } from "../projects/ProjectKgApi"; | ||
import { InlineSubmitButton } from "../../components/buttons/Button"; | ||
|
||
// class Nothing { | ||
// constructor(props) { | ||
// super(props); | ||
// this.state = ProjectDescription.getDerivedStateFromProps(props, {}); | ||
// this.onValueChange = this.handleChange.bind(this); | ||
// this.onSubmit = this.handleSubmit.bind(this); | ||
// } | ||
|
||
// static getDerivedStateFromProps(nextProps, prevState) { | ||
// const update = { value: nextProps.metadata.description, pristine: true }; | ||
// return { ...update, ...prevState }; | ||
// } | ||
|
||
// handleChange(e) { | ||
// if (e.target.values !== this.state.value) | ||
// this.setState({ value: e.target.value, updated: false, pristine: false }); | ||
// } | ||
|
||
// handleSubmit(e) { | ||
// e.preventDefault(); | ||
// this.setState({ value: this.state.value, updating: true }); | ||
// this.props.onProjectDescriptionChange(this.state.value) | ||
// .then(() => { | ||
// this.setState({ value: this.state.value, updated: true, updating: false }); | ||
// }); | ||
// } | ||
// } | ||
|
||
type ProjectDescriptionProps = { | ||
projectPath?: string; | ||
settingsReadOnly: boolean; | ||
}; | ||
|
||
function ProjectDescription({ projectPath, settingsReadOnly }: ProjectDescriptionProps) { | ||
const { data: kgData, isLoading } = useProjectMetadataQuery({ projectPath }, { skip: !projectPath }); | ||
const [isUpdating, setUpdating] = React.useState(false); | ||
const [isUpdated, setUpdated] = React.useState(false); | ||
const [isPristine, setPristine] = React.useState(false); | ||
const [value, setValue] = React.useState(kgData?.description ?? ""); | ||
|
||
const inputField = | ||
settingsReadOnly || isUpdating ? ( | ||
<Input id="projectDescription" readOnly value={value} /> | ||
) : ( | ||
<Input | ||
id="projectDescription" | ||
onChange={(event) => setValue(event.currentTarget.value)} | ||
data-cy="description-input" | ||
value={value} | ||
/> | ||
); | ||
|
||
const submitButton = settingsReadOnly ? null : ( | ||
<InlineSubmitButton | ||
className="updateProjectSettings" | ||
doneText="Updated" | ||
id="update-desc" | ||
isDone={isUpdated} | ||
isMainButton={true} | ||
isReadOnly={isUpdating || isPristine} | ||
isSubmitting={isUpdating} | ||
onSubmit={() => {}} | ||
pristine={isPristine} | ||
text="Update" | ||
tooltipPristine="Modify description to update value" | ||
/> | ||
); | ||
return ( | ||
<Form | ||
onSubmit={(e) => { | ||
console.log("submit"); | ||
}} | ||
> | ||
<FormGroup> | ||
<Label for="projectDescription">Project Description</Label> | ||
<div className="d-flex"> | ||
{inputField} | ||
{submitButton} | ||
</div> | ||
<FormText>A short description for the project</FormText> | ||
</FormGroup> | ||
</Form> | ||
); | ||
} | ||
|
||
export default ProjectDescription; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/*! | ||
* Copyright 2023 - Swiss Data Science Center (SDSC) | ||
* A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and | ||
* Eidgenössische Technische Hochschule Zürich (ETHZ). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import * as React from "react"; | ||
|
||
import { useProjectMetadataQuery } from "../projects/ProjectKgApi"; | ||
import EntityHeader from "../../components/entityHeader/EntityHeader"; | ||
import type { EntityHeaderProps } from "../../components/entityHeader/EntityHeader"; | ||
|
||
function ProjectEntityHeader(props: EntityHeaderProps) { | ||
const { fullPath } = props; | ||
// eslint-disable-next-line no-unused-vars | ||
const { data: _kgData } = useProjectMetadataQuery({ projectPath: fullPath }, { skip: !fullPath }); | ||
return <EntityHeader {...props} />; | ||
// TODO: Return the description from the KG | ||
// if (isError) return <EntityHeader {...props} />; | ||
// const description = { value: kgData?.description ?? "", isLoading }; | ||
// return <EntityHeader {...props} description={description} />; | ||
} | ||
|
||
export default ProjectEntityHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*! | ||
* Copyright 2023 - Swiss Data Science Center (SDSC) | ||
* A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and | ||
* Eidgenössische Technische Hochschule Zürich (ETHZ). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import React from "react"; | ||
import { Helmet } from "react-helmet"; | ||
|
||
import { useProjectJsonLdQuery, useProjectMetadataQuery } from "../projects/ProjectKgApi"; | ||
|
||
type ProjectJsonLdProps = { | ||
projectPathWithNamespace: string; | ||
projectTitle: string; | ||
}; | ||
|
||
function ProjectPageTitle({ projectPathWithNamespace, projectTitle }: ProjectJsonLdProps) { | ||
const kgProjectQueryParams = { | ||
projectPath: projectPathWithNamespace, | ||
}; | ||
const { data, isFetching, isLoading } = useProjectJsonLdQuery(kgProjectQueryParams); | ||
// eslint-disable-next-line no-unused-vars | ||
const { data: kgData } = useProjectMetadataQuery(kgProjectQueryParams); | ||
|
||
const projectDesc = kgData?.description; | ||
const pageTitle = projectDesc | ||
? `${projectTitle} • Project • ${projectPathWithNamespace} • ${projectDesc}` | ||
: `${projectTitle} • Project • ${projectPathWithNamespace}`; | ||
const jsonLd = | ||
!isFetching && !isLoading && data ? <script type="application/ld+json">{JSON.stringify(data)}</script> : null; | ||
return ( | ||
<Helmet key="page-title"> | ||
<title>{pageTitle}</title> | ||
{jsonLd} | ||
</Helmet> | ||
); | ||
} | ||
|
||
export default ProjectPageTitle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ProjectEntityHeader from "./ProjectEntityHeader"; | ||
|
||
export { ProjectEntityHeader }; |
Oops, something went wrong.