From f6aa24eb0d83f0f04e0da7cc4ffed1984fa6d794 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 16 Oct 2021 10:41:16 -0500 Subject: allow supression of Error prefix, selection of icon --- src/web/src/components/Shared/ErrorSegment.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/web/src/components/Shared/ErrorSegment.js b/src/web/src/components/Shared/ErrorSegment.js index 7a6caa9d..43c6fabb 100644 --- a/src/web/src/components/Shared/ErrorSegment.js +++ b/src/web/src/components/Shared/ErrorSegment.js @@ -2,11 +2,11 @@ import React from 'react'; import { Segment, Header, Icon } from 'semantic-ui-react'; -const ErrorSegment = ({ icon, caption }) => ( +const ErrorSegment = ({ icon = 'x', caption, suppressPrefix = false }) => (
- - Error: {caption} + + {!suppressPrefix && "Error: "}{caption}
); -- cgit v1.2.3 From a08880499dd3c7dd3dd6fd07ce6ae94cae09cd53 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 16 Oct 2021 10:41:35 -0500 Subject: remove initializing, fix spacing --- src/web/src/components/LoginForm.js | 140 ++++++++++++++++++------------------ 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/src/web/src/components/LoginForm.js b/src/web/src/components/LoginForm.js index 6d2fc72a..82af0195 100644 --- a/src/web/src/components/LoginForm.js +++ b/src/web/src/components/LoginForm.js @@ -2,82 +2,82 @@ import React, { Component } from 'react' import { Button, Form, Grid, Header, Icon, Segment, Checkbox, Message } from 'semantic-ui-react' const initialState = { - username: '', - password: '', - rememberMe: true, - ready: false, + username: '', + password: '', + rememberMe: true, + ready: false, } class LoginForm extends Component { - state = initialState; + state = initialState; - handleChange = (field, value) => { - this.setState({ - [field]: value, - }, () => { - if (this.state.username !== '' && this.state.password !== '') { - this.setState({ ready: true }) - } else { - this.setState({ ready: false }) - } - }); - } + handleChange = (field, value) => { + this.setState({ + [field]: value, + }, () => { + if (this.state.username !== '' && this.state.password !== '') { + this.setState({ ready: true }) + } else { + this.setState({ ready: false }) + } + }); + } - render = () => { - const { initialized, onLoginAttempt, loading, error } = this.props; - const { username, password, rememberMe, ready } = this.state; + render = () => { + const { onLoginAttempt, loading, error } = this.props; + const { username, password, rememberMe, ready } = this.state; - return ( - <> - {initialized && - -
- slskd -
-
- - this.handleChange('username', event.target.value)} - /> - this.handleChange('password', event.target.value)} - /> - this.handleChange('rememberMe', !rememberMe)} - checked={rememberMe} - /> - - - {error && - - {error.message} - } -
-
-
} - - ) - } + return ( + <> + + +
+ slskd +
+
+ + this.handleChange('username', event.target.value)} + /> + this.handleChange('password', event.target.value)} + /> + this.handleChange('rememberMe', !rememberMe)} + checked={rememberMe} + /> + + + {error && + + {error.message} + } +
+
+
+ + ) + } } export default LoginForm \ No newline at end of file -- cgit v1.2.3 From c3e07215cc6292911777ac8d45da0a45cda73959 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 16 Oct 2021 10:42:32 -0500 Subject: don't stringify token, properly check for null --- src/web/src/lib/session.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/web/src/lib/session.js b/src/web/src/lib/session.js index a9da8965..2627f6cc 100644 --- a/src/web/src/lib/session.js +++ b/src/web/src/lib/session.js @@ -1,8 +1,8 @@ import api from './api'; import { tokenKey, tokenPassthroughValue } from '../config'; -export const getToken = () => JSON.parse(sessionStorage.getItem(tokenKey) || localStorage.getItem(tokenKey)); -const setToken = (storage, token) => storage.setItem(tokenKey, JSON.stringify(token)); +export const getToken = () => sessionStorage.getItem(tokenKey) || localStorage.getItem(tokenKey); +const setToken = (storage, token) => storage.setItem(tokenKey, token); export const getSecurityEnabled = async () => { return (await api.get('/session/enabled')).data; @@ -17,7 +17,7 @@ export const isPassthroughEnabled = () => getToken() === tokenPassthroughValue; export const isLoggedIn = () => { const token = getToken(); - return token !== undefined && token !== tokenPassthroughValue; + return token !== undefined && token !== null && token !== tokenPassthroughValue; } export const login = async ({ username, password, rememberMe = false }) => { @@ -35,8 +35,10 @@ export const logout = () => { export const check = async () => { try { await api.get('/session'); + return true; } catch (error) { - console.error(error) + console.error('session error; not logged in or session has expired') logout(); + return false; } }; \ No newline at end of file -- cgit v1.2.3 From 744e744084a2ea1674eec528adcadf98d0a1a736 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 16 Oct 2021 10:43:10 -0500 Subject: don't try to connect if session is bad, fix spacing --- src/web/src/components/App.js | 427 +++++++++++++++++++++--------------------- 1 file changed, 218 insertions(+), 209 deletions(-) diff --git a/src/web/src/components/App.js b/src/web/src/components/App.js index f8813820..e717b8c0 100644 --- a/src/web/src/components/App.js +++ b/src/web/src/components/App.js @@ -16,225 +16,234 @@ import System from './System/System'; import LoginForm from './LoginForm'; import { - Sidebar, - Segment, - Menu, - Icon, - Modal, - Header, - Button + Sidebar, + Segment, + Menu, + Icon, + Modal, + Header, + Button, + Loader } from 'semantic-ui-react'; import Rooms from './Rooms/Rooms'; import ErrorSegment from './Shared/ErrorSegment'; const initialState = { - login: { - initialized: false, - pending: false, - error: undefined - }, - applicationState: {}, - error: false, + login: { + pending: false, + error: undefined + }, + applicationState: {}, + initialized: false, + error: false, }; class App extends Component { - state = initialState; - - componentDidMount = () => { - this.init(); - }; - - init = async () => { - const { login } = this.state; - - try { - const securityEnabled = await session.getSecurityEnabled(); - - if (!securityEnabled) { - console.debug('application security is not enabled, per api call') - session.enablePassthrough() - } - - await session.check(); - - const appHub = createApplicationHubConnection(); - - appHub.on('state', (state) => { - console.debug(state) - this.setState({ applicationState: state }); - }); - - appHub.onreconnecting(() => this.setState({ error: true })); - appHub.onclose(() => this.setState({ error: true })); - appHub.onreconnected(() => this.setState({ error: false })); - - appHub.start(); - - this.setState({ - login: { - ...login, - initialized: true - }, - error: false, - }); - } catch (err) { - console.error(err) - this.setState({ error: true }, () => setTimeout(() => this.init(), 1000)) - } + state = initialState; + + componentDidMount = () => { + this.init(); + }; + + init = async () => { + try { + const securityEnabled = await session.getSecurityEnabled(); + + if (!securityEnabled) { + console.debug('application security is not enabled, per api call') + session.enablePassthrough() + } + + const sessionOk = await session.check(); + + if (!sessionOk) { + return; + } + + const appHub = createApplicationHubConnection(); + + appHub.on('state', (state) => { + this.setState({ applicationState: state }); + }); + + appHub.onreconnecting(() => this.setState({ error: true })); + appHub.onclose(() => this.setState({ error: true })); + appHub.onreconnected(() => this.setState({ error: false })); + + await appHub.start(); + + this.setState({ + error: false, + }); + } catch (err) { + console.error(err) + this.setState({ error: true }, () => setTimeout(() => this.init(), 1000)) + } finally { + this.setState({ initialized: true }); + } + } + + login = (username, password, rememberMe) => { + this.setState({ login: { ...this.state.login, pending: true, error: undefined }}, async () => { + try { + await session.login({ username, password, rememberMe }); + window.location.reload(); + } catch (error) { + this.setState({ login: { ...this.state.login, pending: false, error }}); + } + }); + }; + + logout = () => { + session.logout(); + this.setState({ ...initialState, login: { ...initialState.login, initialized: true }}); + }; + + withTokenCheck = (component) => { + session.check(); // async, runs in the background + return { ...component }; + }; + + render = () => { + const { login, applicationState = {}, error, initialized } = this.state; + const { version = {}, server } = applicationState; + const { isUpdateAvailable, current, latest } = version; + + if (!initialized) { + return ; + } + + if (error) { + return ; + } + + if (!session.isLoggedIn() && !session.isPassthroughEnabled()) { + return ( + + ); } - login = (username, password, rememberMe) => { - this.setState({ login: { ...this.state.login, pending: true, error: undefined }}, async () => { - try { - await session.login({ username, password, rememberMe }); - window.location.reload(); - } catch (error) { - this.setState({ login: { ...this.state.login, pending: false, error }}); - } - }); - }; - - logout = () => { - session.logout(); - this.setState({ ...initialState, login: { ...initialState.login, initialized: true }}); - }; - - withTokenCheck = (component) => { - session.check(); // async, runs in the background - return { ...component }; - }; - - render = () => { - const { login, applicationState = {}, error } = this.state; - const { version = {}, server } = applicationState; - const { isUpdateAvailable, current, latest } = version; - - return ( - <> - {error ? : !session.isLoggedIn() && !session.isPassthroughEnabled() ? - : - login.initialized && - - - - Search - - - - - Downloads - - - - - Uploads - - - - - Rooms - - - - - Chat - - - - - Users - - - - - Browse - - - - {server?.isConnected && disconnect()} - > - Connected - } - {(!server?.isConnected) && connect()} - > - - - - Disconnected - } - {isUpdateAvailable && - - - New Version! - } - centered - closeIcon - size='mini' - > - New Version! - -

You are currently running version {current} while version {latest} is available.

-
- - - -
} - - - System - - - {session.isLoggedIn() && - Log Out - - } - centered - size='mini' - header={
} - content='Are you sure you want to log out?' - actions={['Cancel', { key: 'done', content: 'Log Out', negative: true, onClick: session.logout }]} - />} -
-
- - - this.withTokenCheck()}/> - this.withTokenCheck()}/> - this.withTokenCheck()}/> - this.withTokenCheck()}/> - this.withTokenCheck()}/> - this.withTokenCheck()}/> - this.withTokenCheck()}/> - this.withTokenCheck()}/> - - -
- } - - ) - }; + return ( + + + + + Search + + + + + Downloads + + + + + Uploads + + + + + Rooms + + + + + Chat + + + + + Users + + + + + Browse + + + + {server?.isConnected && disconnect()} + > + Connected + } + {(!server?.isConnected) && connect()} + > + + + + Disconnected + } + {isUpdateAvailable && + + + New Version! + } + centered + closeIcon + size='mini' + > + New Version! + +

You are currently running version {current} while version {latest} is available.

+
+ + + +
} + + + System + + + {session.isLoggedIn() && + Log Out + + } + centered + size='mini' + header={
} + content='Are you sure you want to log out?' + actions={['Cancel', { key: 'done', content: 'Log Out', negative: true, onClick: session.logout }]} + />} +
+
+ + + this.withTokenCheck()}/> + this.withTokenCheck()}/> + this.withTokenCheck()}/> + this.withTokenCheck()}/> + this.withTokenCheck()}/> + this.withTokenCheck()}/> + this.withTokenCheck()}/> + this.withTokenCheck()}/> + + +
+ ) + }; }; export default App; -- cgit v1.2.3 From 5e53089a26aeaa52a034261dcd1434369d5b0936 Mon Sep 17 00:00:00 2001 From: trippy22 Date: Sat, 16 Oct 2021 15:40:32 -0400 Subject: remove changelog build steps --- .github/configuration/changelog.json | 35 ----------------------------------- .github/workflows/ci.yml | 9 --------- 2 files changed, 44 deletions(-) delete mode 100644 .github/configuration/changelog.json diff --git a/.github/configuration/changelog.json b/.github/configuration/changelog.json deleted file mode 100644 index d48dbbf6..00000000 --- a/.github/configuration/changelog.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "categories": [ - { - "title": "### Features", - "labels": ["feature"] - }, - { - "title": "### Enhancements", - "labels": ["enhancement"] - }, - { - "title": "### Bug Fixes", - "labels": ["bug", "fix"] - }, - { - "title": "### Refactoring", - "labels": ["refactor"] - }, - { - "title": "### Documentation", - "labels": ["documentation"] - }, - { - "title": "### Tests", - "labels": ["tests"] - } - ], - "sort": "ASC", - "template": "${{CHANGELOG}}### Uncategorized\n\n${{UNCATEGORIZED}}", - "pr_template": "- ${{TITLE}} (#${{NUMBER}})", - "empty_template": "- No Changes", - "max_tags_to_fetch": 200, - "max_pull_requests": 200, - "max_back_track_time_days": 180 -} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce0b84c8..3697fd5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -216,19 +216,10 @@ jobs: cd dist/osx-x64 zip -r ../../slskd-${{ env.TAG }}-osx-x64.zip . - - name: Build Changelog - id: build_changelog - uses: mikepenz/release-changelog-builder-action@v1.4.0 - with: - configuration: .github/configuration/changelog.json - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Create Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: - body: ${{ steps.build_changelog.outputs.changelog }} files: | slskd-${{ env.TAG }}-win-x64.zip slskd-${{ env.TAG }}-linux-x64.zip -- cgit v1.2.3