Skip to content

Commit

Permalink
Merge branch 'main' into feat/public-api-assets
Browse files Browse the repository at this point in the history
  • Loading branch information
nourbalaha authored Oct 22, 2024
2 parents dac428f + afe6c7a commit a7be2c1
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 28 deletions.
File renamed without changes.
7 changes: 3 additions & 4 deletions .github/workflows/build_server.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: server-build
on:
workflow_run:
workflows: [ci-server]
types: [completed]
push:
branches: [main, release]
paths: [server/**, .github/workflows/build_server.yml]
concurrency:
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: true
Expand All @@ -27,7 +26,7 @@ jobs:
id: info
# The tag name should be retrieved lazily, as tagging may be delayed.
env:
BRANCH: ${{ github.event.workflow_run.head_branch }}
BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
if [[ "$BRANCH" = "release" ]]; then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: web-build
on:
workflow_run:
workflows: [ci-web]
types: [completed]
branches: [main, release]
push:
branches: [ main, release ]
paths: [ web/**, .github/workflows/build_web.yml ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: true
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/build_worker.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: worker-build
on:
workflow_run:
workflows: [ci-worker]
types: [completed]
push:
branches: [main, release]
paths: [worker/**, .github/workflows/build_worker.yml]
concurrency:
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: true
Expand Down
25 changes: 13 additions & 12 deletions .github/workflows/cron_ion_token_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ on:
- cron: "0 0 2 * *"
workflow_dispatch:
env:
GCS_DOMAIN: gs://cms.test.reearth.dev
REEARTH_CONFIG_FILENAME: reearth_config.json
CMS_WEB: reearth-cms-web
REGION: us-central1
jobs:
update_ion_token:
runs-on: ubuntu-latest
permissions:
contents: read # To checkout
id-token: write # To authenticate with Google Cloud using OIDC
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Download reearth config
run: gsutil cp "${{ env.GCS_DOMAIN }}/${{ env.REEARTH_CONFIG_FILENAME }}" .
service_account: ${{ secrets.GCP_SA_EMAIL }}
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER}}
- name: Get Cesium Ion token
id: ion_token
run: |
Expand All @@ -35,9 +36,9 @@ jobs:
" \
)
echo "token=${ION_TOKEN}" >> $GITHUB_OUTPUT
- name: Update Ion token in reearth config
- name: Update Cloud Run
run: |
echo $(cat ${{ env.REEARTH_CONFIG_FILENAME }} | jq -r '.cesiumIonAccessToken |= "${{ steps.ion_token.outputs.token }}"') > ${{ env.REEARTH_CONFIG_FILENAME }}
echo $(cat ${{ env.REEARTH_CONFIG_FILENAME }})
- name: Upload reearth config
run: gsutil -h "Cache-Control:no-store" cp reearth_config.json "${{ env.GCS_DOMAIN }}/${{ env.REEARTH_CONFIG_FILENAME }}"
gcloud run services update $CMS_WEB \
--update-env-vars REEARTH_CMS_CESIUM_ION_ACCESS_TOKEN=${{ steps.ion_token.outputs.token }} \
--region $REGION \
--platform managed
24 changes: 20 additions & 4 deletions .github/workflows/deploy_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
name: Deploy web to test env
if: github.event.repository.full_name == 'reearth/reearth-cms' && github.event.workflow_run.name == 'ci-web' && github.event.workflow_run.conclusion != 'failure' && github.event.workflow_run.head_branch == 'main'
runs-on: ubuntu-latest
permissions:
contents: read # To checkout
id-token: write # To authenticate with Google Cloud using OIDC
steps:
- uses: actions/create-github-app-token@v1
id: app-token
Expand All @@ -55,7 +58,8 @@ jobs:
run: tar -xvf reearth-cms-web.tar.gz
- uses: google-github-actions/auth@v2
with:
credentials_json: "${{ secrets.GCP_SA_KEY }}"
service_account: ${{ secrets.GCP_SA_EMAIL }}
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Deploy
Expand All @@ -65,12 +69,16 @@ jobs:
name: Deploy server to test env
runs-on: ubuntu-latest
if: github.event.repository.full_name == 'reearth/reearth-cms' && github.event.workflow_run.name == 'server-build' && github.event.workflow_run.conclusion != 'failure' && github.event.workflow_run.head_branch == 'main'
permissions:
contents: read # To checkout
id-token: write # To authenticate with Google Cloud using OIDC
steps:
- uses: actions/checkout@v4

- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
service_account: ${{ secrets.GCP_SA_EMAIL }}
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure docker
Expand All @@ -92,12 +100,16 @@ jobs:
name: Deploy web to test env
runs-on: ubuntu-latest
if: github.event.repository.full_name == 'reearth/reearth-cms' && github.event.workflow_run.name == 'web-build' && github.event.workflow_run.conclusion != 'failure' && github.event.workflow_run.head_branch == 'main'
permissions:
contents: read # To checkout
id-token: write # To authenticate with Google Cloud using OIDC
steps:
- uses: actions/checkout@v4

- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
service_account: ${{ secrets.GCP_SA_EMAIL }}
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure docker
Expand All @@ -119,12 +131,16 @@ jobs:
name: Deploy worker to test env
runs-on: ubuntu-latest
if: github.event.repository.full_name == 'reearth/reearth-cms' && github.event.workflow_run.name == 'worker-build' && github.event.workflow_run.conclusion != 'failure' && github.event.workflow_run.head_branch == 'main'
permissions:
contents: read # To checkout
id-token: write # To authenticate with Google Cloud using OIDC
steps:
- uses: actions/checkout@v4

- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
service_account: ${{ secrets.GCP_SA_EMAIL }}
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure docker
Expand Down
39 changes: 39 additions & 0 deletions web/e2e/project/content/content.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,45 @@ test("Publishing and Unpublishing item has succeeded", async ({ page }) => {
await expect(page.getByText("DRAFT")).toBeVisible();
});

test("Showing item title has succeeded", async ({ page }) => {
await page.locator("li").filter({ hasText: "Text" }).locator("div").first().click();
await handleFieldForm(page, "text");
await page.getByText("Content").click();
await page.getByRole("button", { name: "plus New Item" }).click();
await expect(page.getByTitle("e2e model name", { exact: true })).toBeVisible();
await page.getByLabel("text").click();
await page.getByLabel("text").fill("text");
await page.getByRole("button", { name: "Save" }).click();
await closeNotification(page);
const itemId = await page
.getByRole("main")
.locator("p")
.filter({ hasText: "ID" })
.locator("div > span")
.innerText();
await expect(page.getByTitle(`e2e model name / ${itemId}`, { exact: true })).toBeVisible();

await page.getByText("Schema").click();
await page.getByRole("img", { name: "ellipsis" }).locator("svg").click();
await page.getByLabel("Use as title").check();
await page.getByRole("tab", { name: "Default value" }).click();
await page.getByLabel("Set default value").click();
await page.getByLabel("Set default value").fill("default text");
await page.getByRole("button", { name: "OK" }).click();
await closeNotification(page);

await page.getByText("Content").click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.getByTitle(`e2e model name / text`, { exact: true })).toBeVisible();
await page.getByLabel("Back").click();

await page.getByRole("button", { name: "plus New Item" }).click();
await expect(page.getByTitle("e2e model name", { exact: true })).toBeVisible();
await page.getByRole("button", { name: "Save" }).click();
await closeNotification(page);
await expect(page.getByTitle(`e2e model name / default text`, { exact: true })).toBeVisible();
});

test("Comment CRUD on Content page has succeeded", async ({ page }) => {
await page.locator("li").filter({ hasText: "Text" }).locator("div").first().click();
await handleFieldForm(page, "text");
Expand Down
3 changes: 3 additions & 0 deletions web/src/components/molecules/Content/Details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Props = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
initialFormValues: Record<string, any>;
initialMetaFormValues: Record<string, unknown>;
title: string;
item?: Item;
itemId?: string;
itemLoading: boolean;
Expand Down Expand Up @@ -113,6 +114,7 @@ const ContentDetailsMolecule: React.FC<Props> = ({
modelsMenu,
initialFormValues,
initialMetaFormValues,
title,
item,
itemId,
itemLoading,
Expand Down Expand Up @@ -194,6 +196,7 @@ const ContentDetailsMolecule: React.FC<Props> = ({
<NotFound />
) : (
<ContentForm
title={title}
item={item}
linkItemModalTitle={linkItemModalTitle}
linkItemModalTotalCount={linkItemModalTotalCount}
Expand Down
5 changes: 4 additions & 1 deletion web/src/components/molecules/Content/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { DefaultField } from "./fields/FieldComponents";
import { FIELD_TYPE_COMPONENT_MAP } from "./fields/FieldTypesMap";

type Props = {
title: string;
item?: Item;
loadingReference: boolean;
linkedItemsModalList?: FormItem[];
Expand Down Expand Up @@ -122,6 +123,7 @@ type Props = {
};

const ContentForm: React.FC<Props> = ({
title,
item,
loadingReference,
linkedItemsModalList,
Expand Down Expand Up @@ -484,7 +486,7 @@ const ContentForm: React.FC<Props> = ({
initialValues={initialFormValues}
onValuesChange={handleValuesChange}>
<PageHeader
title={model?.name}
title={title}
onBack={onBack}
extra={
<>
Expand Down Expand Up @@ -724,6 +726,7 @@ const FormItemsWrapper = styled.div`
max-height: calc(100% - 72px);
overflow-y: auto;
padding: 36px;
border-top: 1px solid #00000008;
`;

const SideBarWrapper = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,16 @@ export default () => {
[checkIfItemIsReferenced],
);

const title = useMemo(() => {
let result = currentModel?.name ?? "";
if (currentItem) {
const titleField = currentModel?.schema.fields.find(field => field.isTitle);
const titleValue = titleField && initialFormValues[titleField.id];
result += ` / ${titleValue || currentItem.id}`;
}
return result;
}, [currentItem, currentModel?.name, currentModel?.schema.fields, initialFormValues]);

return {
loadingReference,
linkedItemsModalList,
Expand All @@ -585,6 +595,7 @@ export default () => {
itemLoading,
requestCreationLoading,
currentModel,
title,
currentItem,
initialFormValues,
initialMetaFormValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const ContentDetails: React.FC = () => {
itemId,
itemLoading,
currentModel,
title,
currentItem,
initialFormValues,
initialMetaFormValues,
Expand Down Expand Up @@ -125,6 +126,7 @@ const ContentDetails: React.FC = () => {
/>
) : undefined
}
title={title}
item={currentItem}
itemId={itemId}
itemLoading={itemLoading}
Expand Down

0 comments on commit a7be2c1

Please sign in to comment.