Skip to content

Commit

Permalink
fix delete all
Browse files Browse the repository at this point in the history
  • Loading branch information
moficodes committed Jun 24, 2020
1 parent 7f30e09 commit c1e504f
Show file tree
Hide file tree
Showing 16 changed files with 277 additions and 279 deletions.
4 changes: 3 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"lint": "eslint src/",
"lint-fix": "eslint src/ --fix"
},
"eslintConfig": {
"extends": "react-app"
Expand Down
24 changes: 12 additions & 12 deletions client/src/Login.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React, { useState, useCallback, useEffect } from "react";
import Button from "./common/Button";
import TextInput from "./common/TextInput";
import styles from "./pagestyles.module.css";
import history from "./globalHistory";
import React, { useState, useCallback, useEffect } from 'react';
import Button from './common/Button';
import TextInput from './common/TextInput';
import styles from './pagestyles.module.css';
import history from './globalHistory';

const OneTimePasscodePage = ({ onSubmit }) => {
const [value, setValue] = useState("");
const [value, setValue] = useState('');

const handleChange = useCallback((e) => {
setValue(e.target.value);
}, []);

const handleKeyDown = useCallback(
(e) => {
if (e.key === "Enter") {
if (e.key === 'Enter') {
e.preventDefault();
e.stopPropagation();
onSubmit(value);
Expand All @@ -40,12 +40,12 @@ const Login = () => {
const [identityEndpoint, setIdentityEndpoint] = useState(undefined);

useEffect(() => {
fetch("/api/v1/login").then(({ status }) => {
fetch('/api/v1/login').then(({ status }) => {
if (status === 200) {
setIsLoggedIn(true);
}
});
fetch("/api/v1/identity-endpoints")
fetch('/api/v1/identity-endpoints')
.then((r) => r.json())
.then(({ passcode_endpoint }) => {
console.log(passcode_endpoint);
Expand All @@ -54,8 +54,8 @@ const Login = () => {
}, []);

const handleOTPSubmit = useCallback(async (otp) => {
const { status } = await fetch("/api/v1/authenticate", {
method: "POST",
const { status } = await fetch('/api/v1/authenticate', {
method: 'POST',
body: JSON.stringify({
otp,
}),
Expand All @@ -70,7 +70,7 @@ const Login = () => {
}, []);

if (isLoggedIn) {
history.push("/");
history.push('/');
} else if (attemtedLogin) {
return <OneTimePasscodePage onSubmit={handleOTPSubmit} />;
}
Expand Down
32 changes: 16 additions & 16 deletions client/src/Router.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { useCallback, useEffect, useState, Suspense } from "react";
import { Router, Switch, Route } from "react-router-dom";
import { Loading } from "carbon-components-react";
import Navbar from "./common/Navbar";
import history from "./globalHistory";
import React, { useCallback, useEffect, useState, Suspense } from 'react';
import { Router, Switch, Route } from 'react-router-dom';
import { Loading } from 'carbon-components-react';
import Navbar from './common/Navbar';
import history from './globalHistory';

const AppPage = React.lazy(() => import("./pages/clusters/AppPage"));
const CreatePage = React.lazy(() => import("./pages/create/CreatePage"));
const SchedulePage = React.lazy(() => import("./pages/schedule/SchedulePage"));
const SettingsPage = React.lazy(() => import("./pages/settings/SettingsPage"));
const Login = React.lazy(() => import("./Login"));
const AppPage = React.lazy(() => import('./pages/clusters/AppPage'));
const CreatePage = React.lazy(() => import('./pages/create/CreatePage'));
const SchedulePage = React.lazy(() => import('./pages/schedule/SchedulePage'));
const SettingsPage = React.lazy(() => import('./pages/settings/SettingsPage'));
const Login = React.lazy(() => import('./Login'));

const HolderThing = (props) => {
const [isLoadingAccounts, setLoadingAccounts] = useState(true);
Expand All @@ -19,12 +19,12 @@ const HolderThing = (props) => {
const [tokenUpgraded, setTokenUpgraded] = useState(false);

const setAccountStuff = useCallback(async (guid) => {
localStorage.setItem("accountID", guid);
localStorage.setItem('accountID', guid);
setSelectedAccountID(guid);
setTokenUpgraded(false);
setHasChosenAccount(true);
const { status } = await fetch("/api/v1/authenticate/account", {
method: "POST",
const { status } = await fetch('/api/v1/authenticate/account', {
method: 'POST',
body: JSON.stringify({
id: guid,
}),
Expand All @@ -44,7 +44,7 @@ const HolderThing = (props) => {
useEffect(() => {
const loadAccounts = async () => {
setLoadingAccounts(true);
const response = await fetch("/api/v1/accounts");
const response = await fetch('/api/v1/accounts');
if (response.status !== 200) {
// Somehow did not get any account back.
return;
Expand Down Expand Up @@ -98,9 +98,9 @@ const HolderThing = (props) => {

const AppRouter = () => {
useEffect(() => {
fetch("/api/v1/login").then(({ status }) => {
fetch('/api/v1/login').then(({ status }) => {
if (status !== 200) {
history.push("/login");
history.push('/login');
}
});
}, []);
Expand Down
32 changes: 16 additions & 16 deletions client/src/common/Navbar.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from "react";
import { Dropdown, Button } from "carbon-components-react";
import styles from "./Navbar.module.css";
import { Settings32 as Settings } from "@carbon/icons-react";
import React from 'react';
import { Dropdown, Button } from 'carbon-components-react';
import styles from './Navbar.module.css';
import { Settings32 as Settings } from '@carbon/icons-react';
// import Dropdown from "react-dropdown";
import history from "../globalHistory";
import "./Dropdown.css";
import "./Navbar.css";
import history from '../globalHistory';
import './Dropdown.css';
import './Navbar.css';

const MenuItem = (props) => {
return (
Expand Down Expand Up @@ -36,25 +36,25 @@ const Navbar = (props) => {
if (item) {
const { name } = item.entity;
const softlayerAccountId =
item.entity.bluemix_subscriptions[0].softlayer_account_id || "";
item.entity.bluemix_subscriptions[0].softlayer_account_id || '';

return `${name} ${softlayerAccountId}`;
}
return "Unknown";
return 'Unknown';
};

const handleCreateClick = () => {
history.push("/create");
history.push('/create');
};
const handleScheduleClick = () => {
history.push("/schedule");
history.push('/schedule');
};
const handleSettingsClick = () => {
history.push("/settings");
history.push('/settings');
};

const homeClick = () => {
history.push("/");
history.push('/');
};

return (
Expand All @@ -64,12 +64,12 @@ const Navbar = (props) => {
<span className={styles.bold}>IBM</span> Cloud
</div>
<MenuItem
stylesx={props.path === "/create" ? styles.activeItem : styles.item}
stylesx={props.path === '/create' ? styles.activeItem : styles.item}
label="Create"
onClickHandler={handleCreateClick}
/>
<MenuItem
stylesx={props.path === "/schedule" ? styles.activeItem : styles.item}
stylesx={props.path === '/schedule' ? styles.activeItem : styles.item}
label="Schedule"
onClickHandler={handleScheduleClick}
/>
Expand All @@ -85,7 +85,7 @@ const Navbar = (props) => {
light={false}
/>
<MenuIcon
kind={props.path === "/settings" ? "primary":"secondary"}
kind={props.path === '/settings' ? 'primary':'secondary'}
label="Settings"
onClickHandler={handleSettingsClick}
/>
Expand Down
40 changes: 20 additions & 20 deletions client/src/pages/clusters/Clusters.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useState } from "react";
import React, { useCallback, useState } from 'react';
import {
DataTable,
DataTableSkeleton,
Expand All @@ -14,19 +14,19 @@ import {
SkeletonText,
TagSkeleton,
StructuredListSkeleton,
} from "carbon-components-react";
} from 'carbon-components-react';
import {
Delete16 as Delete,
TagGroup16 as TagGroup,
Reset16 as Reset,
Money16 as Money,
VirtualMachine16 as VM,
} from "@carbon/icons-react";
} from '@carbon/icons-react';

import headers from "../../common/data/headers";
import headers from '../../common/data/headers';

import "./Cluster.css";
import useClusters from "./useClusters";
import './Cluster.css';
import useClusters from './useClusters';

const {
TableContainer,
Expand Down Expand Up @@ -62,7 +62,7 @@ const CustomExpandedRow = ({ name, dateCreated, workers, workersLoading, ownerEm
{workers ? (
<WorkerDetails workers={workers} />
) : workersLoading ? (
<div style={{ width: "500px" }}>
<div style={{ width: '500px' }}>
<StructuredListSkeleton rowCount={3} />
</div>
) : (
Expand Down Expand Up @@ -114,7 +114,7 @@ const Clusters = ({ accountID }) => {

console.log(clusters);

const [tagText, setTagText] = useState("");
const [tagText, setTagText] = useState('');
const [billingLoading, setBillingLoading] = useState(false);
const [workersLoading, setWorkersLoading] = useState(false);

Expand All @@ -133,7 +133,7 @@ const Clusters = ({ accountID }) => {

const onSetTagClicked = useCallback(
(clusters, tagText) => {
setTagText("");
setTagText('');
setTag(clusters, tagText);
},
[setTag]
Expand All @@ -142,29 +142,29 @@ const Clusters = ({ accountID }) => {
const CustomCell = ({ cell, crn, id }) => {
const { info, value } = cell;
switch (info.header) {
case "state":
case 'state':
return (
<span className="oneline">
<span className={`status ${value}`} />
{value}
</span>
);
case "masterKubeVersion":
case 'masterKubeVersion':
return (
<span className="oneline">
<img
alt="logo"
className="logo-image"
src={
value.includes("openshift")
? "https://i.ibb.co/tLktm91/os-icon.png"
: "https://i.ibb.co/Hh2TzLH/k8s-icon.png"
value.includes('openshift')
? 'https://i.ibb.co/tLktm91/os-icon.png'
: 'https://i.ibb.co/Hh2TzLH/k8s-icon.png'
}
/>
{value}
</span>
);
case "tags":
case 'tags':
return (
<>
{value ? (
Expand All @@ -185,18 +185,18 @@ const Clusters = ({ accountID }) => {
)}
</>
);
case "cost":
case 'cost':
if (value) {
return <>${value}</>;
}
return (
<>
{billingLoading ? (
<div style={{ width: "50px" }}>
<div style={{ width: '50px' }}>
<SkeletonText />
</div>
) : (
"$"
'$'
)}
</>
);
Expand Down Expand Up @@ -296,8 +296,8 @@ const Clusters = ({ accountID }) => {
<TableRow>
<TableExpandHeader enableExpando {...getExpandHeaderProps()} />
<TableSelectAll {...getSelectionProps()} />
{headers.map((header) => (
<TableHeader {...getHeaderProps({ header })}>
{headers.map((header, i) => (
<TableHeader key={i} {...getHeaderProps({ header })}>
{header.header}
</TableHeader>
))}
Expand Down
Loading

0 comments on commit c1e504f

Please sign in to comment.