Skip to content

Commit

Permalink
fixed group component in many ways
Browse files Browse the repository at this point in the history
bugfixes:
- group deletion
- adding users to groups
- fix getting started
- delete getting started in the footer
  • Loading branch information
voskvv authored Jan 28, 2019
1 parent 7990f46 commit c5db12f
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 43 deletions.
13 changes: 7 additions & 6 deletions src/actions/getStarted.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ const getStartedFailure = err => ({
err
});

export const fetchGetStarted = (axios: any): ThunkAction => async (
dispatch: Dispatch
) => {
export const fetchGetStarted = (
axios: any,
role: string
): ThunkAction => async (dispatch: Dispatch) => {
dispatch(getStartedRequest());

let dateNow = new Date();
Expand All @@ -48,7 +49,7 @@ export const fetchGetStarted = (axios: any): ThunkAction => async (
dispatch(getStartedSuccess(JSON.parse(githubText).data));
} else {
const response = await axios.get(
`https://raw.githubusercontent.com/containerum/containerum-docs/master/content/getting-started/online.md`,
`https://raw.githubusercontent.com/containerum/containerum-docs/master/content/getting-started/${role}.md`,
{
validateStatus: status => status >= 200 && status <= 505
}
Expand Down Expand Up @@ -86,8 +87,8 @@ export const fetchGetStarted = (axios: any): ThunkAction => async (
}
};

export const fetchGetStartedIfNeeded = (): ThunkAction => (
export const fetchGetStartedIfNeeded = (role: string): ThunkAction => (
dispatch: Dispatch,
getState: GetState,
axios: any
) => dispatch(fetchGetStarted(axios));
) => dispatch(fetchGetStarted(axios, role));
2 changes: 1 addition & 1 deletion src/actions/globalMembership/addUserInGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const fetchAddGlobalUser = (
dispatch(addGlobalUserRequest());

const response = await axios.post(
`${URL}/groups/${idGroup}/members `,
`${URL}/groups/${labelGroup}/members `,
{
members
},
Expand Down
2 changes: 1 addition & 1 deletion src/actions/globalMembership/deleteGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const fetchDeleteGroup = (
const accessToken = cookie.load('accessToken');
dispatch(deleteGroupRequest());

const response = await axios.delete(`${URL}/groups/${id}`, {
const response = await axios.delete(`${URL}/groups/${name}`, {
headers: {
'User-Client': browser,
'User-Token': accessToken
Expand Down
2 changes: 1 addition & 1 deletion src/components/CustomerModal/AdminDeleteUserModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const AdminDeleteUserModal = ({
};
const handleSubmitDeletingEssence = e => {
e.preventDefault();
if (type === 'Deactivate User from Group') {
if (type === 'Delete User from Group') {
handleOpenCloseModal();
onHandleDelete(idGroup, name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/GlobalGroupsList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const GlobalMembershipList = ({
boxShadow: '0 2px 0 0 rgba(0, 0, 0, 0.05)'
}}
key={_.uniqueId()}
onClick={() => handleClickGetGroup(id)}
onClick={() => handleClickGetGroup(label)}
>
<td className={groupshipStyles.td_2_GlobalMembership}>
{label}
Expand Down
15 changes: 10 additions & 5 deletions src/config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ module.exports = {
port: process.env.PORT,
webApi: api,
wsApi: apiWS,
// webApi: 'http://192.168.88.210:8082',
// wsApi: 'wss://192.168.88.210:8082',
// webApi: 'http://192.168.88.210:6443',
// wsApi: 'ws://192.168.88.210:6443',
// webApi: 'http://88.99.247.59:8082',
// wsApi: 'wss://88.99.247.59:8082',
// webApi: 'https://api.containerum.io',
// wsApi: 'wss://api.containerum.io',
// wsApi: 'ws://88.99.247.59:8082',
// webApi: 'http://api.local.containerum.io',
// wsApi: 'ws://api.local.containerum.io',

// webApi: 'http://api.local.containerum.io',
// wsApi: 'ws://api.local.containerum.io',
// 104.248.102.5 local.containerum.io api.local.containerum.io

appRecaptcha: process.env.RECAPTCHA || null,
defaultCountry: process.env.COUNTRY || 'US',
latestRelease: process.env.LATEST_RELEASE || null,
Expand Down
18 changes: 9 additions & 9 deletions src/containers/Footer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ export class Footer extends PureComponent<Props> {
>
Docs
</a>
<a
target="_blank"
rel="noopener noreferrer"
href={externalLinks.fastDeploy}
className={styles.footerHelp}
// onClick={() => this.handleClickAnaliticsHowToFooter()}
>
Get Started
</a>
{/* <a */}
{/* target="_blank" */}
{/* rel="noopener noreferrer" */}
{/* href={externalLinks.fastDeploy} */}
{/* className={styles.footerHelp} */}
{/* // onClick={() => this.handleClickAnaliticsHowToFooter()} */}
{/* > */}
{/* Get Started */}
{/* </a> */}
</div>
</div>
</footer>
Expand Down
3 changes: 2 additions & 1 deletion src/containers/Group/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ class GlobalMembership extends PureComponent<Props> {
name={this.state.inputEmailDelete}
isOpened={this.state.isOpen}
typeName={this.state.idUser}
idGroup={idGroup}
// idGroup={idGroup}
idGroup={label}
handleInputEmailDelete={this.handleInputEmailDelete}
handleOpenCloseModal={this.handleOpenCloseModal}
onHandleDelete={fetchDeleteUserFromGroupIfNeeded}
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Header/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
height: 29px;
width: 29px;
position: absolute;
right: 16%;
right: 270px;

&:hover {
cursor: pointer;
Expand Down
66 changes: 50 additions & 16 deletions src/containers/SideBarGetStarted/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,46 @@ const containerClassName = globalClass(
type Props = {
match: Object,
getStartedReducer: Object,
fetchGetStartedIfNeeded: () => void,
fetchGetStartedIfNeeded: (role: string) => void,
getProfileReducer: () => void,
handleClickDontShow: () => void
};

export class SideBarGetStarted extends PureComponent<Props> {
constructor() {
super();
this.state = {
sideBar: [
{ id: '1-registration', innerHTML: '1. Registration' },
{ id: '2-billing', innerHTML: '2. Billing' },
{ id: '3-create-a-project', innerHTML: '3. Create a Project' },
{ id: '4-create-a-deployment', innerHTML: '4. Create a Deployment' },
{ id: '5-create-a-service', innerHTML: '5. Create a Service' },
{ id: '6-create-a-domain', innerHTML: '6. Create a Domain' },
{ id: '7-go-to-the-domain-page', innerHTML: '7. Go to the domain page' }
sideBarAdmin: [
{ id: '1-create-a-project', innerHTML: '1. Create a Project' },
{ id: '2-create-a-deployment', innerHTML: '2. Create a Deployment' },
{ id: '3-create-a-service', innerHTML: '3. Create a Service' },
{
id: '4-how-to-access-an-application-by-external-ip',
innerHTML: '4. How to access an application by External IP'
},
{
id: '5-how-to-add-a-new-user',
innerHTML: '5. How to add a new user'
},
{
id: '6-how-to-add-a-user-to-a-project',
innerHTML: '6. How to add a user to a project'
}
],
sideBarUser: [
{ id: '1-create-a-deployment', innerHTML: '1. Create a Deployment' },
{ id: '2-create-a-service', innerHTML: '2. Create a Service' },
{
id: '3-how-to-access-an-application-by-external-ip',
innerHTML: '3. How to access an application by External IP'
}
]
};
}
componentDidMount() {
const { fetchGetStartedIfNeeded, getStartedReducer } = this.props;
if (getStartedReducer.readyStatus !== GET_STARTED_SUCCESS) {
fetchGetStartedIfNeeded();
fetchGetStartedIfNeeded(this.props.getProfileReducer.data.role);
}
}
componentWillUnmount() {
Expand Down Expand Up @@ -97,15 +114,26 @@ export class SideBarGetStarted extends PureComponent<Props> {
}

if (getStartedReducer.readyStatus === GET_STARTED_SUCCESS) {
let text = getStartedReducer.data.substring(225);
let text = getStartedReducer.data;
const regexpAbsoluteWebPanelLink = /(\/web-panel\/)/gi;
const regexpAbsoluteCliLink = /(\/cli\/)/gi;
const regexpImg = /<img src="\/img\/content\/getting-started\/online\//gi;
const regexpImgUser = /<img src="\/img\/content\/getting-started\/user\//gi;
const regexpImg = /<img src="\/img\/content\/getting-started\/admin\//gi;
const regexpImgAdmin = /<img src="\/img\/content\/objects\/Membership\//gi;

const regexpImgWithOut = /" width="100%"\/>/gi;
text = text
.replace(
regexpImg,
`![](https://raw.githubusercontent.com/containerum/containerum-docs/master/static_src/img/content/getting-started/online/`
`![](https://raw.githubusercontent.com/containerum/containerum-docs/master/static_src/img/content/getting-started/admin/`
)
.replace(
regexpImgUser,
`![](https://raw.githubusercontent.com/containerum/containerum-docs/master/static_src/img/content/getting-started/user/`
)
.replace(
regexpImgAdmin,
`![](https://raw.githubusercontent.com/containerum/containerum-docs/master/static_src/img/content/objects/Membership/`
)
.replace(regexpImgWithOut, ')')
.replace(
Expand All @@ -119,7 +147,11 @@ export class SideBarGetStarted extends PureComponent<Props> {
};

render() {
const { sideBar } = this.state;
const { sideBarAdmin, sideBarUser } = this.state;
const sideBar =
this.props.getProfileReducer.data.role === 'admin'
? sideBarAdmin
: sideBarUser;
return (
<div>
{this.props.match && (
Expand Down Expand Up @@ -230,15 +262,17 @@ const connector: Connector<{}, Props> = connect(
({
getProfileReducer,
getStartedReducer,
getStartedAdminReducer,
getNamespacesReducer
}: ReduxState) => ({
getProfileReducer,
getStartedReducer,
getStartedAdminReducer,
getNamespacesReducer
}),
(dispatch: Dispatch) => ({
fetchGetStartedIfNeeded: () =>
dispatch(actionGetStarted.fetchGetStartedIfNeeded())
fetchGetStartedIfNeeded: (role: string) =>
dispatch(actionGetStarted.fetchGetStartedIfNeeded(role))
})
);

Expand Down
2 changes: 1 addition & 1 deletion src/containers/SideBarGetStarted/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

.ModalModalListWrap {
position: fixed;
padding: 20px 0 0 30px;
padding: 20px 0 0 10px;

&NavLink {
color:$main-color !important;
Expand Down

0 comments on commit c5db12f

Please sign in to comment.