Skip to content

Commit

Permalink
Merge branch 'main' into fix-web/filter
Browse files Browse the repository at this point in the history
  • Loading branch information
caichi-t authored Oct 17, 2024
2 parents 5904eec + bd13729 commit c83729b
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 52 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: tj-actions/changed-files@v45
with:
files: |
web
web/**
.github/workflows/ci.yml
.github/workflows/ci_web.yml
Expand All @@ -27,7 +27,7 @@ jobs:
uses: tj-actions/changed-files@v45
with:
files: |
server
server/**
.github/workflows/ci.yml
.github/workflows/ci_server.yml
.github/workflows/build_server.yml
Expand All @@ -37,7 +37,7 @@ jobs:
uses: tj-actions/changed-files@v45
with:
files: |
worker
worker/**
.github/workflows/ci.yml
.github/workflows/ci_worker.yml
.github/workflows/build_worker.yml
Expand Down
40 changes: 39 additions & 1 deletion server/e2e/integration_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,45 @@ func TestIntegrationFieldCreateAPI(t *testing.T) {
Expect().
Status(http.StatusBadRequest)

// region bool
// region text
res := e.POST(endpoint, sid1).
WithHeader("authorization", "Bearer "+secret).
WithJSON(map[string]interface{}{
"key": "テスト",
"type": "text",
"multiple": false,
"required": false,
}).
Expect().
Status(http.StatusOK).
JSON().
Object()

res.ContainsKey("id")

res = e.GET("/api/models/{modelId}", mId1).
WithHeader("authorization", "Bearer "+secret).
Expect().
Status(http.StatusOK).
JSON().
Object()

res.HasValue("id", mId1.String()).
HasValue("name", "m1").
HasValue("description", "m1 desc").
HasValue("public", true).
HasValue("key", ikey1.String()).
HasValue("projectId", pid).
HasValue("schemaId", sid1)

res.Value("schema").Object().Value("fields").Array().Length().IsEqual(3)
res.Value("createdAt").NotNull()
res.Value("updatedAt").NotNull()
res.Value("lastModified").NotNull()
// endregion

//region bool
res = e.POST(endpoint, sid1).
WithHeader("authorization", "Bearer "+secret).
WithJSON(map[string]interface{}{
"key": "fKey1",
Expand Down Expand Up @@ -192,6 +229,7 @@ func TestIntegrationFieldCreateAPI(t *testing.T) {
HasValue("projectId", pid).
HasValue("schemaId", sid1)

res.Value("schema").Object().Value("fields").Array().Length().IsEqual(4)
res.Value("createdAt").NotNull()
res.Value("updatedAt").NotNull()
res.Value("lastModified").NotNull()
Expand Down
2 changes: 2 additions & 0 deletions web/src/components/atoms/Icon/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
MenuFoldOutlined,
MenuUnfoldOutlined,
FolderOutlined,
FolderOpenOutlined,
LinkOutlined,
UserAddOutlined,
ClearOutlined,
Expand Down Expand Up @@ -137,6 +138,7 @@ export default {
panelToggleLeft: MenuFoldOutlined,
panelToggleRight: MenuUnfoldOutlined,
folder: FolderOutlined,
folderOpen: FolderOpenOutlined,
dot: Dot,
userAdd: UserAddOutlined,
clear: ClearOutlined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,15 @@ const UnzipFileList: React.FC<Props> = ({
) : (
treeData && (
<Tree
switcherIcon={<Icon icon="caretDown" />}
switcherIcon={({ expanded }) => (
<SwitcherIcon icon={expanded ? "folderOpen" : "folder"} size={14} />
)}
defaultExpandedKeys={["0-0"]}
selectedKeys={selectedKeys}
onSelect={handleSelect}
treeData={treeData}
multiple={false}
showLine
showLine={{ showLeafIcon: true }}
titleRender={({ title, key, path }) => {
return (
<>
Expand Down Expand Up @@ -144,4 +146,10 @@ const CopyIcon = styled(Icon)`
}
`;

const SwitcherIcon = styled(Icon)`
svg {
transform: none !important;
}
`;

export default UnzipFileList;
7 changes: 6 additions & 1 deletion web/src/components/molecules/Asset/AssetListTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,12 @@ const AssetListTable: React.FC<Props> = ({
onClick={props.onCleanSelected}>
{t("Deselect")}
</Button>
<DownloadButton displayDefaultIcon type="link" selected={props.selectedRows} />
<DownloadButton
displayDefaultIcon
size="small"
type="link"
selected={props.selectedRows}
/>
<Button
type="link"
size="small"
Expand Down
39 changes: 21 additions & 18 deletions web/src/components/molecules/Common/Form/AssetItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,21 @@ const AssetItem: React.FC<Props> = ({
<>
<AssetDetailsWrapper>
<AssetButton enabled={!!asset} disabled={disabled} onClick={handleClick}>
<div>
<Icon icon="folder" size={24} />
<AssetName>{asset?.fileName ?? value}</AssetName>
</div>
<Icon icon="folder" size={24} />
<AssetName>{asset?.fileName ?? value}</AssetName>
</AssetButton>
<Tooltip title={asset?.fileName}>
<Link
to={`/workspace/${workspaceId}/project/${projectId}/asset/${value}`}
target="_blank">
<AssetLinkedName enabled={!!asset} type="link">
{asset?.fileName ?? value + " (removed)"}
{asset ? (
<Link
to={`/workspace/${workspaceId}/project/${projectId}/asset/${value}`}
target="_blank">
<AssetLinkedName type="link">{asset.fileName}</AssetLinkedName>
</Link>
) : (
<AssetLinkedName type="link" disabled>
{`${value} (removed)`}
</AssetLinkedName>
</Link>
)}
</Tooltip>
</AssetDetailsWrapper>
<Space />
Expand All @@ -181,10 +183,8 @@ const AssetItem: React.FC<Props> = ({
</>
) : (
<AssetButton disabled={disabled} onClick={handleClick}>
<div>
<Icon icon="linkSolid" size={14} />
<AssetButtonTitle>{t("Asset")}</AssetButtonTitle>
</div>
<Icon icon="linkSolid" size={14} />
<AssetButtonTitle>{t("Asset")}</AssetButtonTitle>
</AssetButton>
)}
{uploadUrl && setUploadUrl && (
Expand Down Expand Up @@ -225,6 +225,8 @@ const AssetButton = styled(Button)<{ enabled?: boolean }>`
border: 1px dashed;
border-color: ${({ enabled }) => (enabled ? "#d9d9d9" : "#00000040")};
color: ${({ enabled }) => (enabled ? "#000000D9" : "#00000040")};
padding: 0 5px;
flex-flow: column;
`;

const Space = styled.div`
Expand All @@ -247,9 +249,8 @@ const AssetLink = styled(Button)`
}
`;

const AssetLinkedName = styled(Button)<{ enabled?: boolean }>`
color: #1890ff;
color: ${({ enabled }) => (enabled ? "#1890ff" : "#00000040")};
const AssetLinkedName = styled(Button)<{ disabled?: boolean }>`
color: ${({ disabled }) => (disabled ? "#00000040" : "#1890ff")};
margin-left: 12px;
span {
text-align: start;
Expand All @@ -268,8 +269,10 @@ const AssetDetailsWrapper = styled.div`
`;

const AssetName = styled.div`
margin-top: 8px;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;

const AssetButtonTitle = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ const GeometryItem: React.FC<Props> = ({
: [GEO_TYPE_MAP[supportedTypes]];
if (convertedTypes.includes(valueJson.type)) {
handleErrorDelete();
} else {
handleErrorAdd();
return;
}
}
throw new Error();
} catch (_) {
return;
handleErrorAdd();
}
} else {
handleErrorDelete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ const MultiValueGeometry: React.FC<Props> = ({
return index !== key;
}),
);
errorDelete?.(key);
},
[onChange, value],
[errorDelete, onChange, value],
);

return (
Expand Down
8 changes: 3 additions & 5 deletions web/src/components/molecules/Content/Form/SidebarWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,20 @@ const ContentSidebarWrapper: React.FC<Props> = ({ item, onNavigateToRequest }) =

const DataRow = styled.div`
display: flex;
margin: 0 -4px;
align-items: center;
justify-content: space-between;
gap: 8px;
padding: 4px 0;
line-height: 22px;
`;

const DataTitle = styled.div`
font-size: 14px;
line-height: 22px;
padding: 4px;
`;

const DataText = styled.div`
color: #00000073;
font-size: 12px;
line-height: 22px;
padding: 4px;
`;

const StyledTag = styled(Tag)`
Expand Down
41 changes: 37 additions & 4 deletions web/src/components/molecules/Schema/FieldModal/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import dayjs from "dayjs";
import { useCallback, useEffect, useMemo, useState, useRef } from "react";

import Form from "@reearth-cms/components/atoms/Form";
import { keyAutoFill, keyReplace } from "@reearth-cms/components/molecules/Common/Form/utils";
import {
keyAutoFill,
keyReplace,
emptyConvert,
} from "@reearth-cms/components/molecules/Common/Form/utils";
import {
Field,
FieldModalTabs,
Expand Down Expand Up @@ -118,9 +122,12 @@ export default (
}
}, []);

const changedKeys = useRef(new Set<string>());
const defaultValueRef = useRef<Partial<FormTypes>>();

useEffect(() => {
setMultipleValue(!!selectedField?.multiple);
form.setFieldsValue({
const defaultValue = {
fieldId: selectedField?.id,
title: selectedField?.title,
description: selectedField?.description,
Expand All @@ -139,7 +146,10 @@ export default (
supportedTypes:
selectedField?.typeProperty?.objectSupportedTypes ||
selectedField?.typeProperty?.editorSupportedTypes?.[0],
});
};
form.setFieldsValue(defaultValue);
defaultValueRef.current = defaultValue;
changedKeys.current.clear();
}, [defaultValueGet, form, selectedField]);

const typePropertyGet = useCallback((values: FormTypes) => {
Expand Down Expand Up @@ -230,14 +240,36 @@ export default (
} else {
form
.validateFields()
.then(() => setButtonDisabled(false))
.then(() => setButtonDisabled(changedKeys.current.size === 0))
.catch(() => setButtonDisabled(true));
}
} else {
setButtonDisabled(true);
}
}, [form, values]);

const handleValuesChange = useCallback(async (changedValues: Record<string, unknown>) => {
const [key, value] = Object.entries(changedValues)[0];
let changedValue = value;
let defaultValue = defaultValueRef.current?.[key as keyof FormTypes];
if (Array.isArray(value)) {
changedValue = [...value].sort();
}
if (Array.isArray(defaultValue)) {
defaultValue = [...defaultValue].sort();
}

if (
JSON.stringify(emptyConvert(changedValue)) === JSON.stringify(emptyConvert(defaultValue))
) {
changedKeys.current.delete(key);
} else {
changedKeys.current.add(key);
}
},
[],
);

const handleNameChange = useCallback(
(e: React.ChangeEvent<HTMLInputElement>) => {
if (selectedField) return;
Expand Down Expand Up @@ -357,6 +389,7 @@ export default (
multipleValue,
handleMultipleChange,
handleTabChange,
handleValuesChange,
handleNameChange,
handleKeyChange,
handleSubmit,
Expand Down
Loading

0 comments on commit c83729b

Please sign in to comment.