Skip to content

Commit

Permalink
fix: changed Content Manager url format
Browse files Browse the repository at this point in the history
  • Loading branch information
cyp3rius committed Jul 1, 2024
1 parent 249a86f commit f16ff5f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion admin/src/hooks/useContentManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { UID } from "@strapi/strapi";
import { fetchReactions } from "../injections/utils/api";
import { StrapiId } from "../../../types";

export type ContentManagerType = 'singleType' | 'collectionType';
export type ContentManagerType = 'single-types' | 'collection-types';

const useContentManager = (uid: UID.ContentType, id: StrapiId) => {
const fetch = useQuery("get-reactions", () => fetchReactions(uid, id));
Expand Down
8 changes: 4 additions & 4 deletions admin/src/injections/EditViewSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import { ReactionCounter, ReactionCounterProps } from "./components/ReactionCoun
import useContentManager, { ContentManagerType } from "../../hooks/useContentManager";
import useConfig from "../../hooks/useConfig";

const CONTENT_MANAGER_PATH_PATTERN = /.*\/(?<type>[a-zA-Z]+)\/(?<uid>[a-z0-9-_]+::[a-z0-9-_]+\.[a-z0-9-_]+)\/?(?<id>\d*)/;
const CONTENT_MANAGER_PATH_PATTERN = /.*\/(?<type>[a-zA-Z-]+)\/(?<uid>[a-z0-9-_]+::[a-z0-9-_]+\.[a-z0-9-_]+)\/?(?<id>\d*)/;
const CONTENT_MANAGER_TYPES: { [key: string]: ContentManagerType } = {
SINGLE_TYPE: 'singleType',
COLLECTION_TYPE: 'collectionType',
SINGLE_TYPE: 'single-types',
COLLECTION_TYPE: 'collection-types',
};

type ContentManagerPathProps = {
Expand All @@ -35,7 +35,7 @@ export const EditViewSummary = () => {

const groups: ContentManagerPathProps = new RegExp(CONTENT_MANAGER_PATH_PATTERN, "gm")
.exec(location.pathname)?.groups as ContentManagerPathProps;
console.log(groups);

const { uid, id, type } = groups;

if (!id && (type === CONTENT_MANAGER_TYPES.COLLECTION_TYPE)) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "strapi-plugin-reactions",
"version": "1.1.8",
"version": "1.1.9",
"description": "Strapi - Reactions plugin",
"strapi": {
"name": "reactions",
Expand Down

0 comments on commit f16ff5f

Please sign in to comment.