Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge vps2 setup to chat #716

Merged
merged 30 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
46e3878
Bump golang.org/x/net from 0.17.0 to 0.23.0 in /server
dependabot[bot] Apr 19, 2024
37a4061
Merge pull request #713 from the-clothing-loop/dependabot/go_modules/…
lil5 Apr 19, 2024
aba1fd9
Add version to login page
lil5 Apr 20, 2024
185f341
Change send icon to mail
lil5 Apr 20, 2024
8a3aa49
Fix untransalated privacy policy button
lil5 Apr 20, 2024
2b7bb68
Add anbi block to donate page (raw text)
lil5 Apr 20, 2024
39a8fbd
Add link on image
lil5 Apr 20, 2024
c77ecb7
New translations translation.json (French)
paloeka Apr 20, 2024
e863514
New translations translation.json (Spanish)
paloeka Apr 20, 2024
6c7ad8d
New translations translation.json (Catalan)
paloeka Apr 20, 2024
235d87c
New translations translation.json (German)
paloeka Apr 20, 2024
0a38f7b
New translations translation.json (Hebrew)
paloeka Apr 20, 2024
1a0eb91
New translations translation.json (Italian)
paloeka Apr 20, 2024
5adf447
New translations translation.json (Japanese)
paloeka Apr 20, 2024
8a4786e
New translations translation.json (Korean)
paloeka Apr 20, 2024
6f66a36
New translations translation.json (Dutch)
paloeka Apr 20, 2024
422fa4c
New translations translation.json (Polish)
paloeka Apr 20, 2024
7f8d200
New translations translation.json (Portuguese)
paloeka Apr 20, 2024
e9674ba
New translations translation.json (Swedish)
paloeka Apr 20, 2024
0b9045b
Merge remote-tracking branch 'origin/l10n_main'
lil5 Apr 22, 2024
8c6d656
Fix missing lines in rules
lil5 Apr 22, 2024
89fdeda
Rename isPaused func to PascalCase & only allow hosts to set bag of p…
lil5 Apr 22, 2024
6508f30
Fix is paused check in app
lil5 Apr 26, 2024
628042a
Migrate acc to vps2
lil5 Apr 29, 2024
ef2ec2f
Fix app build
lil5 Apr 29, 2024
a86cf97
Move to vps2 private vars
lil5 Apr 29, 2024
1057296
Move to id_ed25519
lil5 Apr 29, 2024
7903a9a
Fix ssh in send command
lil5 Apr 29, 2024
c13f3b0
Mattermost installed
lil5 Apr 29, 2024
0ae53dd
Merge branch 'chat' into merge-1
lil5 Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions .github/workflows/deploy-acceptance-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,18 @@ jobs:
- name: Build binary
run: make build-server
working-directory: ./server
- name: Rename binary
run: mv server cl-api-acceptance
working-directory: ./server
- name: Install SSH key
uses: benoitchantre/setup-ssh-authentication-action@1.0.1
with:
private-key: ${{ secrets.VPS1_PRIVKEY }}
known-hosts: ${{ secrets.VPS1_KNOWNHOSTS }}
private-key: ${{ secrets.VPS2_PRIVKEY }}
private-key-name: id_ed25519
known-hosts: ${{ secrets.VPS2_KNOWNHOSTS }}
- name: Send binary to vps and restart service
run: |
rsync -az --delete ./server/cl-api-acceptance admin@vpsnode1.vps.webdock.cloud:/home/admin/
ssh admin@vpsnode1.vps.webdock.cloud "\
sudo rm /home/clothingloop/opt/api-acceptance; \
sudo cp /home/admin/cl-api-acceptance /home/clothingloop/opt/api-acceptance; \
sudo chown root:root /home/clothingloop/opt/api-acceptance; \
sudo chmod 0775 /home/clothingloop/opt/api-acceptance; \
sudo systemctl restart cl-api-acceptance"
rsync -az --delete ./server/server admin@vps2.vps.webdock.cloud:/home/admin/acc.api.clothingloop.org/server.next
ssh admin@vps2.vps.webdock.cloud "\
task-services stop my_api_acc; \
sudo mv /home/admin/acc.api.clothingloop.org/server.next /home/admin/acc.api.clothingloop.org/server; \
sudo chmod +x /home/admin/acc.api.clothingloop.org/server; \
task-services start my_api_acc;"
echo "done"
12 changes: 6 additions & 6 deletions .github/workflows/deploy-acceptance-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ jobs:
- name: Install SSH key
uses: benoitchantre/setup-ssh-authentication-action@1.0.1
with:
private-key: ${{ secrets.VPS1_PRIVKEY }}
known-hosts: ${{ secrets.VPS1_KNOWNHOSTS }}
private-key: ${{ secrets.VPS2_PRIVKEY }}
private-key-name: id_ed25519
known-hosts: ${{ secrets.VPS2_KNOWNHOSTS }}
- name: Send public files to vps
run: |
ssh admin@vpsnode1.vps.webdock.cloud "mkdir -p /home/admin/cl-app-acceptance"
rsync -az --delete ./app/build/ admin@vpsnode1.vps.webdock.cloud:/home/admin/cl-app-acceptance/
ssh admin@vpsnode1.vps.webdock.cloud "\
sudo rsync -z -rlt --chown=caddy:caddy --chmod=0775 --delete /home/admin/cl-app-acceptance/ /var/caddy/acc.app.clothingloop.org/; \
rsync -az --delete ./app/build/ admin@vps2.vps.webdock.cloud:/home/admin/acc.app.clothingloop.org/
ssh admin@vps2.vps.webdock.cloud "\
sudo chmod -R 0775 /home/admin/acc.app.clothingloop.org/; \
sudo systemctl reload caddy"
echo "done"
12 changes: 6 additions & 6 deletions .github/workflows/deploy-acceptance-fe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ jobs:
- name: Install SSH key
uses: benoitchantre/setup-ssh-authentication-action@1.0.1
with:
private-key: ${{ secrets.VPS1_PRIVKEY }}
known-hosts: ${{ secrets.VPS1_KNOWNHOSTS }}
private-key: ${{ secrets.VPS2_PRIVKEY }}
private-key-name: id_ed25519
known-hosts: ${{ secrets.VPS2_KNOWNHOSTS }}
- name: Send public files to vps
run: |
ssh admin@vpsnode1.vps.webdock.cloud "mkdir -p /home/admin/cl-fe-acceptance"
rsync -az --delete ./frontend/build/ admin@vpsnode1.vps.webdock.cloud:/home/admin/cl-fe-acceptance/
ssh admin@vpsnode1.vps.webdock.cloud "\
sudo rsync -z -rlt --chown=caddy:caddy --chmod=0775 --delete /home/admin/cl-fe-acceptance/ /var/caddy/acc.clothingloop.org/; \
rsync -az --delete ./frontend/build/ admin@vps2.vps.webdock.cloud:/home/admin/acc.clothingloop.org/
ssh admin@vps2.vps.webdock.cloud "\
sudo chmod -R 0775 /home/admin/acc.clothingloop.org/; \
sudo systemctl reload caddy"
echo "done"
6 changes: 5 additions & 1 deletion app/src/components/AddressList/AddressListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface AddressListItemProps {
number: number;
routerLink: string | undefined;
isUserPaused: boolean;
isChainAdmin: boolean;
}
export default function AddressListItem({
user,
Expand All @@ -23,6 +24,7 @@ export default function AddressListItem({
number,
routerLink,
isUserPaused,
isChainAdmin,
}: AddressListItemProps) {
return (
<IonItem
Expand All @@ -48,7 +50,9 @@ export default function AddressListItem({
</h5>
<span className="tw-opacity-60">
{isUserPaused ? (
<small>{t("paused")}</small>
isChainAdmin ? (
<small>{user.address}</small>
) : null
) : isAddressPrivate ? (
<small>&nbsp;</small>
) : (
Expand Down
25 changes: 20 additions & 5 deletions app/src/components/Bags/SelectUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ import {
IonSearchbar,
IonRadioGroup,
IonRadio,
IonIcon,
} from "@ionic/react";
import { RefObject, useContext, useState, useMemo } from "react";
import { useTranslation } from "react-i18next";
import { bagPut } from "../../api/bag";
import { UID } from "../../api/types";
import { StoreContext } from "../../stores/Store";
import IsPaused from "../../utils/is_paused";
import { pauseCircleSharp } from "ionicons/icons";

const MIN_USERS_FOR_SEARCH = 15;

Expand All @@ -40,7 +43,7 @@ export default function SelectUserModal({
modal: RefObject<HTMLIonModalElement>;
didDismiss?: (e: IonModalCustomEvent<OverlayEventDetail<any>>) => void;
}) {
const { chain, chainUsers, route, authUser, setChain } =
const { chain, chainUsers, route, authUser, setChain, isChainAdmin } =
useContext(StoreContext);
const { t, i18n } = useTranslation();

Expand Down Expand Up @@ -166,11 +169,23 @@ export default function SelectUserModal({

const isSelected = selected === user.uid;
const isMe = user.uid === authUser?.uid;
const isPaused = IsPaused(user, chain?.uid);
return (
<IonItem lines="full" key={user.uid}>
<span slot="start" className="!tw-font-bold">{`#${
i + 1
}`}</span>
<IonItem
disabled={isPaused && !isChainAdmin}
lines="full"
key={user.uid}
>
<div slot="start" className="tw-flex tw-items-center">
{isPaused ? (
<IonIcon
icon={pauseCircleSharp}
className="tw-w-6 tw-h-6"
/>
) : (
<span className="!tw-font-bold">{`#${i + 1}`}</span>
)}
</div>
<IonLabel>
<h2
className={`tw-text-lg ${isMe ? "tw-text-primary" : ""} ${
Expand Down
7 changes: 4 additions & 3 deletions app/src/components/Bags/UserLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import { User } from "../../api/types";
interface Props {
user: User;
routeIndex: number;
isPaused: boolean;
}

export default function UserLink({ user, routeIndex }: Props) {
export default function UserLink({ user, routeIndex, isPaused }: Props) {
return (
<div className="!tw-font-bold tw-text-medium tw-flex tw-flex-row tw-items-baseline tw-text-xs tw-w-full">
{user.paused_until ? (
{isPaused ? (
<IonIcon
className="tw-translate-y-px tw-w-4 tw-h-4 tw-min-w-[16px] tw-me-[3px]"
icon={pauseCircle}
Expand All @@ -20,7 +21,7 @@ export default function UserLink({ user, routeIndex }: Props) {
)}
<span
className={`ion-text-ellipsis tw-text-sm tw-flex-grow tw-block ${
user.paused_until ? "tw-text-medium" : "tw-text-dark"
isPaused ? "tw-text-medium" : "tw-text-dark"
}`}
>
{user.name}
Expand Down
1 change: 1 addition & 0 deletions app/src/components/Settings/RoutePrivacyExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default function RoutePrivacyExample(props: {
isUserPaused={user.paused_until !== null}
number={i + 5}
routerLink={undefined}
isChainAdmin={true}
/>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions app/src/pages/AddressItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useContext, useMemo } from "react";
import { RouteComponentProps } from "react-router";
import UserCard from "../components/UserCard";
import { StoreContext } from "../stores/Store";
import isPaused from "../utils/is_paused";
import IsPaused from "../utils/is_paused";
import { t } from "i18next";
import Badges from "../components/SizeBadge";
import AddressBagCard from "../components/Bags/AddressBagCard";
Expand All @@ -29,7 +29,7 @@ export default function AddressItem({
let userUID = match.params.uid;
return chainUsers.find((u) => u.uid === userUID) || null;
}, [match.params.uid, chainUsers]);
const isUserPaused = isPaused(user, chain?.uid);
const isUserPaused = IsPaused(user, chain?.uid);

const userBags = useMemo(() => {
return bags.filter((b) => b.user_uid === user?.uid);
Expand Down
5 changes: 3 additions & 2 deletions app/src/pages/AddressList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import AddressListItem, {
} from "../components/AddressList/AddressListItem";
import wrapIndex from "../utils/wrap_index";
import { useDebounce } from "@uidotdev/usehooks";
import isPaused from "../utils/is_paused";
import IsPaused from "../utils/is_paused";

export default function AddressList() {
const {
Expand Down Expand Up @@ -102,7 +102,7 @@ export default function AddressList() {

const isPrivate = IsPrivate(user.email);
const isAddressPrivate = IsPrivate(user.address);
const isUserPaused = isPaused(user, chain.uid);
const isUserPaused = IsPaused(user, chain.uid);

arr.push({
user,
Expand All @@ -113,6 +113,7 @@ export default function AddressList() {
number: i + 1,
isUserPaused,
routerLink: isPrivate ? undefined : "/address/" + user.uid,
isChainAdmin,
});
}

Expand Down
15 changes: 13 additions & 2 deletions app/src/pages/BagsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import UserLink from "../components/Bags/UserLink";
import SelectUserModal from "../components/Bags/SelectUserModal";
import { useDebounce } from "@uidotdev/usehooks";
import dayjs from "../dayjs";
import IsPaused from "../utils/is_paused";

type State = { bag_id?: number } | undefined;

Expand Down Expand Up @@ -408,6 +409,7 @@ export default function BagsList() {
{bagsCard.map((bag) => {
const user = chainUsers.find((u) => u.uid === bag.user_uid);
if (!user) return null;
const isPaused = IsPaused(user, chain?.uid);
let routeIndex = route.indexOf(user.uid);
if (routeIndex === -1) return null;
const { bagUpdatedAt, isBagTooOldMe, isBagTooOldHost } =
Expand Down Expand Up @@ -458,7 +460,11 @@ export default function BagsList() {
routerLink={"/address/" + user.uid}
className="tw-py-3 tw-px-2 tw-block tw-bg-light"
>
<UserLink user={user} routeIndex={routeIndex} />
<UserLink
user={user}
routeIndex={routeIndex}
isPaused={isPaused}
/>
</IonRouterLink>
</Card>
</IonCol>
Expand All @@ -472,6 +478,7 @@ export default function BagsList() {
const { bagUpdatedAt, isBagTooOldMe, isBagTooOldHost } =
useBagTooOld(authUser, isChainAdmin, bag);
let isOpen = openCard == bag.id;
const isPaused = IsPaused(user, chain?.uid);
return (
<IonCol
size="12"
Expand Down Expand Up @@ -536,7 +543,11 @@ export default function BagsList() {
routerLink={"/address/" + user.uid}
className="tw-w-[115px] tw-h-[35px]"
>
<UserLink user={user} routeIndex={routeIndex} />
<UserLink
user={user}
routeIndex={routeIndex}
isPaused={isPaused}
/>
</IonButton>
)}
{isChainAdmin ? (
Expand Down
13 changes: 9 additions & 4 deletions app/src/pages/HelpItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
IonButtons,
IonIcon,
} from "@ionic/react";
import { useContext, useMemo } from "react";
import { Fragment, useContext, useMemo } from "react";
import { useTranslation } from "react-i18next";
import type { TOptionsBase } from "i18next";
import { RouteComponentProps } from "react-router";
Expand Down Expand Up @@ -84,9 +84,14 @@ export default function HelpItem({
>
{item.title}
</h1>
{item.content.split("\n").map((s, i) => (
<p key={i}>{s}</p>
))}
<p>
{item.content.split("\n").map((s, i) => (
<Fragment key={i}>
{s === "" ? null : <span>{s}</span>}
<br />
</Fragment>
))}
</p>
</IonText>
<IonIcon
aria-hidden="true"
Expand Down
12 changes: 10 additions & 2 deletions app/src/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
import {
arrowBack,
arrowForwardOutline,
mailOutline,
mailUnreadOutline,
sendOutline,
} from "ionicons/icons";
import { Fragment, useContext, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
Expand All @@ -29,6 +29,8 @@ import { loginEmail } from "../api/login";
import { StoreContext } from "../stores/Store";
import { AppLauncher } from "@capacitor/app-launcher";

const VERSION = import.meta.env.VITE_APP_VERSION;

enum State {
idle,
error,
Expand Down Expand Up @@ -211,7 +213,7 @@ export default function Login(props: { isLoggedIn: boolean }) {
{sentState === State.success ? (
<IonIcon slot="end" icon={mailUnreadOutline} />
) : sentState === State.loading ? null : (
<IonIcon slot="end" icon={sendOutline} />
<IonIcon slot="end" icon={mailOutline} />
)}
</IonButton>
</IonItem>
Expand Down Expand Up @@ -260,6 +262,12 @@ export default function Login(props: { isLoggedIn: boolean }) {
</IonItem>
</Fragment>
) : null}
<div
className="tw-text-center tw-mt-2 -tw-mb-4 tw-text-medium"
key="version"
>
{VERSION}
</div>
</div>
<div className="tw-relative tw-flex-grow -tw-m-4 tw-mt-8 tw-inset-0 -tw-z-10 tw-bg-green tw-overflow-hidden">
<div className="tw-absolute tw-overflow-hidden tw-inset-0 -tw-z-10">
Expand Down
4 changes: 2 additions & 2 deletions app/src/pages/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import {
warningOutline,
} from "ionicons/icons";
import dayjs from "../dayjs";
import isPaused from "../utils/is_paused";
import IsPaused from "../utils/is_paused";
import Badges from "../components/SizeBadge";
import { Share } from "@capacitor/share";
import { Clipboard } from "@capacitor/clipboard";
Expand Down Expand Up @@ -201,7 +201,7 @@ export default function Settings() {
Share.share({ url });
}

let isUserPaused = isPaused(authUser, chain?.uid);
let isUserPaused = IsPaused(authUser, chain?.uid);
let pausedDayjs = isUserPaused ? dayjs(authUser!.paused_until) : null;
let showExpandButton = (chain?.description.length || 0) > 200;
let emptyDescription = (chain?.description.length || 0) == 0;
Expand Down
6 changes: 3 additions & 3 deletions app/src/utils/is_paused.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect, test } from "vitest";
import isPaused from "./is_paused";
import IsPaused from "./is_paused";
import dayjs from "../dayjs";

function TestIsPausedByDate(date: string | null) {
return isPaused({ chains: [], paused_until: date } as any, "");
return IsPaused({ chains: [], paused_until: date } as any, "");
}

test("should is pause be a date in the past then return true", () => {
Expand All @@ -24,7 +24,7 @@ test("should is pause be null then return false", () => {

test("should be paused when the current user chain is paused", () => {
expect(
isPaused(
IsPaused(
{ chains: [{ chain_uid: "test", is_paused: true }] } as any,
"test",
),
Expand Down
2 changes: 1 addition & 1 deletion app/src/utils/is_paused.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UID, User } from "../api/types";
import dayjs from "../dayjs";

export default function isPaused(
export default function IsPaused(
user: User | null,
currentChainUID: UID | undefined,
): boolean {
Expand Down
Loading
Loading