Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
feat: clean remove license function and update SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
ReidyT committed May 21, 2024
1 parent 4e0affe commit 393636f
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@graasp/chatbox": "3.1.0",
"@graasp/map": "1.11.1",
"@graasp/query-client": "3.8.0",
"@graasp/sdk": "4.9.0",
"@graasp/sdk": "github:graasp/graasp-sdk#set-license-item-setting-nullable",
"@graasp/translations": "1.28.0",
"@graasp/ui": "4.17.1",
"@mui/icons-material": "5.15.15",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type Props = {
handleBack: () => void;
};

// TODO: move to common because it is shared between settings and publish ?
const ConfirmLicenseDialogContent = ({
handleSubmit,
disableSubmission,
Expand Down
14 changes: 6 additions & 8 deletions src/components/hooks/useItemLicense.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { convertLicense, convertSelectionToLicense } from '@/utils/itemLicense';
import LicenseForm from '../item/publish/LicenseForm';
import { CCLicenseChoice, CCSharingLicenseChoice } from '../item/publish/type';

const { useEditItem } = mutations;

const licensePreviewStyle = {
border: '1px solid #eee',
borderRadius: 2,
Expand Down Expand Up @@ -45,7 +47,7 @@ const useItemLicense = ({
const [allowSharingValue, setAllowSharingValue] =
useState<CCSharingLicenseChoice>('yes');

const { mutate: updateCCLicense } = mutations.useEditItem();
const { mutate: updateItem } = useEditItem();

const { id, settings } = item;

Expand All @@ -61,7 +63,7 @@ const useItemLicense = ({

const handleSubmit = () => {
if (requireAttributionValue) {
updateCCLicense({
updateItem({
id,
settings: {
ccLicenseAdaption: convertSelectionToLicense({
Expand All @@ -76,12 +78,8 @@ const useItemLicense = ({
}
};

const removeLicense = () => {
// TODO: update the settings type ?
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
updateCCLicense({ id, settings: { ccLicenseAdaption: null } });
};
const removeLicense = () =>
updateItem({ id, settings: { ccLicenseAdaption: null } });

const licenseForm = (
<LicenseForm
Expand Down
3 changes: 1 addition & 2 deletions src/components/hooks/usePublicationStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ export const usePublicationStatus = ({ item }: Props): UsePublicationStatus => {
validationGroup: lastItemValidationGroup,
}),
);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [itemPublishedEntry, lastItemValidationGroup, item.updatedAt]);
}, [itemPublishedEntry, lastItemValidationGroup, item]);

return {
status,
Expand Down
1 change: 0 additions & 1 deletion src/components/item/publish/EditableText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type Props = {
onUpdate: (newValue?: string) => void;
};

// TODO: rename ?
export const EditableText = ({
value,
placeholder,
Expand Down
2 changes: 0 additions & 2 deletions src/components/item/publish/ItemPublishTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ const ItemPublishTab = (): JSX.Element => {
const { t } = useBuilderTranslation();
const { item, canAdmin } = useOutletContext<OutletType>();
const { isLoading: isMemberLoading } = useCurrentUserContext();

const isMobile = useMediaQuery(theme.breakpoints.down('md'));

// TODO: use context ?
const [notifyCoEditors, setNotifyCoEditors] = useState<boolean>(false);

if (isMemberLoading) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/item/settings/ItemSettingProperty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type Props = {
valueText?: string | JSX.Element;
inputSetting: JSX.Element;
icon?: JSX.Element;
additionalInfo?: JSX.Element;
additionalInfo?: JSX.Element | null;
};

const ItemSettingProperty = ({
Expand Down
2 changes: 1 addition & 1 deletion src/components/item/settings/UpdateLicenseDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { DiscriminatedItem } from '@graasp/sdk';
import { useBuilderTranslation } from '@/config/i18n';
import { BUILDER } from '@/langs/constants';

import ConfirmLicenseDialogContent from '../../common/ConfirmLicenseDialogContent';
import useItemLicense from '../../hooks/useItemLicense';
import ConfirmLicenseDialogContent from '../publish/ConfirmLicenseDialogContent';

type Props = {
open: boolean;
Expand Down
36 changes: 25 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1511,32 +1511,32 @@ __metadata:
languageName: node
linkType: hard

"@graasp/sdk@npm:4.7.1":
version: 4.7.1
resolution: "@graasp/sdk@npm:4.7.1"
"@graasp/sdk@github:graasp/graasp-sdk#set-license-item-setting-nullable":
version: 4.10.1
resolution: "@graasp/sdk@https://github.com/graasp/graasp-sdk.git#commit=74e924e3106267cd0caf859f2534a5ea9a5bbfba"
dependencies:
"@faker-js/faker": "npm:8.4.1"
filesize: "npm:10.1.2"
js-cookie: "npm:3.0.5"
validator: "npm:13.11.0"
validator: "npm:13.12.0"
peerDependencies:
date-fns: ^3
uuid: ^9
checksum: 10/182e2a33fbdf7ed2cac7fbdf5a01378a059415a753345cca501d2ddda4985b9448c81bb2931a7157dc34cd613412c5da42da38cb037e9a46438755707e4ea2aa
checksum: 10/f8c11b7e7366945bc625f0685e1851122e3b97e1ee7bf9e2975cce46c5b24556b6c3cc6040b7e4b599411da30fcee1245496c191a3aa50b30f5ce6146d692be1
languageName: node
linkType: hard

"@graasp/sdk@npm:4.9.0":
version: 4.9.0
resolution: "@graasp/sdk@npm:4.9.0"
"@graasp/sdk@npm:4.7.1":
version: 4.7.1
resolution: "@graasp/sdk@npm:4.7.1"
dependencies:
"@faker-js/faker": "npm:8.4.1"
filesize: "npm:10.1.1"
js-cookie: "npm:3.0.5"
validator: "npm:13.11.0"
peerDependencies:
date-fns: ^3
uuid: ^9
checksum: 10/921439fcfcc67e18c5e93ee1c405b82e1da9600cf33769a029efa4bacbaab78d30c357a0c19f98687e53101e4de19c924be78fad55eb4c9451ef734596d26b3c
checksum: 10/182e2a33fbdf7ed2cac7fbdf5a01378a059415a753345cca501d2ddda4985b9448c81bb2931a7157dc34cd613412c5da42da38cb037e9a46438755707e4ea2aa
languageName: node
linkType: hard

Expand Down Expand Up @@ -6801,6 +6801,13 @@ __metadata:
languageName: node
linkType: hard

"filesize@npm:10.1.2":
version: 10.1.2
resolution: "filesize@npm:10.1.2"
checksum: 10/47830a299cc8cfe7b90089a6c37790d2334f3057b98efd891e1e2e1683c8076962d9bd1d600eb77bb9bc33f5e7c4682e07ccb62281b8833b923d39c5c322e983
languageName: node
linkType: hard

"fill-range@npm:^7.0.1":
version: 7.0.1
resolution: "fill-range@npm:7.0.1"
Expand Down Expand Up @@ -7332,7 +7339,7 @@ __metadata:
"@graasp/chatbox": "npm:3.1.0"
"@graasp/map": "npm:1.11.1"
"@graasp/query-client": "npm:3.8.0"
"@graasp/sdk": "npm:4.9.0"
"@graasp/sdk": "github:graasp/graasp-sdk#set-license-item-setting-nullable"
"@graasp/translations": "npm:1.28.0"
"@graasp/ui": "npm:4.17.1"
"@mui/icons-material": "npm:5.15.15"
Expand Down Expand Up @@ -13348,6 +13355,13 @@ __metadata:
languageName: node
linkType: hard

"validator@npm:13.12.0":
version: 13.12.0
resolution: "validator@npm:13.12.0"
checksum: 10/db6eb0725e2b67d60d30073ae8573982713b5903195d031dc3c7db7e82df8b74e8c13baef8e2106d146d979599fd61a06cde1fec5c148e4abd53d52817ff0fd9
languageName: node
linkType: hard

"vary@npm:~1.1.2":
version: 1.1.2
resolution: "vary@npm:1.1.2"
Expand Down

0 comments on commit 393636f

Please sign in to comment.