Skip to content

Commit

Permalink
Revert "fix(auth): UI logged-in detection for other auths (#2535)" (#…
Browse files Browse the repository at this point in the history
…2660)

This reverts commit 44a05c7.
  • Loading branch information
sneridagh authored Sep 14, 2021
1 parent aefacf8 commit b79519b
Show file tree
Hide file tree
Showing 34 changed files with 357 additions and 470 deletions.
12 changes: 1 addition & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ MAKEFLAGS+=--no-builtin-rules
# Project settings

INSTANCE_PORT=8080
# The defaults from the UI configuration
# export RAZZLE_DEV_PROXY_API_PATH=http://localhost:$(INSTANCE_PORT)/Plone
# export RAZZLE_API_PATH=http://localhost:3000
# Uncomment the following to run against the proxy hosting testbed
# export RAZZLE_DEV_PROXY_API_PATH=
# export RAZZLE_API_PATH=http://localhost:49080/api/Plone

# Recipe snippets for reuse

Expand Down Expand Up @@ -83,7 +77,7 @@ docs-build:
.PHONY: start
# Run both the back-end and the front end
start:
$(MAKE) -e -j 2 start-backend start-frontend
$(MAKE) -j 2 start-backend start-frontend

.PHONY: start-frontend
start-frontend: dist
Expand All @@ -101,10 +95,6 @@ start-backend-docker:
start-backend-docker-guillotina:
docker-compose -f g-api/docker-compose.yml up -d

.PHONY: start-proxy
start-proxy: start
docker-compose up -d traefik

.PHONY: start-test
start-test: ## Start Test
@echo "$(GREEN)==> Start Test$(RESET)"
Expand Down
12 changes: 2 additions & 10 deletions api/buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
index = https://pypi.org/simple/
extends = http://dist.plone.org/release/5.2.4/versions.cfg
find-links += http://dist.plone.org/thirdparty/
parts = instance plonesite site-packages robot-server
parts = instance plonesite robot-server
versions = versions

extensions = mr.developer
auto-checkout =
always-checkout = force

[sources]
kitconcept.volto = git https://github.com/kitconcept/kitconcept.volto.git branch=main
kitconcept.volto = git https://github.com/kitconcept/kitconcept.volto.git branch=workingcopysupport
plone.rest = git git@github.com:plone/plone.rest.git branch=master
plone.restapi = git git://github.com/plone/plone.restapi.git pushurl=git@github.com:plone/plone.restapi.git branch=master

Expand Down Expand Up @@ -62,14 +62,6 @@ upgrade-portal = False
upgrade-all-profiles = False
site-replace = True

[site-packages]
# Reproduce a single directory tree of the Python packages installed in this buildout's
# `rel_client` part. Useful for searching, browsing, or otherwise exploring all the
# source code involved in the application in a way that's more readable and avoids
# duplicates from older versions of eggs.
recipe = collective.recipe.omelette
eggs = ${instance:eggs}

[versions]
setuptools =
zc.buildout =
Expand Down
45 changes: 0 additions & 45 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ services:
- ADDONS=kitconcept.volto
- 'PROFILES=kitconcept.volto:default-homepage'
image: plone
labels:
traefik.enable: "true"
traefik.http.routers.plone.entrypoints: "web"
traefik.http.routers.plone.rule: "PathPrefix(`/api`)"
# https://doc.traefik.io/traefik/middlewares/stripprefix/#configuration-examples
traefik.http.middlewares.strip-api-prefix.stripprefix.prefixes: "/api"
traefik.http.middlewares.rewrite-api-vhost.replacepathregex.regex: "^(.*)$$"
traefik.http.middlewares.rewrite-api-vhost.replacepathregex.replacement: "/VirtualHostBase/http/localhost:49080/VirtualHostRoot/_vh_api$$1"
traefik.http.routers.plone.middlewares: "strip-api-prefix@docker,rewrite-api-vhost@docker"
traefik.http.services.plone.loadbalancer.server.port: "8080"

frontend:
ports:
Expand All @@ -30,38 +20,3 @@ services:
# environment:
# - INTERNAL_API_PATH=plone:8080/Plone
# - ADDONS="volto-slate:asDefault"
labels:
traefik.enable: "true"
traefik.http.routers.frontend.entrypoints: "web"
traefik.http.routers.frontend.rule: "PathPrefix(`/ui`)"
# https://doc.traefik.io/traefik/middlewares/stripprefix/#configuration-examples
traefik.http.middlewares.strip-ui-prefix.stripprefix.prefixes: "/ui"
traefik.http.routers.frontend.middlewares: "strip-ui-prefix@docker"
traefik.http.services.frontend.loadbalancer.server.port: "3000"

traefik:
image: "traefik"
# Disabled so that the proxy can also be used to test deployment scenarios against
# a back-end and/or front-end running on the local host.
# depends_on:
# - plone
# - frontend
command:
# - "--log.level=DEBUG"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:49080"
- "--providers.file.directory=/etc/traefik.d/"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./traefik.d/:/etc/traefik.d/"
ports:
- "49080:49080"

networks:
default:
ipam:
driver: "default"
config:
# Use the same random subnet each time
- subnet: "192.168.80.0/24"
23 changes: 8 additions & 15 deletions docs/source/recipes/folder-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,20 @@ Volto is based on React, Redux, and React-Router. All of the
code is located in the `src` folder. The following convention for locating
resources is used.

## Components

`components` contains all the React components, AKA views. This includes views for the
management interface and the theme.

## Actions

`actions` contains all the redux actions for fetching all backend data like
content, users and external resources that are pulled into our app in general.

## Reducers
## Components

`reducers` contains all the Redux reducers that manage the life-cycle for Redux actions
and make the according changes to state.
`components` contains all the views. This includes views for the management
interface and the theme.

## Selectors
## Config

`selectors` contains all the [Redux
selectors](https://redux.js.org/tutorials/fundamentals/part-2-concepts-data-flow#selectors)
that interpret state into the form used by UI components.
In this folder all configuration is stored. All configuration can be overridden
in your theme package.

## Constants

Expand All @@ -33,10 +27,9 @@ The constants contain all constants including the action types.

`helpers` contains helper methods like for example url helpers.

## Config
## Reducers

In this folder all configuration is stored. All configuration can be overridden
in your theme package.
All the reducers are located here.

## Theme

Expand Down
3 changes: 1 addition & 2 deletions src/actions/types/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import { GET_TYPES } from '@plone/volto/constants/ActionTypes';
import { loggedIn } from '@plone/volto/selectors/userSession/userSession';

/**
* Get types function.
Expand All @@ -14,7 +13,7 @@ import { loggedIn } from '@plone/volto/selectors/userSession/userSession';
*/
export function getTypes(url) {
return (dispatch, getState) => {
if (loggedIn(getState())) {
if (getState().userSession.token) {
dispatch({
type: GET_TYPES,
request: {
Expand Down
8 changes: 3 additions & 5 deletions src/actions/types/types.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { getTypes } from './types';
import { GET_TYPES } from '@plone/volto/constants/ActionTypes';
import { arrayWIdsToObject } from '@plone/volto/helpers/Utils/Utils';

const actions = { user: [{ id: 'logout' }] };
const actionsById = arrayWIdsToObject(actions);

describe('Types action', () => {
describe('getTypes', () => {
it('should create an action to get the types', () => {
const getState = () => ({
actions: { actions, actionsById },
userSession: {
token: 'thetoken',
},
});
const url = '/blog';
const dispatch = jest.fn();
Expand Down
13 changes: 6 additions & 7 deletions src/components/manage/Contents/Contents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import {
updateColumnsContent,
} from '@plone/volto/actions';
import Indexes, { defaultIndexes } from '@plone/volto/constants/Indexes';
import { loggedIn } from '@plone/volto/selectors/userSession/userSession';
import {
ContentsIndexHeader,
ContentsItem,
Expand Down Expand Up @@ -1091,7 +1090,9 @@ class Contents extends Component {
const selected = this.state.selected.length > 0;
const filteredItems = this.state.filteredItems || this.state.selected;
const path = getBaseUrl(this.props.pathname);
const folderContentsAction = this.props.actionsById.object.folderContents;
const folderContentsAction = find(this.props.objectActions, {
id: 'folderContents',
});

const loading =
(this.props.clipboardRequest?.loading &&
Expand All @@ -1101,7 +1102,7 @@ class Contents extends Component {
(this.props.orderRequest?.loading && !this.props.orderRequest?.error) ||
(this.props.searchRequest?.loading && !this.props.searchRequest?.error);

return this.props.userLoggedIn && this.props.objectActions.length > 0 ? (
return this.props.token && this.props.objectActions.length > 0 ? (
<>
{folderContentsAction ? (
<Container id="page-contents" className="folder-contents">
Expand Down Expand Up @@ -1767,8 +1768,7 @@ export const __test__ = compose(
connect(
(store, props) => {
return {
userLoggedIn: loggedIn(store),
actionsById: store.actions.actionsById,
token: store.userSession.token,
items: store.search.items,
sort: store.content.update.sort,
index: store.content.updatecolumns.idx,
Expand Down Expand Up @@ -1809,8 +1809,7 @@ export default compose(
connect(
(store, props) => {
return {
userLoggedIn: loggedIn(store),
actionsById: store.actions.actionsById,
token: store.userSession.token,
items: store.search.items,
sort: store.content.update.sort,
index: store.content.updatecolumns.idx,
Expand Down
30 changes: 15 additions & 15 deletions src/components/manage/Contents/Contents.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Provider } from 'react-intl-redux';
import { MemoryRouter } from 'react-router-dom';

import { __test__ as Contents } from './Contents';
import { arrayWIdsToObject } from '@plone/volto/helpers/Utils/Utils';

const mockStore = configureStore();

Expand All @@ -32,23 +31,24 @@ jest.mock('moment', () =>
})),
);

const actions = {
document_actions: [],
object: [
{
icon: '',
id: 'folderContents',
title: 'Contents',
},
],
user: [{ id: 'logout' }],
};
const actionsById = arrayWIdsToObject(actions);

describe('Contents', () => {
it('renders a folder contents view component', () => {
const store = mockStore({
actions: { actions, actionsById },
actions: {
actions: {
document_actions: [],
object: [
{
icon: '',
id: 'folderContents',
title: 'Contents',
},
],
},
},
userSession: {
token: '14134234123qwdaf',
},
search: {
items: [
{
Expand Down
7 changes: 3 additions & 4 deletions src/components/manage/Edit/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import qs from 'query-string';
import { find } from 'lodash';
import { toast } from 'react-toastify';

import { loggedIn } from '@plone/volto/selectors/userSession/userSession';
import {
Forbidden,
Form,
Expand Down Expand Up @@ -351,7 +350,7 @@ class Edit extends Component {
)}
{!editPermission && (
<>
{this.props.userLoggedIn ? (
{this.props.token ? (
<Forbidden
pathname={this.props.pathname}
staticContext={this.props.staticContext}
Expand Down Expand Up @@ -426,7 +425,7 @@ export const __test__ = compose(
connect(
(state, props) => ({
objectActions: state.actions.actions.object,
userLoggedIn: loggedIn(state),
token: state.userSession.token,
content: state.content.data,
compare_to: state.content.subrequests?.compare_to?.data,
schema: state.schema.schema,
Expand Down Expand Up @@ -472,7 +471,7 @@ export default compose(
connect(
(state, props) => ({
objectActions: state.actions.actions.object,
userLoggedIn: loggedIn(state),
token: state.userSession.token,
content: state.content.data,
compare_to: state.content.subrequests?.compare_to?.data,
schema: state.schema.schema,
Expand Down
Loading

0 comments on commit b79519b

Please sign in to comment.