mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 08:19:07 +00:00
Merge branch 'features/api-token-v2' into api-token-v2/refactor-frontend
This commit is contained in:
commit
061be9d747
@ -13,7 +13,7 @@ const RelationSingle = ({ metadatas, value }) => {
|
||||
<TypographyMaxWidth textColor="neutral800" ellipsis>
|
||||
<CellValue
|
||||
type={metadatas.mainField.schema.type}
|
||||
value={value[metadatas.mainField.name] || value.id}
|
||||
value={value[metadatas.mainField.name] ?? value.id}
|
||||
/>
|
||||
</TypographyMaxWidth>
|
||||
);
|
||||
|
@ -43,13 +43,13 @@ const SingleValue = (props) => {
|
||||
<Component {...props}>
|
||||
<Flex>
|
||||
<StyledBullet title={title} isDraft={isDraft} />
|
||||
<Typography ellipsis>{props.data.label || '-'}</Typography>
|
||||
<Typography ellipsis>{props.data.label ?? '-'}</Typography>
|
||||
</Flex>
|
||||
</Component>
|
||||
);
|
||||
}
|
||||
|
||||
return <Component {...props}>{props.data.label || '-'}</Component>;
|
||||
return <Component {...props}>{props.data.label ?? '-'}</Component>;
|
||||
};
|
||||
|
||||
SingleValue.propTypes = {
|
||||
|
@ -41,13 +41,13 @@ const Option = (props) => {
|
||||
<Component {...props}>
|
||||
<Flex>
|
||||
<StyledBullet title={title} isDraft={isDraft} />
|
||||
<Typography ellipsis>{props.label || '-'}</Typography>
|
||||
<Typography ellipsis>{props.label ?? '-'}</Typography>
|
||||
</Flex>
|
||||
</Component>
|
||||
);
|
||||
}
|
||||
|
||||
return <Component {...props}>{props.label || '-'}</Component>;
|
||||
return <Component {...props}>{props.label ?? '-'}</Component>;
|
||||
};
|
||||
|
||||
Option.defaultProps = {
|
||||
|
@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
const createContext = require('../../../../../../test/helpers/create-context');
|
||||
const contentApiController = require('../content-api');
|
||||
|
||||
describe('Content API permissions', () => {
|
||||
const actionsMap = {
|
||||
'api::address': {
|
||||
controllers: {
|
||||
address: ['find', 'findOne'],
|
||||
},
|
||||
},
|
||||
'api::category': {
|
||||
controllers: {
|
||||
category: ['find', 'findOne', 'create', 'update', 'delete', 'createLocalization'],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
test('return content api layout successfully', async () => {
|
||||
const getActionsMap = jest.fn().mockResolvedValue(actionsMap);
|
||||
const send = jest.fn();
|
||||
const ctx = createContext({}, { send });
|
||||
|
||||
global.strapi = {
|
||||
contentAPI: {
|
||||
permissions: {
|
||||
getActionsMap,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
await contentApiController.getPermissions(ctx);
|
||||
|
||||
expect(getActionsMap).toHaveBeenCalled();
|
||||
expect(send).toHaveBeenCalledWith({ data: actionsMap });
|
||||
});
|
||||
});
|
@ -124,4 +124,11 @@ module.exports = {
|
||||
const apiToken = await apiTokenService.update(id, attributes);
|
||||
ctx.send({ data: apiToken });
|
||||
},
|
||||
|
||||
async getLayout(ctx) {
|
||||
const apiTokenService = getService('api-token');
|
||||
const layout = await apiTokenService.getApiTokenLayout();
|
||||
|
||||
ctx.send({ data: layout });
|
||||
},
|
||||
};
|
||||
|
9
packages/core/admin/server/controllers/content-api.js
Normal file
9
packages/core/admin/server/controllers/content-api.js
Normal file
@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async getPermissions(ctx) {
|
||||
const actionsMap = await strapi.contentAPI.permissions.getActionsMap();
|
||||
|
||||
ctx.send({ data: actionsMap });
|
||||
},
|
||||
};
|
@ -9,4 +9,5 @@ module.exports = {
|
||||
role: require('./role'),
|
||||
user: require('./user'),
|
||||
webhooks: require('./webhooks'),
|
||||
'content-api': require('./content-api'),
|
||||
};
|
||||
|
@ -67,4 +67,12 @@ module.exports = [
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/api-token-layout',
|
||||
handler: 'api-token.getLayout',
|
||||
config: {
|
||||
policies: ['admin::isAuthenticatedAdmin'],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
12
packages/core/admin/server/routes/content-api.js
Normal file
12
packages/core/admin/server/routes/content-api.js
Normal file
@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/content-api/permissions',
|
||||
handler: 'content-api.getPermissions',
|
||||
config: {
|
||||
policies: ['admin::isAuthenticatedAdmin'],
|
||||
},
|
||||
},
|
||||
];
|
@ -7,6 +7,7 @@ const users = require('./users');
|
||||
const roles = require('./roles');
|
||||
const webhooks = require('./webhooks');
|
||||
const apiTokens = require('./api-tokens');
|
||||
const contentApi = require('./content-api');
|
||||
|
||||
module.exports = [
|
||||
...admin,
|
||||
@ -16,4 +17,5 @@ module.exports = [
|
||||
...roles,
|
||||
...webhooks,
|
||||
...apiTokens,
|
||||
...contentApi,
|
||||
];
|
||||
|
@ -73,7 +73,7 @@
|
||||
"@babel/runtime": "7.18.9",
|
||||
"@storybook/addon-actions": "6.5.10",
|
||||
"@storybook/addon-essentials": "6.5.9",
|
||||
"@storybook/addon-links": "6.5.9",
|
||||
"@storybook/addon-links": "6.5.10",
|
||||
"@storybook/builder-webpack5": "6.5.9",
|
||||
"@storybook/manager-webpack5": "6.4.10",
|
||||
"@storybook/react": "^6.5.10",
|
||||
|
16
yarn.lock
16
yarn.lock
@ -3888,16 +3888,16 @@
|
||||
regenerator-runtime "^0.13.7"
|
||||
ts-dedent "^2.0.0"
|
||||
|
||||
"@storybook/addon-links@6.5.9":
|
||||
version "6.5.9"
|
||||
resolved "https://registry.yarnpkg.com/@storybook/addon-links/-/addon-links-6.5.9.tgz#91cbca0c044796badf2498723fdd10dacea5748b"
|
||||
integrity sha512-4BYC7pkxL3NLRnEgTA9jpIkObQKril+XFj1WtmY/lngF90vvK0Kc/TtvTA2/5tSgrHfxEuPevIdxMIyLJ4ejWQ==
|
||||
"@storybook/addon-links@6.5.10":
|
||||
version "6.5.10"
|
||||
resolved "https://registry.yarnpkg.com/@storybook/addon-links/-/addon-links-6.5.10.tgz#f66568fbc84b942032ac2de85f799d69fcf77922"
|
||||
integrity sha512-r3WzYIPz7WjHiaPObC2Tg6bHuZRBb/Kt/X+Eitw+jTqBel7ksvkO36tn81q8Eyj61qIdNQmUWAaX/0aewT0kLA==
|
||||
dependencies:
|
||||
"@storybook/addons" "6.5.9"
|
||||
"@storybook/client-logger" "6.5.9"
|
||||
"@storybook/core-events" "6.5.9"
|
||||
"@storybook/addons" "6.5.10"
|
||||
"@storybook/client-logger" "6.5.10"
|
||||
"@storybook/core-events" "6.5.10"
|
||||
"@storybook/csf" "0.0.2--canary.4566f4d.1"
|
||||
"@storybook/router" "6.5.9"
|
||||
"@storybook/router" "6.5.10"
|
||||
"@types/qs" "^6.9.5"
|
||||
core-js "^3.8.2"
|
||||
global "^4.4.0"
|
||||
|
Loading…
x
Reference in New Issue
Block a user