Skip to content

Commit

Permalink
Merge pull request #391 from mittwald/chore/python-app-version
Browse files Browse the repository at this point in the history
Hide version number of custom python apps
  • Loading branch information
martin-helmich authored Apr 22, 2024
2 parents 8aeb47e + 9b69251 commit 0ca1754
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/commands/app/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { ListBaseCommand } from "../../ListBaseCommand.js";
import { MittwaldAPIV2, MittwaldAPIV2Client } from "@mittwald/api-client";
import { SuccessfulResponse } from "../../types.js";
import { ListColumns } from "../../Formatter.js";
import { phpInstaller } from "./create/php.js";
import { nodeInstaller } from "./create/node.js";
import { getAppFromUuid, getAppVersionFromUuid } from "../../lib/app/uuid.js";
import { isCustomAppInstallation } from "../../lib/app/custom_installation.js";

type AppApp = MittwaldAPIV2.Components.Schemas.AppApp;
type AppAppVersion = MittwaldAPIV2.Components.Schemas.AppAppVersion;
Expand Down Expand Up @@ -93,7 +92,7 @@ export default class List extends ListBaseCommand<
appVersion: {
header: "Version",
get: (i) => {
if ([phpInstaller.appId, nodeInstaller.appId].includes(i.appId)) {
if (isCustomAppInstallation(i.appId)) {
return "n/a";
}

Expand Down
17 changes: 17 additions & 0 deletions src/lib/app/custom_installation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { phpInstaller } from "../../commands/app/create/php.js";
import { nodeInstaller } from "../../commands/app/create/node.js";
import { pythonInstaller } from "../../commands/app/create/python.js";

/**
* Tests if an app installation is for a custom app (for example, a custom PHP
* or Node.js app). These are treated differently in the UI.
*
* @param appId
*/
export function isCustomAppInstallation(appId: string): boolean {
return [
phpInstaller.appId,
nodeInstaller.appId,
pythonInstaller.appId,
].includes(appId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ import type { MittwaldAPIV2 } from "@mittwald/api-client";
import { Box, Text } from "ink";
type AppAppInstallation = MittwaldAPIV2.Components.Schemas.AppAppInstallation;
type AppApp = MittwaldAPIV2.Components.Schemas.AppApp;
import { phpInstaller } from "../../../../commands/app/create/php.js";
import { nodeInstaller } from "../../../../commands/app/create/node.js";
import { useProject } from "../../../../lib/project/hooks.js";
import { IDAndShortID } from "../IDAndShortID.js";
import path from "path";
import { isCustomAppInstallation } from "../../../../lib/app/custom_installation.js";

export const AppInstallationDetails: FC<{
appInstallation: AppAppInstallation;
app: AppApp;
}> = ({ app, appInstallation }) => {
const customInstallation = [phpInstaller.appId, nodeInstaller.appId].includes(
app.id,
);
const desiredAppVersion = useAppVersion(
app.id,
appInstallation.appVersion.desired,
Expand Down Expand Up @@ -65,7 +61,7 @@ export const AppInstallationDetails: FC<{
<Value>{appInstallation.customDocumentRoot ?? "/"}</Value>
),
Description: <Value>{appInstallation.description}</Value>,
Status: customInstallation ? (
Status: isCustomAppInstallation(appInstallation.appId) ? (
<Text>custom application</Text>
) : (
<AppInstallationStatus
Expand Down

0 comments on commit 0ca1754

Please sign in to comment.