mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-05 04:55:50 +01:00
Improve repository information page (#1636)
Only show relevant information for repository on repository information page. The initialization code example is only shown if the repository is still empty.
This commit is contained in:
@@ -21,67 +21,84 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
import React from "react";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import { Repository } from "@scm-manager/ui-types";
|
||||
import { repositories } from "@scm-manager/ui-components";
|
||||
import React, { FC, useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link, Repository } from "@scm-manager/ui-types";
|
||||
import { apiClient, repositories } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = WithTranslation & {
|
||||
type Props = {
|
||||
repository: Repository;
|
||||
};
|
||||
|
||||
class ProtocolInformation extends React.Component<Props> {
|
||||
render() {
|
||||
const { repository, t } = this.props;
|
||||
const href = repositories.getProtocolLinkByType(repository, "http");
|
||||
if (!href) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<h4>{t("scm-hg-plugin.information.clone")}</h4>
|
||||
<pre>
|
||||
<code>hg clone {href}</code>
|
||||
</pre>
|
||||
<h4>{t("scm-hg-plugin.information.create")}</h4>
|
||||
<pre>
|
||||
<code>
|
||||
hg init {repository.name}
|
||||
<br />
|
||||
cd {repository.name}
|
||||
<br />
|
||||
echo "[paths]" > .hg/hgrc
|
||||
<br />
|
||||
echo "default = {href}
|
||||
" >> .hg/hgrc
|
||||
<br />
|
||||
echo "# {repository.name}
|
||||
" > README.md
|
||||
<br />
|
||||
hg add README.md
|
||||
<br />
|
||||
hg commit -m "added readme"
|
||||
<br />
|
||||
<br />
|
||||
hg push
|
||||
<br />
|
||||
</code>
|
||||
</pre>
|
||||
<h4>{t("scm-hg-plugin.information.replace")}</h4>
|
||||
<pre>
|
||||
<code>
|
||||
# add the repository url as default to your .hg/hgrc e.g:
|
||||
<br />
|
||||
default = {href}
|
||||
<br />
|
||||
# push to remote repository
|
||||
<br />
|
||||
hg push
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
const ProtocolInformation: FC<Props> = ({ repository }) => {
|
||||
const [t] = useTranslation("plugins");
|
||||
const [emptyRepository, setEmptyRepository] = useState<boolean>();
|
||||
|
||||
export default withTranslation("plugins")(ProtocolInformation);
|
||||
const href = repositories.getProtocolLinkByType(repository, "http");
|
||||
|
||||
useEffect(() => {
|
||||
if (repository) {
|
||||
apiClient
|
||||
.get((repository._links.changesets as Link).href)
|
||||
.then(r => r.json())
|
||||
.then(result => {
|
||||
const empty = result._embedded.changesets.length === 0;
|
||||
setEmptyRepository(empty);
|
||||
});
|
||||
}
|
||||
}, [repository]);
|
||||
|
||||
if (!href) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<h4>{t("scm-hg-plugin.information.clone")}</h4>
|
||||
<pre>
|
||||
<code>hg clone {href}</code>
|
||||
</pre>
|
||||
{emptyRepository && (
|
||||
<>
|
||||
<h4>{t("scm-hg-plugin.information.create")}</h4>
|
||||
<pre>
|
||||
<code>
|
||||
hg init {repository.name}
|
||||
<br />
|
||||
cd {repository.name}
|
||||
<br />
|
||||
echo "[paths]" > .hg/hgrc
|
||||
<br />
|
||||
echo "default = {href}
|
||||
" >> .hg/hgrc
|
||||
<br />
|
||||
echo "# {repository.name}
|
||||
" > README.md
|
||||
<br />
|
||||
hg add README.md
|
||||
<br />
|
||||
hg commit -m "added readme"
|
||||
<br />
|
||||
<br />
|
||||
hg push
|
||||
<br />
|
||||
</code>
|
||||
</pre>
|
||||
</>
|
||||
)}
|
||||
<h4>{t("scm-hg-plugin.information.replace")}</h4>
|
||||
<pre>
|
||||
<code>
|
||||
# add the repository url as default to your .hg/hgrc e.g:
|
||||
<br />
|
||||
default = {href}
|
||||
<br />
|
||||
# push to remote repository
|
||||
<br />
|
||||
hg push
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProtocolInformation;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"information": {
|
||||
"clone" : "Repository klonen",
|
||||
"create" : "Neues Repository erstellen",
|
||||
"replace" : "Ein bestehendes Repository aktualisieren",
|
||||
"replace" : "Quelle zum bestehenden Repository hinzufügen",
|
||||
"fetch": "Remote-Änderungen herunterladen",
|
||||
"checkout": "Branch wechseln",
|
||||
"checkoutTag": "Tag auschecken"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"information": {
|
||||
"clone" : "Clone the repository",
|
||||
"create" : "Create a New Repository",
|
||||
"replace" : "Push an Existing Repository",
|
||||
"replace" : "Add Remote Origin to an Existing Repository",
|
||||
"fetch": "Get Remote Changes",
|
||||
"checkout": "Switch Branch",
|
||||
"checkoutTag": "Checkout Tag"
|
||||
|
||||
Reference in New Issue
Block a user