mirror of
https://github.com/home-assistant/frontend.git
synced 2026-11-03 03:25:27 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
adaf7b47df | ||
|
|
2a356de25d |
No files matched your search
@@ -149,6 +149,7 @@ const repositories: RepositoryBase[] = [
|
||||
const repositoryInfo = (repository: RepositoryBase): RepositoryInfo => ({
|
||||
...repository,
|
||||
additional_info: `# ${repository.name}\n\n${repository.description}\n\nThis is a demo. Installing is not available.`,
|
||||
beta: false,
|
||||
default_branch: "main",
|
||||
issues: 12,
|
||||
releases: [repository.available_version],
|
||||
|
||||
@@ -34,6 +34,7 @@ export interface RepositoryBase {
|
||||
|
||||
export interface RepositoryInfo extends RepositoryBase {
|
||||
additional_info: string;
|
||||
beta: boolean;
|
||||
default_branch: string;
|
||||
issues: number;
|
||||
releases: string[];
|
||||
@@ -98,6 +99,18 @@ export const uninstallMarketplaceRepository = (
|
||||
repository: repositoryId,
|
||||
});
|
||||
|
||||
// The latest version and the updates include pre-releases when on
|
||||
export const setMarketplaceRepositoryBeta = (
|
||||
hass: CallWS,
|
||||
repositoryId: string,
|
||||
showBeta: boolean
|
||||
) =>
|
||||
hass.callWS<null>({
|
||||
type: "marketplace/repository/beta",
|
||||
repository: repositoryId,
|
||||
show_beta: showBeta,
|
||||
});
|
||||
|
||||
// Fetches the information of the repository from GitHub again
|
||||
export const refreshMarketplaceRepository = (
|
||||
hass: CallWS,
|
||||
|
||||
@@ -8,6 +8,8 @@ import {
|
||||
mdiInformationOutline,
|
||||
mdiMoonNew,
|
||||
mdiReload,
|
||||
mdiTestTube,
|
||||
mdiTestTubeOff,
|
||||
} from "@mdi/js";
|
||||
import { html } from "lit";
|
||||
import { navigate } from "../../../common/navigate";
|
||||
@@ -21,7 +23,10 @@ import {
|
||||
showAlertDialog,
|
||||
showConfirmationDialog,
|
||||
} from "../../../dialogs/generic/show-dialog-box";
|
||||
import type { RepositoryBase } from "../../../data/marketplace/repository";
|
||||
import type {
|
||||
RepositoryBase,
|
||||
RepositoryInfo,
|
||||
} from "../../../data/marketplace/repository";
|
||||
import { marketplaceErrorMessage } from "../../../data/marketplace/websocket";
|
||||
import {
|
||||
dismissNewMarketplaceRepository,
|
||||
@@ -144,10 +149,27 @@ const confirmUninstallRepository = async (
|
||||
});
|
||||
};
|
||||
|
||||
const includePreReleases = async (
|
||||
element: MarketplaceDashboardElement,
|
||||
api: MarketplaceApi,
|
||||
localize: LocalizeFunc,
|
||||
include: boolean
|
||||
) => {
|
||||
try {
|
||||
await (element as HaMarketplaceRepositoryDashboard).includePreReleases(
|
||||
include
|
||||
);
|
||||
} catch (err: unknown) {
|
||||
if (!handleGitHubRateLimited(element, api, localize, err)) {
|
||||
showError(element, localize, err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const repositoryMenuItems = (
|
||||
element: MarketplaceDashboardElement,
|
||||
api: MarketplaceApi,
|
||||
repository: RepositoryBase,
|
||||
repository: RepositoryBase | RepositoryInfo,
|
||||
localize: LocalizeFunc
|
||||
): MarketplaceRepositoryMenuEntry[] => {
|
||||
const entries: MarketplaceRepositoryMenuEntry[] = [];
|
||||
@@ -228,6 +250,41 @@ export const repositoryMenuItems = (
|
||||
}),
|
||||
});
|
||||
|
||||
// Only the repository page knows if pre-releases are included
|
||||
if ("beta" in repository) {
|
||||
entries.push({
|
||||
value: "pre_releases",
|
||||
path: repository.beta ? mdiTestTubeOff : mdiTestTube,
|
||||
label: localize(
|
||||
repository.beta
|
||||
? "ui.panel.marketplace.repository_menu.exclude_pre_releases"
|
||||
: "ui.panel.marketplace.repository_menu.include_pre_releases"
|
||||
),
|
||||
action: () => {
|
||||
if (repository.beta) {
|
||||
includePreReleases(element, api, localize, false);
|
||||
return;
|
||||
}
|
||||
|
||||
showConfirmationDialog(element, {
|
||||
title: localize(
|
||||
"ui.panel.marketplace.dialog.include_pre_releases.title",
|
||||
{ name: repository.name }
|
||||
),
|
||||
text: localize(
|
||||
"ui.panel.marketplace.dialog.include_pre_releases.text"
|
||||
),
|
||||
confirmText: localize(
|
||||
"ui.panel.marketplace.dialog.include_pre_releases.confirm"
|
||||
),
|
||||
confirm: () => {
|
||||
includePreReleases(element, api, localize, true);
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (repository.new) {
|
||||
entries.push({
|
||||
value: "dismiss_new",
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
mdiGithub,
|
||||
mdiRestart,
|
||||
mdiStar,
|
||||
mdiTestTube,
|
||||
mdiUpdate,
|
||||
} from "@mdi/js";
|
||||
import type { PropertyValues, TemplateResult } from "lit";
|
||||
@@ -72,6 +73,7 @@ import {
|
||||
addMarketplaceRepository,
|
||||
fetchMarketplaceRepositories,
|
||||
fetchMarketplaceRepository,
|
||||
setMarketplaceRepositoryBeta,
|
||||
} from "../../../data/marketplace/repository";
|
||||
import {
|
||||
ERROR_GITHUB_RATE_LIMITED,
|
||||
@@ -173,6 +175,8 @@ export class HaMarketplaceRepositoryDashboard extends LitElement {
|
||||
// Only the newest request counts, also one for the same repository
|
||||
private _request = 0;
|
||||
|
||||
private _settingPreReleases = false;
|
||||
|
||||
protected async firstUpdated(
|
||||
changedProperties: PropertyValues<this>
|
||||
): Promise<void> {
|
||||
@@ -344,6 +348,31 @@ export class HaMarketplaceRepositoryDashboard extends LitElement {
|
||||
this._fetchRepository();
|
||||
}
|
||||
|
||||
// Core fetches the repository from GitHub again before answering
|
||||
public async includePreReleases(include: boolean): Promise<void> {
|
||||
if (this._settingPreReleases) {
|
||||
return;
|
||||
}
|
||||
const repositoryId = this._repository!.id;
|
||||
this._repository = { ...this._repository!, beta: include };
|
||||
this._settingPreReleases = true;
|
||||
|
||||
try {
|
||||
await setMarketplaceRepositoryBeta(this._api, repositoryId, include);
|
||||
} catch (err: unknown) {
|
||||
if (this._repository?.id === repositoryId) {
|
||||
this._repository = { ...this._repository, beta: !include };
|
||||
}
|
||||
throw err;
|
||||
} finally {
|
||||
this._settingPreReleases = false;
|
||||
}
|
||||
|
||||
if (this._repository?.id === repositoryId) {
|
||||
this._fetchRepository();
|
||||
}
|
||||
}
|
||||
|
||||
private _loadRepositoryFromRoute(): void {
|
||||
const repositoryId = repositoryIdFromRoute(this.route);
|
||||
if (!repositoryId) {
|
||||
@@ -896,6 +925,14 @@ type: module</pre>`,
|
||||
}),
|
||||
});
|
||||
}
|
||||
if (repository.beta) {
|
||||
signals.push({
|
||||
icon: mdiTestTube,
|
||||
text: localize(
|
||||
"ui.panel.marketplace.repository.details.pre_releases_included"
|
||||
),
|
||||
});
|
||||
}
|
||||
const lastChange = this._relativeTime(repository.last_updated);
|
||||
if (lastChange) {
|
||||
signals.push({
|
||||
|
||||
@@ -13148,6 +13148,7 @@
|
||||
},
|
||||
"details": {
|
||||
"requires": "Requires Home Assistant {version} or newer",
|
||||
"pre_releases_included": "Pre-releases included",
|
||||
"source_code": "View source code",
|
||||
"issue_tracker": "Issue tracker"
|
||||
},
|
||||
@@ -13173,6 +13174,8 @@
|
||||
},
|
||||
"repository_menu": {
|
||||
"dismiss_new": "Dismiss new",
|
||||
"exclude_pre_releases": "Exclude pre-releases",
|
||||
"include_pre_releases": "Include pre-releases",
|
||||
"issue_tracker": "Issue tracker",
|
||||
"install_other_version": "Install another version",
|
||||
"reinstall": "Reinstall",
|
||||
@@ -13208,6 +13211,11 @@
|
||||
"description": "You need to reload your browser for the updated resources to be used.",
|
||||
"confirm": "Do you want to do that now?"
|
||||
},
|
||||
"include_pre_releases": {
|
||||
"title": "Include pre-releases of {name}?",
|
||||
"text": "Updates will include versions marked as pre-release on GitHub, such as betas and release candidates. They are for testers and can contain unstable changes. If you exclude them again later, an installed pre-release stays until a newer stable version is out.",
|
||||
"confirm": "Include"
|
||||
},
|
||||
"uninstall": {
|
||||
"title": "Uninstall {name}?",
|
||||
"message": "This removes the files the Marketplace installed for it.",
|
||||
|
||||
Reference in new issue
Block a user