diff --git a/src/js/locale/en.yaml b/src/js/locale/en.yaml index 8b338653..51795c2c 100755 --- a/src/js/locale/en.yaml +++ b/src/js/locale/en.yaml @@ -421,7 +421,10 @@ settings: upgrade_available: 'Upgrade available (%{version})' upgrade: 'Upgrade to %{version}' up_to_date: Up to date - share_configuration: Share configuration + shared_configuration: + label: Share configuration + share: Export/share + import: Import from server restart: Restart server reset: Reset settings about: @@ -571,8 +574,12 @@ modal: lyrics: Lyrics import_configuration: title: Import configuration - subtitle: Import third-party authorizations and other settings - subtitle_push: Another user has shared their configuration with you + pushed: + title: Configuration received + subtitle: Another user has shared their configuration with you + server: + title: Import configuration + subtitle: Import third-party authorizations and other settings configurations: Configurations to import import_now: Import now share_configuration: diff --git a/src/js/services/pusher/middleware.js b/src/js/services/pusher/middleware.js index 76505869..e6dde22d 100755 --- a/src/js/services/pusher/middleware.js +++ b/src/js/services/pusher/middleware.js @@ -92,7 +92,12 @@ const PusherMiddleware = (function () { store.dispatch(spotifyActions.tokenChanged(params.spotify_token)); break; case 'share_configuration_received': - store.dispatch(uiActions.openModal('import-configuration', params)); + store.dispatch( + uiActions.openModal( + 'import-configuration', + { context: 'pushed', configuration: params }, + ), + ); break; case 'notification': store.dispatch(uiActions.createNotification(params.notification)); diff --git a/src/js/services/ui/actions.js b/src/js/services/ui/actions.js index b036b46e..c12bbc9b 100755 --- a/src/js/services/ui/actions.js +++ b/src/js/services/ui/actions.js @@ -265,13 +265,13 @@ export function removeNotification(key, manual = false) { }; } -export function openModal(name, data) { +export function openModal(name, props) { return { type: 'OPEN_MODAL', name, - data: { + modal_state: { name, - ...data, + props, }, }; } diff --git a/src/js/services/ui/middleware.js b/src/js/services/ui/middleware.js index d19dfb2b..fd61456e 100755 --- a/src/js/services/ui/middleware.js +++ b/src/js/services/ui/middleware.js @@ -37,6 +37,7 @@ const UIMiddleware = (function () { break; case 'CLOSE_MODAL': + next(action); if (action.url) { window.location = action.url; } else { diff --git a/src/js/services/ui/reducer.js b/src/js/services/ui/reducer.js index b2e3b082..8356139d 100755 --- a/src/js/services/ui/reducer.js +++ b/src/js/services/ui/reducer.js @@ -51,9 +51,6 @@ export default function reducer(ui = {}, action) { case 'INSTALL_PROMPT': return { ...ui, install_prompt: action.event }; - /** - * Context menu - * */ case 'SHOW_CONTEXT_MENU': return { ...ui, context_menu: action.data }; @@ -72,18 +69,12 @@ export default function reducer(ui = {}, action) { case 'REMOVE_TOUCH_CONTEXT_MENU': return { ...ui, touch_context_menu: null }; - /** - * Modals - * */ case 'OPEN_MODAL': - return { ...ui, modal: action.data }; + return { ...ui, modal: action.modal_state }; case 'CLOSE_MODAL': return { ...ui, modal: null }; - /** - * Notifications - * */ case 'CREATE_NOTIFICATION': var notifications = { ...ui.notifications }; notifications[action.notification.key] = action.notification; @@ -101,10 +92,6 @@ export default function reducer(ui = {}, action) { delete notifications[action.key]; return { ...ui, notifications }; - /** - * Loading and processes - * */ - case 'START_LOADING': { return { ...ui, diff --git a/src/js/views/Modals/ImportConfiguration.js b/src/js/views/Modals/ImportConfiguration.js index 1bc030db..947375db 100644 --- a/src/js/views/Modals/ImportConfiguration.js +++ b/src/js/views/Modals/ImportConfiguration.js @@ -19,7 +19,10 @@ import { titleCase } from '../../util/helpers'; const ImportConfiguration = () => { const dispatch = useDispatch(); const [selected, setSelected] = useState([]); - const configuration = useSelector((state) => state.ui?.modal || {}); + const { + configuration = {}, + context = 'server', + } = useSelector((state) => state.ui.modal?.props || {}); useEffect(() => { setWindowTitle(i18n('modal.import_configuration.title')); @@ -72,10 +75,10 @@ const ImportConfiguration = () => { return (

- +

- +

@@ -85,12 +88,12 @@ const ImportConfiguration = () => {
- {Object.keys(configuration).map((name) => ( -
+ {Object.keys(configuration).filter((i) => i !== 'name').map((name) => ( +
- {this.renderLocalScanButton()} - +
+ +
+
+ + {pusher.config?.shared_config && ( + + )} +
- {pusher.version.upgrade_available && ( - - )} + {this.renderLocalScanButton()}